Fix mqtt_json color commands (#13617)

This commit is contained in:
Adam Mills authored and Paulus Schoutsen committed 2018-04-01 11:25:51 -07:00
1 parent 9f0f7394fb
commit ff72c5e456
2 files changed
+44 -13

No files matched your search

+27
View File
@@ -334,6 +334,33 @@ class TestLightMQTTJSON(unittest.TestCase):
self.assertEqual('colorloop', state.attributes['effect'])
self.assertEqual(170, state.attributes['white_value'])
# Test a color command
light.turn_on(self.hass, 'light.test',
brightness=50, hs_color=(125, 100))
self.hass.block_till_done()
self.assertEqual('test_light_rgb/set',
self.mock_publish.async_publish.mock_calls[0][1][0])
self.assertEqual(2,
self.mock_publish.async_publish.mock_calls[0][1][2])
self.assertEqual(False,
self.mock_publish.async_publish.mock_calls[0][1][3])
# Get the sent message
message_json = json.loads(
self.mock_publish.async_publish.mock_calls[1][1][1])
self.assertEqual(50, message_json["brightness"])
self.assertEqual({
'r': 0,
'g': 50,
'b': 4,
}, message_json["color"])
self.assertEqual("ON", message_json["state"])
state = self.hass.states.get('light.test')
self.assertEqual(STATE_ON, state.state)
self.assertEqual(50, state.attributes['brightness'])
self.assertEqual((125, 100), state.attributes['hs_color'])
def test_flash_short_and_long(self): \
# pylint: disable=invalid-name
"""Test for flash length being sent when included."""