Skip to content

Commit

Permalink
fix bug: make sure 'last_state is not None'
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Oct 22, 2020
1 parent 4d24249 commit 4ffa6fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 3 additions & 1 deletion custom_components/adaptive_lighting/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,9 @@ async def async_added_to_hass(self) -> None:
"""Call when entity about to be added to hass."""
last_state = await self.async_get_last_state()
_LOGGER.debug("%s: last state is %s", self._name, last_state)
if (last_state is None and self._initial_state) or last_state.state == STATE_ON:
if (last_state is None and self._initial_state) or (
last_state is not None and last_state.state == STATE_ON
):
await self.async_turn_on()
else:
await self.async_turn_off()
Expand Down
9 changes: 3 additions & 6 deletions custom_components/adaptive_lighting/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
"step": {
"init": {
"title": "Adaptive Lighting Optionen",
"description": "Alle Einstellungen für eine Adaptive Lighting Komponente. Die Optionsnamen entsprechen den YAML-Einstellungen. Es werden keine Optionen angezeigt, wenn dieser Eintrag in YAML konfiguriert wurde.",
"description": "Alle Einstellungen für eine Adaptive Lighting Komponente. Die Optionsnamen entsprechen den YAML-Einstellungen. Es werden keine Optionen angezeigt, wenn dieser Eintrag in YAML konfiguriert wurde.",
"data": {
"lights": "Lichter",
"adapt_brightness": "adapt_brightness, Helligkeit anpassen",
"adapt_color_temp": "adapt_color_temp, Farbtemperatur anpassen, wenn color_temp unterstüzt",
"adapt_rgb_color": "adapt_rgb_color, Farbtemperatur anpassen, wenn RGB/XY unterstüzt",
"initial_transition": "initial_transition, wenn Lichter von 'off' zu 'on' wechseln oder wenn 'sleep_state' wechselt",
"interval": "interval, Zeit zwischen Updates des Switches",
"max_brightness": "max_brightness, maximale Helligkeit in %",
Expand All @@ -39,7 +36,7 @@
"sunset_offset": "sunset_offset, Sonnenuntergang Verschiebung in +/- seconds",
"sunset_time": "sunset_time, Sonnenuntergangszeit in 'HH:MM:SS' Format (wenn 'None' wird die aktuelle Zeit des Sonnenuntergangs an deiner Position verwendet)",
"take_over_control": "take_over_control, wenn irgendetwas während ein Licht an ist außer Adaptive Lighting den Service 'light.turn_on' aufruft, stoppe die Anpassung des Lichtes (oder des Schalters) bis dieser wieder von off -> on geschaltet wird.",
"detect_non_ha_changes": "detect_non_ha_changes, entdeckt alle Änderungen über 5% am Licht (auch außerhalb von HA gemacht), 'take_over_control' muss aktiviert sein (ruft 'homeassistant.update_entity' jede 'interval' auf!)",
"detect_non_ha_changes": "detect_non_ha_changes, entdeckt alle Änderungen über 10% am Licht (auch außerhalb von HA gemacht), 'take_over_control' muss aktiviert sein (ruft 'homeassistant.update_entity' jede 'interval' auf!)",
"transition": "transition, Wechselzeit in Sekunden"
}
}
Expand All @@ -48,4 +45,4 @@
"option_error": "Fehlerhafte Option"
}
}
}
}

0 comments on commit 4ffa6fc

Please sign in to comment.