mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
fix pep8 errors and typos in tests.
This commit is contained in:
@@ -11,11 +11,11 @@ import voluptuous as vol
|
|||||||
|
|
||||||
import homeassistant.components.mqtt as mqtt
|
import homeassistant.components.mqtt as mqtt
|
||||||
from homeassistant.components.light import (
|
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)
|
SUPPORT_RGB_COLOR, SUPPORT_COLOR_TEMP, Light)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE, CONF_PAYLOAD_OFF,
|
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)
|
CONF_COLOR_TEMP)
|
||||||
from homeassistant.components.mqtt import (
|
from homeassistant.components.mqtt import (
|
||||||
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN)
|
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
|
topic[CONF_BRIGHTNESS_STATE_TOPIC] is not None
|
||||||
and SUPPORT_BRIGHTNESS)
|
and SUPPORT_BRIGHTNESS)
|
||||||
self._supported_features |= (
|
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)
|
and SUPPORT_COLOR_TEMP)
|
||||||
|
|
||||||
templates = {key: ((lambda value: value) if tpl is None else
|
templates = {key: ((lambda value: value) if tpl is None else
|
||||||
@@ -210,7 +210,6 @@ class MqttLight(Light):
|
|||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
return self._color_temp
|
return self._color_temp
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
@@ -186,9 +186,9 @@ class TestLightMQTT(unittest.TestCase):
|
|||||||
self.assertEqual(100,
|
self.assertEqual(100,
|
||||||
light_state.attributes['brightness'])
|
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()
|
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.hass.block_till_done()
|
||||||
self.assertEqual(300, light_state.attributes['color_temp'])
|
self.assertEqual(300, light_state.attributes['color_temp'])
|
||||||
|
|
||||||
@@ -260,6 +260,7 @@ class TestLightMQTT(unittest.TestCase):
|
|||||||
'state_topic': 'test_light_rgb/status',
|
'state_topic': 'test_light_rgb/status',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'brightness_state_topic': 'test_light_rgb/brightness/status',
|
'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',
|
'rgb_state_topic': 'test_light_rgb/rgb/status',
|
||||||
'state_value_template': '{{ value_json.hello }}',
|
'state_value_template': '{{ value_json.hello }}',
|
||||||
'brightness_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',
|
fire_mqtt_message(self.hass, 'test_light_rgb/brightness/status',
|
||||||
'{"hello": "50"}')
|
'{"hello": "50"}')
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status',
|
fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status',
|
||||||
'{"hello": "300}')
|
'{"hello": "300"}')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
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."""
|
"""Test the color temp only if a command topic is present."""
|
||||||
self.hass.config.components = ['mqtt']
|
self.hass.config.components = ['mqtt']
|
||||||
assert _setup_component(self.hass, light.DOMAIN, {
|
assert _setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN:{
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt',
|
'platform': 'mqtt',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'color_temp_command_topic': 'test_light_rgb/brightness/set',
|
'color_temp_command_topic': 'test_light_rgb/brightness/set',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'state_topic': 'test_light_rgb/status'
|
'state_topic': 'test_light_rgb/status'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(STATE_OFF, state.state)
|
self.assertEqual(STATE_OFF, state.state)
|
||||||
self.assertIsNone(state.attributes.get('color_temp'))
|
self.assertIsNone(state.attributes.get('color_temp'))
|
||||||
@@ -395,4 +396,4 @@ class TestLightMQTT(unittest.TestCase):
|
|||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(STATE_ON, state.state)
|
self.assertEqual(STATE_ON, state.state)
|
||||||
self.assertEqual(150, state.attributes.get('color_temp'))
|
self.assertEqual(150, state.attributes.get('color_temp'))
|
||||||
|
Reference in New Issue
Block a user