I observed that it doesn’t always report as soon as the power changes. Consequence: my device stopped already, but the plug didn’t report 0 current or power. Only after about 5 minutes these values were updated.
I observed that neither this plug or other ZigBee plugs cannot queried for this param. The doc says:
Instantaneous measured power. Value can be found in the published state on the power property. It’s not possible to read (/get) or write (/set) this value.
It’s not clear to me if this a limitation of zigbee2mqtt. E.g. some missing JS code to do conversion or so. Or it’s a hardware limitation.
Have you got some hints on what hardware I could use? ZigBee, or Wifi, or whatever?
It depends on how technically competent you are as to the way to approach this. If you want a quick response, having all the timing in the sensor unit would be the way to go.
I would look at either a split core or Hall effect current sensor attached to the ADC input of an ESP32, a simple resettable timer loop counting off 1 minute. Stop or reset while the ADC input is below a pre-set threshold (low enough to know the motor is running and high enough to not be triggered by noise).
If the timer gets to 1 minute, spit out an alert to an MQTT topic. Doesn’t need to be anything long, A state change from 0 to 1 would suffice. HA will react as programmed. You could add birth and death notices if you like.
With pretty much any power monitoring device, if you are only seeing data update on the order of 5 minutes, I thing there is something else causing these long intervals. As soon as I saw your words ‘water pump’, I wondered how far away this was from your hubs and/or what kind of ‘shields’ are between the sensor at the pump and your hubs. Any device with decent network connection should be showing multiple reading per minute.
Tuya stuff is not a great place to start an ‘adventure’ in what you are trying to accomplish IMHO. Just a lot of gotchas. If you search the various forums around most Tuya devices. It’s not that they can not be a useful sensor, just that they seem to have a lot of ‘corner case’ issues that you may find. I would recommend finding a more ‘main stream’ device. Search the forums for folks ‘success’ stories and read the zigbee2mqtt database and issues logs to learn from others.
I have looked into the issue around the number of reading/samples that you should expect from most of these power monitoring devices, and from my experience you should see for most devices at least/around 1 to 5 reading per minute. And for the most part from my experience, those will show power changes well within the one minute interval. Don’t get me wrong, these device are NOT megahertz ADC devices. If you toggle a switch attached to most of these device 20 times in a minute, you will be lucky to capture 5 to 10 of those events.
Since years I’m using a sonoff pow r2 powered by esphome for that task. Full control and ownership (hardware & software wise) makes that a treat
Works great - never let me down so far and I set the internal update interval to 0.1 seconds so I don’t miss any spikes.
Actually I also included a “dry run” protection as the (old pump) doesn’t have one. So if the power draw drops under a certain level for a period of time the pump will be turned off to protect it from damage. This all happens on the device thank’s to the magic of esphome
Obviously you can also trigger every alert in HA from/with a esphome node including sending alerts via mail etc.