jimpastos / wink-relay-manager

Manage Wink Relay's native sensors and publish to MQTT
46 stars 24 forks source link

Heartbeat and Touch Input event. label:enhancement #16

Open jusplainmike opened 2 years ago

jusplainmike commented 2 years ago

I was looking at your code trying to figure out how to add two extra mqtt events. One to send out a status of the connection on something like Relay01/status "ONLINE". I was thinking maybe on the same timer that checks the relays and humidity or when connection is setup to mqtt. Could add a last will for "OFFLINE". Also I noticed you are able to detect touch screen inputs but it doesn't send any mqtt messages. I wanted to create a screensaver of sorts. I have MagicMirror and Homeassistant web portals both on the home screen. I use Tasker and AutoInput to switch between them after an amount of inactivity. I would like to keep magic mirror displayed when waking the screen from proximity and if touched switch to homeassistant, a kind of crude screensaver I guess. Would it be difficult to send mqtt payloads on those two events? I have been trying to hack together a solution with my poor understanding of C but to no avail.

jimpastos commented 2 years ago

There are no timers for state checks. Proximity, humidity and temp are only updated when they change.

Sending an ONLINE state is trivial but you won't know when its offline, unless the device sends periodic heartbeats indicating its online and anyone listening has logic to know that online state is only valid for a certain amount of time. (Which I believe MQTT Sensors do in HomeAssistant, but we don't follow that flow)

Not exactly sure what you are asking for the second part. Proximity and Screen state is sent. We can't really send events on touches because they are VERY noisy (hundreds of events when touching/dragging). Can you not work off the Screen state when its On/Off?

Maybe breakdown your flow/requirements and we can figure out any intermediate events that can be sent.

jusplainmike commented 2 years ago

There is a line in your code every 500s to check the relay state, temp and humidity. Also can we not use the Last Will and Testament feature for status? Have it set to OFFLINE.

I will update this post with my workflow and possible requirements tomorrow. Late here and I'm doing a poor job describing my process.

jimpastos commented 2 years ago

You’re right. Haven’t looked at the code in ages :). I was mixing up the sensor (proximity and buttons) blocking polls with temp/humidity data. i’ll wait for your follow up