elric91 / homeassistant_zigate

Custom components for Home Assistant
MIT License
22 stars 5 forks source link

poll sensors/switches when the plugin starts. #5

Open lolorc opened 6 years ago

lolorc commented 6 years ago

when HA starts, is there a way to make it poll every registered sensors ? Sensors don’t talk quite often if there’s no significant changes, I guess I could restore states from before but I’d prefer to poll them instead. Is that possible ?

alexbarcelo commented 6 years ago

expanding on this issue, I use Xiaomi Aqara wall switches and sometimes the messages are lost. That means that Home Assistant tells a certain state (switch on) but the real state is the other way around. It is cumbersome.

I was planning to add this feature, but was unable to find the command of "get state of a switch" here. Any advice on how to support that feature? Easiest way to achieve that? A safe poll (say, every 5 minutes, and make the interval configurable) seems to be robust and IMHO it would not saturate the zigbee network.

ISO-B commented 6 years ago

You can ask values from device using command 0x0100. You need to know endpoint, cluster and parameter id. You can find cluster id and parameter from Zigbee cluster documentation (I have been using document JN-UG-3115)

pyzigate has function for that, its called read_attribute. It should have good enough comment to get you started. (https://github.com/elric91/ZiGate/blob/54bc898b00d692a0183e8f7cd354b40ca0a103a8/pyzigate/commands_helpers.py#L5)

If you need to findout which cluster and endpoints your device have, take a look for issue #1. There is commands for those.

ISO-B commented 6 years ago

It could be possible to send polling command after device is initialized on hass. There is two problems:

  1. Some devices won't process zigbee commands without pushing button, example Heiman motion sensor. Xiaomi Aqara motion sensor gives response 8702 : APS Data Confirm Fail. I don't have any switches so I cant test how those work.
  2. User would have to specify cluster and attribute to configuration file so we could request right parameter. Most cases probably sensor type would be enough, since basic data almost always is on same attribute.

Anyone having any progress with this?

cmorlok commented 6 years ago

Not exactly your preferred solution, but good enough for me: #22