1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Allow device_class for template covers

* #23486. Allows device_class to be set for template covers
This commit is contained in:
Penny Wood
2019-04-29 20:38:59 +08:00
committed by GitHub
parent 471a26bde1
commit 5e045f3df2
2 changed files with 75 additions and 4 deletions

View File

@@ -756,3 +756,65 @@ async def test_entity_picture_template(hass, calls):
state = hass.states.get('cover.test_template_cover')
assert state.attributes['entity_picture'] == '/local/cover.png'
async def test_device_class(hass, calls):
"""Test device class."""
with assert_setup_component(1, 'cover'):
assert await setup.async_setup_component(hass, 'cover', {
'cover': {
'platform': 'template',
'covers': {
'test_template_cover': {
'value_template':
"{{ states.cover.test_state.state }}",
'device_class': "door",
'open_cover': {
'service': 'cover.open_cover',
'entity_id': 'cover.test_state'
},
'close_cover': {
'service': 'cover.close_cover',
'entity_id': 'cover.test_state'
},
}
}
}
})
await hass.async_start()
await hass.async_block_till_done()
state = hass.states.get('cover.test_template_cover')
assert state.attributes.get('device_class') == 'door'
async def test_invalid_device_class(hass, calls):
"""Test device class."""
with assert_setup_component(0, 'cover'):
assert await setup.async_setup_component(hass, 'cover', {
'cover': {
'platform': 'template',
'covers': {
'test_template_cover': {
'value_template':
"{{ states.cover.test_state.state }}",
'device_class': "barnacle_bill",
'open_cover': {
'service': 'cover.open_cover',
'entity_id': 'cover.test_state'
},
'close_cover': {
'service': 'cover.close_cover',
'entity_id': 'cover.test_state'
},
}
}
}
})
await hass.async_start()
await hass.async_block_till_done()
state = hass.states.get('cover.test_template_cover')
assert not state