Add native Python types support to templates (#41227)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
cbb4324c84
commit
ee914366a8
29 changed files with 349 additions and 282 deletions
|
@ -136,7 +136,16 @@ class SwitchTemplate(TemplateEntity, SwitchEntity, RestoreEntity):
|
|||
if isinstance(result, TemplateError):
|
||||
self._state = None
|
||||
return
|
||||
self._state = result.lower() in ("true", STATE_ON)
|
||||
|
||||
if isinstance(result, bool):
|
||||
self._state = result
|
||||
return
|
||||
|
||||
if isinstance(result, str):
|
||||
self._state = result.lower() in ("true", STATE_ON)
|
||||
return
|
||||
|
||||
self._state = False
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue