diff --git a/homeassistant/components/garage_door/wink.py b/homeassistant/components/garage_door/wink.py index aa714a790ca..b32b20dde0a 100644 --- a/homeassistant/components/garage_door/wink.py +++ b/homeassistant/components/garage_door/wink.py @@ -11,7 +11,7 @@ import logging from homeassistant.components.garage_door import GarageDoorDevice from homeassistant.const import CONF_ACCESS_TOKEN -REQUIREMENTS = ['python-wink==0.5.0'] +REQUIREMENTS = ['python-wink==0.6.0'] def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/homeassistant/components/light/wink.py b/homeassistant/components/light/wink.py index 6b7bb1afcec..2fed8904762 100644 --- a/homeassistant/components/light/wink.py +++ b/homeassistant/components/light/wink.py @@ -11,7 +11,7 @@ import logging from homeassistant.components.light import ATTR_BRIGHTNESS, Light from homeassistant.const import CONF_ACCESS_TOKEN -REQUIREMENTS = ['python-wink==0.5.0'] +REQUIREMENTS = ['python-wink==0.6.0'] def setup_platform(hass, config, add_devices_callback, discovery_info=None): diff --git a/homeassistant/components/lock/wink.py b/homeassistant/components/lock/wink.py index 9c73c35d130..be558dceee7 100644 --- a/homeassistant/components/lock/wink.py +++ b/homeassistant/components/lock/wink.py @@ -11,7 +11,7 @@ import logging from homeassistant.components.lock import LockDevice from homeassistant.const import CONF_ACCESS_TOKEN -REQUIREMENTS = ['python-wink==0.5.0'] +REQUIREMENTS = ['python-wink==0.6.0'] def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/homeassistant/components/sensor/wink.py b/homeassistant/components/sensor/wink.py index 48583426d72..71fadff157b 100644 --- a/homeassistant/components/sensor/wink.py +++ b/homeassistant/components/sensor/wink.py @@ -11,7 +11,7 @@ import logging from homeassistant.helpers.entity import Entity from homeassistant.const import CONF_ACCESS_TOKEN, STATE_OPEN, STATE_CLOSED -REQUIREMENTS = ['python-wink==0.5.0'] +REQUIREMENTS = ['python-wink==0.6.0'] def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/homeassistant/components/switch/wink.py b/homeassistant/components/switch/wink.py index 19abc1c4fce..23ba434ad2b 100644 --- a/homeassistant/components/switch/wink.py +++ b/homeassistant/components/switch/wink.py @@ -11,7 +11,7 @@ import logging from homeassistant.components.wink import WinkToggleDevice from homeassistant.const import CONF_ACCESS_TOKEN -REQUIREMENTS = ['python-wink==0.5.0'] +REQUIREMENTS = ['python-wink==0.6.0'] def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index 6fa2b9287e9..ef97e958dc0 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -16,7 +16,7 @@ from homeassistant.const import ( ATTR_SERVICE, ATTR_DISCOVERED) DOMAIN = "wink" -REQUIREMENTS = ['python-wink==0.5.0'] +REQUIREMENTS = ['python-wink==0.6.0'] DISCOVER_LIGHTS = "wink.lights" DISCOVER_SWITCHES = "wink.switches" diff --git a/homeassistant/core.py b/homeassistant/core.py index 39a10beda8d..37f909e218a 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -309,7 +309,7 @@ class State(object): "Format should be .").format(entity_id)) self.entity_id = entity_id.lower() - self.state = state + self.state = str(state) self.attributes = MappingProxyType(attributes or {}) self.last_updated = dt_util.strip_microseconds( last_updated or dt_util.utcnow()) diff --git a/homeassistant/helpers/state.py b/homeassistant/helpers/state.py index 1a3520d4733..23673e678ca 100644 --- a/homeassistant/helpers/state.py +++ b/homeassistant/helpers/state.py @@ -109,16 +109,5 @@ def state_as_number(state): elif state.state in (STATE_OFF, STATE_UNLOCKED, STATE_UNKNOWN, STATE_BELOW_HORIZON, STATE_CLOSED): return 0 - else: - try: - # This distinction is probably not important, - # but in case something downstream cares about - # int vs. float, try to be helpful here. - if '.' in state.state: - return float(state.state) - else: - return int(state.state) - except (ValueError, TypeError): - pass - raise ValueError('State is not a number') + return float(state.state) diff --git a/requirements_all.txt b/requirements_all.txt index b5532905ca3..bfd1e8c7c45 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -199,7 +199,7 @@ python-twitch==1.2.0 # homeassistant.components.lock.wink # homeassistant.components.sensor.wink # homeassistant.components.switch.wink -python-wink==0.5.0 +python-wink==0.6.0 # homeassistant.components.keyboard pyuserinput==0.1.9 diff --git a/tests/components/test_graphite.py b/tests/components/test_graphite.py index c0ca228efe2..34ad93a86c4 100644 --- a/tests/components/test_graphite.py +++ b/tests/components/test_graphite.py @@ -89,6 +89,7 @@ class TestGraphite(unittest.TestCase): 'bat': 'NaN', } expected = [ + 'ha.entity.state 0.000000 12345', 'ha.entity.foo 1.000000 12345', 'ha.entity.bar 2.000000 12345', 'ha.entity.baz 1.000000 12345', diff --git a/tests/components/test_statsd.py b/tests/components/test_statsd.py index a793e519a2e..5057ac7bc19 100644 --- a/tests/components/test_statsd.py +++ b/tests/components/test_statsd.py @@ -7,6 +7,7 @@ Tests StatsD feeder. import unittest from unittest import mock +import homeassistant.core as ha import homeassistant.components.statsd as statsd from homeassistant.const import STATE_ON, STATE_OFF, EVENT_STATE_CHANGED @@ -78,6 +79,6 @@ class TestStatsd(unittest.TestCase): mock_gauge.return_value.send.reset_mock() for invalid in ('foo', '', object): - state = mock.MagicMock(state=invalid) - handler_method(mock.MagicMock(data={'new_state': state})) + handler_method(mock.MagicMock(data={ + 'new_state': ha.State('domain.test', invalid, {})})) self.assertFalse(mock_gauge.return_value.send.called) diff --git a/tests/helpers/test_state.py b/tests/helpers/test_state.py index 3924bd0489e..e11426e2f95 100644 --- a/tests/helpers/test_state.py +++ b/tests/helpers/test_state.py @@ -163,24 +163,18 @@ class TestStateHelpers(unittest.TestCase): ha.State('domain.test', _state, {}))) def test_as_number_coercion(self): - for _state in ('0', '0.0'): - self.assertEqual(0.0, float( - state.state_as_number( - ha.State('domain.test', _state, {})))) - for _state in ('1', '1.0'): + for _state in ('0', '0.0', 0, 0.0): self.assertEqual( - 1.0, float(state.state_as_number( - ha.State('domain.test', _state, {})))) - - def test_as_number_tries_to_keep_types(self): - result = state.state_as_number(ha.State('domain.test', '1', {})) - self.assertTrue(isinstance(result, int)) - result = state.state_as_number(ha.State('domain.test', '1.0', {})) - self.assertTrue(isinstance(result, float)) + 0.0, state.state_as_number( + ha.State('domain.test', _state, {}))) + for _state in ('1', '1.0', 1, 1.0): + self.assertEqual( + 1.0, state.state_as_number( + ha.State('domain.test', _state, {}))) def test_as_number_invalid_cases(self): - for _state in ('', 'foo', 'foo.bar', None, False, True, None, - object, object()): + for _state in ('', 'foo', 'foo.bar', None, False, True, object, + object()): self.assertRaises(ValueError, state.state_as_number, ha.State('domain.test', _state, {}))