Fix line endings [skipci] (#12333)
This commit is contained in:
parent
669929de06
commit
5d15b257c4
7 changed files with 1411 additions and 1410 deletions
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -7,3 +7,4 @@
|
||||||
*.jpg binary
|
*.jpg binary
|
||||||
*.png binary
|
*.png binary
|
||||||
*.zip binary
|
*.zip binary
|
||||||
|
*.mp3 binary
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
# Describes the format for available alarm control panel services
|
# Describes the format for available alarm control panel services
|
||||||
|
|
||||||
alarm_disarm:
|
alarm_disarm:
|
||||||
description: Send the alarm the command for disarm.
|
description: Send the alarm the command for disarm.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name of alarm control panel to disarm.
|
description: Name of alarm control panel to disarm.
|
||||||
example: 'alarm_control_panel.downstairs'
|
example: 'alarm_control_panel.downstairs'
|
||||||
code:
|
code:
|
||||||
description: An optional code to disarm the alarm control panel with.
|
description: An optional code to disarm the alarm control panel with.
|
||||||
example: 1234
|
example: 1234
|
||||||
|
|
||||||
alarm_arm_home:
|
alarm_arm_home:
|
||||||
description: Send the alarm the command for arm home.
|
description: Send the alarm the command for arm home.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name of alarm control panel to arm home.
|
description: Name of alarm control panel to arm home.
|
||||||
example: 'alarm_control_panel.downstairs'
|
example: 'alarm_control_panel.downstairs'
|
||||||
code:
|
code:
|
||||||
description: An optional code to arm home the alarm control panel with.
|
description: An optional code to arm home the alarm control panel with.
|
||||||
example: 1234
|
example: 1234
|
||||||
|
|
||||||
alarm_arm_away:
|
alarm_arm_away:
|
||||||
description: Send the alarm the command for arm away.
|
description: Send the alarm the command for arm away.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name of alarm control panel to arm away.
|
description: Name of alarm control panel to arm away.
|
||||||
example: 'alarm_control_panel.downstairs'
|
example: 'alarm_control_panel.downstairs'
|
||||||
code:
|
code:
|
||||||
description: An optional code to arm away the alarm control panel with.
|
description: An optional code to arm away the alarm control panel with.
|
||||||
example: 1234
|
example: 1234
|
||||||
|
|
||||||
alarm_arm_night:
|
alarm_arm_night:
|
||||||
description: Send the alarm the command for arm night.
|
description: Send the alarm the command for arm night.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name of alarm control panel to arm night.
|
description: Name of alarm control panel to arm night.
|
||||||
example: 'alarm_control_panel.downstairs'
|
example: 'alarm_control_panel.downstairs'
|
||||||
code:
|
code:
|
||||||
description: An optional code to arm night the alarm control panel with.
|
description: An optional code to arm night the alarm control panel with.
|
||||||
example: 1234
|
example: 1234
|
||||||
|
|
||||||
alarm_trigger:
|
alarm_trigger:
|
||||||
description: Send the alarm the command for trigger.
|
description: Send the alarm the command for trigger.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name of alarm control panel to trigger.
|
description: Name of alarm control panel to trigger.
|
||||||
example: 'alarm_control_panel.downstairs'
|
example: 'alarm_control_panel.downstairs'
|
||||||
code:
|
code:
|
||||||
description: An optional code to trigger the alarm control panel with.
|
description: An optional code to trigger the alarm control panel with.
|
||||||
example: 1234
|
example: 1234
|
||||||
|
|
||||||
envisalink_alarm_keypress:
|
envisalink_alarm_keypress:
|
||||||
description: Send custom keypresses to the alarm.
|
description: Send custom keypresses to the alarm.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name of the alarm control panel to trigger.
|
description: Name of the alarm control panel to trigger.
|
||||||
example: 'alarm_control_panel.downstairs'
|
example: 'alarm_control_panel.downstairs'
|
||||||
keypress:
|
keypress:
|
||||||
description: 'String to send to the alarm panel (1-6 characters).'
|
description: 'String to send to the alarm panel (1-6 characters).'
|
||||||
example: '*71'
|
example: '*71'
|
||||||
|
|
||||||
alarmdecoder_alarm_toggle_chime:
|
alarmdecoder_alarm_toggle_chime:
|
||||||
description: Send the alarm the toggle chime command.
|
description: Send the alarm the toggle chime command.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name of the alarm control panel to trigger.
|
description: Name of the alarm control panel to trigger.
|
||||||
example: 'alarm_control_panel.downstairs'
|
example: 'alarm_control_panel.downstairs'
|
||||||
code:
|
code:
|
||||||
description: A required code to toggle the alarm control panel chime with.
|
description: A required code to toggle the alarm control panel chime with.
|
||||||
example: 1234
|
example: 1234
|
||||||
|
|
|
@ -1,63 +1,63 @@
|
||||||
# Describes the format for available cover services
|
# Describes the format for available cover services
|
||||||
|
|
||||||
open_cover:
|
open_cover:
|
||||||
description: Open all or specified cover.
|
description: Open all or specified cover.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) to open.
|
description: Name(s) of cover(s) to open.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
|
|
||||||
close_cover:
|
close_cover:
|
||||||
description: Close all or specified cover.
|
description: Close all or specified cover.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) to close.
|
description: Name(s) of cover(s) to close.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
|
|
||||||
set_cover_position:
|
set_cover_position:
|
||||||
description: Move to specific position all or specified cover.
|
description: Move to specific position all or specified cover.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) to set cover position.
|
description: Name(s) of cover(s) to set cover position.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
position:
|
position:
|
||||||
description: Position of the cover (0 to 100).
|
description: Position of the cover (0 to 100).
|
||||||
example: 30
|
example: 30
|
||||||
|
|
||||||
stop_cover:
|
stop_cover:
|
||||||
description: Stop all or specified cover.
|
description: Stop all or specified cover.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) to stop.
|
description: Name(s) of cover(s) to stop.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
|
|
||||||
open_cover_tilt:
|
open_cover_tilt:
|
||||||
description: Open all or specified cover tilt.
|
description: Open all or specified cover tilt.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) tilt to open.
|
description: Name(s) of cover(s) tilt to open.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
|
|
||||||
close_cover_tilt:
|
close_cover_tilt:
|
||||||
description: Close all or specified cover tilt.
|
description: Close all or specified cover tilt.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) to close tilt.
|
description: Name(s) of cover(s) to close tilt.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
|
|
||||||
set_cover_tilt_position:
|
set_cover_tilt_position:
|
||||||
description: Move to specific position all or specified cover tilt.
|
description: Move to specific position all or specified cover tilt.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) to set cover tilt position.
|
description: Name(s) of cover(s) to set cover tilt position.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
tilt_position:
|
tilt_position:
|
||||||
description: Tilt position of the cover (0 to 100).
|
description: Tilt position of the cover (0 to 100).
|
||||||
example: 30
|
example: 30
|
||||||
|
|
||||||
stop_cover_tilt:
|
stop_cover_tilt:
|
||||||
description: Stop all or specified cover.
|
description: Stop all or specified cover.
|
||||||
fields:
|
fields:
|
||||||
entity_id:
|
entity_id:
|
||||||
description: Name(s) of cover(s) to stop.
|
description: Name(s) of cover(s) to stop.
|
||||||
example: 'cover.living_room'
|
example: 'cover.living_room'
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,498 +1,498 @@
|
||||||
"""The tests for the MQTT Template light platform.
|
"""The tests for the MQTT Template light platform.
|
||||||
|
|
||||||
Configuration example with all features:
|
Configuration example with all features:
|
||||||
|
|
||||||
light:
|
light:
|
||||||
platform: mqtt_template
|
platform: mqtt_template
|
||||||
name: mqtt_template_light_1
|
name: mqtt_template_light_1
|
||||||
state_topic: 'home/rgb1'
|
state_topic: 'home/rgb1'
|
||||||
command_topic: 'home/rgb1/set'
|
command_topic: 'home/rgb1/set'
|
||||||
command_on_template: >
|
command_on_template: >
|
||||||
on,{{ brightness|d }},{{ red|d }}-{{ green|d }}-{{ blue|d }}
|
on,{{ brightness|d }},{{ red|d }}-{{ green|d }}-{{ blue|d }}
|
||||||
command_off_template: 'off'
|
command_off_template: 'off'
|
||||||
state_template: '{{ value.split(",")[0] }}'
|
state_template: '{{ value.split(",")[0] }}'
|
||||||
brightness_template: '{{ value.split(",")[1] }}'
|
brightness_template: '{{ value.split(",")[1] }}'
|
||||||
color_temp_template: '{{ value.split(",")[2] }}'
|
color_temp_template: '{{ value.split(",")[2] }}'
|
||||||
white_value_template: '{{ value.split(",")[3] }}'
|
white_value_template: '{{ value.split(",")[3] }}'
|
||||||
red_template: '{{ value.split(",")[4].split("-")[0] }}'
|
red_template: '{{ value.split(",")[4].split("-")[0] }}'
|
||||||
green_template: '{{ value.split(",")[4].split("-")[1] }}'
|
green_template: '{{ value.split(",")[4].split("-")[1] }}'
|
||||||
blue_template: '{{ value.split(",")[4].split("-")[2] }}'
|
blue_template: '{{ value.split(",")[4].split("-")[2] }}'
|
||||||
|
|
||||||
If your light doesn't support brightness feature, omit `brightness_template`.
|
If your light doesn't support brightness feature, omit `brightness_template`.
|
||||||
|
|
||||||
If your light doesn't support color temp feature, omit `color_temp_template`.
|
If your light doesn't support color temp feature, omit `color_temp_template`.
|
||||||
|
|
||||||
If your light doesn't support white value feature, omit `white_value_template`.
|
If your light doesn't support white value feature, omit `white_value_template`.
|
||||||
|
|
||||||
If your light doesn't support RGB feature, omit `(red|green|blue)_template`.
|
If your light doesn't support RGB feature, omit `(red|green|blue)_template`.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from homeassistant.setup import setup_component
|
from homeassistant.setup import setup_component
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ON, STATE_OFF, STATE_UNAVAILABLE, ATTR_ASSUMED_STATE)
|
STATE_ON, STATE_OFF, STATE_UNAVAILABLE, ATTR_ASSUMED_STATE)
|
||||||
import homeassistant.components.light as light
|
import homeassistant.components.light as light
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
get_test_home_assistant, mock_mqtt_component, fire_mqtt_message,
|
get_test_home_assistant, mock_mqtt_component, fire_mqtt_message,
|
||||||
assert_setup_component)
|
assert_setup_component)
|
||||||
|
|
||||||
|
|
||||||
class TestLightMQTTTemplate(unittest.TestCase):
|
class TestLightMQTTTemplate(unittest.TestCase):
|
||||||
"""Test the MQTT Template light."""
|
"""Test the MQTT Template light."""
|
||||||
|
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
"""Setup things to be run when tests are started."""
|
"""Setup things to be run when tests are started."""
|
||||||
self.hass = get_test_home_assistant()
|
self.hass = get_test_home_assistant()
|
||||||
self.mock_publish = mock_mqtt_component(self.hass)
|
self.mock_publish = mock_mqtt_component(self.hass)
|
||||||
|
|
||||||
def tearDown(self): # pylint: disable=invalid-name
|
def tearDown(self): # pylint: disable=invalid-name
|
||||||
"""Stop everything that was started."""
|
"""Stop everything that was started."""
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
|
||||||
def test_setup_fails(self): \
|
def test_setup_fails(self): \
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
"""Test that setup fails with missing required configuration items."""
|
"""Test that setup fails with missing required configuration items."""
|
||||||
with assert_setup_component(0, light.DOMAIN):
|
with assert_setup_component(0, light.DOMAIN):
|
||||||
assert setup_component(self.hass, light.DOMAIN, {
|
assert setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(self.hass.states.get('light.test'))
|
self.assertIsNone(self.hass.states.get('light.test'))
|
||||||
|
|
||||||
def test_state_change_via_topic(self): \
|
def test_state_change_via_topic(self): \
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
"""Test state change via topic."""
|
"""Test state change via topic."""
|
||||||
with assert_setup_component(1, light.DOMAIN):
|
with assert_setup_component(1, light.DOMAIN):
|
||||||
assert setup_component(self.hass, light.DOMAIN, {
|
assert setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'state_topic': 'test_light_rgb',
|
'state_topic': 'test_light_rgb',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,'
|
'command_on_template': 'on,'
|
||||||
'{{ brightness|d }},'
|
'{{ brightness|d }},'
|
||||||
'{{ color_temp|d }},'
|
'{{ color_temp|d }},'
|
||||||
'{{ white_value|d }},'
|
'{{ white_value|d }},'
|
||||||
'{{ red|d }}-'
|
'{{ red|d }}-'
|
||||||
'{{ green|d }}-'
|
'{{ green|d }}-'
|
||||||
'{{ blue|d }}',
|
'{{ blue|d }}',
|
||||||
'command_off_template': 'off',
|
'command_off_template': 'off',
|
||||||
'state_template': '{{ value.split(",")[0] }}'
|
'state_template': '{{ value.split(",")[0] }}'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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('rgb_color'))
|
self.assertIsNone(state.attributes.get('rgb_color'))
|
||||||
self.assertIsNone(state.attributes.get('brightness'))
|
self.assertIsNone(state.attributes.get('brightness'))
|
||||||
self.assertIsNone(state.attributes.get('color_temp'))
|
self.assertIsNone(state.attributes.get('color_temp'))
|
||||||
self.assertIsNone(state.attributes.get('white_value'))
|
self.assertIsNone(state.attributes.get('white_value'))
|
||||||
self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
|
self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||||
|
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
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.assertIsNone(state.attributes.get('rgb_color'))
|
self.assertIsNone(state.attributes.get('rgb_color'))
|
||||||
self.assertIsNone(state.attributes.get('brightness'))
|
self.assertIsNone(state.attributes.get('brightness'))
|
||||||
self.assertIsNone(state.attributes.get('color_temp'))
|
self.assertIsNone(state.attributes.get('color_temp'))
|
||||||
self.assertIsNone(state.attributes.get('white_value'))
|
self.assertIsNone(state.attributes.get('white_value'))
|
||||||
|
|
||||||
def test_state_brightness_color_effect_temp_white_change_via_topic(self): \
|
def test_state_brightness_color_effect_temp_white_change_via_topic(self): \
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
"""Test state, bri, color, effect, color temp, white val change."""
|
"""Test state, bri, color, effect, color temp, white val change."""
|
||||||
with assert_setup_component(1, light.DOMAIN):
|
with assert_setup_component(1, light.DOMAIN):
|
||||||
assert setup_component(self.hass, light.DOMAIN, {
|
assert setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'effect_list': ['rainbow', 'colorloop'],
|
'effect_list': ['rainbow', 'colorloop'],
|
||||||
'state_topic': 'test_light_rgb',
|
'state_topic': 'test_light_rgb',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,'
|
'command_on_template': 'on,'
|
||||||
'{{ brightness|d }},'
|
'{{ brightness|d }},'
|
||||||
'{{ color_temp|d }},'
|
'{{ color_temp|d }},'
|
||||||
'{{ white_value|d }},'
|
'{{ white_value|d }},'
|
||||||
'{{ red|d }}-'
|
'{{ red|d }}-'
|
||||||
'{{ green|d }}-'
|
'{{ green|d }}-'
|
||||||
'{{ blue|d }},'
|
'{{ blue|d }},'
|
||||||
'{{ effect|d }}',
|
'{{ effect|d }}',
|
||||||
'command_off_template': 'off',
|
'command_off_template': 'off',
|
||||||
'state_template': '{{ value.split(",")[0] }}',
|
'state_template': '{{ value.split(",")[0] }}',
|
||||||
'brightness_template': '{{ value.split(",")[1] }}',
|
'brightness_template': '{{ value.split(",")[1] }}',
|
||||||
'color_temp_template': '{{ value.split(",")[2] }}',
|
'color_temp_template': '{{ value.split(",")[2] }}',
|
||||||
'white_value_template': '{{ value.split(",")[3] }}',
|
'white_value_template': '{{ value.split(",")[3] }}',
|
||||||
'red_template': '{{ value.split(",")[4].'
|
'red_template': '{{ value.split(",")[4].'
|
||||||
'split("-")[0] }}',
|
'split("-")[0] }}',
|
||||||
'green_template': '{{ value.split(",")[4].'
|
'green_template': '{{ value.split(",")[4].'
|
||||||
'split("-")[1] }}',
|
'split("-")[1] }}',
|
||||||
'blue_template': '{{ value.split(",")[4].'
|
'blue_template': '{{ value.split(",")[4].'
|
||||||
'split("-")[2] }}',
|
'split("-")[2] }}',
|
||||||
'effect_template': '{{ value.split(",")[5] }}'
|
'effect_template': '{{ value.split(",")[5] }}'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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('rgb_color'))
|
self.assertIsNone(state.attributes.get('rgb_color'))
|
||||||
self.assertIsNone(state.attributes.get('brightness'))
|
self.assertIsNone(state.attributes.get('brightness'))
|
||||||
self.assertIsNone(state.attributes.get('effect'))
|
self.assertIsNone(state.attributes.get('effect'))
|
||||||
self.assertIsNone(state.attributes.get('color_temp'))
|
self.assertIsNone(state.attributes.get('color_temp'))
|
||||||
self.assertIsNone(state.attributes.get('white_value'))
|
self.assertIsNone(state.attributes.get('white_value'))
|
||||||
self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
|
self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||||
|
|
||||||
# turn on the light, full white
|
# turn on the light, full white
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb',
|
fire_mqtt_message(self.hass, 'test_light_rgb',
|
||||||
'on,255,145,123,255-128-64,')
|
'on,255,145,123,255-128-64,')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
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([255, 128, 64], state.attributes.get('rgb_color'))
|
self.assertEqual([255, 128, 64], state.attributes.get('rgb_color'))
|
||||||
self.assertEqual(255, state.attributes.get('brightness'))
|
self.assertEqual(255, state.attributes.get('brightness'))
|
||||||
self.assertEqual(145, state.attributes.get('color_temp'))
|
self.assertEqual(145, state.attributes.get('color_temp'))
|
||||||
self.assertEqual(123, state.attributes.get('white_value'))
|
self.assertEqual(123, state.attributes.get('white_value'))
|
||||||
self.assertIsNone(state.attributes.get('effect'))
|
self.assertIsNone(state.attributes.get('effect'))
|
||||||
|
|
||||||
# turn the light off
|
# turn the light off
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'off')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'off')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
# lower the brightness
|
# lower the brightness
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,100')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,100')
|
||||||
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(100, light_state.attributes['brightness'])
|
self.assertEqual(100, light_state.attributes['brightness'])
|
||||||
|
|
||||||
# change the color temp
|
# change the color temp
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,195')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,195')
|
||||||
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(195, light_state.attributes['color_temp'])
|
self.assertEqual(195, light_state.attributes['color_temp'])
|
||||||
|
|
||||||
# change the color
|
# change the color
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,,,41-42-43')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,,,41-42-43')
|
||||||
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.assertEqual([41, 42, 43], light_state.attributes.get('rgb_color'))
|
self.assertEqual([41, 42, 43], light_state.attributes.get('rgb_color'))
|
||||||
|
|
||||||
# change the white value
|
# change the white value
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,,134')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,,134')
|
||||||
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(134, light_state.attributes['white_value'])
|
self.assertEqual(134, light_state.attributes['white_value'])
|
||||||
|
|
||||||
# change the effect
|
# change the effect
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb',
|
fire_mqtt_message(self.hass, 'test_light_rgb',
|
||||||
'on,,,,41-42-43,rainbow')
|
'on,,,,41-42-43,rainbow')
|
||||||
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.assertEqual('rainbow', light_state.attributes.get('effect'))
|
self.assertEqual('rainbow', light_state.attributes.get('effect'))
|
||||||
|
|
||||||
def test_optimistic(self): \
|
def test_optimistic(self): \
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
"""Test optimistic mode."""
|
"""Test optimistic mode."""
|
||||||
with assert_setup_component(1, light.DOMAIN):
|
with assert_setup_component(1, light.DOMAIN):
|
||||||
assert setup_component(self.hass, light.DOMAIN, {
|
assert setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,'
|
'command_on_template': 'on,'
|
||||||
'{{ brightness|d }},'
|
'{{ brightness|d }},'
|
||||||
'{{ color_temp|d }},'
|
'{{ color_temp|d }},'
|
||||||
'{{ white_value|d }},'
|
'{{ white_value|d }},'
|
||||||
'{{ red|d }}-'
|
'{{ red|d }}-'
|
||||||
'{{ green|d }}-'
|
'{{ green|d }}-'
|
||||||
'{{ blue|d }}',
|
'{{ blue|d }}',
|
||||||
'command_off_template': 'off',
|
'command_off_template': 'off',
|
||||||
'qos': 2
|
'qos': 2
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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.assertTrue(state.attributes.get(ATTR_ASSUMED_STATE))
|
self.assertTrue(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||||
|
|
||||||
# turn on the light
|
# turn on the light
|
||||||
light.turn_on(self.hass, 'light.test')
|
light.turn_on(self.hass, 'light.test')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'on,,,,--', 2, False)
|
'test_light_rgb/set', 'on,,,,--', 2, False)
|
||||||
self.mock_publish.async_publish.reset_mock()
|
self.mock_publish.async_publish.reset_mock()
|
||||||
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)
|
||||||
|
|
||||||
# turn the light off
|
# turn the light off
|
||||||
light.turn_off(self.hass, 'light.test')
|
light.turn_off(self.hass, 'light.test')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'off', 2, False)
|
'test_light_rgb/set', 'off', 2, False)
|
||||||
self.mock_publish.async_publish.reset_mock()
|
self.mock_publish.async_publish.reset_mock()
|
||||||
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)
|
||||||
|
|
||||||
# turn on the light with brightness, color
|
# turn on the light with brightness, color
|
||||||
light.turn_on(self.hass, 'light.test', brightness=50,
|
light.turn_on(self.hass, 'light.test', brightness=50,
|
||||||
rgb_color=[75, 75, 75])
|
rgb_color=[75, 75, 75])
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'on,50,,,75-75-75', 2, False)
|
'test_light_rgb/set', 'on,50,,,75-75-75', 2, False)
|
||||||
self.mock_publish.async_publish.reset_mock()
|
self.mock_publish.async_publish.reset_mock()
|
||||||
|
|
||||||
# turn on the light with color temp and white val
|
# turn on the light with color temp and white val
|
||||||
light.turn_on(self.hass, 'light.test', color_temp=200, white_value=139)
|
light.turn_on(self.hass, 'light.test', color_temp=200, white_value=139)
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'on,,200,139,--', 2, False)
|
'test_light_rgb/set', 'on,,200,139,--', 2, False)
|
||||||
|
|
||||||
# check the state
|
# check the state
|
||||||
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((75, 75, 75), state.attributes['rgb_color'])
|
self.assertEqual((75, 75, 75), state.attributes['rgb_color'])
|
||||||
self.assertEqual(50, state.attributes['brightness'])
|
self.assertEqual(50, state.attributes['brightness'])
|
||||||
self.assertEqual(200, state.attributes['color_temp'])
|
self.assertEqual(200, state.attributes['color_temp'])
|
||||||
self.assertEqual(139, state.attributes['white_value'])
|
self.assertEqual(139, state.attributes['white_value'])
|
||||||
|
|
||||||
def test_flash(self): \
|
def test_flash(self): \
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
"""Test flash."""
|
"""Test flash."""
|
||||||
with assert_setup_component(1, light.DOMAIN):
|
with assert_setup_component(1, light.DOMAIN):
|
||||||
assert setup_component(self.hass, light.DOMAIN, {
|
assert setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,{{ flash }}',
|
'command_on_template': 'on,{{ flash }}',
|
||||||
'command_off_template': 'off',
|
'command_off_template': 'off',
|
||||||
'qos': 0
|
'qos': 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
# short flash
|
# short flash
|
||||||
light.turn_on(self.hass, 'light.test', flash='short')
|
light.turn_on(self.hass, 'light.test', flash='short')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'on,short', 0, False)
|
'test_light_rgb/set', 'on,short', 0, False)
|
||||||
self.mock_publish.async_publish.reset_mock()
|
self.mock_publish.async_publish.reset_mock()
|
||||||
|
|
||||||
# long flash
|
# long flash
|
||||||
light.turn_on(self.hass, 'light.test', flash='long')
|
light.turn_on(self.hass, 'light.test', flash='long')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'on,long', 0, False)
|
'test_light_rgb/set', 'on,long', 0, False)
|
||||||
|
|
||||||
def test_transition(self):
|
def test_transition(self):
|
||||||
"""Test for transition time being sent when included."""
|
"""Test for transition time being sent when included."""
|
||||||
with assert_setup_component(1, light.DOMAIN):
|
with assert_setup_component(1, light.DOMAIN):
|
||||||
assert setup_component(self.hass, light.DOMAIN, {
|
assert setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,{{ transition }}',
|
'command_on_template': 'on,{{ transition }}',
|
||||||
'command_off_template': 'off,{{ transition|d }}'
|
'command_off_template': 'off,{{ transition|d }}'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
# transition on
|
# transition on
|
||||||
light.turn_on(self.hass, 'light.test', transition=10)
|
light.turn_on(self.hass, 'light.test', transition=10)
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'on,10', 0, False)
|
'test_light_rgb/set', 'on,10', 0, False)
|
||||||
self.mock_publish.async_publish.reset_mock()
|
self.mock_publish.async_publish.reset_mock()
|
||||||
|
|
||||||
# transition off
|
# transition off
|
||||||
light.turn_off(self.hass, 'light.test', transition=4)
|
light.turn_off(self.hass, 'light.test', transition=4)
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
self.mock_publish.async_publish.assert_called_once_with(
|
self.mock_publish.async_publish.assert_called_once_with(
|
||||||
'test_light_rgb/set', 'off,4', 0, False)
|
'test_light_rgb/set', 'off,4', 0, False)
|
||||||
|
|
||||||
def test_invalid_values(self): \
|
def test_invalid_values(self): \
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
"""Test that invalid values are ignored."""
|
"""Test that invalid values are ignored."""
|
||||||
with assert_setup_component(1, light.DOMAIN):
|
with assert_setup_component(1, light.DOMAIN):
|
||||||
assert setup_component(self.hass, light.DOMAIN, {
|
assert setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'effect_list': ['rainbow', 'colorloop'],
|
'effect_list': ['rainbow', 'colorloop'],
|
||||||
'state_topic': 'test_light_rgb',
|
'state_topic': 'test_light_rgb',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,'
|
'command_on_template': 'on,'
|
||||||
'{{ brightness|d }},'
|
'{{ brightness|d }},'
|
||||||
'{{ color_temp|d }},'
|
'{{ color_temp|d }},'
|
||||||
'{{ red|d }}-'
|
'{{ red|d }}-'
|
||||||
'{{ green|d }}-'
|
'{{ green|d }}-'
|
||||||
'{{ blue|d }},'
|
'{{ blue|d }},'
|
||||||
'{{ effect|d }}',
|
'{{ effect|d }}',
|
||||||
'command_off_template': 'off',
|
'command_off_template': 'off',
|
||||||
'state_template': '{{ value.split(",")[0] }}',
|
'state_template': '{{ value.split(",")[0] }}',
|
||||||
'brightness_template': '{{ value.split(",")[1] }}',
|
'brightness_template': '{{ value.split(",")[1] }}',
|
||||||
'color_temp_template': '{{ value.split(",")[2] }}',
|
'color_temp_template': '{{ value.split(",")[2] }}',
|
||||||
'white_value_template': '{{ value.split(",")[3] }}',
|
'white_value_template': '{{ value.split(",")[3] }}',
|
||||||
'red_template': '{{ value.split(",")[4].'
|
'red_template': '{{ value.split(",")[4].'
|
||||||
'split("-")[0] }}',
|
'split("-")[0] }}',
|
||||||
'green_template': '{{ value.split(",")[4].'
|
'green_template': '{{ value.split(",")[4].'
|
||||||
'split("-")[1] }}',
|
'split("-")[1] }}',
|
||||||
'blue_template': '{{ value.split(",")[4].'
|
'blue_template': '{{ value.split(",")[4].'
|
||||||
'split("-")[2] }}',
|
'split("-")[2] }}',
|
||||||
'effect_template': '{{ value.split(",")[5] }}',
|
'effect_template': '{{ value.split(",")[5] }}',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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('rgb_color'))
|
self.assertIsNone(state.attributes.get('rgb_color'))
|
||||||
self.assertIsNone(state.attributes.get('brightness'))
|
self.assertIsNone(state.attributes.get('brightness'))
|
||||||
self.assertIsNone(state.attributes.get('color_temp'))
|
self.assertIsNone(state.attributes.get('color_temp'))
|
||||||
self.assertIsNone(state.attributes.get('effect'))
|
self.assertIsNone(state.attributes.get('effect'))
|
||||||
self.assertIsNone(state.attributes.get('white_value'))
|
self.assertIsNone(state.attributes.get('white_value'))
|
||||||
self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
|
self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||||
|
|
||||||
# turn on the light, full white
|
# turn on the light, full white
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb',
|
fire_mqtt_message(self.hass, 'test_light_rgb',
|
||||||
'on,255,215,222,255-255-255,rainbow')
|
'on,255,215,222,255-255-255,rainbow')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
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(255, state.attributes.get('brightness'))
|
self.assertEqual(255, state.attributes.get('brightness'))
|
||||||
self.assertEqual(215, state.attributes.get('color_temp'))
|
self.assertEqual(215, state.attributes.get('color_temp'))
|
||||||
self.assertEqual([255, 255, 255], state.attributes.get('rgb_color'))
|
self.assertEqual([255, 255, 255], state.attributes.get('rgb_color'))
|
||||||
self.assertEqual(222, state.attributes.get('white_value'))
|
self.assertEqual(222, state.attributes.get('white_value'))
|
||||||
self.assertEqual('rainbow', state.attributes.get('effect'))
|
self.assertEqual('rainbow', state.attributes.get('effect'))
|
||||||
|
|
||||||
# bad state value
|
# bad state value
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'offf')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'offf')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
# state should not have changed
|
# state should not have changed
|
||||||
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)
|
||||||
|
|
||||||
# bad brightness values
|
# bad brightness values
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,off,255-255-255')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,off,255-255-255')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
# brightness should not have changed
|
# brightness should not have changed
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(255, state.attributes.get('brightness'))
|
self.assertEqual(255, state.attributes.get('brightness'))
|
||||||
|
|
||||||
# bad color temp values
|
# bad color temp values
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,off,255-255-255')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,off,255-255-255')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
# color temp should not have changed
|
# color temp should not have changed
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(215, state.attributes.get('color_temp'))
|
self.assertEqual(215, state.attributes.get('color_temp'))
|
||||||
|
|
||||||
# bad color values
|
# bad color values
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,255,a-b-c')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,255,a-b-c')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
# color should not have changed
|
# color should not have changed
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual([255, 255, 255], state.attributes.get('rgb_color'))
|
self.assertEqual([255, 255, 255], state.attributes.get('rgb_color'))
|
||||||
|
|
||||||
# bad white value values
|
# bad white value values
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,,off,255-255-255')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,,,off,255-255-255')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
# white value should not have changed
|
# white value should not have changed
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(222, state.attributes.get('white_value'))
|
self.assertEqual(222, state.attributes.get('white_value'))
|
||||||
|
|
||||||
# bad effect value
|
# bad effect value
|
||||||
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,255,a-b-c,white')
|
fire_mqtt_message(self.hass, 'test_light_rgb', 'on,255,a-b-c,white')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
# effect should not have changed
|
# effect should not have changed
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual('rainbow', state.attributes.get('effect'))
|
self.assertEqual('rainbow', state.attributes.get('effect'))
|
||||||
|
|
||||||
def test_default_availability_payload(self):
|
def test_default_availability_payload(self):
|
||||||
"""Test availability by default payload with defined topic."""
|
"""Test availability by default payload with defined topic."""
|
||||||
self.assertTrue(setup_component(self.hass, light.DOMAIN, {
|
self.assertTrue(setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,{{ transition }}',
|
'command_on_template': 'on,{{ transition }}',
|
||||||
'command_off_template': 'off,{{ transition|d }}',
|
'command_off_template': 'off,{{ transition|d }}',
|
||||||
'availability_topic': 'availability-topic'
|
'availability_topic': 'availability-topic'
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||||
|
|
||||||
fire_mqtt_message(self.hass, 'availability-topic', 'online')
|
fire_mqtt_message(self.hass, 'availability-topic', 'online')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertNotEqual(STATE_UNAVAILABLE, state.state)
|
self.assertNotEqual(STATE_UNAVAILABLE, state.state)
|
||||||
|
|
||||||
fire_mqtt_message(self.hass, 'availability-topic', 'offline')
|
fire_mqtt_message(self.hass, 'availability-topic', 'offline')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||||
|
|
||||||
def test_custom_availability_payload(self):
|
def test_custom_availability_payload(self):
|
||||||
"""Test availability by custom payload with defined topic."""
|
"""Test availability by custom payload with defined topic."""
|
||||||
self.assertTrue(setup_component(self.hass, light.DOMAIN, {
|
self.assertTrue(setup_component(self.hass, light.DOMAIN, {
|
||||||
light.DOMAIN: {
|
light.DOMAIN: {
|
||||||
'platform': 'mqtt_template',
|
'platform': 'mqtt_template',
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'command_topic': 'test_light_rgb/set',
|
'command_topic': 'test_light_rgb/set',
|
||||||
'command_on_template': 'on,{{ transition }}',
|
'command_on_template': 'on,{{ transition }}',
|
||||||
'command_off_template': 'off,{{ transition|d }}',
|
'command_off_template': 'off,{{ transition|d }}',
|
||||||
'availability_topic': 'availability-topic',
|
'availability_topic': 'availability-topic',
|
||||||
'payload_available': 'good',
|
'payload_available': 'good',
|
||||||
'payload_not_available': 'nogood'
|
'payload_not_available': 'nogood'
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||||
|
|
||||||
fire_mqtt_message(self.hass, 'availability-topic', 'good')
|
fire_mqtt_message(self.hass, 'availability-topic', 'good')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertNotEqual(STATE_UNAVAILABLE, state.state)
|
self.assertNotEqual(STATE_UNAVAILABLE, state.state)
|
||||||
|
|
||||||
fire_mqtt_message(self.hass, 'availability-topic', 'nogood')
|
fire_mqtt_message(self.hass, 'availability-topic', 'nogood')
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
state = self.hass.states.get('light.test')
|
state = self.hass.states.get('light.test')
|
||||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||||
|
|
86
tests/fixtures/pushbullet_devices.json
vendored
86
tests/fixtures/pushbullet_devices.json
vendored
|
@ -1,43 +1,43 @@
|
||||||
{
|
{
|
||||||
"accounts": [],
|
"accounts": [],
|
||||||
"blocks": [],
|
"blocks": [],
|
||||||
"channels": [],
|
"channels": [],
|
||||||
"chats": [],
|
"chats": [],
|
||||||
"clients": [],
|
"clients": [],
|
||||||
"contacts": [],
|
"contacts": [],
|
||||||
"devices": [{
|
"devices": [{
|
||||||
"active": true,
|
"active": true,
|
||||||
"iden": "identity1",
|
"iden": "identity1",
|
||||||
"created": 1.514520333770855e+09,
|
"created": 1.514520333770855e+09,
|
||||||
"modified": 1.5151951594363022e+09,
|
"modified": 1.5151951594363022e+09,
|
||||||
"type": "windows",
|
"type": "windows",
|
||||||
"kind": "windows",
|
"kind": "windows",
|
||||||
"nickname": "DESKTOP",
|
"nickname": "DESKTOP",
|
||||||
"manufacturer": "Microsoft",
|
"manufacturer": "Microsoft",
|
||||||
"model": "Windows 10 Home",
|
"model": "Windows 10 Home",
|
||||||
"app_version": 396,
|
"app_version": 396,
|
||||||
"fingerprint": "{\"cpu\":\"AMD\",\"computer_name\":\"DESKTOP\"}",
|
"fingerprint": "{\"cpu\":\"AMD\",\"computer_name\":\"DESKTOP\"}",
|
||||||
"pushable": true,
|
"pushable": true,
|
||||||
"icon": "desktop",
|
"icon": "desktop",
|
||||||
"remote_files": "disabled"
|
"remote_files": "disabled"
|
||||||
}, {
|
}, {
|
||||||
"active": true,
|
"active": true,
|
||||||
"iden": "identity2",
|
"iden": "identity2",
|
||||||
"created": 1.5144974875448499e+09,
|
"created": 1.5144974875448499e+09,
|
||||||
"modified": 1.514574792288634e+09,
|
"modified": 1.514574792288634e+09,
|
||||||
"type": "ios",
|
"type": "ios",
|
||||||
"kind": "ios",
|
"kind": "ios",
|
||||||
"nickname": "My iPhone",
|
"nickname": "My iPhone",
|
||||||
"manufacturer": "Apple",
|
"manufacturer": "Apple",
|
||||||
"model": "iPhone",
|
"model": "iPhone",
|
||||||
"app_version": 8646,
|
"app_version": 8646,
|
||||||
"push_token": "production:mytoken",
|
"push_token": "production:mytoken",
|
||||||
"pushable": true,
|
"pushable": true,
|
||||||
"icon": "phone"
|
"icon": "phone"
|
||||||
}],
|
}],
|
||||||
"grants": [],
|
"grants": [],
|
||||||
"pushes": [],
|
"pushes": [],
|
||||||
"profiles": [],
|
"profiles": [],
|
||||||
"subscriptions": [],
|
"subscriptions": [],
|
||||||
"texts": []
|
"texts": []
|
||||||
}
|
}
|
||||||
|
|
276
tests/fixtures/yahooweather.json
vendored
276
tests/fixtures/yahooweather.json
vendored
|
@ -1,138 +1,138 @@
|
||||||
{
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"created": "2017-11-17T13:40:47Z",
|
"created": "2017-11-17T13:40:47Z",
|
||||||
"lang": "en-US",
|
"lang": "en-US",
|
||||||
"results": {
|
"results": {
|
||||||
"channel": {
|
"channel": {
|
||||||
"units": {
|
"units": {
|
||||||
"distance": "km",
|
"distance": "km",
|
||||||
"pressure": "mb",
|
"pressure": "mb",
|
||||||
"speed": "km/h",
|
"speed": "km/h",
|
||||||
"temperature": "C"
|
"temperature": "C"
|
||||||
},
|
},
|
||||||
"title": "Yahoo! Weather - San Diego, CA, US",
|
"title": "Yahoo! Weather - San Diego, CA, US",
|
||||||
"link": "http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-23511632/",
|
"link": "http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-23511632/",
|
||||||
"description": "Yahoo! Weather for San Diego, CA, US",
|
"description": "Yahoo! Weather for San Diego, CA, US",
|
||||||
"language": "en-us",
|
"language": "en-us",
|
||||||
"lastBuildDate": "Fri, 17 Nov 2017 05:40 AM PST",
|
"lastBuildDate": "Fri, 17 Nov 2017 05:40 AM PST",
|
||||||
"ttl": "60",
|
"ttl": "60",
|
||||||
"location": {
|
"location": {
|
||||||
"city": "San Diego",
|
"city": "San Diego",
|
||||||
"country": "United States",
|
"country": "United States",
|
||||||
"region": " CA"
|
"region": " CA"
|
||||||
},
|
},
|
||||||
"wind": {
|
"wind": {
|
||||||
"chill": "56",
|
"chill": "56",
|
||||||
"direction": "0",
|
"direction": "0",
|
||||||
"speed": "6.34"
|
"speed": "6.34"
|
||||||
},
|
},
|
||||||
"atmosphere": {
|
"atmosphere": {
|
||||||
"humidity": "71",
|
"humidity": "71",
|
||||||
"pressure": "33863.75",
|
"pressure": "33863.75",
|
||||||
"rising": "0",
|
"rising": "0",
|
||||||
"visibility": "22.91"
|
"visibility": "22.91"
|
||||||
},
|
},
|
||||||
"astronomy": {
|
"astronomy": {
|
||||||
"sunrise": "6:21 am",
|
"sunrise": "6:21 am",
|
||||||
"sunset": "4:47 pm"
|
"sunset": "4:47 pm"
|
||||||
},
|
},
|
||||||
"image": {
|
"image": {
|
||||||
"title": "Yahoo! Weather",
|
"title": "Yahoo! Weather",
|
||||||
"width": "142",
|
"width": "142",
|
||||||
"height": "18",
|
"height": "18",
|
||||||
"link": "http://weather.yahoo.com",
|
"link": "http://weather.yahoo.com",
|
||||||
"url": "http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
|
"url": "http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
|
||||||
},
|
},
|
||||||
"item": {
|
"item": {
|
||||||
"title": "Conditions for San Diego, CA, US at 05:00 AM PST",
|
"title": "Conditions for San Diego, CA, US at 05:00 AM PST",
|
||||||
"lat": "32.878101",
|
"lat": "32.878101",
|
||||||
"long": "-117.23497",
|
"long": "-117.23497",
|
||||||
"link": "http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-23511632/",
|
"link": "http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-23511632/",
|
||||||
"pubDate": "Fri, 17 Nov 2017 05:00 AM PST",
|
"pubDate": "Fri, 17 Nov 2017 05:00 AM PST",
|
||||||
"condition": {
|
"condition": {
|
||||||
"code": "26",
|
"code": "26",
|
||||||
"date": "Fri, 17 Nov 2017 05:00 AM PST",
|
"date": "Fri, 17 Nov 2017 05:00 AM PST",
|
||||||
"temp": "18",
|
"temp": "18",
|
||||||
"text": "Cloudy"
|
"text": "Cloudy"
|
||||||
},
|
},
|
||||||
"forecast": [{
|
"forecast": [{
|
||||||
"code": "28",
|
"code": "28",
|
||||||
"date": "17 Nov 2017",
|
"date": "17 Nov 2017",
|
||||||
"day": "Fri",
|
"day": "Fri",
|
||||||
"high": "23",
|
"high": "23",
|
||||||
"low": "16",
|
"low": "16",
|
||||||
"text": "Mostly Cloudy"
|
"text": "Mostly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "30",
|
"code": "30",
|
||||||
"date": "18 Nov 2017",
|
"date": "18 Nov 2017",
|
||||||
"day": "Sat",
|
"day": "Sat",
|
||||||
"high": "22",
|
"high": "22",
|
||||||
"low": "13",
|
"low": "13",
|
||||||
"text": "Partly Cloudy"
|
"text": "Partly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "30",
|
"code": "30",
|
||||||
"date": "19 Nov 2017",
|
"date": "19 Nov 2017",
|
||||||
"day": "Sun",
|
"day": "Sun",
|
||||||
"high": "22",
|
"high": "22",
|
||||||
"low": "12",
|
"low": "12",
|
||||||
"text": "Partly Cloudy"
|
"text": "Partly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "28",
|
"code": "28",
|
||||||
"date": "20 Nov 2017",
|
"date": "20 Nov 2017",
|
||||||
"day": "Mon",
|
"day": "Mon",
|
||||||
"high": "21",
|
"high": "21",
|
||||||
"low": "11",
|
"low": "11",
|
||||||
"text": "Mostly Cloudy"
|
"text": "Mostly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "28",
|
"code": "28",
|
||||||
"date": "21 Nov 2017",
|
"date": "21 Nov 2017",
|
||||||
"day": "Tue",
|
"day": "Tue",
|
||||||
"high": "24",
|
"high": "24",
|
||||||
"low": "14",
|
"low": "14",
|
||||||
"text": "Mostly Cloudy"
|
"text": "Mostly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "30",
|
"code": "30",
|
||||||
"date": "22 Nov 2017",
|
"date": "22 Nov 2017",
|
||||||
"day": "Wed",
|
"day": "Wed",
|
||||||
"high": "27",
|
"high": "27",
|
||||||
"low": "15",
|
"low": "15",
|
||||||
"text": "Partly Cloudy"
|
"text": "Partly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "34",
|
"code": "34",
|
||||||
"date": "23 Nov 2017",
|
"date": "23 Nov 2017",
|
||||||
"day": "Thu",
|
"day": "Thu",
|
||||||
"high": "27",
|
"high": "27",
|
||||||
"low": "15",
|
"low": "15",
|
||||||
"text": "Mostly Sunny"
|
"text": "Mostly Sunny"
|
||||||
}, {
|
}, {
|
||||||
"code": "30",
|
"code": "30",
|
||||||
"date": "24 Nov 2017",
|
"date": "24 Nov 2017",
|
||||||
"day": "Fri",
|
"day": "Fri",
|
||||||
"high": "23",
|
"high": "23",
|
||||||
"low": "16",
|
"low": "16",
|
||||||
"text": "Partly Cloudy"
|
"text": "Partly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "30",
|
"code": "30",
|
||||||
"date": "25 Nov 2017",
|
"date": "25 Nov 2017",
|
||||||
"day": "Sat",
|
"day": "Sat",
|
||||||
"high": "22",
|
"high": "22",
|
||||||
"low": "15",
|
"low": "15",
|
||||||
"text": "Partly Cloudy"
|
"text": "Partly Cloudy"
|
||||||
}, {
|
}, {
|
||||||
"code": "28",
|
"code": "28",
|
||||||
"date": "26 Nov 2017",
|
"date": "26 Nov 2017",
|
||||||
"day": "Sun",
|
"day": "Sun",
|
||||||
"high": "24",
|
"high": "24",
|
||||||
"low": "13",
|
"low": "13",
|
||||||
"text": "Mostly Cloudy"
|
"text": "Mostly Cloudy"
|
||||||
}],
|
}],
|
||||||
"description": "<![CDATA[<img src=\"http://l.yimg.com/a/i/us/we/52/26.gif\"/>\n<BR />\n<b>Current Conditions:</b>\n<BR />Cloudy\n<BR />\n<BR />\n<b>Forecast:</b>\n<BR /> Fri - Mostly Cloudy. High: 23Low: 16\n<BR /> Sat - Partly Cloudy. High: 22Low: 13\n<BR /> Sun - Partly Cloudy. High: 22Low: 12\n<BR /> Mon - Mostly Cloudy. High: 21Low: 11\n<BR /> Tue - Mostly Cloudy. High: 24Low: 14\n<BR />\n<BR />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-23511632/\">Full Forecast at Yahoo! Weather</a>\n<BR />\n<BR />\n<BR />\n]]>",
|
"description": "<![CDATA[<img src=\"http://l.yimg.com/a/i/us/we/52/26.gif\"/>\n<BR />\n<b>Current Conditions:</b>\n<BR />Cloudy\n<BR />\n<BR />\n<b>Forecast:</b>\n<BR /> Fri - Mostly Cloudy. High: 23Low: 16\n<BR /> Sat - Partly Cloudy. High: 22Low: 13\n<BR /> Sun - Partly Cloudy. High: 22Low: 12\n<BR /> Mon - Mostly Cloudy. High: 21Low: 11\n<BR /> Tue - Mostly Cloudy. High: 24Low: 14\n<BR />\n<BR />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-23511632/\">Full Forecast at Yahoo! Weather</a>\n<BR />\n<BR />\n<BR />\n]]>",
|
||||||
"guid": {
|
"guid": {
|
||||||
"isPermaLink": "false"
|
"isPermaLink": "false"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue