Hello @Busmeikel
I assume that you have already Domoticz configured, so that Domoticz and the MQTT broker communicates.
If not, see:
https://www.domoticz.com/wiki/MQTT
1. Create a new device in Domoticz ==> Hardware.
Type: Dummy (Does nothing, use for virtuals switches only)
2. Press "Create Virtual Sensors".
Select Sensor Type: "Counter" and give it a name (In this example I use "Water Usage")
3. Go to the device under the "Utility" tab.
Edit the device as follows:
- Screenshot_water_usage3.png (25.93 KiB) Viewed 879 times
Make a note of the Idx:. In this case it is 12.
For this type of device the following command is required:
(source:
https://piandmore.wordpress.com/2019/02 ... -domoticz/)
Counter
The counter sensor will show usage. You can add digits after the decimal if needed. The main display will show it rounded of to 2 digits while beneath it, it will show the whole number you upload. For some reason the log shows the value for every hour and that value is the value at the start of the hour.
{"command":"udevice", "idx":1234, "svalue":"3.45"}
The tricky part is that the type of counter determines what number you should upload:
Energy, upload per Wh, displayed in kWh
Gas, upload per 0.01 m3, displayed in m3
Water, upload per 10 l, display in l (and in m3 below the main display)
Counter, upload per 1 something, also displayed in the same format
Energy generated, upload per Wh, displayed in kWh
For water, the value, we have to upload is in 10L and so we have to multiply the received value with 100.
The flow looks as follows:
- Screenshot_water_usage1.png (35.06 KiB) Viewed 879 times
The Function node "translates" the received input to the required Domoticz input.
The contents is as follows:
Code: Select all
msg.payload = {"command":"udevice", "idx":12, "svalue":(parseFloat(msg.payload) * 100).toFixed(1)}
return msg;
Brief explanation:
As you have seen above the Water sensor receives its value in the svalue variable.
But we have to calculate with the value.
1. The first function (parseFloat) converts the string ("131,638") to a Number.
2. This number is multiplied with 100
3. The result is formatted to 1 digit after the comma (toFixed(1))
4. This value is sent to Domoticz
See the "debug" part in the picture.
If everything is correct, you will see:
- Screenshot_water_usage2.png (88.56 KiB) Viewed 879 times
You asked:
It is the value in m³, published every 5 minutes. It would be fine to have that counter in Domoticz and also a function maybe "Liter per day" or something like that.
The Liter per day, you will find in the Log files of the Sensor.
If you have available a flow meting, you can also use the other sensor (Currently Red, as it receives no data)
Regards