Closed shred86 closed 4 years ago
Finally figured out a fix to the issue I was having. Ended up removing a lot of unnecessary code too with how it's implemented. Should be good to go now, although I can't figure out why Travis CI is failing:
ERROR: InvocationError for command /home/travis/build/MisterWil/abodepy/.tox/py37/bin/py.test --timeout=30 --cov=abodepy --cov-report term-missing -s (exited with code 3)
This is a work in progress but I wanted to make this PR to be able to get some feedback.I'm attempting to add support for setting the entityavailable
property in Home Assistant for abode devices/automations. Basically, whenavailable
isTrue
, the entities are available to use and whenFalse
, the entities are greyed out in the HA UI and can't be used. Here's an overview on my initial thought at implementation:_on_socket_connect
and_on_socket_disconnect
callbacks in theAbodeEventController
class in event_controller.py. These are called when the web socket connection to the Abode server is connected and disconnected.self._is_connected
on theAbodeEventController
that is set toFalse
by default. This willTrue
when_on_socket_connect
is called andFalse
when_on_socket_disconnect
is called. A property methodis_connected
is also created to returnself._is_connected
for accessing outside the class.add_connection_status_callback
that appends callbacks to a newly added empty listself._connection_status_callback
.From the Home Assistant side, I'm simply calling
add_connection_status_callback
for each instance ofAbodeDevice
(in the abode HA integration). This in turn adds a simple callback method:When
_on_socket_connect
is called, it will call the callback above for every Abode device in Home Assistant which will set theself._available
property based on theself._is_connected
boolean.Everything is working as expected during testing but I'd like to get some other opinions.