mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
Fix light template to return brightness as int (#12447)
This commit is contained in:
parent
b651cdd8f2
commit
fcf97524a2
@ -237,7 +237,6 @@ class LightTemplate(Light):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_update(self):
|
def async_update(self):
|
||||||
"""Update the state from the template."""
|
"""Update the state from the template."""
|
||||||
print("ASYNC UPDATE")
|
|
||||||
if self._template is not None:
|
if self._template is not None:
|
||||||
try:
|
try:
|
||||||
state = self._template.async_render().lower()
|
state = self._template.async_render().lower()
|
||||||
@ -262,7 +261,7 @@ class LightTemplate(Light):
|
|||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
if 0 <= int(brightness) <= 255:
|
if 0 <= int(brightness) <= 255:
|
||||||
self._brightness = brightness
|
self._brightness = int(brightness)
|
||||||
else:
|
else:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
'Received invalid brightness : %s' +
|
'Received invalid brightness : %s' +
|
||||||
|
@ -586,7 +586,7 @@ class TestTemplateLight:
|
|||||||
state = self.hass.states.get('light.test_template_light')
|
state = self.hass.states.get('light.test_template_light')
|
||||||
assert state is not None
|
assert state is not None
|
||||||
|
|
||||||
assert state.attributes.get('brightness') == '42'
|
assert state.attributes.get('brightness') == 42
|
||||||
|
|
||||||
def test_friendly_name(self):
|
def test_friendly_name(self):
|
||||||
"""Test the accessibility of the friendly_name attribute."""
|
"""Test the accessibility of the friendly_name attribute."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user