maximvelichko / pyvera

A python library to control devices via the Vera hub
GNU General Public License v2.0
26 stars 30 forks source link

Handle comm failure status being None. #146

Closed pavoni closed 3 years ago

pavoni commented 3 years ago

Fixes #145

pavoni commented 3 years ago

Thanks.

Are you using this in Home Assistant?

If so I'll try and get this in the next release. They've started the new beta - but they're usually happy to drop in bug fixes.

tgrusendorf commented 3 years ago

Yes, I am using it with Home Assistant. I'm working on getting devices with a comm failure to show 'Unavailable', in particular so that I can generate notifications when things such as my flood sensor are offline.

I have two more hurdles so far:

  1. After a comm failure returns to normal, the Vera subscription does not always report the state returning to -1, so often the last subscription update I get for the device shows state 1 with comm failure = 0. It looks like you've encountered a similar issue with locks not returning state to -1, so I'm using your lock workaround for all devices at the moment. Requesting a complete update from Vera does show that the state has returned to -1. I'm planning to add another issue for this, it probably needs some discussion.

  2. Once a device is in comm failure, Vera doesn't necessarily continue trying it. For my flood sensor it does, so it will return to normal on its own. For my dimmers it does not, so I have to ask Vera to poll the device. I'm considering adding a 'Poll Device' service to the Vera integration so that I can trigger a poll from HA. Would you consider adding periodic polling of devices with comm failure to pyvera?

Do you maintain the HA integration too?

pavoni commented 3 years ago

Sounds like it's worth holding off on the HA release until we've covered the issue more completely.

I'd also love my HA devices to properly handle comm failure!

I've done some work on the HA integration - although until the last week when I fixed a problem with initial states I hadn't done anything since @vangorra re-wrote and upgraded it. So I'm not 100% up to speed.

I'm pretty sure @vangorra modified the HA integration so that the HA devices poll as well as responding to subscription updates (HA objects poll by default unless you tell them not to - and he just removed my code that turned this off).

The catch is they poll the pyvera device - which returns cached values (unless you pass refresh=true to get the status from the real device).

But you can perhaps force a refresh in the HA integration if the device is in comm failure?

Would also be happy for you to add a poll_device call to VeraDevice. Again you could call this from HA if needed.

I think @vangorra is busy with other things - but he might have a few moments to comment.

Added as an issue here: https://github.com/pavoni/pyvera/issues/147