Bugfix slider (#7047)

* Bugfix slider

* Update input_slider.py

* Update input_slider.py
This commit is contained in:
Pascal Vizeli 2017-04-11 18:23:41 +02:00 committed by Paulus Schoutsen
parent b52cabf2c0
commit 11125864c6
2 changed files with 20 additions and 2 deletions

View file

@ -174,8 +174,8 @@ class InputSlider(Entity):
state = yield from async_get_last_state(self.hass, self.entity_id)
value = state and float(state.state)
# Check against False because value can be 0
if value is not False and self._minimum < value < self._maximum:
# Check against None because value can be 0
if value is not None and self._minimum <= value <= self._maximum:
self._current_value = value
else:
self._current_value = self._minimum

View file

@ -133,3 +133,21 @@ def test_initial_state_overrules_restore_state(hass):
state = hass.states.get('input_slider.b2')
assert state
assert float(state.state) == 60
@asyncio.coroutine
def test_no_initial_state_and_no_restore_state(hass):
"""Ensure that entity is create without initial and restore feature."""
hass.state = CoreState.starting
yield from async_setup_component(hass, DOMAIN, {
DOMAIN: {
'b1': {
'min': 0,
'max': 100,
},
}})
state = hass.states.get('input_slider.b1')
assert state
assert float(state.state) == 0