Skip to content

Device improvements - #178

Open
rneswold wants to merge 8 commits into
DrMemCS:mainfrom
rneswold:PR
Open

rneswold wants to merge 8 commits into
DrMemCS:mainfrom
rneswold:PR

Conversation

@rneswold

@rneswold rneswold commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor
  • OverridableDevice was refactored. It now uses a simpler state machine and more unit tests were added to verify the behavior.
  • The device classes were simplified:
    • Switch now has error and state devices
    • Dimmer now has error and brightness devices
    • ColorBulb now has error and color devices (where the color device can be RGBA or color temperature

This type had some issues with real hardware (esp. Philips Hue devices.)

The state machine was simplified and the `OverridableDevice` type added a
setting "envelope" where we reassert the setting if polling shows a different
value than the setting in the envelope time.

Drivers that use `OverridableDevice` now take an optional envelope
config parameter.

Unit tests were added to further test that the new state machine works.

This rewrite was done with AI assistance.
This simplifies the method signatures. However, we do lose the
constraint that the returned `Future<>` needs to be `Send`. We'll see if
this becomes an issue.
Not all manufacturers add an LED indicator to their products. For two of
the drivers I wrote, I was stubbing out the indicator devices. Rather
than force all drivers to have a possibly nonfunctional indicator
device, we'll let the few drivers that do have it include it in their
implementation.
Having the brightness and color be separate devices made it more
difficult to use the logic block because it required two expressions to
control a combined, desired result. The settings aren't atomic.

By rolling the brightness into the color, we have one device to provide
the same output as two. And the logic blocks can control both by using
`WITH_BRIGHTNESS()`:

```
WITH_BRIGHTNESS(color_expr, brightness_expr) -> {bulb}
```
- add `debug!` messages
- remove optional envelope -- an overridable device always needs to
  verify the setting
- remove test for empty envelope
The Hue driver mostly worked with the new `OverridableDevice` changes. However
when trying to control color bulbs, it would send settings rapidly because they
didn't compare.
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