added shelly example

This commit is contained in:
simonox 2023-09-16 15:37:14 +02:00
parent 785062d554
commit bb3b374715
10 changed files with 62 additions and 3 deletions

View file

@ -74,9 +74,7 @@ InfluxDb is running here: http://localhost:8086/ (you have to create an initial
You can login to Grafana: http://localhost:3000/login (admin:admin) You can login to Grafana: http://localhost:3000/login (admin:admin)
## Usage ## Examples and set-up
### Setting up a simple flow in Node-RED ### Setting up a simple flow in Node-RED
@ -86,10 +84,16 @@ A simple introduction to Node-RED can be found - along with the nodes / the code
A more sophisticated exampe on how to connect Node-RED to influx is also available in [this repository](./docs/flow/docs/node-influx.md). A more sophisticated exampe on how to connect Node-RED to influx is also available in [this repository](./docs/flow/docs/node-influx.md).
### Setting up Grafana ### Setting up Grafana
Have a look at the [HowTo in this repository](./docs/dashboard/README.md). Have a look at the [HowTo in this repository](./docs/dashboard/README.md).
### Attaching a Shelly plug
As an example you can use a Shelly plug flashed with Tasmota and feed MQTT data with Node-RED into InfluxDB and visualize it with Grafana. Have a look, [here](./docs/shelly/README.md).
## Contribution ## Contribution
Feel free to open an issue for bugs, feature requests, or questions. Contributions are welcome. Feel free to open an issue for bugs, feature requests, or questions. Contributions are welcome.

55
docs/shelly/README.md Normal file
View file

@ -0,0 +1,55 @@
# Shelly Plug (S)
Shelly Plugs S are quite cheap but relatively accurate to measure power consumptions less than 2.5 kW.
![Shelly Plug](https://shelly.hr/wp-content/uploads/2020/11/shelly_plug_s_1-1.jpg)
In our [smart-energy-montior](https://code.curious.bio/curious.bio/smart-energy-monitor) project we already have set up a Shelly using Tasmota, on Open Source alternative firmware, that also runs on various other consumer off the shelf devices.
## InfluxDB Bucket
In Influx 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 only store usefull information:
```
return {
payload: {
power: Number(msg.payload.ENERGY.Power),
voltage: 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 looks 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"] == "voltage" 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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB