Initial state over restore state (#6924)

* Input Boolean: initial state > restore state

* Input select: initial state overrules restored state

* Input slider: initial state overrule restore state

* Lint

* Lint
This commit is contained in:
Paulus Schoutsen 2017-04-04 09:29:49 -07:00 committed by GitHub
parent c5574c2684
commit c4e1255a84
7 changed files with 147 additions and 63 deletions

View file

@ -229,7 +229,6 @@ def test_restore_state(hass):
'middle option',
'last option',
],
'initial': 'middle option',
}
yield from async_setup_component(hass, DOMAIN, {
@ -242,6 +241,38 @@ def test_restore_state(hass):
assert state
assert state.state == 'last option'
state = hass.states.get('input_select.s2')
assert state
assert state.state == 'first option'
@asyncio.coroutine
def test_initial_state_overrules_restore_state(hass):
"""Ensure states are restored on startup."""
mock_restore_cache(hass, (
State('input_select.s1', 'last option'),
State('input_select.s2', 'bad option'),
))
options = {
'options': [
'first option',
'middle option',
'last option',
],
'initial': 'middle option',
}
yield from async_setup_component(hass, DOMAIN, {
DOMAIN: {
's1': options,
's2': options,
}})
state = hass.states.get('input_select.s1')
assert state
assert state.state == 'middle option'
state = hass.states.get('input_select.s2')
assert state
assert state.state == 'middle option'