Skip to content

Commit

Permalink
Fix for LIDL 14149505L/14149506L color handling (#5588)
Browse files Browse the repository at this point in the history
* Fix stuck color state

This fixes a bug where the color in the state wasn't updated because it
was using "h" and "s" as field names. Those fields are just copies for
Home Assistant while the actual canonical field names are "hue" and
"saturation".

* Support color sync

This allows the color sync functionality to work if it's enabled in the
device settings.
  • Loading branch information
AndreKR committed Mar 18, 2023
1 parent d074c0d commit 5abafbe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions devices/lidl.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ const tzLocal = {
// Load current state or defaults
const newSettings = {
brightness: meta.state.brightness ?? 254, // full brightness
hue: (meta.state.color ?? {}).h ?? 0, // red
saturation: (meta.state.color ?? {}).s ?? 100, // full saturation
hue: (meta.state.color ?? {}).hue ?? 0, // red
saturation: (meta.state.color ?? {}).saturation ?? 100, // full saturation
};

// Apply changes
Expand All @@ -217,8 +217,8 @@ const tzLocal = {
newSettings.saturation = color.saturation;

newState.color = {
h: color.hue,
s: color.saturation,
hue: color.hue,
saturation: color.saturation,
};
}

Expand All @@ -234,6 +234,10 @@ const tzLocal = {
}
}

// If we're in white mode, calculate a matching display color for the set color temperature. This also kind
// of works in the other direction.
Object.assign(newState, libColor.syncColorState(newState, meta.state, entity, meta.options, meta.logger));

return {state: newState};
},
convertGet: async (entity, key, meta) => {
Expand Down

0 comments on commit 5abafbe

Please sign in to comment.