dingusdk / haihc-betatest

The Home Assistant IHC integration as a custom component. for beta testing
GNU General Public License v3.0
16 stars 7 forks source link

Added support for stateless airlink buttons. #9

Closed holstebroe closed 1 year ago

holstebroe commented 1 year ago

Support for toggle buttons such as LK FUGA airlink. These buttons send an event rather than a state switch and cannot be properly represented as switches, since a 1:1 relation with an outlet toggle cannot be guaranteed.

holstebroe commented 1 year ago

Note that this PR conflicts with #8, since it creates multiple entity names for the same multi-button device. If pulled, then #8 should be closed.

holstebroe commented 1 year ago

It turns out that physical IHC button press events are not sent as state changes. This needs a bit more work to properly catch button press events from IHC. Closing for now.

dingusdk commented 1 year ago

The button in ha, can only tigger someryhing when clicked. It does not have a up and down state. Buttons in ihc are more advances because your can do something on down or up events, and long press is very common in ihc automation.

I appreciate your work helping, but for now, I will not add new functionality or change functionality to the integration, only fix bugs, because that will complicate the accept of the pr to get this into the official ha. The process has already been way too long: PR here The pr was originally too big, and I have already spit it into several smaller, but still waiting for it to get merged. If nothing happens to the pr I will drop the ihc integration build into ha, and continue a version 2 as a custom integration.

holstebroe commented 1 year ago

The button in ha, can only tigger someryhing when clicked. It does not have a up and down state. Buttons in ihc are more advances because your can do something on down or up events, and long press is very common in ihc automation.

The idea of integrating buttons in HA is to use spare buttons for any purpose one can think of. I have previously used IHC Captain for that specific feature and been quite happy about it.

As for the up/down events from the buttons, both events are sent and can be captured. It would be fairly trivial to generate up/down, short, long events from these. I am aware that the "ButtonDevice" in HA is just a simple one-job event, but for what I want to do with the buttons, this is sufficient. I believe it should be possible to make a more rich event generating device in HA, if that is a wish, but I am fine with the simple "press" event for buttons.

I actually got it to work, but if you don't want to integrate buttons, I suppose I will continue on my own fork. To make it work, it required a change to the underlying IHC python library, since multiple events within the same poll window were ignored in wait_for_resource_value_changes and short button presses are often packed in the same chunk. There was also a bug where a ResourceID had to exist in the XML node, but this is not the case for buttons, here the changed value is listed after the resource node. I tried to make the changes optional, so if you are interested, I can make a PR to the core IHC library.

I also made a battery and signal strength monitor for the airlink devices. It is nice to be able to generate a low battery event within HA. I will push that to my own fork when it has been tested.