mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-12 06:44:04 +02:00
Merge pull request #326 from basnijholt/fix_no_settings
Make sure that 'settings' dict is populated when switch is off
This commit is contained in:
commit
49fb9d8686
2 changed files with 6 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
|||
"config_flow": true,
|
||||
"dependencies": [],
|
||||
"codeowners": ["@basnijholt", "@RubenKelevra"],
|
||||
"version": "1.0.19",
|
||||
"version": "1.0.20",
|
||||
"requirements": [],
|
||||
"iot_class": "calculated"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -793,6 +793,11 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
if "transition" in features:
|
||||
service_data[ATTR_TRANSITION] = transition
|
||||
|
||||
# The switch might be off and not have _settings set.
|
||||
self._settings = self._sun_light_settings.get_settings(
|
||||
self.sleep_mode_switch.is_on, transition
|
||||
)
|
||||
|
||||
if "brightness" in features and adapt_brightness:
|
||||
brightness = round(255 * self._settings["brightness_pct"] / 100)
|
||||
service_data[ATTR_BRIGHTNESS] = brightness
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue