diff --git a/homeassistant/components/flux_led/manifest.json b/homeassistant/components/flux_led/manifest.json index d0134d07f79369..429465a0f3cc26 100644 --- a/homeassistant/components/flux_led/manifest.json +++ b/homeassistant/components/flux_led/manifest.json @@ -3,7 +3,7 @@ "name": "Flux LED/MagicHome", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/flux_led", - "requirements": ["flux_led==0.24.14"], + "requirements": ["flux_led==0.24.17"], "quality_scale": "platinum", "codeowners": ["@icemanch"], "iot_class": "local_push", diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index 78b3f2073a7208..d6df32fa9317e2 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -370,7 +370,7 @@ def _async_remove_empty_devices( device_reg = async_get(self.hass) device_list = async_entries_for_config_entry(device_reg, config_entry.entry_id) for device_entry in device_list: - if async_entries_for_device( + if not async_entries_for_device( entity_reg, device_entry.id, include_disabled_entities=True, diff --git a/homeassistant/components/frontend/manifest.json b/homeassistant/components/frontend/manifest.json index c913de3367fb64..43e0e7e86bcb22 100644 --- a/homeassistant/components/frontend/manifest.json +++ b/homeassistant/components/frontend/manifest.json @@ -3,7 +3,7 @@ "name": "Home Assistant Frontend", "documentation": "https://www.home-assistant.io/integrations/frontend", "requirements": [ - "home-assistant-frontend==20211103.0" + "home-assistant-frontend==20211108.0" ], "dependencies": [ "api", diff --git a/homeassistant/components/guardian/manifest.json b/homeassistant/components/guardian/manifest.json index baa7eb50e7ab13..44da7d01cc992d 100644 --- a/homeassistant/components/guardian/manifest.json +++ b/homeassistant/components/guardian/manifest.json @@ -3,7 +3,7 @@ "name": "Elexa Guardian", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/guardian", - "requirements": ["aioguardian==1.0.8"], + "requirements": ["aioguardian==2021.11.0"], "zeroconf": ["_api._udp.local."], "codeowners": ["@bachya"], "iot_class": "local_polling", diff --git a/homeassistant/components/mqtt/manifest.json b/homeassistant/components/mqtt/manifest.json index c5d9ad21ed614b..6fb81deeb4d9f4 100644 --- a/homeassistant/components/mqtt/manifest.json +++ b/homeassistant/components/mqtt/manifest.json @@ -3,7 +3,7 @@ "name": "MQTT", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/mqtt", - "requirements": ["paho-mqtt==1.5.1"], + "requirements": ["paho-mqtt==1.6.1"], "dependencies": ["http"], "codeowners": ["@emontnemery"], "iot_class": "local_push" diff --git a/homeassistant/components/recollect_waste/sensor.py b/homeassistant/components/recollect_waste/sensor.py index 06a96a3bb74f79..619a12a42f74a6 100644 --- a/homeassistant/components/recollect_waste/sensor.py +++ b/homeassistant/components/recollect_waste/sensor.py @@ -1,17 +1,11 @@ """Support for ReCollect Waste sensors.""" from __future__ import annotations -from datetime import date, datetime, time - from aiorecollect.client import PickupType from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_ATTRIBUTION, - CONF_FRIENDLY_NAME, - DEVICE_CLASS_TIMESTAMP, -) +from homeassistant.const import ATTR_ATTRIBUTION, CONF_FRIENDLY_NAME, DEVICE_CLASS_DATE from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -19,7 +13,6 @@ CoordinatorEntity, DataUpdateCoordinator, ) -from homeassistant.util.dt import as_utc from .const import CONF_PLACE_ID, CONF_SERVICE_ID, DATA_COORDINATOR, DOMAIN @@ -47,12 +40,6 @@ def async_get_pickup_type_names( ] -@callback -def async_get_utc_midnight(target_date: date) -> datetime: - """Get UTC midnight for a given date.""" - return as_utc(datetime.combine(target_date, time(0))) - - async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: @@ -64,7 +51,7 @@ async def async_setup_entry( class ReCollectWasteSensor(CoordinatorEntity, SensorEntity): """ReCollect Waste Sensor.""" - _attr_device_class = DEVICE_CLASS_TIMESTAMP + _attr_device_class = DEVICE_CLASS_DATE def __init__(self, coordinator: DataUpdateCoordinator, entry: ConfigEntry) -> None: """Initialize the sensor.""" @@ -91,8 +78,13 @@ async def async_added_to_hass(self) -> None: @callback def update_from_latest_data(self) -> None: """Update the state.""" - pickup_event = self.coordinator.data[0] - next_pickup_event = self.coordinator.data[1] + try: + pickup_event = self.coordinator.data[0] + next_pickup_event = self.coordinator.data[1] + except IndexError: + self._attr_native_value = None + self._attr_extra_state_attributes = {} + return self._attr_extra_state_attributes.update( { @@ -103,9 +95,7 @@ def update_from_latest_data(self) -> None: ATTR_NEXT_PICKUP_TYPES: async_get_pickup_type_names( self._entry, next_pickup_event.pickup_types ), - ATTR_NEXT_PICKUP_DATE: async_get_utc_midnight( - next_pickup_event.date - ).isoformat(), + ATTR_NEXT_PICKUP_DATE: next_pickup_event.date.isoformat(), } ) - self._attr_native_value = async_get_utc_midnight(pickup_event.date).isoformat() + self._attr_native_value = pickup_event.date.isoformat() diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index e33a2d87317443..0a610545180f36 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -282,9 +282,6 @@ def __init__(self, wrapper: BlockDeviceWrapper, block: Block) -> None: self.wrapper = wrapper self.block = block self._name = get_block_entity_name(wrapper.device, block) - self._attr_device_info = DeviceInfo( - connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} - ) @property def name(self) -> str: @@ -296,6 +293,13 @@ def should_poll(self) -> bool: """If device should be polled.""" return False + @property + def device_info(self) -> DeviceInfo: + """Device info.""" + return { + "connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)} + } + @property def available(self) -> bool: """Available.""" @@ -344,9 +348,9 @@ def __init__(self, wrapper: RpcDeviceWrapper, key: str) -> None: self.wrapper = wrapper self.key = key self._attr_should_poll = False - self._attr_device_info = DeviceInfo( - connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} - ) + self._attr_device_info = { + "connections": {(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} + } self._attr_unique_id = f"{wrapper.mac}-{key}" self._attr_name = get_rpc_entity_name(wrapper.device, key) @@ -490,15 +494,19 @@ def __init__( self.description = description self._name = get_block_entity_name(wrapper.device, None, self.description.name) self._last_value = None - self._attr_device_info = DeviceInfo( - connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} - ) @property def name(self) -> str: """Name of sensor.""" return self._name + @property + def device_info(self) -> DeviceInfo: + """Device info.""" + return { + "connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)} + } + @property def entity_registry_enabled_default(self) -> bool: """Return if it should be enabled by default.""" diff --git a/homeassistant/components/shelly/manifest.json b/homeassistant/components/shelly/manifest.json index 09a046ee78d393..389d31ac195be7 100644 --- a/homeassistant/components/shelly/manifest.json +++ b/homeassistant/components/shelly/manifest.json @@ -3,7 +3,7 @@ "name": "Shelly", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/shelly", - "requirements": ["aioshelly==1.0.2"], + "requirements": ["aioshelly==1.0.4"], "zeroconf": [ { "type": "_http._tcp.local.", diff --git a/homeassistant/components/shiftr/manifest.json b/homeassistant/components/shiftr/manifest.json index f7f04eb5a86632..fc475c2f48efaf 100644 --- a/homeassistant/components/shiftr/manifest.json +++ b/homeassistant/components/shiftr/manifest.json @@ -2,7 +2,7 @@ "domain": "shiftr", "name": "shiftr.io", "documentation": "https://www.home-assistant.io/integrations/shiftr", - "requirements": ["paho-mqtt==1.5.1"], + "requirements": ["paho-mqtt==1.6.1"], "codeowners": ["@fabaff"], "iot_class": "cloud_push" } diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index b3bb850244eec2..7db9225278004e 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -103,9 +103,11 @@ DEFAULT_ENTITY_MODEL = "alarm_control_panel" DEFAULT_ENTITY_NAME = "Alarm Control Panel" +DEFAULT_REST_API_ERROR_COUNT = 2 DEFAULT_SCAN_INTERVAL = timedelta(seconds=30) DEFAULT_SOCKET_MIN_RETRY = 15 + DISPATCHER_TOPIC_WEBSOCKET_EVENT = "simplisafe_websocket_event_{0}" EVENT_SIMPLISAFE_EVENT = "SIMPLISAFE_EVENT" @@ -556,6 +558,8 @@ def __init__( assert simplisafe.coordinator super().__init__(simplisafe.coordinator) + self._rest_api_errors = 0 + if device: model = device.type.name device_name = device.name @@ -618,11 +622,24 @@ def available(self) -> bool: else: system_offline = False - return super().available and self._online and not system_offline + return ( + self._rest_api_errors < DEFAULT_REST_API_ERROR_COUNT + and self._online + and not system_offline + ) @callback def _handle_coordinator_update(self) -> None: """Update the entity with new REST API data.""" + # SimpliSafe can incorrectly return an error state when there isn't any + # error. This can lead to the system having an unknown state frequently. + # To protect against that, we measure how many "error states" we receive + # and only alter the state if we detect a few in a row: + if self.coordinator.last_update_success: + self._rest_api_errors = 0 + else: + self._rest_api_errors += 1 + self.async_update_from_rest_api() self.async_write_ha_state() diff --git a/homeassistant/components/simplisafe/alarm_control_panel.py b/homeassistant/components/simplisafe/alarm_control_panel.py index bc2e2a8ac74ce1..5d2ffdcbd9879d 100644 --- a/homeassistant/components/simplisafe/alarm_control_panel.py +++ b/homeassistant/components/simplisafe/alarm_control_panel.py @@ -72,8 +72,6 @@ ATTR_WALL_POWER_LEVEL = "wall_power_level" ATTR_WIFI_STRENGTH = "wifi_strength" -DEFAULT_ERRORS_TO_ACCOMMODATE = 2 - VOLUME_STRING_MAP = { VOLUME_HIGH: "high", VOLUME_LOW: "low", @@ -141,8 +139,6 @@ def __init__(self, simplisafe: SimpliSafe, system: SystemV2 | SystemV3) -> None: additional_websocket_events=WEBSOCKET_EVENTS_TO_LISTEN_FOR, ) - self._errors = 0 - if code := self._simplisafe.entry.options.get(CONF_CODE): if code.isdigit(): self._attr_code_format = FORMAT_NUMBER @@ -249,19 +245,6 @@ def async_update_from_rest_api(self) -> None: } ) - # SimpliSafe can incorrectly return an error state when there isn't any - # error. This can lead to the system having an unknown state frequently. - # To protect against that, we measure how many "error states" we receive - # and only alter the state if we detect a few in a row: - if self._system.state == SystemStates.error: - if self._errors > DEFAULT_ERRORS_TO_ACCOMMODATE: - self._attr_state = None - else: - self._errors += 1 - return - - self._errors = 0 - self._set_state_from_system_data() @callback diff --git a/homeassistant/components/stream/worker.py b/homeassistant/components/stream/worker.py index 881614b04a36a0..e4be31683938fd 100644 --- a/homeassistant/components/stream/worker.py +++ b/homeassistant/components/stream/worker.py @@ -102,18 +102,18 @@ def make_new_av( # The LL-HLS spec allows for a fragment's duration to be within the range [0.85x,1.0x] # of the part target duration. We use the frag_duration option to tell ffmpeg to try to # cut the fragments when they reach frag_duration. However, the resulting fragments can - # have variability in their durations and can end up being too short or too long. If - # there are two tracks, as in the case of a video feed with audio, the fragment cut seems - # to be done on the first track that crosses the desired threshold, and cutting on the - # audio track may result in a shorter video fragment than desired. Conversely, with a + # have variability in their durations and can end up being too short or too long. With a # video track with no audio, the discrete nature of frames means that the frame at the # end of a fragment will sometimes extend slightly beyond the desired frag_duration. - # Given this, our approach is to use a frag_duration near the upper end of the range for - # outputs with audio using a frag_duration at the lower end of the range for outputs with - # only video. + # If there are two tracks, as in the case of a video feed with audio, there is an added + # wrinkle as the fragment cut seems to be done on the first track that crosses the desired + # threshold, and cutting on the audio track may also result in a shorter video fragment + # than desired. + # Given this, our approach is to give ffmpeg a frag_duration somewhere in the middle + # of the range, hoping that the parts stay pretty well bounded, and we adjust the part + # durations a bit in the hls metadata so that everything "looks" ok. "frag_duration": str( - self._stream_settings.part_target_duration - * (98e4 if add_audio else 9e5) + self._stream_settings.part_target_duration * 9e5 ), } if self._stream_settings.ll_hls diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index a8e35178be4d79..1801e96d2bd130 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -233,7 +233,7 @@ async def async_coordinator_update_data_cameras() -> dict[ surveillance_station = api.surveillance_station try: - async with async_timeout.timeout(10): + async with async_timeout.timeout(30): await hass.async_add_executor_job(surveillance_station.update) except SynologyDSMAPIErrorException as err: raise UpdateFailed(f"Error communicating with API: {err}") from err diff --git a/homeassistant/components/totalconnect/__init__.py b/homeassistant/components/totalconnect/__init__.py index bd1f693fd0778c..8acc7801de8c3c 100644 --- a/homeassistant/components/totalconnect/__init__.py +++ b/homeassistant/components/totalconnect/__init__.py @@ -38,7 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: TotalConnectClient, username, password, usercodes ) - if not client.is_valid_credentials(): + if not client.is_logged_in(): raise ConfigEntryAuthFailed("TotalConnect authentication failed") coordinator = TotalConnectDataUpdateCoordinator(hass, client) @@ -88,5 +88,3 @@ def sync_update_data(self): raise UpdateFailed(exception) from exception except ValueError as exception: raise UpdateFailed("Unknown state from TotalConnect") from exception - - return True diff --git a/homeassistant/components/totalconnect/config_flow.py b/homeassistant/components/totalconnect/config_flow.py index 7ba96f11a1e87e..f3550722de5a6f 100644 --- a/homeassistant/components/totalconnect/config_flow.py +++ b/homeassistant/components/totalconnect/config_flow.py @@ -40,7 +40,7 @@ async def async_step_user(self, user_input=None): TotalConnectClient, username, password, None ) - if client.is_valid_credentials(): + if client.is_logged_in(): # username/password valid so show user locations self.username = username self.password = password @@ -136,7 +136,7 @@ async def async_step_reauth_confirm(self, user_input=None): self.usercodes, ) - if not client.is_valid_credentials(): + if not client.is_logged_in(): errors["base"] = "invalid_auth" return self.async_show_form( step_id="reauth_confirm", diff --git a/homeassistant/components/totalconnect/manifest.json b/homeassistant/components/totalconnect/manifest.json index 25fb2fd2c75303..c70eafd9c31b82 100644 --- a/homeassistant/components/totalconnect/manifest.json +++ b/homeassistant/components/totalconnect/manifest.json @@ -2,7 +2,7 @@ "domain": "totalconnect", "name": "Total Connect", "documentation": "https://www.home-assistant.io/integrations/totalconnect", - "requirements": ["total_connect_client==2021.8.3"], + "requirements": ["total_connect_client==2021.11.2"], "dependencies": [], "codeowners": ["@austinmroczek"], "config_flow": true, diff --git a/homeassistant/components/tradfri/base_class.py b/homeassistant/components/tradfri/base_class.py index a54c9f7d500887..8a7cc6a2f4af5d 100644 --- a/homeassistant/components/tradfri/base_class.py +++ b/homeassistant/components/tradfri/base_class.py @@ -60,7 +60,6 @@ def __init__( """Initialize a device.""" self._api = handle_error(api) self._attr_name = device.name - self._attr_available = device.reachable self._device: Device = device self._device_control: BlindControl | LightControl | SocketControl | SignalRepeaterControl | AirPurifierControl | None = ( None @@ -105,7 +104,6 @@ def _refresh(self, device: Device, write_ha: bool = True) -> None: """Refresh the device data.""" self._device = device self._attr_name = device.name - self._attr_available = device.reachable if write_ha: self.async_write_ha_state() @@ -116,6 +114,16 @@ class TradfriBaseDevice(TradfriBaseClass): All devices should inherit from this class. """ + def __init__( + self, + device: Device, + api: Callable[[Command | list[Command]], Any], + gateway_id: str, + ) -> None: + """Initialize a device.""" + self._attr_available = device.reachable + super().__init__(device, api, gateway_id) + @property def device_info(self) -> DeviceInfo: """Return the device info.""" @@ -128,3 +136,11 @@ def device_info(self) -> DeviceInfo: sw_version=info.firmware_version, via_device=(DOMAIN, self._gateway_id), ) + + def _refresh(self, device: Device, write_ha: bool = True) -> None: + """Refresh the device data.""" + # The base class _refresh cannot be used, because + # there are devices (group) that do not have .reachable + # so set _attr_available here and let the base class do the rest. + self._attr_available = device.reachable + super()._refresh(device, write_ha) diff --git a/homeassistant/components/velbus/manifest.json b/homeassistant/components/velbus/manifest.json index 454b9d24d0777e..5fb3c58c3c7cda 100644 --- a/homeassistant/components/velbus/manifest.json +++ b/homeassistant/components/velbus/manifest.json @@ -2,7 +2,7 @@ "domain": "velbus", "name": "Velbus", "documentation": "https://www.home-assistant.io/integrations/velbus", - "requirements": ["velbus-aio==2021.11.0"], + "requirements": ["velbus-aio==2021.11.6"], "config_flow": true, "codeowners": ["@Cereal2nd", "@brefra"], "iot_class": "local_push" diff --git a/homeassistant/components/xiaomi_miio/__init__.py b/homeassistant/components/xiaomi_miio/__init__.py index de5baf69683ab5..0f36d884207cb5 100644 --- a/homeassistant/components/xiaomi_miio/__init__.py +++ b/homeassistant/components/xiaomi_miio/__init__.py @@ -66,6 +66,8 @@ MODELS_PURIFIER_MIOT, MODELS_SWITCH, MODELS_VACUUM, + ROBOROCK_GENERIC, + ROCKROBO_GENERIC, AuthException, SetupException, ) @@ -267,7 +269,7 @@ async def async_create_miio_device_and_coordinator( hass: core.HomeAssistant, entry: config_entries.ConfigEntry ): """Set up a data coordinator and one miio device to service multiple entities.""" - model = entry.data[CONF_MODEL] + model: str = entry.data[CONF_MODEL] host = entry.data[CONF_HOST] token = entry.data[CONF_TOKEN] name = entry.title @@ -280,6 +282,8 @@ async def async_create_miio_device_and_coordinator( model not in MODELS_HUMIDIFIER and model not in MODELS_FAN and model not in MODELS_VACUUM + and not model.startswith(ROBOROCK_GENERIC) + and not model.startswith(ROCKROBO_GENERIC) ): return @@ -304,7 +308,11 @@ async def async_create_miio_device_and_coordinator( device = AirPurifier(host, token) elif model.startswith("zhimi.airfresh."): device = AirFresh(host, token) - elif model in MODELS_VACUUM: + elif ( + model in MODELS_VACUUM + or model.startswith(ROBOROCK_GENERIC) + or model.startswith(ROCKROBO_GENERIC) + ): device = Vacuum(host, token) update_method = _async_update_data_vacuum coordinator_class = DataUpdateCoordinator[VacuumCoordinatorData] diff --git a/homeassistant/components/xiaomi_miio/const.py b/homeassistant/components/xiaomi_miio/const.py index 60c16a0717a2e9..8c83c8015b2015 100644 --- a/homeassistant/components/xiaomi_miio/const.py +++ b/homeassistant/components/xiaomi_miio/const.py @@ -202,7 +202,8 @@ class SetupException(Exception): ROCKROBO_S5_MAX = "roborock.vacuum.s5e" ROCKROBO_S6_PURE = "roborock.vacuum.a08" ROCKROBO_E2 = "roborock.vacuum.e2" -ROCKROBO_GENERIC = "roborock.vacuum" +ROBOROCK_GENERIC = "roborock.vacuum" +ROCKROBO_GENERIC = "rockrobo.vacuum" MODELS_VACUUM = [ ROCKROBO_V1, ROCKROBO_E2, @@ -214,6 +215,7 @@ class SetupException(Exception): ROCKROBO_S6_MAXV, ROCKROBO_S6_PURE, ROCKROBO_S7, + ROBOROCK_GENERIC, ROCKROBO_GENERIC, ] MODELS_VACUUM_WITH_MOP = [ diff --git a/homeassistant/components/xiaomi_miio/sensor.py b/homeassistant/components/xiaomi_miio/sensor.py index aefeea7c20a012..0d67014ced93b6 100644 --- a/homeassistant/components/xiaomi_miio/sensor.py +++ b/homeassistant/components/xiaomi_miio/sensor.py @@ -81,6 +81,8 @@ MODELS_PURIFIER_MIIO, MODELS_PURIFIER_MIOT, MODELS_VACUUM, + ROBOROCK_GENERIC, + ROCKROBO_GENERIC, ) from .device import XiaomiCoordinatedMiioEntity, XiaomiMiioEntity from .gateway import XiaomiGatewayDevice @@ -374,7 +376,6 @@ class XiaomiMiioSensorDescription(SensorEntityDescription): ATTR_FILTER_LIFE_REMAINING, ATTR_FILTER_USE, ATTR_HUMIDITY, - ATTR_ILLUMINANCE_LUX, ATTR_PM25, ATTR_TEMPERATURE, ATTR_USE_TIME, @@ -593,7 +594,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): elif config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE: host = config_entry.data[CONF_HOST] token = config_entry.data[CONF_TOKEN] - model = config_entry.data[CONF_MODEL] + model: str = config_entry.data[CONF_MODEL] if model in (MODEL_FAN_ZA1, MODEL_FAN_ZA3, MODEL_FAN_ZA4, MODEL_FAN_P5): return @@ -625,7 +626,11 @@ async def async_setup_entry(hass, config_entry, async_add_entities): sensors = PURIFIER_MIIO_SENSORS elif model in MODELS_PURIFIER_MIOT: sensors = PURIFIER_MIOT_SENSORS - elif model in MODELS_VACUUM: + elif ( + model in MODELS_VACUUM + or model.startswith(ROBOROCK_GENERIC) + or model.startswith(ROCKROBO_GENERIC) + ): return _setup_vacuum_sensors(hass, config_entry, async_add_entities) for sensor, description in SENSOR_TYPES.items(): diff --git a/homeassistant/components/zha/sensor.py b/homeassistant/components/zha/sensor.py index d7c3e0797b8ce0..2281d5295bca07 100644 --- a/homeassistant/components/zha/sensor.py +++ b/homeassistant/components/zha/sensor.py @@ -226,6 +226,22 @@ class Battery(Sensor): _unit = PERCENTAGE _attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC + @classmethod + def create_entity( + cls, + unique_id: str, + zha_device: ZhaDeviceType, + channels: list[ChannelType], + **kwargs, + ) -> ZhaEntity | None: + """Entity Factory. + + Unlike any other entity, PowerConfiguration cluster may not support + battery_percent_remaining attribute, but zha-device-handlers takes care of it + so create the entity regardless + """ + return cls(unique_id, zha_device, channels, **kwargs) + @staticmethod def formatter(value: int) -> int: """Return the state of the entity.""" diff --git a/homeassistant/const.py b/homeassistant/const.py index 36b43ee25f17ef..dcd68543068ed3 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -5,7 +5,7 @@ MAJOR_VERSION: Final = 2021 MINOR_VERSION: Final = 11 -PATCH_VERSION: Final = "1" +PATCH_VERSION: Final = "2" __short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__: Final = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 8, 0) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 2dd084fc5fc246..a290aaadd39479 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -15,11 +15,11 @@ ciso8601==2.2.0 cryptography==3.4.8 emoji==1.5.0 hass-nabucasa==0.50.0 -home-assistant-frontend==20211103.0 +home-assistant-frontend==20211108.0 httpx==0.19.0 ifaddr==0.1.7 jinja2==3.0.2 -paho-mqtt==1.5.1 +paho-mqtt==1.6.1 pillow==8.2.0 pip>=8.0.3,<20.3 pyserial==3.5 diff --git a/requirements_all.txt b/requirements_all.txt index c5f93ad7251c95..3cb1b05e7e26e1 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -173,7 +173,7 @@ aioftp==0.12.0 aiogithubapi==21.8.0 # homeassistant.components.guardian -aioguardian==1.0.8 +aioguardian==2021.11.0 # homeassistant.components.harmony aioharmony==0.2.8 @@ -243,7 +243,7 @@ aiopylgtv==0.4.0 aiorecollect==1.0.8 # homeassistant.components.shelly -aioshelly==1.0.2 +aioshelly==1.0.4 # homeassistant.components.switcher_kis aioswitcher==2.0.6 @@ -652,7 +652,7 @@ fjaraskupan==1.0.2 flipr-api==1.4.1 # homeassistant.components.flux_led -flux_led==0.24.14 +flux_led==0.24.17 # homeassistant.components.homekit fnvhash==0.1.0 @@ -813,7 +813,7 @@ hole==0.5.1 holidays==0.11.3.1 # homeassistant.components.frontend -home-assistant-frontend==20211103.0 +home-assistant-frontend==20211108.0 # homeassistant.components.zwave homeassistant-pyozw==0.1.10 @@ -1163,7 +1163,7 @@ p1monitor==1.0.0 # homeassistant.components.mqtt # homeassistant.components.shiftr -paho-mqtt==1.5.1 +paho-mqtt==1.6.1 # homeassistant.components.panasonic_bluray panacotta==0.1 @@ -2314,7 +2314,7 @@ todoist-python==8.0.0 toonapi==0.2.1 # homeassistant.components.totalconnect -total_connect_client==2021.8.3 +total_connect_client==2021.11.2 # homeassistant.components.tplink_lte tp-connected==0.0.4 @@ -2360,7 +2360,7 @@ uvcclient==0.11.0 vallox-websocket-api==2.8.1 # homeassistant.components.velbus -velbus-aio==2021.11.0 +velbus-aio==2021.11.6 # homeassistant.components.venstar venstarcolortouch==0.14 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index fdacbc25dd28dc..401e872c6d356c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -115,7 +115,7 @@ aioesphomeapi==10.2.0 aioflo==0.4.1 # homeassistant.components.guardian -aioguardian==1.0.8 +aioguardian==2021.11.0 # homeassistant.components.harmony aioharmony==0.2.8 @@ -170,7 +170,7 @@ aiopylgtv==0.4.0 aiorecollect==1.0.8 # homeassistant.components.shelly -aioshelly==1.0.2 +aioshelly==1.0.4 # homeassistant.components.switcher_kis aioswitcher==2.0.6 @@ -387,7 +387,7 @@ fjaraskupan==1.0.2 flipr-api==1.4.1 # homeassistant.components.flux_led -flux_led==0.24.14 +flux_led==0.24.17 # homeassistant.components.homekit fnvhash==0.1.0 @@ -500,7 +500,7 @@ hole==0.5.1 holidays==0.11.3.1 # homeassistant.components.frontend -home-assistant-frontend==20211103.0 +home-assistant-frontend==20211108.0 # homeassistant.components.zwave homeassistant-pyozw==0.1.10 @@ -689,7 +689,7 @@ p1monitor==1.0.0 # homeassistant.components.mqtt # homeassistant.components.shiftr -paho-mqtt==1.5.1 +paho-mqtt==1.6.1 # homeassistant.components.panasonic_viera panasonic_viera==0.3.6 @@ -1330,7 +1330,7 @@ tesla-powerwall==0.3.12 toonapi==0.2.1 # homeassistant.components.totalconnect -total_connect_client==2021.8.3 +total_connect_client==2021.11.2 # homeassistant.components.transmission transmissionrpc==0.11 @@ -1364,7 +1364,7 @@ url-normalize==1.4.1 uvcclient==0.11.0 # homeassistant.components.velbus -velbus-aio==2021.11.0 +velbus-aio==2021.11.6 # homeassistant.components.venstar venstarcolortouch==0.14 diff --git a/tests/components/totalconnect/common.py b/tests/components/totalconnect/common.py index 29278d33273df4..ec0c182895f4e2 100644 --- a/tests/components/totalconnect/common.py +++ b/tests/components/totalconnect/common.py @@ -1,9 +1,7 @@ """Common methods used across tests for TotalConnect.""" from unittest.mock import patch -from total_connect_client.client import TotalConnectClient -from total_connect_client.const import ArmingState -from total_connect_client.zone import ZoneStatus, ZoneType +from total_connect_client import ArmingState, ResultCode, ZoneStatus, ZoneType from homeassistant.components.totalconnect.const import CONF_USERCODES, DOMAIN from homeassistant.const import CONF_PASSWORD, CONF_USERNAME @@ -44,7 +42,7 @@ } RESPONSE_AUTHENTICATE = { - "ResultCode": TotalConnectClient.SUCCESS, + "ResultCode": ResultCode.SUCCESS.value, "SessionID": 1, "Locations": LOCATIONS, "ModuleFlags": MODULE_FLAGS, @@ -52,7 +50,7 @@ } RESPONSE_AUTHENTICATE_FAILED = { - "ResultCode": TotalConnectClient.BAD_USER_OR_PASSWORD, + "ResultCode": ResultCode.BAD_USER_OR_PASSWORD.value, "ResultData": "test bad authentication", } @@ -255,18 +253,18 @@ "ArmingState": ArmingState.DISARMED, } -RESPONSE_ARM_SUCCESS = {"ResultCode": TotalConnectClient.ARM_SUCCESS} -RESPONSE_ARM_FAILURE = {"ResultCode": TotalConnectClient.COMMAND_FAILED} -RESPONSE_DISARM_SUCCESS = {"ResultCode": TotalConnectClient.DISARM_SUCCESS} +RESPONSE_ARM_SUCCESS = {"ResultCode": ResultCode.ARM_SUCCESS.value} +RESPONSE_ARM_FAILURE = {"ResultCode": ResultCode.COMMAND_FAILED.value} +RESPONSE_DISARM_SUCCESS = {"ResultCode": ResultCode.DISARM_SUCCESS.value} RESPONSE_DISARM_FAILURE = { - "ResultCode": TotalConnectClient.COMMAND_FAILED, + "ResultCode": ResultCode.COMMAND_FAILED.value, "ResultData": "Command Failed", } RESPONSE_USER_CODE_INVALID = { - "ResultCode": TotalConnectClient.USER_CODE_INVALID, + "ResultCode": ResultCode.USER_CODE_INVALID.value, "ResultData": "testing user code invalid", } -RESPONSE_SUCCESS = {"ResultCode": TotalConnectClient.SUCCESS} +RESPONSE_SUCCESS = {"ResultCode": ResultCode.SUCCESS.value} USERNAME = "username@me.com" PASSWORD = "password" @@ -292,7 +290,7 @@ PARTITION_DETAILS = {"PartitionDetails": [PARTITION_DETAILS_1, PARTITION_DETAILS_2]} RESPONSE_PARTITION_DETAILS = { - "ResultCode": TotalConnectClient.SUCCESS, + "ResultCode": ResultCode.SUCCESS.value, "ResultData": "testing partition details", "PartitionsInfoList": PARTITION_DETAILS, } diff --git a/tests/components/totalconnect/test_config_flow.py b/tests/components/totalconnect/test_config_flow.py index 20497102c6d72e..a9debb26dd415d 100644 --- a/tests/components/totalconnect/test_config_flow.py +++ b/tests/components/totalconnect/test_config_flow.py @@ -95,7 +95,7 @@ async def test_abort_if_already_setup(hass): with patch( "homeassistant.components.totalconnect.config_flow.TotalConnectClient" ) as client_mock: - client_mock.return_value.is_valid_credentials.return_value = True + client_mock.return_value.is_logged_in.return_value = True result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -111,7 +111,7 @@ async def test_login_failed(hass): with patch( "homeassistant.components.totalconnect.config_flow.TotalConnectClient" ) as client_mock: - client_mock.return_value.is_valid_credentials.return_value = False + client_mock.return_value.is_logged_in.return_value = False result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -143,7 +143,7 @@ async def test_reauth(hass): "homeassistant.components.totalconnect.async_setup_entry", return_value=True ): # first test with an invalid password - client_mock.return_value.is_valid_credentials.return_value = False + client_mock.return_value.is_logged_in.return_value = False result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_PASSWORD: "password"} @@ -153,7 +153,7 @@ async def test_reauth(hass): assert result["errors"] == {"base": "invalid_auth"} # now test with the password valid - client_mock.return_value.is_valid_credentials.return_value = True + client_mock.return_value.is_logged_in.return_value = True result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_PASSWORD: "password"} diff --git a/tests/components/totalconnect/test_init.py b/tests/components/totalconnect/test_init.py index 41cd8bbae90afc..f1797f840abbc5 100644 --- a/tests/components/totalconnect/test_init.py +++ b/tests/components/totalconnect/test_init.py @@ -22,7 +22,7 @@ async def test_reauth_started(hass): "homeassistant.components.totalconnect.TotalConnectClient", autospec=True, ) as mock_client: - mock_client.return_value.is_valid_credentials.return_value = False + mock_client.return_value.is_logged_in.return_value = False assert await async_setup_component(hass, DOMAIN, {}) await hass.async_block_till_done()