Allow getting number of available states in template (#9158)
This commit is contained in:
parent
c367021aa4
commit
5629157740
2 changed files with 22 additions and 0 deletions
|
@ -782,3 +782,17 @@ def test_state_with_unit(hass):
|
|||
hass)
|
||||
|
||||
assert tpl.async_render() == ''
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_length_of_states(hass):
|
||||
"""Test fetching the length of states."""
|
||||
hass.states.async_set('sensor.test', '23')
|
||||
hass.states.async_set('sensor.test2', 'wow')
|
||||
hass.states.async_set('climate.test2', 'cooling')
|
||||
|
||||
tpl = template.Template('{{ states | length }}', hass)
|
||||
assert tpl.async_render() == '3'
|
||||
|
||||
tpl = template.Template('{{ states.sensor | length }}', hass)
|
||||
assert tpl.async_render() == '2'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue