Skip to content

Add color_mode to lights and make motion sensor is_on optional - #148

Merged
Leggin merged 1 commit into
mainfrom
light-color-mode-optional-motion-is-on
Oct 23, 2026
Merged

Leggin merged 1 commit into
mainfrom
light-color-mode-optional-motion-is-on

Conversation

@Leggin

@Leggin Leggin commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Two model gaps that the Home Assistant integration (nrbrt/dirigera_platform) currently works around with its own subclasses.

Lights: color_mode

The hub reports "colorMode": "temperature" | "color" on every light, but LightAttributes dropped it (pydantic ignores unknown fields). It is now kept as attributes.color_mode (None if a bulb does not report it). set_color_temperature() and set_light_color() update it locally, like the other attributes those setters write.

Replaces the integration's LightX / LightAttributesX.

Motion sensors: optional is_on

Some motion sensors, such as MYGGSPRAY, do not report isOn, so parsing them as MotionSensor failed with a validation error. is_on is now Optional[bool].

Replaces the integration's MotionSensorX / MotionSensorAttributesX.

Compatibility

No runtime change for existing code. For type-checked users, MotionSensorAttributes.is_on is now Optional[bool] instead of bool. Planned as 1.6.0.

Tests

  • New: color_mode is parsed; a motion sensor without isOn parses with is_on is None.
  • Extended: set_color_temperature() switches color_mode from "color" to "temperature", set_light_color() sets "color".
  • mypy ., pytest (88 passed) and pylint (score unchanged vs main) pass locally. README attribute tables updated.

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.
@Leggin
Leggin merged commit 38e3db2 into main Oct 23, 2026
8 checks passed
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

Successfully merging this pull request may close these issues.

1 participant