Remove service helper (5) (#16917)
* Update switch * Update script * Update light * Fix tests * Fix config/script hook * Async_create_task * Fix flux switch
This commit is contained in:
parent
a7248d4574
commit
70b901017f
27 changed files with 385 additions and 316 deletions
|
@ -98,9 +98,11 @@ from homeassistant.const import (
|
|||
ATTR_SUPPORTED_FEATURES)
|
||||
import homeassistant.components.light as light
|
||||
import homeassistant.core as ha
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, mock_mqtt_component, fire_mqtt_message,
|
||||
assert_setup_component, mock_coro)
|
||||
from tests.components.light import common
|
||||
|
||||
|
||||
class TestLightMQTTJSON(unittest.TestCase):
|
||||
|
@ -315,7 +317,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
self.assertEqual(191, state.attributes.get(ATTR_SUPPORTED_FEATURES))
|
||||
self.assertTrue(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||
|
||||
light.turn_on(self.hass, 'light.test')
|
||||
common.turn_on(self.hass, 'light.test')
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
|
@ -324,7 +326,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
|
||||
light.turn_off(self.hass, 'light.test')
|
||||
common.turn_off(self.hass, 'light.test')
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
|
@ -333,9 +335,9 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_OFF, state.state)
|
||||
|
||||
light.turn_on(self.hass, 'light.test',
|
||||
brightness=50, color_temp=155, effect='colorloop',
|
||||
white_value=170)
|
||||
common.turn_on(self.hass, 'light.test',
|
||||
brightness=50, color_temp=155, effect='colorloop',
|
||||
white_value=170)
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual('test_light_rgb/set',
|
||||
|
@ -361,8 +363,8 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
self.assertEqual(170, state.attributes['white_value'])
|
||||
|
||||
# Test a color command
|
||||
light.turn_on(self.hass, 'light.test',
|
||||
brightness=50, hs_color=(125, 100))
|
||||
common.turn_on(self.hass, 'light.test',
|
||||
brightness=50, hs_color=(125, 100))
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual('test_light_rgb/set',
|
||||
|
@ -398,7 +400,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
}
|
||||
})
|
||||
|
||||
light.turn_on(self.hass, 'light.test', hs_color=(180.0, 50.0))
|
||||
common.turn_on(self.hass, 'light.test', hs_color=(180.0, 50.0))
|
||||
self.hass.block_till_done()
|
||||
|
||||
message_json = json.loads(
|
||||
|
@ -427,7 +429,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
self.assertEqual(STATE_OFF, state.state)
|
||||
self.assertEqual(40, state.attributes.get(ATTR_SUPPORTED_FEATURES))
|
||||
|
||||
light.turn_on(self.hass, 'light.test', flash="short")
|
||||
common.turn_on(self.hass, 'light.test', flash="short")
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual('test_light_rgb/set',
|
||||
|
@ -443,7 +445,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
self.assertEqual("ON", message_json["state"])
|
||||
|
||||
self.mock_publish.async_publish.reset_mock()
|
||||
light.turn_on(self.hass, 'light.test', flash="long")
|
||||
common.turn_on(self.hass, 'light.test', flash="long")
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual('test_light_rgb/set',
|
||||
|
@ -474,7 +476,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
self.assertEqual(STATE_OFF, state.state)
|
||||
self.assertEqual(40, state.attributes.get(ATTR_SUPPORTED_FEATURES))
|
||||
|
||||
light.turn_on(self.hass, 'light.test', transition=10)
|
||||
common.turn_on(self.hass, 'light.test', transition=10)
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual('test_light_rgb/set',
|
||||
|
@ -490,7 +492,7 @@ class TestLightMQTTJSON(unittest.TestCase):
|
|||
self.assertEqual("ON", message_json["state"])
|
||||
|
||||
# Transition back off
|
||||
light.turn_off(self.hass, 'light.test', transition=10)
|
||||
common.turn_off(self.hass, 'light.test', transition=10)
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual('test_light_rgb/set',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue