-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Avoid redundant calls to async_write_ha_state
in MQTT light
#100690
Conversation
Hey there @emontnemery, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
async_write_ha_state
in MQTT light
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
||
add_topic(CONF_RGB_STATE_TOPIC, rgb_received) | ||
|
||
@callback | ||
@log_messages(self.hass, self.entity_id) | ||
@write_state_on_attr_change( | ||
self, {"_attr_brightness", "_attr_color_mode", "_attr_rgbw_color"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides _attr_rgbw_color
also _attr_brightness
or _attr_color_mode
might have changes change. Tests added.
|
||
add_topic(CONF_RGBW_STATE_TOPIC, rgbw_received) | ||
|
||
@callback | ||
@log_messages(self.hass, self.entity_id) | ||
@write_state_on_attr_change( | ||
self, {"_attr_brightness", "_attr_color_mode", "_attr_rgbww_color"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides _attr_rgbww_color
also _attr_brightness
or _attr_color_mode
might have changes change. Tests added.
@@ -500,6 +499,9 @@ def _rgbx_received( | |||
|
|||
@callback | |||
@log_messages(self.hass, self.entity_id) | |||
@write_state_on_attr_change( | |||
self, {"_attr_brightness", "_attr_color_mode", "_attr_rgb_color"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides _attr_rgb_color
also _attr_brightness
or _attr_color_mode
might have changes change. Tests added.
("rgb-state-topic", "128,128,128", "128,128,64"), | ||
("rgbw-state-topic", "128,128,128,255", "128,128,128,128"), | ||
("rgbww-state-topic", "128,128,128,32,255", "128,128,128,64,255"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added cases
7a74b55
to
ade314c
Compare
Opended #100707 to fix a bug and additional tests on processing rgbx values without a state topic for brightness. |
ade314c
to
e58d164
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @jbouwh 👍
Proposed change
Follow up on #100438, Avoid redundant calls to
async_write_ha_state
in MQTT light for all schema's.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: