mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Fix displaying of friendly_name for light template component (#9413)
This commit is contained in:
parent
3430c1c8bc
commit
371d1cc872
@ -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."""
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user