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

[hue] Use auto update policy 'veto' for light channels (API v2) #15984

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

jlaur
Copy link
Contributor

@jlaur jlaur commented Nov 30, 2023

This pull request addresses an issue with auto update policy being default, which causes commands to trigger state update immediately rather than awaiting the final state from the bridge.

This can cause:

Example:

2023-11-25 23:56:36.113 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness' received command 30
2023-11-25 23:56:36.114 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Brightness' predicted to become 30
2023-11-25 23:56:36.115 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness' changed from 0 to 30
2023-11-25 23:56:36.207 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness' changed from 30 to 30.04
2023-11-25 23:56:36.207 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch' changed from OFF to ON

Or even worse:

2023-11-25 23:59:12.488 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness' received command ON
2023-11-25 23:59:12.488 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Brightness' predicted to become ON
2023-11-25 23:59:12.489 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness' changed from 0 to 100
2023-11-25 23:59:12.730 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness' changed from 100 to 30.04
2023-11-25 23:59:12.730 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch' changed from OFF to ON

With auto update policy veto:

2023-11-25 23:42:53.686 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness' received command 30
2023-11-25 23:42:53.781 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness' changed from 0 to 30.04
2023-11-25 23:42:53.782 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch' changed from OFF to ON

and:

2023-11-26 00:03:51.614 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Brightness' received command ON
2023-11-26 00:03:51.694 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Brightness' changed from 0 to 30.04
2023-11-26 00:03:51.695 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch' changed from OFF to ON

Using auto update policy veto will allow us to await the final state from the bridge. This will happen quite quickly since we receive events through SSE with API v2.

Fixes #15983
Related to #15700, #15995
Depends on openhab/openhab-core#3888

@jlaur jlaur added enhancement An enhancement or new feature for an existing add-on awaiting other PR Depends on another PR labels Nov 30, 2023
@jlaur jlaur changed the title [hue] Use auto update policy 'veto' for light channels [hue] Use auto update policy 'veto' for light channels (API v2) Nov 30, 2023
@jlaur jlaur force-pushed the 15983-hue-auto-update-policy branch from c863a57 to a0df376 Compare November 30, 2023 22:17
@andrewfg
Copy link
Contributor

@jlaur as you added a description text to some of the channels, perhaps you need to run update properties script to update the .properties file? Or?

@jlaur jlaur force-pushed the 15983-hue-auto-update-policy branch from a0df376 to 59202e8 Compare November 30, 2023 23:02
@jlaur jlaur removed the awaiting other PR Depends on another PR label Dec 4, 2023
@jlaur jlaur requested a review from a team December 4, 2023 17:32
@jlaur
Copy link
Contributor Author

jlaur commented Dec 4, 2023

as you added a description text to some of the channels, perhaps you need to run update properties script to update the .properties file? Or?

Yes, thanks for the reminder, it was done. Ready for final review.

@jlaur jlaur force-pushed the 15983-hue-auto-update-policy branch from fe69b81 to 5f6e124 Compare December 4, 2023 21:47
@jlaur jlaur force-pushed the 15983-hue-auto-update-policy branch from 5f6e124 to d61e828 Compare December 4, 2023 21:52
Copy link
Contributor

@andrewfg andrewfg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jlaur
Copy link
Contributor Author

jlaur commented Dec 5, 2023

@kaikreuzer - could I indiscreetly bring this to your attention as well? 😉 That would give @andrewfg and I a good baseline for the next PR's.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlaur certainly any time!
Thanks for this improvement!

@kaikreuzer kaikreuzer merged commit 2fae1dd into openhab:main Dec 5, 2023
3 checks passed
@kaikreuzer kaikreuzer added this to the 4.1 milestone Dec 5, 2023
@jlaur jlaur deleted the 15983-hue-auto-update-policy branch December 5, 2023 21:15
austvik pushed a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/philips-hue-clip-2-api-v2-discussion-thread/142111/502

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[hue] States are changed multiple times because of rounding
4 participants