diff --git a/software/dashboard/grafana/grafana.db b/software/dashboard/grafana/grafana.db index e34c65c..2276b56 100644 Binary files a/software/dashboard/grafana/grafana.db and b/software/dashboard/grafana/grafana.db differ diff --git a/software/firmware/shelly-monitor/README.md b/software/firmware/shelly-monitor/README.md index 347ae9d..290c668 100644 --- a/software/firmware/shelly-monitor/README.md +++ b/software/firmware/shelly-monitor/README.md @@ -108,8 +108,96 @@ Your shelly will return something like a JSON object that looks like that: } ``` -After a while your Shelly Plug S should be flashed with Tasmota firmware and create a new Wifi. Join that Wifi and [configure the device)(http://192.164.4.1/). +After a while your Shelly Plug S should be flashed with Tasmota firmware. -> Note: This bricked my shelly device. I cannot reach it, anymore. +> Just be patient. This took longer than five minutes in my DSL connected network. + +It will create create a new Wifi. + +![Tasmota Wifi](./docs/images/wifi.png) + +Join that Wifi and [configure the device)(http://192.164.4.1/). + +![Join Wifi](./docs/images/configure-wifi.png) + +You can configure it a a BlitzWolf SHP product. + +Then it offers you power measurement and a programmable toogle. + +![BlitzWolf](./docs/images/blitzwolf.png) It should be configurable just like our [plant monitor](../plant-monitor/README.md). + +Just enable MQTT and enter a shorter telemetry period. + +![MQTT](./docs/images/mqtt.png) ![Telemetry period](./docs/images/telemetry-period.png) + +It will post MQTT messages unter a topic `tele/tasmota_891E97/SENSOR` like this one: + +``` +{ + "Time": "2023-02-27T16:45:07", + "ENERGY": { + "TotalStartTime": "2023-02-27T16:33:06", + "Total": 0.004, + "Yesterday": 0, + "Today": 0.004, + "Period": 0, + "Power": 34, + "ApparentPower": 44, + "ReactivePower": 27, + "Factor": 0.79, + "Voltage": 253, + "Current": 0.172 + } +} +``` + +We now can consume this messages in Node-RED and post them into InfluxDB and build a dashboard in Grafana. + +### InfluxDB Bucket + +I created a bucket called `Shelly`in InfluxDB, so we can store the messages in this bucket. + +### Node-RED + +I create a usual flow in Node-RED. A MQTT node fetches the values. + +![Node-RED](./docs/images/node-red.png) + +The message is fed into a filter function to filter usefull information: + +``` +return { + payload: { + power: Number(msg.payload.ENERGY.Power), + volate: Number(msg.payload.ENERGY.Voltage), + current: Number(msg.payload.ENERGY.Current) + } +}; +```` + +The `payload` will be stored in InfluxDB in the bucket "shelly". + +### InfluxDB Data Explorer + +In Influx DB Data Explorer you can query the stored data. + +![Data Explorer](./docs/images/data-explorer.png) + +The query created by Data Explorer look like that: + +``` +from(bucket: "shelly") + |> range(start: v.timeRangeStart, stop: v.timeRangeStop) + |> filter(fn: (r) => r["_measurement"] == "msg") + |> filter(fn: (r) => r["_field"] == "power" or r["_field"] == "volate" or r["_field"] == "current") + |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) + |> yield(name: "mean") +``` + +### Grafana + +Using this query you can crate a dashboard in Grafana. + +![Grafana](./docs/images/grafana.png) \ No newline at end of file diff --git a/software/firmware/shelly-monitor/docs/images/blitzwolf.png b/software/firmware/shelly-monitor/docs/images/blitzwolf.png new file mode 100644 index 0000000..deb3ca2 Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/blitzwolf.png differ diff --git a/software/firmware/shelly-monitor/docs/images/configure-wifi.png b/software/firmware/shelly-monitor/docs/images/configure-wifi.png new file mode 100644 index 0000000..cb38d7e Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/configure-wifi.png differ diff --git a/software/firmware/shelly-monitor/docs/images/data-explorer.png b/software/firmware/shelly-monitor/docs/images/data-explorer.png new file mode 100644 index 0000000..d17a8c5 Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/data-explorer.png differ diff --git a/software/firmware/shelly-monitor/docs/images/grafana.png b/software/firmware/shelly-monitor/docs/images/grafana.png new file mode 100644 index 0000000..3fd5b44 Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/grafana.png differ diff --git a/software/firmware/shelly-monitor/docs/images/mqtt.png b/software/firmware/shelly-monitor/docs/images/mqtt.png new file mode 100644 index 0000000..3618697 Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/mqtt.png differ diff --git a/software/firmware/shelly-monitor/docs/images/node-red.png b/software/firmware/shelly-monitor/docs/images/node-red.png new file mode 100644 index 0000000..21ce6d5 Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/node-red.png differ diff --git a/software/firmware/shelly-monitor/docs/images/telemetry-period.png b/software/firmware/shelly-monitor/docs/images/telemetry-period.png new file mode 100644 index 0000000..204bb56 Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/telemetry-period.png differ diff --git a/software/firmware/shelly-monitor/docs/images/wifi.png b/software/firmware/shelly-monitor/docs/images/wifi.png new file mode 100644 index 0000000..85142cb Binary files /dev/null and b/software/firmware/shelly-monitor/docs/images/wifi.png differ diff --git a/software/flow/.flows.json.backup b/software/flow/.flows.json.backup index fe30396..4430f4e 100644 --- a/software/flow/.flows.json.backup +++ b/software/flow/.flows.json.backup @@ -299,7 +299,6 @@ "y": 720, "wires": [ [ - "e3742f5060cf6cb7", "29cd45a4f1feb505" ] ] @@ -335,26 +334,103 @@ "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 500, - "y": 780, + "x": 760, + "y": 760, "wires": [] }, { "id": "29cd45a4f1feb505", "type": "function", "z": "f6f2187d.f17ca8", - "name": "toNumber", - "func": "var newMsg = {\n payload: {\n temperature: Number(msg.payload.DHT.Temperature),\n humidity: Number(msg.payload.DHT11.Humidity)\n }\n};\nreturn newMsg;", + "name": "plant2Influx", + "func": "var newMsg = {\n payload: {\n temperature: Number(msg.payload.DHT11.Temperature),\n humidity: Number(msg.payload.DHT11.Humidity)\n }\n};\nreturn newMsg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 520, + "x": 530, "y": 640, "wires": [ [ - "23c62c30ebabca6e" + "23c62c30ebabca6e", + "e3742f5060cf6cb7" + ] + ] + }, + { + "id": "f21213aec2f647ff", + "type": "mqtt in", + "z": "f6f2187d.f17ca8", + "name": "", + "topic": "tele/tasmota_891E97/SENSOR", + "qos": "1", + "datatype": "auto-detect", + "broker": "7ce136dbb8c897d1", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 190, + "y": 1000, + "wires": [ + [ + "5e4f2b3e1acad45b" + ] + ] + }, + { + "id": "26b455c1bd337375", + "type": "influxdb out", + "z": "f6f2187d.f17ca8", + "influxdb": "d61a7da6caeb26aa", + "name": "Influx Shelly device", + "measurement": "msg", + "precision": "", + "retentionPolicy": "", + "database": "database", + "precisionV18FluxV20": "ms", + "retentionPolicyV18Flux": "", + "org": "Curious Community Labs", + "bucket": "shelly", + "x": 770, + "y": 920, + "wires": [] + }, + { + "id": "96eaf14353a89e9c", + "type": "debug", + "z": "f6f2187d.f17ca8", + "name": "shelly", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 730, + "y": 1040, + "wires": [] + }, + { + "id": "5e4f2b3e1acad45b", + "type": "function", + "z": "f6f2187d.f17ca8", + "name": "shelly2Influx", + "func": "return {\n payload: {\n power: Number(msg.payload.ENERGY.Power),\n volate: Number(msg.payload.ENERGY.Voltage),\n current: Number(msg.payload.ENERBY.Current)\n }\n};\n", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 490, + "y": 1000, + "wires": [ + [ + "26b455c1bd337375", + "96eaf14353a89e9c" ] ] }, diff --git a/software/flow/flows.json b/software/flow/flows.json index ca6eed9..da5fafd 100644 --- a/software/flow/flows.json +++ b/software/flow/flows.json @@ -342,14 +342,14 @@ "id": "29cd45a4f1feb505", "type": "function", "z": "f6f2187d.f17ca8", - "name": "toNumber", + "name": "plant2Influx", "func": "var newMsg = {\n payload: {\n temperature: Number(msg.payload.DHT11.Temperature),\n humidity: Number(msg.payload.DHT11.Humidity)\n }\n};\nreturn newMsg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 520, + "x": 530, "y": 640, "wires": [ [ @@ -358,6 +358,82 @@ ] ] }, + { + "id": "f21213aec2f647ff", + "type": "mqtt in", + "z": "f6f2187d.f17ca8", + "name": "", + "topic": "tele/tasmota_891E97/SENSOR", + "qos": "1", + "datatype": "auto-detect", + "broker": "7ce136dbb8c897d1", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 190, + "y": 1000, + "wires": [ + [ + "5e4f2b3e1acad45b" + ] + ] + }, + { + "id": "26b455c1bd337375", + "type": "influxdb out", + "z": "f6f2187d.f17ca8", + "influxdb": "d61a7da6caeb26aa", + "name": "Influx Shelly device", + "measurement": "msg", + "precision": "", + "retentionPolicy": "", + "database": "database", + "precisionV18FluxV20": "ms", + "retentionPolicyV18Flux": "", + "org": "Curious Community Labs", + "bucket": "shelly", + "x": 770, + "y": 920, + "wires": [] + }, + { + "id": "96eaf14353a89e9c", + "type": "debug", + "z": "f6f2187d.f17ca8", + "name": "shelly", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 730, + "y": 1040, + "wires": [] + }, + { + "id": "5e4f2b3e1acad45b", + "type": "function", + "z": "f6f2187d.f17ca8", + "name": "shelly2Influx", + "func": "return {\n payload: {\n power: Number(msg.payload.ENERGY.Power),\n volate: Number(msg.payload.ENERGY.Voltage),\n current: Number(msg.payload.ENERGY.Current)\n }\n};\n", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 490, + "y": 1000, + "wires": [ + [ + "26b455c1bd337375", + "96eaf14353a89e9c" + ] + ] + }, { "id": "e0977f2582bfaaa6", "type": "mqtt in",