Repository navigation
Add color_mode to lights and make motion sensor is_on optional - #148
Merged
Merged
Conversation
The hub reports "colorMode" ("temperature" or "color") on lights, but
LightAttributes dropped it. Keep it as attributes.color_mode, and update
it locally in set_color_temperature() and set_light_color() like the
other attributes those setters write.
Some motion sensors, such as MYGGSPRAY, do not report isOn, so parsing
them as MotionSensor failed. Make is_on optional.
Both gaps are currently patched around in the Home Assistant integration
(LightX and MotionSensorX in dirigera_platform), which can drop those
subclasses once it depends on a release with this change.
1 of 2 tasks
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.
Two model gaps that the Home Assistant integration (nrbrt/dirigera_platform) currently works around with its own subclasses.
Lights:
color_modeThe hub reports
"colorMode": "temperature" | "color"on every light, butLightAttributesdropped it (pydantic ignores unknown fields). It is now kept asattributes.color_mode(Noneif a bulb does not report it).set_color_temperature()andset_light_color()update it locally, like the other attributes those setters write.Replaces the integration's
LightX/LightAttributesX.Motion sensors: optional
is_onSome motion sensors, such as MYGGSPRAY, do not report
isOn, so parsing them asMotionSensorfailed with a validation error.is_onis nowOptional[bool].Replaces the integration's
MotionSensorX/MotionSensorAttributesX.Compatibility
No runtime change for existing code. For type-checked users,
MotionSensorAttributes.is_onis nowOptional[bool]instead ofbool. Planned as 1.6.0.Tests
color_modeis parsed; a motion sensor withoutisOnparses withis_on is None.set_color_temperature()switchescolor_modefrom"color"to"temperature",set_light_color()sets"color".mypy .,pytest(88 passed) and pylint (score unchanged vs main) pass locally. README attribute tables updated.