Add callback for abode connection status#67
Merged
MisterWil merged 8 commits intoMisterWil:masterfrom Apr 3, 2020
Merged
Conversation
shred86
commented
Mar 17, 2020
shred86
commented
Mar 18, 2020
20 tasks
shred86
commented
Mar 19, 2020
Contributor
Author
|
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 entityavailableproperty in Home Assistant for abode devices/automations. Basically, whenavailableisTrue, 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_connectand_on_socket_disconnectcallbacks in theAbodeEventControllerclass in event_controller.py. These are called when the web socket connection to the Abode server is connected and disconnected.self._is_connectedon theAbodeEventControllerthat is set toFalseby default. This willTruewhen_on_socket_connectis called andFalsewhen_on_socket_disconnectis called. A property methodis_connectedis also created to returnself._is_connectedfor accessing outside the class.add_connection_status_callbackthat appends callbacks to a newly added empty listself._connection_status_callback.From the Home Assistant side, I'm simply calling
add_connection_status_callbackfor each instance ofAbodeDevice(in the abode HA integration). This in turn adds a simple callback method:When
_on_socket_connectis called, it will call the callback above for every Abode device in Home Assistant which will set theself._availableproperty based on theself._is_connectedboolean.Everything is working as expected during testing but I'd like to get some other opinions.