Fix displaying of friendly_name for light template component (#9413)

This commit is contained in:
rollbrettler 2017-09-14 10:13:01 +02:00 committed by Pascal Vizeli
parent 3430c1c8bc
commit 371d1cc872
2 changed files with 43 additions and 0 deletions

View File

@ -127,6 +127,11 @@ class LightTemplate(Light):
"""Return the brightness of the light."""
return self._brightness
@property
def name(self):
"""Return the display name of this light."""
return self._name
@property
def supported_features(self):
"""Flag supported features."""

View File

@ -590,6 +590,44 @@ class TestTemplateLight:
assert state.attributes.get('brightness') == '42'
def test_friendly_name(self):
"""Test the accessibility of the friendly_name attribute."""
with assert_setup_component(1, 'light'):
assert setup.setup_component(self.hass, 'light', {
'light': {
'platform': 'template',
'lights': {
'test_template_light': {
'friendly_name': 'Template light',
'value_template': "{{ 1 == 1 }}",
'turn_on': {
'service': 'light.turn_on',
'entity_id': 'light.test_state'
},
'turn_off': {
'service': 'light.turn_off',
'entity_id': 'light.test_state'
},
'set_level': {
'service': 'light.turn_on',
'data_template': {
'entity_id': 'light.test_state',
'brightness': '{{brightness}}'
}
}
}
}
}
})
self.hass.start()
self.hass.block_till_done()
state = self.hass.states.get('light.test_template_light')
assert state is not None
assert state.attributes.get('friendly_name') == 'Template light'
@asyncio.coroutine
def test_restore_state(hass):