raetha / wyzesense2mqtt

Configurable WyzeSense to MQTT Gateway intended for use with Home Assistant or other platforms that use MQTT discovery mechanisms.
MIT License
79 stars 22 forks source link

Sensor Status Updates #50

Closed AK5nowman closed 3 years ago

AK5nowman commented 3 years ago

Add support for sensor status updates (battery notifications). Credits to maage89 for putting the pieces together.

Added an "event" property to the mqtt message that is pusblished. Event type "alarm" is the sensor triggerings. Event type "status" is the sensor checking in.

AK5nowman commented 3 years ago

Should note, I don't use HA so not sure if the discovery topic payload needs to change to support this.

raetha commented 3 years ago

Nice job! I think I'll need to do some things to make it more HA friendly, but at least the updates will go through. I may end up creating a new alarms topic for each sensor, but will probably wait until I can see what it looks like and try to get HA to trigger.

Side question, how are you using this stuff? I'm happy to have it get more use, but had figured mostly only HA folks were interested.

AK5nowman commented 3 years ago

I use node-red solo. I work in the industrial automation world so the whole yaml based automations wasn't all that intuitive so I scrapped it after a few days of playing with it. Only thing I'm missing is a nice control dashboard. Right now I just use iOS and setup a quick https2mqtt so I can make http calls from iOS shortcuts to publish stuff to my broker, lets me control my lights easy enough.

I'd love to scrap node-red in favor of a software PLC with a MQTT connector but I haven't had much luck finding one.

raetha commented 3 years ago

I hear you on the HA automation yaml, which is why I use node-red in parallel with HA. Got both running in docker and interconnected. Most of my automations, including notifications and alerts, trigger via node-red flows, but based on the status and control functions in HA. They actually play really well together and give a nice UI to interact with things, while having better automation than HA started with.

That said, I know HA has put a ton of work into the GUI for their automation stuff, and you almost never need to jump into yaml anymore. I keep meaning to take a look and see if I can eventually replace node-red.

Side note on these changes specifically, I'm not seeing any status triggers since updating my instance. Have you actually seen both the status and alert messages coming through? Wondering if you made some further tweaks that got missed here, or if something isn't working right in my environment.

AK5nowman commented 3 years ago

That's really interesting. Most of my sensors are triggered often enough to not need these status messages but the couple that I paired after making this change just sitting on my desk regularly (not periodically though) send me status messages. It appears to never go longer than 181 minutes before sending a status message. And I see as soon as 19 minutes. When comparing branches I don't think I missed anything, ill take another look after work today and report back

trankillity commented 3 years ago

Totally off topic to the PR itself (which is fantastic to have merged!), but you both may wish to investigate AppDaemon (Python) or NetDaemon (C#) depending on your preferred language/poison. I find them much more flexible and re-usable than using Node-RED for my automations.

AK5nowman commented 3 years ago

@trankillity I had seen AppDaemon but not NetDaemon. C# is by far my preferred language so I will have to keep NetDaemon in mind. Thanks!

Update on my Status messages: Turns out the message is periodic with a 4hr period, regardless if alarms are triggered or not. They all seem to be 30 minutes out of phase with each other, though.