From e61dda4dd349a6f357185854ead952167222ff1e Mon Sep 17 00:00:00 2001 From: Ryan Spicer Date: Sun, 18 Sep 2016 22:43:04 -0700 Subject: [PATCH] fix pep8 errors and typos in tests. --- homeassistant/components/light/mqtt.py | 7 +++---- tests/components/light/test_mqtt.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/light/mqtt.py b/homeassistant/components/light/mqtt.py index 79cb2b275cc..f7e334b7cf7 100644 --- a/homeassistant/components/light/mqtt.py +++ b/homeassistant/components/light/mqtt.py @@ -11,11 +11,11 @@ import voluptuous as vol import homeassistant.components.mqtt as mqtt from homeassistant.components.light import ( - ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_COLOR_TEMP, SUPPORT_BRIGHTNESS, + ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_COLOR_TEMP, SUPPORT_BRIGHTNESS, SUPPORT_RGB_COLOR, SUPPORT_COLOR_TEMP, Light) from homeassistant.const import ( CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE, CONF_PAYLOAD_OFF, - CONF_PAYLOAD_ON, CONF_STATE, CONF_BRIGHTNESS, CONF_RGB, + CONF_PAYLOAD_ON, CONF_STATE, CONF_BRIGHTNESS, CONF_RGB, CONF_COLOR_TEMP) from homeassistant.components.mqtt import ( CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN) @@ -129,7 +129,7 @@ class MqttLight(Light): topic[CONF_BRIGHTNESS_STATE_TOPIC] is not None and SUPPORT_BRIGHTNESS) self._supported_features |= ( - topic[CONF_COLOR_TEMP_STATE_TOPIC] is not None + topic[CONF_COLOR_TEMP_STATE_TOPIC] is not None and SUPPORT_COLOR_TEMP) templates = {key: ((lambda value: value) if tpl is None else @@ -210,7 +210,6 @@ class MqttLight(Light): @property def color_temp(self): return self._color_temp - @property def should_poll(self): diff --git a/tests/components/light/test_mqtt.py b/tests/components/light/test_mqtt.py index e74bc4c2dd1..375a4a45905 100644 --- a/tests/components/light/test_mqtt.py +++ b/tests/components/light/test_mqtt.py @@ -186,9 +186,9 @@ class TestLightMQTT(unittest.TestCase): self.assertEqual(100, light_state.attributes['brightness']) - fire_mqtt_message(self.hass, 'test_lgith_rgb/color_temp/status', '300') + fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status', '300') self.hass.block_till_done() - light_state = self.hass.states.get('light-test') + light_state = self.hass.states.get('light.test') self.hass.block_till_done() self.assertEqual(300, light_state.attributes['color_temp']) @@ -260,6 +260,7 @@ class TestLightMQTT(unittest.TestCase): 'state_topic': 'test_light_rgb/status', 'command_topic': 'test_light_rgb/set', 'brightness_state_topic': 'test_light_rgb/brightness/status', + 'color_temp_state_topic': 'test_light_rgb/color_temp/status', 'rgb_state_topic': 'test_light_rgb/rgb/status', 'state_value_template': '{{ value_json.hello }}', 'brightness_value_template': '{{ value_json.hello }}', @@ -280,7 +281,7 @@ class TestLightMQTT(unittest.TestCase): fire_mqtt_message(self.hass, 'test_light_rgb/brightness/status', '{"hello": "50"}') fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status', - '{"hello": "300}') + '{"hello": "300"}') self.hass.block_till_done() state = self.hass.states.get('light.test') @@ -377,15 +378,15 @@ class TestLightMQTT(unittest.TestCase): """Test the color temp only if a command topic is present.""" self.hass.config.components = ['mqtt'] assert _setup_component(self.hass, light.DOMAIN, { - light.DOMAIN:{ + light.DOMAIN: { 'platform': 'mqtt', 'name': 'test', 'color_temp_command_topic': 'test_light_rgb/brightness/set', 'command_topic': 'test_light_rgb/set', 'state_topic': 'test_light_rgb/status' } - }) - + }) + state = self.hass.states.get('light.test') self.assertEqual(STATE_OFF, state.state) self.assertIsNone(state.attributes.get('color_temp')) @@ -395,4 +396,4 @@ class TestLightMQTT(unittest.TestCase): state = self.hass.states.get('light.test') self.assertEqual(STATE_ON, state.state) - self.assertEqual(150, state.attributes.get('color_temp')) \ No newline at end of file + self.assertEqual(150, state.attributes.get('color_temp'))