Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global_setter for accessories #91

Open
cdce8p opened this issue Apr 17, 2018 · 6 comments
Open

Global_setter for accessories #91

cdce8p opened this issue Apr 17, 2018 · 6 comments

Comments

@cdce8p
Copy link
Contributor

cdce8p commented Apr 17, 2018

I think it might be useful to implement something like a global_setter for services. Those should get called when one or more char values of this service are about to be changed to provide an access point for end users.

The concrete case is an issue / bug with the HomeKit lightbulb service. When setting the light to a specific brightness in the Home app from the off state, HomeKit calls to char client_update_values, one for the state (on / off) and one for the brightness char.
Reacting to both with the currently used setter_callbacks could lead to flickering if say the light is first set to on (100%) and only then to the wanted brightness.

Links:

Update
I've looked at the HAP doc, it might be better to implement it in the accessory class.

@cdce8p cdce8p changed the title Global_setter for services Global_setter for accessories Apr 17, 2018
@ikalchev
Copy link
Owner

I see the problem. This can be handled in the setters for the bulb I guess (with a small wait before applying I suppose). How do you think it would be the most useful? How should the setter figure out that more than one char is about to be changed?

@cdce8p
Copy link
Contributor Author

cdce8p commented Apr 18, 2018

I though that using the accessory_dirver/set_characteristics method might work as an entry point. That way we can avoid using delays.
I did a little test and this is what this method is called with in this case:

# aid=2 --> Light
# iid=9 --> State (on/off)
# iid=10 --> Brightness
{'characteristics': [{'aid': 2, 'iid': 9, 'value': 1}, {'aid': 2, 'iid': 10, 'value': 60}]}

It should be fairly simple to call the hook method from that. Thought about passing a dictionary with the

{char_1: value, char_2: value}

where char_1 and char_2 are the char objects.

I should be able to have a PR for it this week.

@andrewatwood
Copy link

I though that using the accessory_dirver/set_characteristics method might work as an entry point. That way we can avoid using delays.
I did a little test and this is what this method is called with in this case:

# aid=2 --> Light
# iid=9 --> State (on/off)
# iid=10 --> Brightness
{'characteristics': [{'aid': 2, 'iid': 9, 'value': 1}, {'aid': 2, 'iid': 10, 'value': 60}]}

It should be fairly simple to call the hook method from that. Thought about passing a dictionary with the

{char_1: value, char_2: value}

where char_1 and char_2 are the char objects.

I should be able to have a PR for it this week.

Any progress on that? Still having that annoying symptom on my end of lights hitting 100% before going to their set dim level when setting via Homekit

@cwawak
Copy link

cwawak commented Mar 2, 2020

Hi. I’m still interested in the outcome of this issue as I understand it triggers an annoying bug in Home Assistant causing lights to go to 100% before going to desired brightness. My eyes! Let me know if I can help test any patches. Thank you.

@bdraco
Copy link
Contributor

bdraco commented Mar 2, 2020

@cwawak home-assistant/core#32348

@bdraco
Copy link
Contributor

bdraco commented Aug 22, 2021

This was done in #373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants