From d57ef3f2e44128f26733d4ef31979fd59128e99f Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 30 Sep 2020 12:54:02 +0200 Subject: [PATCH] sync PR --- custom_components/adaptive_lighting/strings.json | 4 ++-- custom_components/adaptive_lighting/switch.py | 3 ++- custom_components/adaptive_lighting/translations/en.json | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/custom_components/adaptive_lighting/strings.json b/custom_components/adaptive_lighting/strings.json index 0c08519e..97fb913b 100644 --- a/custom_components/adaptive_lighting/strings.json +++ b/custom_components/adaptive_lighting/strings.json @@ -26,7 +26,7 @@ "adapt_rgb_color": "adapt_rgb_color, adapt color temperature using RGB/XY if supported", "disable_entity": "disable_entity, entity_id that stops the switch from adapting lights", "disable_state": "disable_state, state(s) of 'disable_entity', e.g., 'off' or 'total,half'", - "initial_transition": "initial_transition, the transition of the lights when turning them on or when 'disable_state' or 'sleep_state' change", + "initial_transition": "initial_transition, when lights go 'off' → 'on' or when 'disable_state'/'sleep_state' changes", "interval": "interval, time between switch updates in seconds", "max_brightness": "max_brightness, in %", "max_color_temp": "max_color_temp, in Kelvin", @@ -36,7 +36,7 @@ "prefer_rgb_color": "prefer_rgb_color, use 'rgb_color' over 'color_temp' when possible", "sleep_brightness": "sleep_brightness, in %", "sleep_color_temp": "sleep_color_temp, in Kelvin", - "sleep_entity": "sleep_entity, entity_id turns the switch into sleep mode", + "sleep_entity": "sleep_entity, 'entity_id' that manages the switch's sleep mode", "sleep_state": "sleep_state, state(s) of 'sleep_entity', e.g., 'off' or 'total,half'", "sunrise_offset": "sunrise_offset, in +/- seconds", "sunrise_time": "sunrise_time, in 'HH:MM:SS' format", diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 640809cc..c3e6e358 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -290,7 +290,8 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): EVENT_HOMEASSISTANT_START, self._setup_listeners ) last_state = await self.async_get_last_state() - if last_state and last_state.state == STATE_ON: + is_new_entry = last_state is None # newly added to HA + if is_new_entry or last_state.state == STATE_ON: await self.async_turn_on(adapt_lights=not self._only_once) else: self._state = False diff --git a/custom_components/adaptive_lighting/translations/en.json b/custom_components/adaptive_lighting/translations/en.json index 0c08519e..97fb913b 100644 --- a/custom_components/adaptive_lighting/translations/en.json +++ b/custom_components/adaptive_lighting/translations/en.json @@ -26,7 +26,7 @@ "adapt_rgb_color": "adapt_rgb_color, adapt color temperature using RGB/XY if supported", "disable_entity": "disable_entity, entity_id that stops the switch from adapting lights", "disable_state": "disable_state, state(s) of 'disable_entity', e.g., 'off' or 'total,half'", - "initial_transition": "initial_transition, the transition of the lights when turning them on or when 'disable_state' or 'sleep_state' change", + "initial_transition": "initial_transition, when lights go 'off' → 'on' or when 'disable_state'/'sleep_state' changes", "interval": "interval, time between switch updates in seconds", "max_brightness": "max_brightness, in %", "max_color_temp": "max_color_temp, in Kelvin", @@ -36,7 +36,7 @@ "prefer_rgb_color": "prefer_rgb_color, use 'rgb_color' over 'color_temp' when possible", "sleep_brightness": "sleep_brightness, in %", "sleep_color_temp": "sleep_color_temp, in Kelvin", - "sleep_entity": "sleep_entity, entity_id turns the switch into sleep mode", + "sleep_entity": "sleep_entity, 'entity_id' that manages the switch's sleep mode", "sleep_state": "sleep_state, state(s) of 'sleep_entity', e.g., 'off' or 'total,half'", "sunrise_offset": "sunrise_offset, in +/- seconds", "sunrise_time": "sunrise_time, in 'HH:MM:SS' format",