Hey All, I’ve been trying for a while to work this out but going round in circles.
I would like to calculate water usage per hour, day, week, etc…
I have modified a zigbee window sensor by extending the reed switch on some wires so I can insert into the water meter. This is all connected and working well. When the tap goes on, the meter goes around and the zigbee window sensor cycles around “open” and “close” as expected. I can see these on the timeline by looking at the sensor.
I have then created a counter to calculate a value rather than boolean state. My expectation is that this will create a new sensor called “sensor.mains_meter_usage_pulse_count” and sum the total state changes:
The result doesn’t seem correct. When I turn on the tap I can see the state changing but the counter doesn’t increase and I assume this is why the utility meters don’t read correctly:
Clearly I’m doing something wrong but I can’t see it. I wonder if someone can see it and guide me.
Thanks for the pointer, I’ve followed the approach in the post and it’s working.
I have used the same sensors (Zigbee Xiaomi/Aqara door sensor) using ZHA and Ikea range extenders where needed. I have three sensors: Mains Water, Recycled Water and Gas. I had to take the sensor apart, de-solder the reed switch and extended it on some wires. In the water meters there is a hole on the side to insert the reed switch into and on the gas meter it needed placing just under the counter on the meter. All seem to be collecting data.
Next steps are to calibrate the counters and values to match the flow rates from the meters, for now I’m using 1 rotation per unit (either Litres or M3 for gas.
I’ve also setup “utility_meters” for each to track period stats and added the Gas metering to Home Assistant Energy. It would be great to be able to add both Mains and Recycled water to HA Energy but for now they are separate stats.
Thanks for the pointer and I’ll update this post soon with configuration specifics and pictures.
Here’s the code I’m using. Note that for now I’ve set the device_class to “gas” for everything as there isn’t a “water” option yet.
Add the Zigbee device and rename both the Name and Entity to something sensible eg: binary_sensor.gas_meter_pulse_on_off
Define a counter using HA —> Configuration —> Helpers —> Add Helpers —> Counter counter.gas_counter
Create an automation to increment the counter when a pulse is seen from the binary sensor. Note that I wanted it to trigger for both open and close events so left the trigger state blank. I’ll revisit this when trying to calibrate counters to match the gas consumed.
- id: '1639558938199'
alias: Increment Gas Counter
description: ''
trigger:
- platform: state
entity_id: binary_sensor.gas_meter_pulse_on_off
condition: []
action:
- service: counter.increment
target:
entity_id: counter.gas_counter
mode: single
I was playing aorund with my water meter, a reed switch and my multimeter and wasnt avle to find the the spot to get a pulse - it looks like either my reed is not sensitve enough or the target is not storng enough to close the reed. Anyhow the meter has its own “cyble” sensor that sits on the spinning sensor that I can use - but apprantly there are none in Australia at the moment due to shiping limitatins etc. So probably a project for the new year.
Just looking at your coundter incremnet - my gess is that you will be using a “pulse” as a full cycle of the switch though (i.e. when it returns to either on or off). Based on my research of my water meter which is clibrated to have a single “pulse” for each 1L of water.