forked from home-assistant/core
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b32caa71f | ||
|
|
9b46796969 | ||
|
|
8409385fca | ||
|
|
27859a2784 | ||
|
|
28f78c0c67 | ||
|
|
a3429848a2 | ||
|
|
757d05a74e | ||
|
|
253950f84f | ||
|
|
af36a67b89 | ||
|
|
b784cc011d | ||
|
|
7c0a933452 | ||
|
|
8b207df819 | ||
|
|
d297be2698 | ||
|
|
de67135e86 | ||
|
|
b684007fbb | ||
|
|
98347345d1 | ||
|
|
c0302e6eca | ||
|
|
06bc98a3a2 | ||
|
|
32858bcea3 | ||
|
|
979260f4be | ||
|
|
408b52de1b |
@@ -3,7 +3,7 @@
|
||||
"name": "Google Cast",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/cast",
|
||||
"requirements": ["pychromecast==7.0.1"],
|
||||
"requirements": ["pychromecast==7.1.2"],
|
||||
"after_dependencies": ["cloud","zeroconf"],
|
||||
"zeroconf": ["_googlecast._tcp.local."],
|
||||
"codeowners": ["@emontnemery"]
|
||||
|
||||
@@ -279,6 +279,8 @@ class CastDevice(MediaPlayerEntity):
|
||||
cast_info.uuid,
|
||||
cast_info.model_name,
|
||||
cast_info.friendly_name,
|
||||
None,
|
||||
None,
|
||||
),
|
||||
ChromeCastZeroconf.get_zeroconf(),
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"domain": "frontend",
|
||||
"name": "Home Assistant Frontend",
|
||||
"documentation": "https://www.home-assistant.io/integrations/frontend",
|
||||
"requirements": ["home-assistant-frontend==20200715.0"],
|
||||
"requirements": ["home-assistant-frontend==20200716.0"],
|
||||
"dependencies": [
|
||||
"api",
|
||||
"auth",
|
||||
|
||||
@@ -353,7 +353,7 @@ def setup(hass: HomeAssistant, base_config):
|
||||
return True
|
||||
|
||||
|
||||
class CecDevice(Entity):
|
||||
class CecEntity(Entity):
|
||||
"""Representation of a HDMI CEC device entity."""
|
||||
|
||||
def __init__(self, device, logical) -> None:
|
||||
@@ -388,6 +388,15 @@ class CecDevice(Entity):
|
||||
"""Device status changed, schedule an update."""
|
||||
self.schedule_update_ha_state(True)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""
|
||||
Return false.
|
||||
|
||||
CecEntity.update() is called by the HDMI network when there is new data.
|
||||
"""
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
|
||||
@@ -43,7 +43,7 @@ from homeassistant.const import (
|
||||
STATE_PLAYING,
|
||||
)
|
||||
|
||||
from . import ATTR_NEW, CecDevice
|
||||
from . import ATTR_NEW, CecEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -57,16 +57,16 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
entities = []
|
||||
for device in discovery_info[ATTR_NEW]:
|
||||
hdmi_device = hass.data.get(device)
|
||||
entities.append(CecPlayerDevice(hdmi_device, hdmi_device.logical_address))
|
||||
entities.append(CecPlayerEntity(hdmi_device, hdmi_device.logical_address))
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
class CecPlayerDevice(CecDevice, MediaPlayerEntity):
|
||||
class CecPlayerEntity(CecEntity, MediaPlayerEntity):
|
||||
"""Representation of a HDMI device as a Media player."""
|
||||
|
||||
def __init__(self, device, logical) -> None:
|
||||
"""Initialize the HDMI device."""
|
||||
CecDevice.__init__(self, device, logical)
|
||||
CecEntity.__init__(self, device, logical)
|
||||
self.entity_id = f"{DOMAIN}.hdmi_{hex(self._logical_address)[2:]}"
|
||||
|
||||
def send_keypress(self, key):
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
from homeassistant.components.switch import DOMAIN, SwitchEntity
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_STANDBY
|
||||
|
||||
from . import ATTR_NEW, CecDevice
|
||||
from . import ATTR_NEW, CecEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -18,27 +18,29 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
entities = []
|
||||
for device in discovery_info[ATTR_NEW]:
|
||||
hdmi_device = hass.data.get(device)
|
||||
entities.append(CecSwitchDevice(hdmi_device, hdmi_device.logical_address))
|
||||
entities.append(CecSwitchEntity(hdmi_device, hdmi_device.logical_address))
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
class CecSwitchDevice(CecDevice, SwitchEntity):
|
||||
class CecSwitchEntity(CecEntity, SwitchEntity):
|
||||
"""Representation of a HDMI device as a Switch."""
|
||||
|
||||
def __init__(self, device, logical) -> None:
|
||||
"""Initialize the HDMI device."""
|
||||
CecDevice.__init__(self, device, logical)
|
||||
CecEntity.__init__(self, device, logical)
|
||||
self.entity_id = f"{DOMAIN}.hdmi_{hex(self._logical_address)[2:]}"
|
||||
|
||||
def turn_on(self, **kwargs) -> None:
|
||||
"""Turn device on."""
|
||||
self._device.turn_on()
|
||||
self._state = STATE_ON
|
||||
self.schedule_update_ha_state(force_refresh=False)
|
||||
|
||||
def turn_off(self, **kwargs) -> None:
|
||||
"""Turn device off."""
|
||||
self._device.turn_off()
|
||||
self._state = STATE_ON
|
||||
self._state = STATE_OFF
|
||||
self.schedule_update_ha_state(force_refresh=False)
|
||||
|
||||
def toggle(self, **kwargs):
|
||||
"""Toggle the entity."""
|
||||
@@ -47,6 +49,7 @@ class CecSwitchDevice(CecDevice, SwitchEntity):
|
||||
self._state = STATE_OFF
|
||||
else:
|
||||
self._state = STATE_ON
|
||||
self.schedule_update_ha_state(force_refresh=False)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
||||
@@ -74,6 +74,13 @@ from .util import temperature_to_homekit, temperature_to_states
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_HVAC_MODES = [
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
]
|
||||
|
||||
HC_HOMEKIT_VALID_MODES_WATER_HEATER = {"Heat": 1}
|
||||
UNIT_HASS_TO_HOMEKIT = {TEMP_CELSIUS: 0, TEMP_FAHRENHEIT: 1}
|
||||
|
||||
@@ -117,7 +124,6 @@ class Thermostat(HomeAccessory):
|
||||
"""Initialize a Thermostat accessory object."""
|
||||
super().__init__(*args, category=CATEGORY_THERMOSTAT)
|
||||
self._unit = self.hass.config.units.temperature_unit
|
||||
self._state_updates = 0
|
||||
self.hc_homekit_to_hass = None
|
||||
self.hc_hass_to_homekit = None
|
||||
hc_min_temp, hc_max_temp = self.get_temperature_range()
|
||||
@@ -237,14 +243,20 @@ class Thermostat(HomeAccessory):
|
||||
# Homekit will reset the mode when VIEWING the temp
|
||||
# Ignore it if its the same mode
|
||||
if char_values[CHAR_TARGET_HEATING_COOLING] != homekit_hvac_mode:
|
||||
service = SERVICE_SET_HVAC_MODE_THERMOSTAT
|
||||
hass_value = self.hc_homekit_to_hass[
|
||||
char_values[CHAR_TARGET_HEATING_COOLING]
|
||||
]
|
||||
params = {ATTR_HVAC_MODE: hass_value}
|
||||
events.append(
|
||||
f"{CHAR_TARGET_HEATING_COOLING} to {char_values[CHAR_TARGET_HEATING_COOLING]}"
|
||||
)
|
||||
target_hc = char_values[CHAR_TARGET_HEATING_COOLING]
|
||||
if target_hc in self.hc_homekit_to_hass:
|
||||
service = SERVICE_SET_HVAC_MODE_THERMOSTAT
|
||||
hass_value = self.hc_homekit_to_hass[target_hc]
|
||||
params = {ATTR_HVAC_MODE: hass_value}
|
||||
events.append(
|
||||
f"{CHAR_TARGET_HEATING_COOLING} to {char_values[CHAR_TARGET_HEATING_COOLING]}"
|
||||
)
|
||||
else:
|
||||
_LOGGER.warning(
|
||||
"The entity: %s does not have a %s mode",
|
||||
self.entity_id,
|
||||
target_hc,
|
||||
)
|
||||
|
||||
if CHAR_TARGET_TEMPERATURE in char_values:
|
||||
hc_target_temp = char_values[CHAR_TARGET_TEMPERATURE]
|
||||
@@ -321,20 +333,8 @@ class Thermostat(HomeAccessory):
|
||||
|
||||
def _configure_hvac_modes(self, state):
|
||||
"""Configure target mode characteristics."""
|
||||
hc_modes = state.attributes.get(ATTR_HVAC_MODES)
|
||||
if not hc_modes:
|
||||
# This cannot be none OR an empty list
|
||||
_LOGGER.error(
|
||||
"%s: HVAC modes not yet available. Please disable auto start for homekit",
|
||||
self.entity_id,
|
||||
)
|
||||
hc_modes = (
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
)
|
||||
|
||||
# This cannot be none OR an empty list
|
||||
hc_modes = state.attributes.get(ATTR_HVAC_MODES) or DEFAULT_HVAC_MODES
|
||||
# Determine available modes for this entity,
|
||||
# Prefer HEAT_COOL over AUTO and COOL over FAN_ONLY, DRY
|
||||
#
|
||||
@@ -379,26 +379,23 @@ class Thermostat(HomeAccessory):
|
||||
@callback
|
||||
def async_update_state(self, new_state):
|
||||
"""Update thermostat state after state changed."""
|
||||
if self._state_updates < 3:
|
||||
# When we get the first state updates
|
||||
# we recheck valid hvac modes as the entity
|
||||
# may not have been fully setup when we saw it the
|
||||
# first time
|
||||
original_hc_hass_to_homekit = self.hc_hass_to_homekit
|
||||
self._configure_hvac_modes(new_state)
|
||||
if self.hc_hass_to_homekit != original_hc_hass_to_homekit:
|
||||
if self.char_target_heat_cool.value not in self.hc_homekit_to_hass:
|
||||
# We must make sure the char value is
|
||||
# in the new valid values before
|
||||
# setting the new valid values or
|
||||
# changing them with throw
|
||||
self.char_target_heat_cool.set_value(
|
||||
list(self.hc_homekit_to_hass)[0], should_notify=False
|
||||
)
|
||||
self.char_target_heat_cool.override_properties(
|
||||
valid_values=self.hc_hass_to_homekit
|
||||
# We always recheck valid hvac modes as the entity
|
||||
# may not have been fully setup when we saw it last
|
||||
original_hc_hass_to_homekit = self.hc_hass_to_homekit
|
||||
self._configure_hvac_modes(new_state)
|
||||
|
||||
if self.hc_hass_to_homekit != original_hc_hass_to_homekit:
|
||||
if self.char_target_heat_cool.value not in self.hc_homekit_to_hass:
|
||||
# We must make sure the char value is
|
||||
# in the new valid values before
|
||||
# setting the new valid values or
|
||||
# changing them with throw
|
||||
self.char_target_heat_cool.set_value(
|
||||
list(self.hc_homekit_to_hass)[0], should_notify=False
|
||||
)
|
||||
self._state_updates += 1
|
||||
self.char_target_heat_cool.override_properties(
|
||||
valid_values=self.hc_hass_to_homekit
|
||||
)
|
||||
|
||||
self._async_update_state(new_state)
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ class NetatmoPublicSensor(Entity):
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if entity is available."""
|
||||
return bool(self._state)
|
||||
return self._state is not None
|
||||
|
||||
def update(self):
|
||||
"""Get the latest data from Netatmo API and updates the states."""
|
||||
|
||||
@@ -51,7 +51,7 @@ LOCK_N_GO_SERVICE_SCHEMA = vol.Schema(
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Nuki lock platform."""
|
||||
bridge = NukiBridge(
|
||||
config[CONF_HOST], config[CONF_TOKEN], config[CONF_PORT], DEFAULT_TIMEOUT,
|
||||
config[CONF_HOST], config[CONF_TOKEN], config[CONF_PORT], True, DEFAULT_TIMEOUT,
|
||||
)
|
||||
|
||||
devices = [NukiLockEntity(lock) for lock in bridge.locks]
|
||||
|
||||
@@ -174,7 +174,8 @@ class ZWaveClimateEntity(ZWaveDeviceEntity, ClimateEntity):
|
||||
def hvac_mode(self):
|
||||
"""Return hvac operation ie. heat, cool mode."""
|
||||
if not self.values.mode:
|
||||
return None
|
||||
# Thermostat(valve) with no support for setting a mode is considered heating-only
|
||||
return HVAC_MODE_HEAT
|
||||
return ZW_HVAC_MODE_MAPPINGS.get(
|
||||
self.values.mode.value[VALUE_SELECTED_ID], HVAC_MODE_HEAT_COOL
|
||||
)
|
||||
@@ -197,7 +198,7 @@ class ZWaveClimateEntity(ZWaveDeviceEntity, ClimateEntity):
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
"""Return the unit of measurement."""
|
||||
if self.values.temperature and self.values.temperature.units == "F":
|
||||
if self.values.temperature is not None and self.values.temperature.units == "F":
|
||||
return TEMP_FAHRENHEIT
|
||||
return TEMP_CELSIUS
|
||||
|
||||
@@ -220,6 +221,8 @@ class ZWaveClimateEntity(ZWaveDeviceEntity, ClimateEntity):
|
||||
def preset_mode(self):
|
||||
"""Return preset operation ie. eco, away."""
|
||||
# A Zwave mode that can not be translated to a hass mode is considered a preset
|
||||
if not self.values.mode:
|
||||
return None
|
||||
if self.values.mode.value[VALUE_SELECTED_ID] not in MODES_LIST:
|
||||
return self.values.mode.value[VALUE_SELECTED_LABEL]
|
||||
return PRESET_NONE
|
||||
@@ -274,8 +277,14 @@ class ZWaveClimateEntity(ZWaveDeviceEntity, ClimateEntity):
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode):
|
||||
"""Set new target hvac mode."""
|
||||
if not self.values.mode:
|
||||
# Thermostat(valve) with no support for setting a mode
|
||||
_LOGGER.warning(
|
||||
"Thermostat %s does not support setting a mode", self.entity_id
|
||||
)
|
||||
return
|
||||
hvac_mode_value = self._hvac_modes.get(hvac_mode)
|
||||
if not hvac_mode_value:
|
||||
if hvac_mode_value is None:
|
||||
_LOGGER.warning("Received an invalid hvac mode: %s", hvac_mode)
|
||||
return
|
||||
self.values.mode.send_value(hvac_mode_value)
|
||||
@@ -320,8 +329,11 @@ class ZWaveClimateEntity(ZWaveDeviceEntity, ClimateEntity):
|
||||
|
||||
def _get_current_mode_setpoint_values(self) -> Tuple:
|
||||
"""Return a tuple of current setpoint Z-Wave value(s)."""
|
||||
current_mode = self.values.mode.value[VALUE_SELECTED_ID]
|
||||
setpoint_names = MODE_SETPOINT_MAPPINGS.get(current_mode, ())
|
||||
if not self.values.mode:
|
||||
setpoint_names = ("setpoint_heating",)
|
||||
else:
|
||||
current_mode = self.values.mode.value[VALUE_SELECTED_ID]
|
||||
setpoint_names = MODE_SETPOINT_MAPPINGS.get(current_mode, ())
|
||||
# we do not want None values in our tuple so check if the value exists
|
||||
return tuple(
|
||||
getattr(self.values, value_name)
|
||||
@@ -331,20 +343,21 @@ class ZWaveClimateEntity(ZWaveDeviceEntity, ClimateEntity):
|
||||
|
||||
def _set_modes_and_presets(self):
|
||||
"""Convert Z-Wave Thermostat modes into Home Assistant modes and presets."""
|
||||
if not self.values.mode:
|
||||
return
|
||||
all_modes = {}
|
||||
all_presets = {PRESET_NONE: None}
|
||||
# Z-Wave uses one list for both modes and presets.
|
||||
# Iterate over all Z-Wave ThermostatModes and extract the hvac modes and presets.
|
||||
for val in self.values.mode.value[VALUE_LIST]:
|
||||
if val[VALUE_ID] in MODES_LIST:
|
||||
# treat value as hvac mode
|
||||
hass_mode = ZW_HVAC_MODE_MAPPINGS.get(val[VALUE_ID])
|
||||
all_modes[hass_mode] = val[VALUE_ID]
|
||||
else:
|
||||
# treat value as hvac preset
|
||||
all_presets[val[VALUE_LABEL]] = val[VALUE_ID]
|
||||
if self.values.mode:
|
||||
# Z-Wave uses one list for both modes and presets.
|
||||
# Iterate over all Z-Wave ThermostatModes and extract the hvac modes and presets.
|
||||
for val in self.values.mode.value[VALUE_LIST]:
|
||||
if val[VALUE_ID] in MODES_LIST:
|
||||
# treat value as hvac mode
|
||||
hass_mode = ZW_HVAC_MODE_MAPPINGS.get(val[VALUE_ID])
|
||||
all_modes[hass_mode] = val[VALUE_ID]
|
||||
else:
|
||||
# treat value as hvac preset
|
||||
all_presets[val[VALUE_LABEL]] = val[VALUE_ID]
|
||||
else:
|
||||
all_modes[HVAC_MODE_HEAT] = None
|
||||
self._hvac_modes = all_modes
|
||||
self._hvac_presets = all_presets
|
||||
|
||||
|
||||
@@ -131,6 +131,37 @@ DISCOVERY_SCHEMAS = (
|
||||
},
|
||||
},
|
||||
},
|
||||
{ # Z-Wave Thermostat device without mode support
|
||||
const.DISC_COMPONENT: "climate",
|
||||
const.DISC_GENERIC_DEVICE_CLASS: (const_ozw.GENERIC_TYPE_THERMOSTAT,),
|
||||
const.DISC_SPECIFIC_DEVICE_CLASS: (
|
||||
const_ozw.SPECIFIC_TYPE_SETPOINT_THERMOSTAT,
|
||||
),
|
||||
const.DISC_VALUES: {
|
||||
const.DISC_PRIMARY: {
|
||||
const.DISC_COMMAND_CLASS: (CommandClass.THERMOSTAT_SETPOINT,)
|
||||
},
|
||||
"temperature": {
|
||||
const.DISC_COMMAND_CLASS: (CommandClass.SENSOR_MULTILEVEL,),
|
||||
const.DISC_INDEX: (1,),
|
||||
const.DISC_OPTIONAL: True,
|
||||
},
|
||||
"operating_state": {
|
||||
const.DISC_COMMAND_CLASS: (CommandClass.THERMOSTAT_OPERATING_STATE,),
|
||||
const.DISC_OPTIONAL: True,
|
||||
},
|
||||
"valve_position": {
|
||||
const.DISC_COMMAND_CLASS: (CommandClass.SWITCH_MULTILEVEL,),
|
||||
const.DISC_INDEX: (0,),
|
||||
const.DISC_OPTIONAL: True,
|
||||
},
|
||||
"setpoint_heating": {
|
||||
const.DISC_COMMAND_CLASS: (CommandClass.THERMOSTAT_SETPOINT,),
|
||||
const.DISC_INDEX: (1,),
|
||||
const.DISC_OPTIONAL: True,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ # Rollershutter
|
||||
const.DISC_COMPONENT: "cover",
|
||||
const.DISC_GENERIC_DEVICE_CLASS: (const_ozw.GENERIC_TYPE_SWITCH_MULTILEVEL,),
|
||||
|
||||
@@ -215,7 +215,7 @@ def play_on_sonos(hass, service_call):
|
||||
|
||||
sonos = hass.components.sonos
|
||||
try:
|
||||
sonos_id = sonos.get_coordinator_id(entity_id)
|
||||
sonos_name = sonos.get_coordinator_name(entity_id)
|
||||
except HomeAssistantError as err:
|
||||
_LOGGER.error("Cannot get Sonos device: %s", err)
|
||||
return
|
||||
@@ -239,10 +239,10 @@ def play_on_sonos(hass, service_call):
|
||||
else:
|
||||
plex_server = next(iter(plex_servers))
|
||||
|
||||
sonos_speaker = plex_server.account.sonos_speaker_by_id(sonos_id)
|
||||
sonos_speaker = plex_server.account.sonos_speaker(sonos_name)
|
||||
if sonos_speaker is None:
|
||||
_LOGGER.error(
|
||||
"Sonos speaker '%s' could not be found on this Plex account", sonos_id
|
||||
"Sonos speaker '%s' could not be found on this Plex account", sonos_name
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from homeassistant.const import (
|
||||
UV_INDEX,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from .const import (
|
||||
ATTR_EVENT,
|
||||
@@ -92,9 +92,15 @@ def _bytearray_string(data):
|
||||
raise vol.Invalid("Data must be a hex string with multiple of two characters")
|
||||
|
||||
|
||||
def _ensure_device(value):
|
||||
if value is None:
|
||||
return DEVICE_DATA_SCHEMA({})
|
||||
return DEVICE_DATA_SCHEMA(value)
|
||||
|
||||
|
||||
SERVICE_SEND_SCHEMA = vol.Schema({ATTR_EVENT: _bytearray_string})
|
||||
|
||||
DEVICE_SCHEMA = vol.Schema(
|
||||
DEVICE_DATA_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||
vol.Optional(CONF_FIRE_EVENT, default=False): cv.boolean,
|
||||
@@ -110,7 +116,7 @@ BASE_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_DEBUG, default=False): cv.boolean,
|
||||
vol.Optional(CONF_AUTOMATIC_ADD, default=False): cv.boolean,
|
||||
vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA},
|
||||
vol.Optional(CONF_DEVICES, default={}): {cv.string: _ensure_device},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -337,7 +343,7 @@ def get_device_id(device, data_bits=None):
|
||||
return (f"{device.packettype:x}", f"{device.subtype:x}", id_string)
|
||||
|
||||
|
||||
class RfxtrxDevice(Entity):
|
||||
class RfxtrxDevice(RestoreEntity):
|
||||
"""Represents a Rfxtrx device.
|
||||
|
||||
Contains the common logic for Rfxtrx lights and switches.
|
||||
@@ -348,6 +354,7 @@ class RfxtrxDevice(Entity):
|
||||
self.signal_repetitions = signal_repetitions
|
||||
self._name = f"{device.type_string} {device.id_string}"
|
||||
self._device = device
|
||||
self._event = None
|
||||
self._state = None
|
||||
self._device_id = device_id
|
||||
self._unique_id = "_".join(x for x in self._device_id)
|
||||
@@ -355,6 +362,17 @@ class RfxtrxDevice(Entity):
|
||||
if event:
|
||||
self._apply_event(event)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Restore RFXtrx device state (ON/OFF)."""
|
||||
if self._event:
|
||||
return
|
||||
|
||||
old_state = await self.async_get_last_state()
|
||||
if old_state is not None:
|
||||
event = old_state.attributes.get(ATTR_EVENT)
|
||||
if event:
|
||||
self._apply_event(get_rfx_object(event))
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed for a RFXtrx switch."""
|
||||
@@ -365,6 +383,13 @@ class RfxtrxDevice(Entity):
|
||||
"""Return the name of the device if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the device state attributes."""
|
||||
if not self._event:
|
||||
return None
|
||||
return {ATTR_EVENT: "".join(f"{x:02x}" for x in self._event.data)}
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if device is on."""
|
||||
@@ -391,6 +416,7 @@ class RfxtrxDevice(Entity):
|
||||
|
||||
def _apply_event(self, event):
|
||||
"""Apply a received event."""
|
||||
self._event = event
|
||||
|
||||
def _send_command(self, command, brightness=0):
|
||||
rfx_object = self.hass.data[DATA_RFXOBJECT]
|
||||
|
||||
@@ -12,6 +12,7 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import event as evt
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from . import (
|
||||
CONF_AUTOMATIC_ADD,
|
||||
@@ -25,6 +26,7 @@ from . import (
|
||||
get_rfx_object,
|
||||
)
|
||||
from .const import (
|
||||
ATTR_EVENT,
|
||||
COMMAND_OFF_LIST,
|
||||
COMMAND_ON_LIST,
|
||||
DATA_RFXTRX_CONFIG,
|
||||
@@ -54,7 +56,7 @@ async def async_setup_entry(
|
||||
_LOGGER.error("Invalid device: %s", packet_id)
|
||||
continue
|
||||
if not supported(event):
|
||||
return
|
||||
continue
|
||||
|
||||
device_id = get_device_id(event.device, data_bits=entity.get(CONF_DATA_BITS))
|
||||
if device_id in device_ids:
|
||||
@@ -105,7 +107,7 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
|
||||
class RfxtrxBinarySensor(BinarySensorEntity):
|
||||
class RfxtrxBinarySensor(BinarySensorEntity, RestoreEntity):
|
||||
"""A representation of a RFXtrx binary sensor."""
|
||||
|
||||
def __init__(
|
||||
@@ -120,7 +122,7 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
||||
event=None,
|
||||
):
|
||||
"""Initialize the RFXtrx sensor."""
|
||||
self.event = None
|
||||
self._event = None
|
||||
self._device = device
|
||||
self._name = f"{device.type_string} {device.id_string}"
|
||||
self._device_class = device_class
|
||||
@@ -141,6 +143,13 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
||||
"""Restore RFXtrx switch device state (ON/OFF)."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
if self._event is None:
|
||||
old_state = await self.async_get_last_state()
|
||||
if old_state is not None:
|
||||
event = old_state.attributes.get(ATTR_EVENT)
|
||||
if event:
|
||||
self._apply_event(get_rfx_object(event))
|
||||
|
||||
self.async_on_remove(
|
||||
self.hass.helpers.dispatcher.async_dispatcher_connect(
|
||||
SIGNAL_EVENT, self._handle_event
|
||||
@@ -152,6 +161,13 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
||||
"""Return the device name."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the device state attributes."""
|
||||
if not self._event:
|
||||
return None
|
||||
return {ATTR_EVENT: "".join(f"{x:02x}" for x in self._event.data)}
|
||||
|
||||
@property
|
||||
def data_bits(self):
|
||||
"""Return the number of data bits."""
|
||||
@@ -172,6 +188,11 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def force_update(self) -> bool:
|
||||
"""We should force updates. Repeated states have meaning."""
|
||||
return True
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the sensor class."""
|
||||
@@ -221,6 +242,7 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
||||
|
||||
def _apply_event(self, event):
|
||||
"""Apply command from rfxtrx."""
|
||||
self._event = event
|
||||
if event.device.packettype == DEVICE_PACKET_TYPE_LIGHTING4:
|
||||
self._apply_event_lighting4(event)
|
||||
else:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import logging
|
||||
|
||||
from homeassistant.components.cover import CoverEntity
|
||||
from homeassistant.const import CONF_DEVICES, STATE_OPEN
|
||||
from homeassistant.const import CONF_DEVICES
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
@@ -86,10 +86,6 @@ class RfxtrxCover(RfxtrxDevice, CoverEntity, RestoreEntity):
|
||||
"""Restore RFXtrx cover device state (OPEN/CLOSE)."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
old_state = await self.async_get_last_state()
|
||||
if old_state is not None:
|
||||
self._state = old_state.state == STATE_OPEN
|
||||
|
||||
self.async_on_remove(
|
||||
self.hass.helpers.dispatcher.async_dispatcher_connect(
|
||||
SIGNAL_EVENT, self._handle_event
|
||||
@@ -120,6 +116,7 @@ class RfxtrxCover(RfxtrxDevice, CoverEntity, RestoreEntity):
|
||||
|
||||
def _apply_event(self, event):
|
||||
"""Apply command from rfxtrx."""
|
||||
super()._apply_event(event)
|
||||
if event.values["Command"] in COMMAND_ON_LIST:
|
||||
self._state = True
|
||||
elif event.values["Command"] in COMMAND_OFF_LIST:
|
||||
|
||||
@@ -8,9 +8,8 @@ from homeassistant.components.light import (
|
||||
SUPPORT_BRIGHTNESS,
|
||||
LightEntity,
|
||||
)
|
||||
from homeassistant.const import CONF_DEVICES, STATE_ON
|
||||
from homeassistant.const import CONF_DEVICES
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from . import (
|
||||
CONF_AUTOMATIC_ADD,
|
||||
@@ -93,7 +92,7 @@ async def async_setup_entry(
|
||||
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, light_update)
|
||||
|
||||
|
||||
class RfxtrxLight(RfxtrxDevice, LightEntity, RestoreEntity):
|
||||
class RfxtrxLight(RfxtrxDevice, LightEntity):
|
||||
"""Representation of a RFXtrx light."""
|
||||
|
||||
_brightness = 0
|
||||
@@ -102,17 +101,6 @@ class RfxtrxLight(RfxtrxDevice, LightEntity, RestoreEntity):
|
||||
"""Restore RFXtrx device state (ON/OFF)."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
old_state = await self.async_get_last_state()
|
||||
if old_state is not None:
|
||||
self._state = old_state.state == STATE_ON
|
||||
|
||||
# Restore the brightness of dimmable devices
|
||||
if (
|
||||
old_state is not None
|
||||
and old_state.attributes.get(ATTR_BRIGHTNESS) is not None
|
||||
):
|
||||
self._brightness = int(old_state.attributes[ATTR_BRIGHTNESS])
|
||||
|
||||
self.async_on_remove(
|
||||
self.hass.helpers.dispatcher.async_dispatcher_connect(
|
||||
SIGNAL_EVENT, self._handle_event
|
||||
@@ -147,6 +135,7 @@ class RfxtrxLight(RfxtrxDevice, LightEntity, RestoreEntity):
|
||||
|
||||
def _apply_event(self, event):
|
||||
"""Apply command from rfxtrx."""
|
||||
super()._apply_event(event)
|
||||
if event.values["Command"] in COMMAND_ON_LIST:
|
||||
self._state = True
|
||||
elif event.values["Command"] in COMMAND_OFF_LIST:
|
||||
|
||||
@@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
|
||||
)
|
||||
from homeassistant.const import CONF_DEVICES
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from . import (
|
||||
CONF_AUTOMATIC_ADD,
|
||||
@@ -21,7 +21,7 @@ from . import (
|
||||
get_device_id,
|
||||
get_rfx_object,
|
||||
)
|
||||
from .const import DATA_RFXTRX_CONFIG
|
||||
from .const import ATTR_EVENT, DATA_RFXTRX_CONFIG
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -113,12 +113,12 @@ async def async_setup_entry(
|
||||
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, sensor_update)
|
||||
|
||||
|
||||
class RfxtrxSensor(Entity):
|
||||
class RfxtrxSensor(RestoreEntity):
|
||||
"""Representation of a RFXtrx sensor."""
|
||||
|
||||
def __init__(self, device, device_id, data_type, event=None):
|
||||
"""Initialize the sensor."""
|
||||
self.event = None
|
||||
self._event = None
|
||||
self._device = device
|
||||
self._name = f"{device.type_string} {device.id_string} {data_type}"
|
||||
self.data_type = data_type
|
||||
@@ -136,6 +136,13 @@ class RfxtrxSensor(Entity):
|
||||
"""Restore RFXtrx switch device state (ON/OFF)."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
if self._event is None:
|
||||
old_state = await self.async_get_last_state()
|
||||
if old_state is not None:
|
||||
event = old_state.attributes.get(ATTR_EVENT)
|
||||
if event:
|
||||
self._apply_event(get_rfx_object(event))
|
||||
|
||||
self.async_on_remove(
|
||||
self.hass.helpers.dispatcher.async_dispatcher_connect(
|
||||
SIGNAL_EVENT, self._handle_event
|
||||
@@ -149,9 +156,9 @@ class RfxtrxSensor(Entity):
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
if not self.event:
|
||||
if not self._event:
|
||||
return None
|
||||
value = self.event.values.get(self.data_type)
|
||||
value = self._event.values.get(self.data_type)
|
||||
return self._convert_fun(value)
|
||||
|
||||
@property
|
||||
@@ -162,15 +169,25 @@ class RfxtrxSensor(Entity):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the device state attributes."""
|
||||
if not self.event:
|
||||
if not self._event:
|
||||
return None
|
||||
return self.event.values
|
||||
return {ATTR_EVENT: "".join(f"{x:02x}" for x in self._event.data)}
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit this state is expressed in."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def force_update(self) -> bool:
|
||||
"""We should force updates. Repeated states have meaning."""
|
||||
return True
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return a device class for sensor."""
|
||||
@@ -192,7 +209,7 @@ class RfxtrxSensor(Entity):
|
||||
|
||||
def _apply_event(self, event):
|
||||
"""Apply command from rfxtrx."""
|
||||
self.event = event
|
||||
self._event = event
|
||||
|
||||
@callback
|
||||
def _handle_event(self, event, device_id):
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
import RFXtrx as rfxtrxmod
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.const import CONF_DEVICES, STATE_ON
|
||||
from homeassistant.const import CONF_DEVICES
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
@@ -96,10 +96,6 @@ class RfxtrxSwitch(RfxtrxDevice, SwitchEntity, RestoreEntity):
|
||||
"""Restore RFXtrx switch device state (ON/OFF)."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
old_state = await self.async_get_last_state()
|
||||
if old_state is not None:
|
||||
self._state = old_state.state == STATE_ON
|
||||
|
||||
self.async_on_remove(
|
||||
self.hass.helpers.dispatcher.async_dispatcher_connect(
|
||||
SIGNAL_EVENT, self._handle_event
|
||||
@@ -108,6 +104,7 @@ class RfxtrxSwitch(RfxtrxDevice, SwitchEntity, RestoreEntity):
|
||||
|
||||
def _apply_event(self, event):
|
||||
"""Apply command from rfxtrx."""
|
||||
super()._apply_event(event)
|
||||
if event.values["Command"] in COMMAND_ON_LIST:
|
||||
self._state = True
|
||||
elif event.values["Command"] in COMMAND_OFF_LIST:
|
||||
|
||||
@@ -58,8 +58,10 @@ async def async_setup_entry(hass, entry):
|
||||
|
||||
|
||||
@bind_hass
|
||||
def get_coordinator_id(hass, entity_id):
|
||||
"""Obtain the unique_id of a device's coordinator.
|
||||
def get_coordinator_name(hass, entity_id):
|
||||
"""Obtain the room/name of a device's coordinator.
|
||||
|
||||
Used by the Plex integration.
|
||||
|
||||
This function is safe to run inside the event loop.
|
||||
"""
|
||||
@@ -71,5 +73,5 @@ def get_coordinator_id(hass, entity_id):
|
||||
)
|
||||
|
||||
if device.is_coordinator:
|
||||
return device.unique_id
|
||||
return device.coordinator.unique_id
|
||||
return device.name
|
||||
return device.coordinator.name
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "Sonos",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/sonos",
|
||||
"requirements": ["pysonos==0.0.31"],
|
||||
"requirements": ["pysonos==0.0.32"],
|
||||
"ssdp": [
|
||||
{
|
||||
"st": "urn:schemas-upnp-org:device:ZonePlayer:1"
|
||||
|
||||
@@ -245,7 +245,7 @@ class ZigbeeChannel(LogMixin):
|
||||
self._cluster,
|
||||
[attribute],
|
||||
allow_cache=from_cache,
|
||||
only_cache=from_cache,
|
||||
only_cache=from_cache and not self._ch_pool.is_mains_powered,
|
||||
manufacturer=manufacturer,
|
||||
)
|
||||
return result.get(attribute)
|
||||
@@ -260,7 +260,7 @@ class ZigbeeChannel(LogMixin):
|
||||
result, _ = await self.cluster.read_attributes(
|
||||
attributes,
|
||||
allow_cache=from_cache,
|
||||
only_cache=from_cache,
|
||||
only_cache=from_cache and not self._ch_pool.is_mains_powered,
|
||||
manufacturer=manufacturer,
|
||||
)
|
||||
return result
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import Optional
|
||||
|
||||
import zigpy.zcl.clusters.homeautomation as homeautomation
|
||||
|
||||
from .. import registries, typing as zha_typing
|
||||
from .. import registries
|
||||
from ..const import (
|
||||
CHANNEL_ELECTRICAL_MEASUREMENT,
|
||||
REPORT_CONFIG_DEFAULT,
|
||||
@@ -51,14 +51,6 @@ class ElectricalMeasurementChannel(ZigbeeChannel):
|
||||
|
||||
REPORT_CONFIG = ({"attr": "active_power", "config": REPORT_CONFIG_DEFAULT},)
|
||||
|
||||
def __init__(
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
|
||||
) -> None:
|
||||
"""Initialize Metering."""
|
||||
super().__init__(cluster, ch_pool)
|
||||
self._divisor = None
|
||||
self._multiplier = None
|
||||
|
||||
async def async_update(self):
|
||||
"""Retrieve latest state."""
|
||||
self.debug("async_update")
|
||||
@@ -80,7 +72,9 @@ class ElectricalMeasurementChannel(ZigbeeChannel):
|
||||
|
||||
async def fetch_config(self, from_cache):
|
||||
"""Fetch config from device and updates format specifier."""
|
||||
results = await self.get_attributes(
|
||||
|
||||
# prime the cache
|
||||
await self.get_attributes(
|
||||
[
|
||||
"ac_power_divisor",
|
||||
"power_divisor",
|
||||
@@ -89,22 +83,20 @@ class ElectricalMeasurementChannel(ZigbeeChannel):
|
||||
],
|
||||
from_cache=from_cache,
|
||||
)
|
||||
self._divisor = results.get(
|
||||
"ac_power_divisor", results.get("power_divisor", self._divisor)
|
||||
)
|
||||
self._multiplier = results.get(
|
||||
"ac_power_multiplier", results.get("power_multiplier", self._multiplier)
|
||||
)
|
||||
|
||||
@property
|
||||
def divisor(self) -> Optional[int]:
|
||||
"""Return active power divisor."""
|
||||
return self._divisor or 1
|
||||
return self.cluster.get(
|
||||
"ac_power_divisor", self.cluster.get("power_divisor", 1)
|
||||
)
|
||||
|
||||
@property
|
||||
def multiplier(self) -> Optional[int]:
|
||||
"""Return active power divisor."""
|
||||
return self._multiplier or 1
|
||||
return self.cluster.get(
|
||||
"ac_power_multiplier", self.cluster.get("power_multiplier", 1)
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
|
||||
@@ -3,7 +3,7 @@ import logging
|
||||
|
||||
import zigpy.zcl.clusters.smartenergy as smartenergy
|
||||
|
||||
from homeassistant.const import LENGTH_FEET, TIME_HOURS, TIME_SECONDS
|
||||
from homeassistant.const import LENGTH_FEET, POWER_WATT, TIME_HOURS, TIME_SECONDS
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .. import registries, typing as zha_typing
|
||||
@@ -60,7 +60,7 @@ class Metering(ZigbeeChannel):
|
||||
REPORT_CONFIG = [{"attr": "instantaneous_demand", "config": REPORT_CONFIG_DEFAULT}]
|
||||
|
||||
unit_of_measure_map = {
|
||||
0x00: "kW",
|
||||
0x00: POWER_WATT,
|
||||
0x01: f"m³/{TIME_HOURS}",
|
||||
0x02: f"{LENGTH_FEET}³/{TIME_HOURS}",
|
||||
0x03: f"ccf/{TIME_HOURS}",
|
||||
@@ -135,6 +135,12 @@ class Metering(ZigbeeChannel):
|
||||
|
||||
def formatter_function(self, value):
|
||||
"""Return formatted value for display."""
|
||||
if self.unit_of_measurement == POWER_WATT:
|
||||
# Zigbee spec power unit is kW, but we show the value in W
|
||||
value_watt = value * 1000
|
||||
if value_watt < 100:
|
||||
return round(value_watt, 1)
|
||||
return round(value_watt)
|
||||
return self._format_spec.format(value).lstrip()
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ from homeassistant.components.light import (
|
||||
)
|
||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.core import State, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
import homeassistant.util.color as color_util
|
||||
|
||||
@@ -71,6 +75,7 @@ UNSUPPORTED_ATTRIBUTE = 0x86
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, light.DOMAIN)
|
||||
GROUP_MATCH = functools.partial(ZHA_ENTITIES.group_match, light.DOMAIN)
|
||||
PARALLEL_UPDATES = 0
|
||||
SIGNAL_LIGHT_GROUP_STATE_CHANGED = "zha_light_group_state_changed"
|
||||
|
||||
SUPPORT_GROUP_LIGHT = (
|
||||
SUPPORT_BRIGHTNESS
|
||||
@@ -378,6 +383,12 @@ class Light(BaseLight, ZhaEntity):
|
||||
self._cancel_refresh_handle = async_track_time_interval(
|
||||
self.hass, self._refresh, timedelta(seconds=refresh_interval)
|
||||
)
|
||||
await self.async_accept_signal(
|
||||
None,
|
||||
SIGNAL_LIGHT_GROUP_STATE_CHANGED,
|
||||
self._maybe_force_refresh,
|
||||
signal_override=True,
|
||||
)
|
||||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Disconnect entity object when removed."""
|
||||
@@ -406,7 +417,7 @@ class Light(BaseLight, ZhaEntity):
|
||||
|
||||
async def async_get_state(self, from_cache=True):
|
||||
"""Attempt to retrieve on off state from the light."""
|
||||
self.debug("polling current state")
|
||||
self.debug("polling current state - from cache: %s", from_cache)
|
||||
if self._on_off_channel:
|
||||
state = await self._on_off_channel.get_attribute_value(
|
||||
"on_off", from_cache=from_cache
|
||||
@@ -468,6 +479,12 @@ class Light(BaseLight, ZhaEntity):
|
||||
await self.async_get_state(from_cache=False)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def _maybe_force_refresh(self, signal):
|
||||
"""Force update the state if the signal contains the entity id for this entity."""
|
||||
if self.entity_id in signal["entity_ids"]:
|
||||
await self.async_get_state(from_cache=False)
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
@STRICT_MATCH(
|
||||
channel_names=CHANNEL_ON_OFF,
|
||||
@@ -494,6 +511,30 @@ class LightGroup(BaseLight, ZhaGroupEntity):
|
||||
self._level_channel = group.endpoint[LevelControl.cluster_id]
|
||||
self._color_channel = group.endpoint[Color.cluster_id]
|
||||
self._identify_channel = group.endpoint[Identify.cluster_id]
|
||||
self._debounced_member_refresh = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Run when about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
if self._debounced_member_refresh is None:
|
||||
force_refresh_debouncer = Debouncer(
|
||||
self.hass,
|
||||
_LOGGER,
|
||||
cooldown=3,
|
||||
immediate=True,
|
||||
function=self._force_member_updates,
|
||||
)
|
||||
self._debounced_member_refresh = force_refresh_debouncer
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn the entity on."""
|
||||
await super().async_turn_on(**kwargs)
|
||||
await self._debounced_member_refresh.async_call()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the entity off."""
|
||||
await super().async_turn_off(**kwargs)
|
||||
await self._debounced_member_refresh.async_call()
|
||||
|
||||
async def async_update(self) -> None:
|
||||
"""Query all members and determine the light group state."""
|
||||
@@ -541,3 +582,11 @@ class LightGroup(BaseLight, ZhaGroupEntity):
|
||||
# Bitwise-and the supported features with the GroupedLight's features
|
||||
# so that we don't break in the future when a new feature is added.
|
||||
self._supported_features &= SUPPORT_GROUP_LIGHT
|
||||
|
||||
async def _force_member_updates(self):
|
||||
"""Force the update of member entities to ensure the states are correct for bulbs that don't report their state."""
|
||||
async_dispatcher_send(
|
||||
self.hass,
|
||||
SIGNAL_LIGHT_GROUP_STATE_CHANGED,
|
||||
{"entity_ids": self._entity_ids},
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"zha-quirks==0.0.42",
|
||||
"zigpy-cc==0.4.4",
|
||||
"zigpy-deconz==0.9.2",
|
||||
"zigpy==0.22.1",
|
||||
"zigpy==0.22.2",
|
||||
"zigpy-xbee==0.12.1",
|
||||
"zigpy-zigate==0.6.1"
|
||||
],
|
||||
|
||||
@@ -511,8 +511,8 @@ async def async_process_ha_core_config(hass: HomeAssistant, config: Dict) -> Non
|
||||
elif LEGACY_CONF_WHITELIST_EXTERNAL_DIRS in config:
|
||||
_LOGGER.warning(
|
||||
"Key %s has been replaced with %s. Please update your config",
|
||||
CONF_ALLOWLIST_EXTERNAL_DIRS,
|
||||
LEGACY_CONF_WHITELIST_EXTERNAL_DIRS,
|
||||
CONF_ALLOWLIST_EXTERNAL_DIRS,
|
||||
)
|
||||
hac.allowlist_external_dirs.update(
|
||||
set(config[LEGACY_CONF_WHITELIST_EXTERNAL_DIRS])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 113
|
||||
PATCH_VERSION = "0b0"
|
||||
PATCH_VERSION = "0b3"
|
||||
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
|
||||
__version__ = f"{__short_version__}.{PATCH_VERSION}"
|
||||
REQUIRED_PYTHON_VER = (3, 7, 1)
|
||||
|
||||
@@ -135,7 +135,9 @@ track_state_change = threaded_listener_factory(async_track_state_change)
|
||||
|
||||
@bind_hass
|
||||
def async_track_state_change_event(
|
||||
hass: HomeAssistant, entity_ids: Iterable[str], action: Callable[[Event], None]
|
||||
hass: HomeAssistant,
|
||||
entity_ids: Union[str, Iterable[str]],
|
||||
action: Callable[[Event], None],
|
||||
) -> Callable[[], None]:
|
||||
"""Track specific state change events indexed by entity_id.
|
||||
|
||||
@@ -161,7 +163,7 @@ def async_track_state_change_event(
|
||||
if entity_id not in entity_callbacks:
|
||||
return
|
||||
|
||||
for action in entity_callbacks[entity_id]:
|
||||
for action in entity_callbacks[entity_id][:]:
|
||||
try:
|
||||
hass.async_run_job(action, event)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
@@ -173,13 +175,13 @@ def async_track_state_change_event(
|
||||
EVENT_STATE_CHANGED, _async_state_change_dispatcher
|
||||
)
|
||||
|
||||
if isinstance(entity_ids, str):
|
||||
entity_ids = [entity_ids]
|
||||
|
||||
entity_ids = [entity_id.lower() for entity_id in entity_ids]
|
||||
|
||||
for entity_id in entity_ids:
|
||||
if entity_id not in entity_callbacks:
|
||||
entity_callbacks[entity_id] = []
|
||||
|
||||
entity_callbacks[entity_id].append(action)
|
||||
entity_callbacks.setdefault(entity_id, []).append(action)
|
||||
|
||||
@callback
|
||||
def remove_listener() -> None:
|
||||
@@ -247,7 +249,7 @@ def async_track_same_state(
|
||||
hass: HomeAssistant,
|
||||
period: timedelta,
|
||||
action: Callable[..., None],
|
||||
async_check_same_func: Callable[[str, State, State], bool],
|
||||
async_check_same_func: Callable[[str, Optional[State], Optional[State]], bool],
|
||||
entity_ids: Union[str, Iterable[str]] = MATCH_ALL,
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Track the state of entities for a period and run an action.
|
||||
@@ -279,10 +281,12 @@ def async_track_same_state(
|
||||
hass.async_run_job(action)
|
||||
|
||||
@callback
|
||||
def state_for_cancel_listener(
|
||||
entity: str, from_state: State, to_state: State
|
||||
) -> None:
|
||||
def state_for_cancel_listener(event: Event) -> None:
|
||||
"""Fire on changes and cancel for listener if changed."""
|
||||
entity: str = event.data["entity_id"]
|
||||
from_state: Optional[State] = event.data.get("old_state")
|
||||
to_state: Optional[State] = event.data.get("new_state")
|
||||
|
||||
if not async_check_same_func(entity, from_state, to_state):
|
||||
clear_listener()
|
||||
|
||||
@@ -290,9 +294,16 @@ def async_track_same_state(
|
||||
hass, state_for_listener, dt_util.utcnow() + period
|
||||
)
|
||||
|
||||
async_remove_state_for_cancel = async_track_state_change(
|
||||
hass, entity_ids, state_for_cancel_listener
|
||||
)
|
||||
if entity_ids == MATCH_ALL:
|
||||
async_remove_state_for_cancel = hass.bus.async_listen(
|
||||
EVENT_STATE_CHANGED, state_for_cancel_listener
|
||||
)
|
||||
else:
|
||||
async_remove_state_for_cancel = async_track_state_change_event(
|
||||
hass,
|
||||
[entity_ids] if isinstance(entity_ids, str) else entity_ids,
|
||||
state_for_cancel_listener,
|
||||
)
|
||||
|
||||
return clear_listener
|
||||
|
||||
|
||||
@@ -760,14 +760,16 @@ class Script:
|
||||
raise
|
||||
|
||||
async def _async_stop(self, update_state):
|
||||
await asyncio.wait([run.async_stop() for run in self._runs])
|
||||
aws = [run.async_stop() for run in self._runs]
|
||||
if not aws:
|
||||
return
|
||||
await asyncio.wait(aws)
|
||||
if update_state:
|
||||
self._changed()
|
||||
|
||||
async def async_stop(self, update_state: bool = True) -> None:
|
||||
"""Stop running script."""
|
||||
if self.is_running:
|
||||
await asyncio.shield(self._async_stop(update_state))
|
||||
await asyncio.shield(self._async_stop(update_state))
|
||||
|
||||
async def _async_get_condition(self, config):
|
||||
config_cache_key = frozenset((k, str(v)) for k, v in config.items())
|
||||
|
||||
@@ -13,7 +13,7 @@ defusedxml==0.6.0
|
||||
distro==1.5.0
|
||||
emoji==0.5.4
|
||||
hass-nabucasa==0.34.7
|
||||
home-assistant-frontend==20200715.0
|
||||
home-assistant-frontend==20200716.0
|
||||
importlib-metadata==1.6.0;python_version<'3.8'
|
||||
jinja2>=2.11.1
|
||||
netdisco==2.8.0
|
||||
|
||||
@@ -724,7 +724,7 @@ hole==0.5.1
|
||||
holidays==0.10.2
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20200715.0
|
||||
home-assistant-frontend==20200716.0
|
||||
|
||||
# homeassistant.components.zwave
|
||||
homeassistant-pyozw==0.1.10
|
||||
@@ -1244,7 +1244,7 @@ pycfdns==0.0.1
|
||||
pychannels==1.0.0
|
||||
|
||||
# homeassistant.components.cast
|
||||
pychromecast==7.0.1
|
||||
pychromecast==7.1.2
|
||||
|
||||
# homeassistant.components.cmus
|
||||
pycmus==0.1.1
|
||||
@@ -1623,7 +1623,7 @@ pysnmp==4.4.12
|
||||
pysoma==0.0.10
|
||||
|
||||
# homeassistant.components.sonos
|
||||
pysonos==0.0.31
|
||||
pysonos==0.0.32
|
||||
|
||||
# homeassistant.components.spc
|
||||
pyspcwebgw==0.4.0
|
||||
@@ -2269,7 +2269,7 @@ zigpy-xbee==0.12.1
|
||||
zigpy-zigate==0.6.1
|
||||
|
||||
# homeassistant.components.zha
|
||||
zigpy==0.22.1
|
||||
zigpy==0.22.2
|
||||
|
||||
# homeassistant.components.zoneminder
|
||||
zm-py==0.4.0
|
||||
|
||||
@@ -350,7 +350,7 @@ hole==0.5.1
|
||||
holidays==0.10.2
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20200715.0
|
||||
home-assistant-frontend==20200716.0
|
||||
|
||||
# homeassistant.components.zwave
|
||||
homeassistant-pyozw==0.1.10
|
||||
@@ -577,7 +577,7 @@ pyblackbird==0.5
|
||||
pybotvac==0.0.17
|
||||
|
||||
# homeassistant.components.cast
|
||||
pychromecast==7.0.1
|
||||
pychromecast==7.1.2
|
||||
|
||||
# homeassistant.components.coolmaster
|
||||
pycoolmasternet==0.0.4
|
||||
@@ -743,7 +743,7 @@ pysmartthings==0.7.1
|
||||
pysoma==0.0.10
|
||||
|
||||
# homeassistant.components.sonos
|
||||
pysonos==0.0.31
|
||||
pysonos==0.0.32
|
||||
|
||||
# homeassistant.components.spc
|
||||
pyspcwebgw==0.4.0
|
||||
@@ -999,4 +999,4 @@ zigpy-xbee==0.12.1
|
||||
zigpy-zigate==0.6.1
|
||||
|
||||
# homeassistant.components.zha
|
||||
zigpy==0.22.1
|
||||
zigpy==0.22.2
|
||||
|
||||
@@ -6,6 +6,7 @@ from homeassistant.components.climate.const import (
|
||||
ATTR_FAN_MODES,
|
||||
ATTR_HVAC_ACTION,
|
||||
ATTR_HVAC_MODES,
|
||||
ATTR_PRESET_MODE,
|
||||
ATTR_PRESET_MODES,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
@@ -218,3 +219,47 @@ async def test_climate(hass, climate_data, sent_messages, climate_msg, caplog):
|
||||
)
|
||||
assert len(sent_messages) == 8
|
||||
assert "Received an invalid preset mode: invalid preset mode" in caplog.text
|
||||
|
||||
# test thermostat device without a mode commandclass
|
||||
state = hass.states.get("climate.danfoss_living_connect_z_v1_06_014g0013_heating_1")
|
||||
assert state is not None
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVAC_MODE_HEAT,
|
||||
]
|
||||
assert state.attributes.get(ATTR_CURRENT_TEMPERATURE) is None
|
||||
assert round(state.attributes[ATTR_TEMPERATURE], 0) == 21
|
||||
assert state.attributes.get(ATTR_TARGET_TEMP_LOW) is None
|
||||
assert state.attributes.get(ATTR_TARGET_TEMP_HIGH) is None
|
||||
assert state.attributes.get(ATTR_PRESET_MODE) is None
|
||||
assert state.attributes.get(ATTR_PRESET_MODES) is None
|
||||
|
||||
# Test set target temperature
|
||||
await hass.services.async_call(
|
||||
"climate",
|
||||
"set_temperature",
|
||||
{
|
||||
"entity_id": "climate.danfoss_living_connect_z_v1_06_014g0013_heating_1",
|
||||
"temperature": 28.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
assert len(sent_messages) == 9
|
||||
msg = sent_messages[-1]
|
||||
assert msg["topic"] == "OpenZWave/1/command/setvalue/"
|
||||
assert msg["payload"] == {
|
||||
"Value": 28.0,
|
||||
"ValueIDKey": 281475116220434,
|
||||
}
|
||||
|
||||
await hass.services.async_call(
|
||||
"climate",
|
||||
"set_hvac_mode",
|
||||
{
|
||||
"entity_id": "climate.danfoss_living_connect_z_v1_06_014g0013_heating_1",
|
||||
"hvac_mode": HVAC_MODE_HEAT,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
assert len(sent_messages) == 9
|
||||
assert "does not support setting a mode" in caplog.text
|
||||
|
||||
@@ -78,9 +78,9 @@ class MockPlexAccount:
|
||||
"""Mock the PlexAccount resources listing method."""
|
||||
return self._resources
|
||||
|
||||
def sonos_speaker_by_id(self, machine_identifier):
|
||||
def sonos_speaker(self, speaker_name):
|
||||
"""Mock the PlexAccount Sonos lookup method."""
|
||||
return MockPlexSonosClient(machine_identifier)
|
||||
return MockPlexSonosClient(speaker_name)
|
||||
|
||||
|
||||
class MockPlexSystemAccount:
|
||||
@@ -378,9 +378,9 @@ class MockPlexMediaTrack(MockPlexMediaItem):
|
||||
class MockPlexSonosClient:
|
||||
"""Mock a PlexSonosClient instance."""
|
||||
|
||||
def __init__(self, machine_identifier):
|
||||
def __init__(self, name):
|
||||
"""Initialize the object."""
|
||||
self.machineIdentifier = machine_identifier
|
||||
self.name = name
|
||||
|
||||
def playMedia(self, item):
|
||||
"""Mock the playMedia method."""
|
||||
|
||||
@@ -39,7 +39,7 @@ async def test_sonos_playback(hass):
|
||||
|
||||
# Test Sonos integration lookup failure
|
||||
with patch.object(
|
||||
hass.components.sonos, "get_coordinator_id", side_effect=HomeAssistantError
|
||||
hass.components.sonos, "get_coordinator_name", side_effect=HomeAssistantError
|
||||
):
|
||||
assert await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@@ -55,7 +55,7 @@ async def test_sonos_playback(hass):
|
||||
# Test success with dict
|
||||
with patch.object(
|
||||
hass.components.sonos,
|
||||
"get_coordinator_id",
|
||||
"get_coordinator_name",
|
||||
return_value="media_player.sonos_kitchen",
|
||||
), patch("plexapi.playqueue.PlayQueue.create"):
|
||||
assert await hass.services.async_call(
|
||||
@@ -72,7 +72,7 @@ async def test_sonos_playback(hass):
|
||||
# Test success with plex_key
|
||||
with patch.object(
|
||||
hass.components.sonos,
|
||||
"get_coordinator_id",
|
||||
"get_coordinator_name",
|
||||
return_value="media_player.sonos_kitchen",
|
||||
), patch("plexapi.playqueue.PlayQueue.create"):
|
||||
assert await hass.services.async_call(
|
||||
@@ -89,7 +89,7 @@ async def test_sonos_playback(hass):
|
||||
# Test invalid Plex server requested
|
||||
with patch.object(
|
||||
hass.components.sonos,
|
||||
"get_coordinator_id",
|
||||
"get_coordinator_name",
|
||||
return_value="media_player.sonos_kitchen",
|
||||
):
|
||||
assert await hass.services.async_call(
|
||||
@@ -105,10 +105,10 @@ async def test_sonos_playback(hass):
|
||||
|
||||
# Test no speakers available
|
||||
with patch.object(
|
||||
loaded_server.account, "sonos_speaker_by_id", return_value=None
|
||||
loaded_server.account, "sonos_speaker", return_value=None
|
||||
), patch.object(
|
||||
hass.components.sonos,
|
||||
"get_coordinator_id",
|
||||
"get_coordinator_name",
|
||||
return_value="media_player.sonos_kitchen",
|
||||
):
|
||||
assert await hass.services.async_call(
|
||||
|
||||
@@ -265,3 +265,58 @@ async def test_temp_uom(
|
||||
assert state is not None
|
||||
assert round(float(state.state)) == expected
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == uom
|
||||
|
||||
|
||||
async def test_electrical_measurement_init(
|
||||
hass, zigpy_device_mock, zha_device_joined,
|
||||
):
|
||||
"""Test proper initialization of the electrical measurement cluster."""
|
||||
|
||||
cluster_id = homeautomation.ElectricalMeasurement.cluster_id
|
||||
zigpy_device = zigpy_device_mock(
|
||||
{
|
||||
1: {
|
||||
"in_clusters": [cluster_id, general.Basic.cluster_id],
|
||||
"out_cluster": [],
|
||||
"device_type": 0x0000,
|
||||
}
|
||||
}
|
||||
)
|
||||
cluster = zigpy_device.endpoints[1].in_clusters[cluster_id]
|
||||
zha_device = await zha_device_joined(zigpy_device)
|
||||
entity_id = await find_entity_id(DOMAIN, zha_device, hass)
|
||||
|
||||
# allow traffic to flow through the gateway and devices
|
||||
await async_enable_traffic(hass, [zha_device])
|
||||
|
||||
# test that the sensor now have a state of unknown
|
||||
assert hass.states.get(entity_id).state == STATE_UNKNOWN
|
||||
|
||||
await send_attributes_report(hass, cluster, {0: 1, 1291: 100, 10: 1000})
|
||||
assert int(hass.states.get(entity_id).state) == 100
|
||||
|
||||
channel = zha_device.channels.pools[0].all_channels["1:0x0b04"]
|
||||
assert channel.divisor == 1
|
||||
assert channel.multiplier == 1
|
||||
|
||||
# update power divisor
|
||||
await send_attributes_report(hass, cluster, {0: 1, 1291: 20, 0x0403: 5, 10: 1000})
|
||||
assert channel.divisor == 5
|
||||
assert channel.multiplier == 1
|
||||
assert hass.states.get(entity_id).state == "4.0"
|
||||
|
||||
await send_attributes_report(hass, cluster, {0: 1, 1291: 30, 0x0605: 10, 10: 1000})
|
||||
assert channel.divisor == 10
|
||||
assert channel.multiplier == 1
|
||||
assert hass.states.get(entity_id).state == "3.0"
|
||||
|
||||
# update power multiplier
|
||||
await send_attributes_report(hass, cluster, {0: 1, 1291: 20, 0x0402: 6, 10: 1000})
|
||||
assert channel.divisor == 10
|
||||
assert channel.multiplier == 6
|
||||
assert hass.states.get(entity_id).state == "12.0"
|
||||
|
||||
await send_attributes_report(hass, cluster, {0: 1, 1291: 30, 0x0604: 20, 10: 1000})
|
||||
assert channel.divisor == 10
|
||||
assert channel.multiplier == 20
|
||||
assert hass.states.get(entity_id).state == "60.0"
|
||||
|
||||
36
tests/fixtures/ozw/climate_network_dump.csv
vendored
36
tests/fixtures/ozw/climate_network_dump.csv
vendored
File diff suppressed because one or more lines are too long
@@ -1011,3 +1011,104 @@ async def test_async_call_later(hass):
|
||||
assert p_action is action
|
||||
assert p_point == now + timedelta(seconds=3)
|
||||
assert remove is mock()
|
||||
|
||||
|
||||
async def test_track_state_change_event_chain_multple_entity(hass):
|
||||
"""Test that adding a new state tracker inside a tracker does not fire right away."""
|
||||
tracker_called = []
|
||||
chained_tracker_called = []
|
||||
|
||||
chained_tracker_unsub = []
|
||||
tracker_unsub = []
|
||||
|
||||
@ha.callback
|
||||
def chained_single_run_callback(event):
|
||||
old_state = event.data.get("old_state")
|
||||
new_state = event.data.get("new_state")
|
||||
|
||||
chained_tracker_called.append((old_state, new_state))
|
||||
|
||||
@ha.callback
|
||||
def single_run_callback(event):
|
||||
old_state = event.data.get("old_state")
|
||||
new_state = event.data.get("new_state")
|
||||
|
||||
tracker_called.append((old_state, new_state))
|
||||
|
||||
chained_tracker_unsub.append(
|
||||
async_track_state_change_event(
|
||||
hass, ["light.bowl", "light.top"], chained_single_run_callback
|
||||
)
|
||||
)
|
||||
|
||||
tracker_unsub.append(
|
||||
async_track_state_change_event(
|
||||
hass, ["light.bowl", "light.top"], single_run_callback
|
||||
)
|
||||
)
|
||||
|
||||
hass.states.async_set("light.bowl", "on")
|
||||
hass.states.async_set("light.top", "on")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(tracker_called) == 2
|
||||
assert len(chained_tracker_called) == 1
|
||||
assert len(tracker_unsub) == 1
|
||||
assert len(chained_tracker_unsub) == 2
|
||||
|
||||
hass.states.async_set("light.bowl", "off")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(tracker_called) == 3
|
||||
assert len(chained_tracker_called) == 3
|
||||
assert len(tracker_unsub) == 1
|
||||
assert len(chained_tracker_unsub) == 3
|
||||
|
||||
|
||||
async def test_track_state_change_event_chain_single_entity(hass):
|
||||
"""Test that adding a new state tracker inside a tracker does not fire right away."""
|
||||
tracker_called = []
|
||||
chained_tracker_called = []
|
||||
|
||||
chained_tracker_unsub = []
|
||||
tracker_unsub = []
|
||||
|
||||
@ha.callback
|
||||
def chained_single_run_callback(event):
|
||||
old_state = event.data.get("old_state")
|
||||
new_state = event.data.get("new_state")
|
||||
|
||||
chained_tracker_called.append((old_state, new_state))
|
||||
|
||||
@ha.callback
|
||||
def single_run_callback(event):
|
||||
old_state = event.data.get("old_state")
|
||||
new_state = event.data.get("new_state")
|
||||
|
||||
tracker_called.append((old_state, new_state))
|
||||
|
||||
chained_tracker_unsub.append(
|
||||
async_track_state_change_event(
|
||||
hass, "light.bowl", chained_single_run_callback
|
||||
)
|
||||
)
|
||||
|
||||
tracker_unsub.append(
|
||||
async_track_state_change_event(hass, "light.bowl", single_run_callback)
|
||||
)
|
||||
|
||||
hass.states.async_set("light.bowl", "on")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(tracker_called) == 1
|
||||
assert len(chained_tracker_called) == 0
|
||||
assert len(tracker_unsub) == 1
|
||||
assert len(chained_tracker_unsub) == 1
|
||||
|
||||
hass.states.async_set("light.bowl", "off")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(tracker_called) == 2
|
||||
assert len(chained_tracker_called) == 1
|
||||
assert len(tracker_unsub) == 1
|
||||
assert len(chained_tracker_unsub) == 2
|
||||
|
||||
Reference in New Issue
Block a user