mirror of
https://github.com/home-assistant/core.git
synced 2026-01-25 00:52:39 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
370c3f28b8 | ||
|
|
66110a7d57 | ||
|
|
a02d7989d5 | ||
|
|
7325847fa9 | ||
|
|
124495dd84 | ||
|
|
0ea2d99910 | ||
|
|
6456f66b47 | ||
|
|
6e5a2a77ab | ||
|
|
35b609dd8b | ||
|
|
0df99f8762 | ||
|
|
a4b843eb2d | ||
|
|
302717e8a1 | ||
|
|
617647c5fd | ||
|
|
4b5d578c08 | ||
|
|
e98e7e2751 |
@@ -45,7 +45,7 @@ class NeatoCleaningMap(Camera):
|
||||
self.update()
|
||||
return self._image
|
||||
|
||||
@Throttle(timedelta(seconds=10))
|
||||
@Throttle(timedelta(seconds=60))
|
||||
def update(self):
|
||||
"""Check the contents of the map list."""
|
||||
self.neato.update_robots()
|
||||
|
||||
@@ -26,7 +26,7 @@ from homeassistant.helpers.translation import async_get_translations
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.util.yaml import load_yaml
|
||||
|
||||
REQUIREMENTS = ['home-assistant-frontend==20180620.0']
|
||||
REQUIREMENTS = ['home-assistant-frontend==20180622.1']
|
||||
|
||||
DOMAIN = 'frontend'
|
||||
DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log']
|
||||
|
||||
@@ -17,7 +17,7 @@ import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
REQUIREMENTS = ['insteonplm==0.9.2']
|
||||
REQUIREMENTS = ['insteonplm==0.10.0']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -29,17 +29,31 @@ CONF_CAT = 'cat'
|
||||
CONF_SUBCAT = 'subcat'
|
||||
CONF_FIRMWARE = 'firmware'
|
||||
CONF_PRODUCT_KEY = 'product_key'
|
||||
CONF_X10 = 'x10_devices'
|
||||
CONF_HOUSECODE = 'housecode'
|
||||
CONF_UNITCODE = 'unitcode'
|
||||
CONF_DIM_STEPS = 'dim_steps'
|
||||
CONF_X10_ALL_UNITS_OFF = 'x10_all_units_off'
|
||||
CONF_X10_ALL_LIGHTS_ON = 'x10_all_lights_on'
|
||||
CONF_X10_ALL_LIGHTS_OFF = 'x10_all_lights_off'
|
||||
|
||||
SRV_ADD_ALL_LINK = 'add_all_link'
|
||||
SRV_DEL_ALL_LINK = 'delete_all_link'
|
||||
SRV_LOAD_ALDB = 'load_all_link_database'
|
||||
SRV_PRINT_ALDB = 'print_all_link_database'
|
||||
SRV_PRINT_IM_ALDB = 'print_im_all_link_database'
|
||||
SRV_X10_ALL_UNITS_OFF = 'x10_all_units_off'
|
||||
SRV_X10_ALL_LIGHTS_OFF = 'x10_all_lights_off'
|
||||
SRV_X10_ALL_LIGHTS_ON = 'x10_all_lights_on'
|
||||
SRV_ALL_LINK_GROUP = 'group'
|
||||
SRV_ALL_LINK_MODE = 'mode'
|
||||
SRV_LOAD_DB_RELOAD = 'reload'
|
||||
SRV_CONTROLLER = 'controller'
|
||||
SRV_RESPONDER = 'responder'
|
||||
SRV_HOUSECODE = 'housecode'
|
||||
|
||||
HOUSECODES = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']
|
||||
|
||||
CONF_DEVICE_OVERRIDE_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_PLATFORM), vol.Schema({
|
||||
@@ -51,11 +65,24 @@ CONF_DEVICE_OVERRIDE_SCHEMA = vol.All(
|
||||
vol.Optional(CONF_PLATFORM): cv.string,
|
||||
}))
|
||||
|
||||
CONF_X10_SCHEMA = vol.All(
|
||||
vol.Schema({
|
||||
vol.Required(CONF_HOUSECODE): cv.string,
|
||||
vol.Required(CONF_UNITCODE): vol.Range(min=1, max=16),
|
||||
vol.Required(CONF_PLATFORM): cv.string,
|
||||
vol.Optional(CONF_DIM_STEPS): vol.Range(min=2, max=255)
|
||||
}))
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_PORT): cv.string,
|
||||
vol.Optional(CONF_OVERRIDE): vol.All(
|
||||
cv.ensure_list_csv, [CONF_DEVICE_OVERRIDE_SCHEMA])
|
||||
cv.ensure_list_csv, [CONF_DEVICE_OVERRIDE_SCHEMA]),
|
||||
vol.Optional(CONF_X10_ALL_UNITS_OFF): vol.In(HOUSECODES),
|
||||
vol.Optional(CONF_X10_ALL_LIGHTS_ON): vol.In(HOUSECODES),
|
||||
vol.Optional(CONF_X10_ALL_LIGHTS_OFF): vol.In(HOUSECODES),
|
||||
vol.Optional(CONF_X10): vol.All(
|
||||
cv.ensure_list_csv, [CONF_X10_SCHEMA])
|
||||
})
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
@@ -77,6 +104,10 @@ PRINT_ALDB_SCHEMA = vol.Schema({
|
||||
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||
})
|
||||
|
||||
X10_HOUSECODE_SCHEMA = vol.Schema({
|
||||
vol.Required(SRV_HOUSECODE): vol.In(HOUSECODES),
|
||||
})
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup(hass, config):
|
||||
@@ -89,6 +120,10 @@ def async_setup(hass, config):
|
||||
conf = config[DOMAIN]
|
||||
port = conf.get(CONF_PORT)
|
||||
overrides = conf.get(CONF_OVERRIDE, [])
|
||||
x10_devices = conf.get(CONF_X10, [])
|
||||
x10_all_units_off_housecode = conf.get(CONF_X10_ALL_UNITS_OFF)
|
||||
x10_all_lights_on_housecode = conf.get(CONF_X10_ALL_LIGHTS_ON)
|
||||
x10_all_lights_off_housecode = conf.get(CONF_X10_ALL_LIGHTS_OFF)
|
||||
|
||||
@callback
|
||||
def async_plm_new_device(device):
|
||||
@@ -106,7 +141,7 @@ def async_setup(hass, config):
|
||||
hass.async_add_job(
|
||||
discovery.async_load_platform(
|
||||
hass, platform, DOMAIN,
|
||||
discovered={'address': device.address.hex,
|
||||
discovered={'address': device.address.id,
|
||||
'state_key': state_key},
|
||||
hass_config=config))
|
||||
|
||||
@@ -151,6 +186,21 @@ def async_setup(hass, config):
|
||||
# Furture direction is to create an INSTEON control panel.
|
||||
print_aldb_to_log(plm.aldb)
|
||||
|
||||
def x10_all_units_off(service):
|
||||
"""Send the X10 All Units Off command."""
|
||||
housecode = service.data.get(SRV_HOUSECODE)
|
||||
plm.x10_all_units_off(housecode)
|
||||
|
||||
def x10_all_lights_off(service):
|
||||
"""Send the X10 All Lights Off command."""
|
||||
housecode = service.data.get(SRV_HOUSECODE)
|
||||
plm.x10_all_lights_off(housecode)
|
||||
|
||||
def x10_all_lights_on(service):
|
||||
"""Send the X10 All Lights On command."""
|
||||
housecode = service.data.get(SRV_HOUSECODE)
|
||||
plm.x10_all_lights_on(housecode)
|
||||
|
||||
def _register_services():
|
||||
hass.services.register(DOMAIN, SRV_ADD_ALL_LINK, add_all_link,
|
||||
schema=ADD_ALL_LINK_SCHEMA)
|
||||
@@ -162,6 +212,15 @@ def async_setup(hass, config):
|
||||
schema=PRINT_ALDB_SCHEMA)
|
||||
hass.services.register(DOMAIN, SRV_PRINT_IM_ALDB, print_im_aldb,
|
||||
schema=None)
|
||||
hass.services.register(DOMAIN, SRV_X10_ALL_UNITS_OFF,
|
||||
x10_all_units_off,
|
||||
schema=X10_HOUSECODE_SCHEMA)
|
||||
hass.services.register(DOMAIN, SRV_X10_ALL_LIGHTS_OFF,
|
||||
x10_all_lights_off,
|
||||
schema=X10_HOUSECODE_SCHEMA)
|
||||
hass.services.register(DOMAIN, SRV_X10_ALL_LIGHTS_ON,
|
||||
x10_all_lights_on,
|
||||
schema=X10_HOUSECODE_SCHEMA)
|
||||
_LOGGER.debug("Insteon_plm Services registered")
|
||||
|
||||
_LOGGER.info("Looking for PLM on %s", port)
|
||||
@@ -192,6 +251,36 @@ def async_setup(hass, config):
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, conn.close)
|
||||
|
||||
plm.devices.add_device_callback(async_plm_new_device)
|
||||
|
||||
if x10_all_units_off_housecode:
|
||||
device = plm.add_x10_device(x10_all_units_off_housecode,
|
||||
20,
|
||||
'allunitsoff')
|
||||
if x10_all_lights_on_housecode:
|
||||
device = plm.add_x10_device(x10_all_lights_on_housecode,
|
||||
21,
|
||||
'alllightson')
|
||||
if x10_all_lights_off_housecode:
|
||||
device = plm.add_x10_device(x10_all_lights_off_housecode,
|
||||
22,
|
||||
'alllightsoff')
|
||||
for device in x10_devices:
|
||||
housecode = device.get(CONF_HOUSECODE)
|
||||
unitcode = device.get(CONF_UNITCODE)
|
||||
x10_type = 'onoff'
|
||||
steps = device.get(CONF_DIM_STEPS, 22)
|
||||
if device.get(CONF_PLATFORM) == 'light':
|
||||
x10_type = 'dimmable'
|
||||
elif device.get(CONF_PLATFORM) == 'binary_sensor':
|
||||
x10_type = 'sensor'
|
||||
_LOGGER.debug("Adding X10 device to insteonplm: %s %d %s",
|
||||
housecode, unitcode, x10_type)
|
||||
device = plm.add_x10_device(housecode,
|
||||
unitcode,
|
||||
x10_type)
|
||||
if device and hasattr(device.states[0x01], 'steps'):
|
||||
device.states[0x01].steps = steps
|
||||
|
||||
hass.async_add_job(_register_services)
|
||||
|
||||
return True
|
||||
@@ -219,6 +308,13 @@ class IPDB(object):
|
||||
IoLincSensor,
|
||||
LeakSensorDryWet)
|
||||
|
||||
from insteonplm.states.x10 import (X10DimmableSwitch,
|
||||
X10OnOffSwitch,
|
||||
X10OnOffSensor,
|
||||
X10AllUnitsOffSensor,
|
||||
X10AllLightsOnSensor,
|
||||
X10AllLightsOffSensor)
|
||||
|
||||
self.states = [State(OnOffSwitch_OutletTop, 'switch'),
|
||||
State(OnOffSwitch_OutletBottom, 'switch'),
|
||||
State(OpenClosedRelay, 'switch'),
|
||||
@@ -231,7 +327,14 @@ class IPDB(object):
|
||||
State(VariableSensor, 'sensor'),
|
||||
|
||||
State(DimmableSwitch_Fan, 'fan'),
|
||||
State(DimmableSwitch, 'light')]
|
||||
State(DimmableSwitch, 'light'),
|
||||
|
||||
State(X10DimmableSwitch, 'light'),
|
||||
State(X10OnOffSwitch, 'switch'),
|
||||
State(X10OnOffSensor, 'binary_sensor'),
|
||||
State(X10AllUnitsOffSensor, 'binary_sensor'),
|
||||
State(X10AllLightsOnSensor, 'binary_sensor'),
|
||||
State(X10AllLightsOffSensor, 'binary_sensor')]
|
||||
|
||||
def __len__(self):
|
||||
"""Return the number of INSTEON state types mapped to HA platforms."""
|
||||
|
||||
@@ -30,3 +30,21 @@ print_all_link_database:
|
||||
example: 'light.1a2b3c'
|
||||
print_im_all_link_database:
|
||||
description: Print the All-Link Database for the INSTEON Modem (IM).
|
||||
x10_all_units_off:
|
||||
description: Send X10 All Units Off command
|
||||
fields:
|
||||
housecode:
|
||||
description: X10 house code
|
||||
example: c
|
||||
x10_all_lights_on:
|
||||
description: Send X10 All Lights On command
|
||||
fields:
|
||||
housecode:
|
||||
description: X10 house code
|
||||
example: c
|
||||
x10_all_lights_off:
|
||||
description: Send X10 All Lights Off command
|
||||
fields:
|
||||
housecode:
|
||||
description: X10 house code
|
||||
example: c
|
||||
|
||||
@@ -442,8 +442,15 @@ class MqttLight(MqttAvailability, Light):
|
||||
self._topic[CONF_RGB_COMMAND_TOPIC] is not None:
|
||||
|
||||
hs_color = kwargs[ATTR_HS_COLOR]
|
||||
brightness = kwargs.get(
|
||||
ATTR_BRIGHTNESS, self._brightness if self._brightness else 255)
|
||||
|
||||
# If there's a brightness topic set, we don't want to scale the RGB
|
||||
# values given using the brightness.
|
||||
if self._topic[CONF_BRIGHTNESS_COMMAND_TOPIC] is not None:
|
||||
brightness = 255
|
||||
else:
|
||||
brightness = kwargs.get(
|
||||
ATTR_BRIGHTNESS, self._brightness if self._brightness else
|
||||
255)
|
||||
rgb = color_util.color_hsv_to_RGB(
|
||||
hs_color[0], hs_color[1], brightness / 255 * 100)
|
||||
tpl = self._templates[CONF_RGB_COMMAND_TEMPLATE]
|
||||
|
||||
@@ -345,9 +345,14 @@ class MqttJson(MqttAvailability, Light):
|
||||
hs_color = kwargs[ATTR_HS_COLOR]
|
||||
message['color'] = {}
|
||||
if self._rgb:
|
||||
brightness = kwargs.get(
|
||||
ATTR_BRIGHTNESS,
|
||||
self._brightness if self._brightness else 255)
|
||||
# If there's a brightness topic set, we don't want to scale the
|
||||
# RGB values given using the brightness.
|
||||
if self._brightness is not None:
|
||||
brightness = 255
|
||||
else:
|
||||
brightness = kwargs.get(
|
||||
ATTR_BRIGHTNESS,
|
||||
self._brightness if self._brightness else 255)
|
||||
rgb = color_util.color_hsv_to_RGB(
|
||||
hs_color[0], hs_color[1], brightness / 255 * 100)
|
||||
message['color']['r'] = rgb[0]
|
||||
|
||||
@@ -317,8 +317,15 @@ class MqttTemplate(MqttAvailability, Light):
|
||||
|
||||
if ATTR_HS_COLOR in kwargs:
|
||||
hs_color = kwargs[ATTR_HS_COLOR]
|
||||
brightness = kwargs.get(
|
||||
ATTR_BRIGHTNESS, self._brightness if self._brightness else 255)
|
||||
|
||||
# If there's a brightness topic set, we don't want to scale the RGB
|
||||
# values given using the brightness.
|
||||
if self._templates[CONF_BRIGHTNESS_TEMPLATE] is not None:
|
||||
brightness = 255
|
||||
else:
|
||||
brightness = kwargs.get(
|
||||
ATTR_BRIGHTNESS, self._brightness if self._brightness else
|
||||
255)
|
||||
rgb = color_util.color_hsv_to_RGB(
|
||||
hs_color[0], hs_color[1], brightness / 255 * 100)
|
||||
values['red'] = rgb[0]
|
||||
|
||||
@@ -17,8 +17,8 @@ from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
REQUIREMENTS = ['https://github.com/jabesq/pybotvac/archive/v0.0.5.zip'
|
||||
'#pybotvac==0.0.5']
|
||||
REQUIREMENTS = ['https://github.com/jabesq/pybotvac/archive/v0.0.6.zip'
|
||||
'#pybotvac==0.0.6']
|
||||
|
||||
DOMAIN = 'neato'
|
||||
NEATO_ROBOTS = 'neato_robots'
|
||||
@@ -122,7 +122,7 @@ class NeatoHub(object):
|
||||
_LOGGER.error("Unable to connect to Neato API")
|
||||
return False
|
||||
|
||||
@Throttle(timedelta(seconds=1))
|
||||
@Throttle(timedelta(seconds=60))
|
||||
def update_robots(self):
|
||||
"""Update the robot states."""
|
||||
_LOGGER.debug("Running HUB.update_robots %s",
|
||||
|
||||
@@ -30,7 +30,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
device.address.hex, device.states[state_key].name)
|
||||
|
||||
new_entity = None
|
||||
if state_name in ['lightOnOff', 'outletTopOnOff', 'outletBottomOnOff']:
|
||||
if state_name in ['lightOnOff', 'outletTopOnOff', 'outletBottomOnOff',
|
||||
'x10OnOffSwitch']:
|
||||
new_entity = InsteonPLMSwitchDevice(device, state_key)
|
||||
elif state_name == 'openClosedRelay':
|
||||
new_entity = InsteonPLMOpenClosedDevice(device, state_key)
|
||||
|
||||
@@ -5,10 +5,12 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.neato/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import requests
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.components.neato import NEATO_ROBOTS, NEATO_LOGIN
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -50,6 +52,7 @@ class NeatoConnectedSwitch(ToggleEntity):
|
||||
self._schedule_state = None
|
||||
self._clean_state = None
|
||||
|
||||
@Throttle(timedelta(seconds=60))
|
||||
def update(self):
|
||||
"""Update the states of Neato switches."""
|
||||
_LOGGER.debug("Running switch update")
|
||||
|
||||
@@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/vacuum.neato/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from datetime import timedelta
|
||||
import requests
|
||||
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
@@ -15,6 +15,7 @@ from homeassistant.components.vacuum import (
|
||||
SUPPORT_MAP, ATTR_STATUS, ATTR_BATTERY_LEVEL, ATTR_BATTERY_ICON)
|
||||
from homeassistant.components.neato import (
|
||||
NEATO_ROBOTS, NEATO_LOGIN, NEATO_MAP_DATA, ACTION, ERRORS, MODE, ALERTS)
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -62,6 +63,7 @@ class NeatoConnectedVacuum(VacuumDevice):
|
||||
self.clean_suspension_charge_count = None
|
||||
self.clean_suspension_time = None
|
||||
|
||||
@Throttle(timedelta(seconds=60))
|
||||
def update(self):
|
||||
"""Update the states of Neato Vacuums."""
|
||||
_LOGGER.debug("Running Neato Vacuums update")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 72
|
||||
PATCH_VERSION = '0b6'
|
||||
PATCH_VERSION = '0'
|
||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||
REQUIRED_PYTHON_VER = (3, 5, 3)
|
||||
|
||||
@@ -404,7 +404,7 @@ hipnotify==1.0.8
|
||||
holidays==0.9.5
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20180620.0
|
||||
home-assistant-frontend==20180622.1
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
# homekit==0.6
|
||||
@@ -425,7 +425,7 @@ httplib2==0.10.3
|
||||
https://github.com/aparraga/braviarc/archive/0.3.7.zip#braviarc==0.3.7
|
||||
|
||||
# homeassistant.components.neato
|
||||
https://github.com/jabesq/pybotvac/archive/v0.0.5.zip#pybotvac==0.0.5
|
||||
https://github.com/jabesq/pybotvac/archive/v0.0.6.zip#pybotvac==0.0.6
|
||||
|
||||
# homeassistant.components.switch.anel_pwrctrl
|
||||
https://github.com/mweinelt/anel-pwrctrl/archive/ed26e8830e28a2bfa4260a9002db23ce3e7e63d7.zip#anel_pwrctrl==0.0.1
|
||||
@@ -464,7 +464,7 @@ influxdb==5.0.0
|
||||
insteonlocal==0.53
|
||||
|
||||
# homeassistant.components.insteon_plm
|
||||
insteonplm==0.9.2
|
||||
insteonplm==0.10.0
|
||||
|
||||
# homeassistant.components.sensor.iperf3
|
||||
iperf3==0.1.10
|
||||
|
||||
@@ -81,7 +81,7 @@ hbmqtt==0.9.2
|
||||
holidays==0.9.5
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20180620.0
|
||||
home-assistant-frontend==20180622.1
|
||||
|
||||
# homeassistant.components.influxdb
|
||||
# homeassistant.components.sensor.influxdb
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"""Helper script to bump the current version."""
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from packaging.version import Version
|
||||
|
||||
@@ -117,12 +118,21 @@ def main():
|
||||
help="The type of the bump the version to.",
|
||||
choices=['beta', 'dev', 'patch', 'minor'],
|
||||
)
|
||||
parser.add_argument(
|
||||
'--commit', action='store_true',
|
||||
help='Create a version bump commit.')
|
||||
arguments = parser.parse_args()
|
||||
current = Version(const.__version__)
|
||||
bumped = bump_version(current, arguments.type)
|
||||
assert bumped > current, 'BUG! New version is not newer than old version'
|
||||
write_version(bumped)
|
||||
|
||||
if not arguments.commit:
|
||||
return
|
||||
|
||||
subprocess.run([
|
||||
'git', 'commit', '-am', 'Bumped version to {}'.format(bumped)])
|
||||
|
||||
|
||||
def test_bump_version():
|
||||
"""Make sure it all works."""
|
||||
|
||||
@@ -523,24 +523,24 @@ class TestLightMQTT(unittest.TestCase):
|
||||
self.mock_publish.reset_mock()
|
||||
light.turn_on(self.hass, 'light.test',
|
||||
brightness=50, xy_color=[0.123, 0.123])
|
||||
light.turn_on(self.hass, 'light.test', rgb_color=[75, 75, 75],
|
||||
light.turn_on(self.hass, 'light.test', rgb_color=[255, 128, 0],
|
||||
white_value=80)
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
mock.call('test_light_rgb/set', 'on', 2, False),
|
||||
mock.call('test_light_rgb/rgb/set', '50,50,50', 2, False),
|
||||
mock.call('test_light_rgb/rgb/set', '255,128,0', 2, False),
|
||||
mock.call('test_light_rgb/brightness/set', 50, 2, False),
|
||||
mock.call('test_light_rgb/white_value/set', 80, 2, False),
|
||||
mock.call('test_light_rgb/xy/set', '0.323,0.329', 2, False),
|
||||
mock.call('test_light_rgb/xy/set', '0.14,0.131', 2, False),
|
||||
], any_order=True)
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertEqual((255, 255, 255), state.attributes['rgb_color'])
|
||||
self.assertEqual((255, 128, 0), state.attributes['rgb_color'])
|
||||
self.assertEqual(50, state.attributes['brightness'])
|
||||
self.assertEqual(80, state.attributes['white_value'])
|
||||
self.assertEqual((0.323, 0.329), state.attributes['xy_color'])
|
||||
self.assertEqual((0.611, 0.375), state.attributes['xy_color'])
|
||||
|
||||
def test_sending_mqtt_rgb_command_with_template(self):
|
||||
"""Test the sending of RGB command with template."""
|
||||
@@ -808,11 +808,11 @@ class TestLightMQTT(unittest.TestCase):
|
||||
|
||||
# Turn on w/ just a color to insure brightness gets
|
||||
# added and sent.
|
||||
light.turn_on(self.hass, 'light.test', rgb_color=[75, 75, 75])
|
||||
light.turn_on(self.hass, 'light.test', rgb_color=[255, 128, 0])
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
mock.call('test_light/rgb', '50,50,50', 0, False),
|
||||
mock.call('test_light/rgb', '255,128,0', 0, False),
|
||||
mock.call('test_light/bright', 50, 0, False)
|
||||
], any_order=True)
|
||||
|
||||
|
||||
@@ -381,8 +381,8 @@ class TestLightMQTTJSON(unittest.TestCase):
|
||||
self.assertEqual(50, message_json["brightness"])
|
||||
self.assertEqual({
|
||||
'r': 0,
|
||||
'g': 50,
|
||||
'b': 4,
|
||||
'g': 255,
|
||||
'b': 21,
|
||||
}, message_json["color"])
|
||||
self.assertEqual("ON", message_json["state"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user