From 9cae786f40c9deec0058abf6a3574cb01e7d778b Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 27 Aug 2024 14:20:57 +0200 Subject: [PATCH 01/67] Add ConfigEntries.async_get_loaded (#124705) --- homeassistant/config_entries.py | 10 ++++++++ tests/test_config_entries.py | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index e48313cab334fb..f3b0aa0338368e 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -1742,6 +1742,16 @@ def async_entries( and (include_disabled or not entry.disabled_by) ] + @callback + def async_loaded_entries(self, domain: str) -> list[ConfigEntry]: + """Return loaded entries for a specific domain. + + This will exclude ignored or disabled config entruis. + """ + entries = self._entries.get_entries_for_domain(domain) + + return [entry for entry in entries if entry.state == ConfigEntryState.LOADED] + @callback def async_entry_for_domain_unique_id( self, domain: str, unique_id: str diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index dccebff13e5eaf..3042ccb28d95f9 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -6001,3 +6001,44 @@ async def test_migration_from_1_2( ] }, } + + +async def test_async_loaded_entries( + hass: HomeAssistant, manager: config_entries.ConfigEntries +) -> None: + """Test that we can get loaded config entries.""" + entry1 = MockConfigEntry(domain="comp") + entry1.add_to_hass(hass) + entry2 = MockConfigEntry(domain="comp", source=config_entries.SOURCE_IGNORE) + entry2.add_to_hass(hass) + entry3 = MockConfigEntry( + domain="comp", disabled_by=config_entries.ConfigEntryDisabler.USER + ) + entry3.add_to_hass(hass) + + mock_setup = AsyncMock(return_value=True) + mock_setup_entry = AsyncMock(return_value=True) + mock_unload_entry = AsyncMock(return_value=True) + + mock_integration( + hass, + MockModule( + "comp", + async_setup=mock_setup, + async_setup_entry=mock_setup_entry, + async_unload_entry=mock_unload_entry, + ), + ) + mock_platform(hass, "comp.config_flow", None) + + assert hass.config_entries.async_loaded_entries("comp") == [] + + assert await manager.async_setup(entry1.entry_id) + assert not await manager.async_setup(entry2.entry_id) + assert not await manager.async_setup(entry3.entry_id) + + assert hass.config_entries.async_loaded_entries("comp") == [entry1] + + assert await hass.config_entries.async_unload(entry1.entry_id) + + assert hass.config_entries.async_loaded_entries("comp") == [] From 53479b592454ccf7d8ab5d60ae36e6fe06230d92 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 27 Aug 2024 15:13:58 +0200 Subject: [PATCH 02/67] Adjust name of legacy Home Assistant Cloud TTS provider (#124685) --- homeassistant/components/cloud/tts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/cloud/tts.py b/homeassistant/components/cloud/tts.py index 8cf18c08314def..4dbee10fbaf5a5 100644 --- a/homeassistant/components/cloud/tts.py +++ b/homeassistant/components/cloud/tts.py @@ -221,7 +221,7 @@ class CloudProvider(Provider): def __init__(self, cloud: Cloud[CloudClient]) -> None: """Initialize cloud provider.""" self.cloud = cloud - self.name = "Cloud" + self.name = "Home Assistant Cloud" self._language, self._voice = cloud.client.prefs.tts_default_voice cloud.client.prefs.async_listen_updates(self._sync_prefs) From f802611359ec14dfcdf944bf043f15851f900ea5 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:04:00 +0200 Subject: [PATCH 03/67] Cleanup unused import in somfy_mylink config flow (#124709) --- homeassistant/components/somfy_mylink/config_flow.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/homeassistant/components/somfy_mylink/config_flow.py b/homeassistant/components/somfy_mylink/config_flow.py index 9a8b5d76d3fac2..231f93b0cb78fa 100644 --- a/homeassistant/components/somfy_mylink/config_flow.py +++ b/homeassistant/components/somfy_mylink/config_flow.py @@ -116,11 +116,6 @@ async def async_step_user( errors=errors, ) - async def async_step_import(self, user_input): - """Handle import.""" - self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]}) - return await self.async_step_user(user_input) - @staticmethod @callback def async_get_options_flow( From 318259689ffdaa000ee7ff4bb1f02e135dfe8fa0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:18:11 +0200 Subject: [PATCH 04/67] Standardize import step variable name (part 4) (#124692) * Standardize import step variable name (part 4) * One more * Revert geonetnz_volcano * Revert SMS due to coverage * Revert somfy_mylink due to coverage --- homeassistant/components/broadlink/config_flow.py | 6 +++--- homeassistant/components/ecobee/config_flow.py | 2 +- .../components/emulated_roku/config_flow.py | 4 ++-- .../components/geonetnz_quakes/config_flow.py | 4 ++-- .../components/google_assistant/config_flow.py | 10 ++++++---- homeassistant/components/habitica/config_flow.py | 2 +- homeassistant/components/hlk_sw16/config_flow.py | 4 ++-- homeassistant/components/juicenet/config_flow.py | 4 ++-- homeassistant/components/kodi/config_flow.py | 10 ++++++---- homeassistant/components/konnected/config_flow.py | 14 +++++++------- .../components/lutron_caseta/config_flow.py | 10 +++++----- homeassistant/components/octoprint/config_flow.py | 4 ++-- .../components/opentherm_gw/config_flow.py | 8 ++++---- homeassistant/components/sabnzbd/config_flow.py | 2 +- homeassistant/components/spider/config_flow.py | 2 +- .../components/tellduslive/config_flow.py | 10 +++++----- 16 files changed, 50 insertions(+), 46 deletions(-) diff --git a/homeassistant/components/broadlink/config_flow.py b/homeassistant/components/broadlink/config_flow.py index 2d79ba4bea154c..5d7acfd8b84764 100644 --- a/homeassistant/components/broadlink/config_flow.py +++ b/homeassistant/components/broadlink/config_flow.py @@ -314,10 +314,10 @@ async def async_step_finish(self, user_input=None): step_id="finish", data_schema=vol.Schema(data_schema), errors=errors ) - async def async_step_import(self, import_info): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a device.""" - self._async_abort_entries_match({CONF_HOST: import_info[CONF_HOST]}) - return await self.async_step_user(import_info) + self._async_abort_entries_match({CONF_HOST: import_data[CONF_HOST]}) + return await self.async_step_user(import_data) async def async_step_reauth( self, entry_data: Mapping[str, Any] diff --git a/homeassistant/components/ecobee/config_flow.py b/homeassistant/components/ecobee/config_flow.py index e9a89e0fba5458..c0d4d9b03fce54 100644 --- a/homeassistant/components/ecobee/config_flow.py +++ b/homeassistant/components/ecobee/config_flow.py @@ -80,7 +80,7 @@ async def async_step_authorize(self, user_input=None): description_placeholders={"pin": self._ecobee.pin}, ) - async def async_step_import(self, import_data): + async def async_step_import(self, import_data: None) -> ConfigFlowResult: """Import ecobee config from configuration.yaml. Triggered by async_setup only if a config entry doesn't already exist. diff --git a/homeassistant/components/emulated_roku/config_flow.py b/homeassistant/components/emulated_roku/config_flow.py index 0e5cc1ba55a353..eed0298fc57114 100644 --- a/homeassistant/components/emulated_roku/config_flow.py +++ b/homeassistant/components/emulated_roku/config_flow.py @@ -56,6 +56,6 @@ async def async_step_user( errors=errors, ) - async def async_step_import(self, import_config): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Handle a flow import.""" - return await self.async_step_user(import_config) + return await self.async_step_user(import_data) diff --git a/homeassistant/components/geonetnz_quakes/config_flow.py b/homeassistant/components/geonetnz_quakes/config_flow.py index ac5a2e8c48ecd6..083ac29b362624 100644 --- a/homeassistant/components/geonetnz_quakes/config_flow.py +++ b/homeassistant/components/geonetnz_quakes/config_flow.py @@ -45,9 +45,9 @@ async def _show_form(self, errors=None): step_id="user", data_schema=DATA_SCHEMA, errors=errors or {} ) - async def async_step_import(self, import_config): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a config entry from configuration.yaml.""" - return await self.async_step_user(import_config) + return await self.async_step_user(import_data) async def async_step_user( self, user_input: dict[str, Any] | None = None diff --git a/homeassistant/components/google_assistant/config_flow.py b/homeassistant/components/google_assistant/config_flow.py index 9504c623138da6..5934657f9ae120 100644 --- a/homeassistant/components/google_assistant/config_flow.py +++ b/homeassistant/components/google_assistant/config_flow.py @@ -1,6 +1,8 @@ """Config flow for google assistant component.""" -from homeassistant.config_entries import ConfigFlow +from typing import Any + +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from .const import CONF_PROJECT_ID, DOMAIN @@ -10,10 +12,10 @@ class GoogleAssistantHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 - async def async_step_import(self, user_input): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a config entry.""" - await self.async_set_unique_id(unique_id=user_input[CONF_PROJECT_ID]) + await self.async_set_unique_id(unique_id=import_data[CONF_PROJECT_ID]) self._abort_if_unique_id_configured() return self.async_create_entry( - title=user_input[CONF_PROJECT_ID], data=user_input + title=import_data[CONF_PROJECT_ID], data=import_data ) diff --git a/homeassistant/components/habitica/config_flow.py b/homeassistant/components/habitica/config_flow.py index 742523751a2f4f..a40261c09021f7 100644 --- a/homeassistant/components/habitica/config_flow.py +++ b/homeassistant/components/habitica/config_flow.py @@ -82,7 +82,7 @@ async def async_step_user( description_placeholders={}, ) - async def async_step_import(self, import_data): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import habitica config from configuration.yaml.""" async_create_issue( diff --git a/homeassistant/components/hlk_sw16/config_flow.py b/homeassistant/components/hlk_sw16/config_flow.py index df2f32088cffc9..8dd75561af3e72 100644 --- a/homeassistant/components/hlk_sw16/config_flow.py +++ b/homeassistant/components/hlk_sw16/config_flow.py @@ -70,9 +70,9 @@ class SW16FlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 - async def async_step_import(self, user_input): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Handle import.""" - return await self.async_step_user(user_input) + return await self.async_step_user(import_data) async def async_step_user( self, user_input: dict[str, Any] | None = None diff --git a/homeassistant/components/juicenet/config_flow.py b/homeassistant/components/juicenet/config_flow.py index 393e6842274087..8bcee5677e69b1 100644 --- a/homeassistant/components/juicenet/config_flow.py +++ b/homeassistant/components/juicenet/config_flow.py @@ -69,9 +69,9 @@ async def async_step_user( step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - async def async_step_import(self, user_input): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Handle import.""" - return await self.async_step_user(user_input) + return await self.async_step_user(import_data) class CannotConnect(exceptions.HomeAssistantError): diff --git a/homeassistant/components/kodi/config_flow.py b/homeassistant/components/kodi/config_flow.py index c740aeb605709e..26b5214c733c43 100644 --- a/homeassistant/components/kodi/config_flow.py +++ b/homeassistant/components/kodi/config_flow.py @@ -226,12 +226,12 @@ async def async_step_ws_port(self, user_input=None): return self._show_ws_port_form(errors) - async def async_step_import(self, data): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Handle import from YAML.""" reason = None try: - await validate_http(self.hass, data) - await validate_ws(self.hass, data) + await validate_http(self.hass, import_data) + await validate_ws(self.hass, import_data) except InvalidAuth: _LOGGER.exception("Invalid Kodi credentials") reason = "invalid_auth" @@ -242,7 +242,9 @@ async def async_step_import(self, data): _LOGGER.exception("Unexpected exception") reason = "unknown" else: - return self.async_create_entry(title=data[CONF_NAME], data=data) + return self.async_create_entry( + title=import_data[CONF_NAME], data=import_data + ) return self.async_abort(reason=reason) diff --git a/homeassistant/components/konnected/config_flow.py b/homeassistant/components/konnected/config_flow.py index 6c9a542c53b960..48016cd066a393 100644 --- a/homeassistant/components/konnected/config_flow.py +++ b/homeassistant/components/konnected/config_flow.py @@ -202,24 +202,24 @@ async def async_gen_config(self, host, port): random.choices(f"{string.ascii_uppercase}{string.digits}", k=20) ) - async def async_step_import(self, device_config): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a configuration.yaml config. This flow is triggered by `async_setup` for configured panels. """ - _LOGGER.debug(device_config) + _LOGGER.debug(import_data) # save the data and confirm connection via user step - await self.async_set_unique_id(device_config["id"]) - self.options = device_config[CONF_DEFAULT_OPTIONS] + await self.async_set_unique_id(import_data["id"]) + self.options = import_data[CONF_DEFAULT_OPTIONS] # config schema ensures we have port if we have host - if device_config.get(CONF_HOST): + if import_data.get(CONF_HOST): # automatically connect if we have host info return await self.async_step_user( user_input={ - CONF_HOST: device_config[CONF_HOST], - CONF_PORT: device_config[CONF_PORT], + CONF_HOST: import_data[CONF_HOST], + CONF_PORT: import_data[CONF_PORT], } ) diff --git a/homeassistant/components/lutron_caseta/config_flow.py b/homeassistant/components/lutron_caseta/config_flow.py index 0458b8ee1857a4..703fbb813c61f9 100644 --- a/homeassistant/components/lutron_caseta/config_flow.py +++ b/homeassistant/components/lutron_caseta/config_flow.py @@ -166,21 +166,21 @@ def _configure_tls_assets(self): for asset_key, conf_key in FILE_MAPPING.items(): self.data[conf_key] = TLS_ASSET_TEMPLATE.format(self.bridge_id, asset_key) - async def async_step_import(self, import_info): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a new Caseta bridge as a config entry. This flow is triggered by `async_setup`. """ - host = import_info[CONF_HOST] + host = import_data[CONF_HOST] # Store the imported config for other steps in this flow to access. self.data[CONF_HOST] = host # Abort if existing entry with matching host exists. self._async_abort_entries_match({CONF_HOST: self.data[CONF_HOST]}) - self.data[CONF_KEYFILE] = import_info[CONF_KEYFILE] - self.data[CONF_CERTFILE] = import_info[CONF_CERTFILE] - self.data[CONF_CA_CERTS] = import_info[CONF_CA_CERTS] + self.data[CONF_KEYFILE] = import_data[CONF_KEYFILE] + self.data[CONF_CERTFILE] = import_data[CONF_CERTFILE] + self.data[CONF_CA_CERTS] = import_data[CONF_CA_CERTS] if not (lutron_id := await self.async_get_lutron_id()): # Ultimately we won't have a dedicated step for import failure, but diff --git a/homeassistant/components/octoprint/config_flow.py b/homeassistant/components/octoprint/config_flow.py index 22943b85f4eb55..8e4257ab821784 100644 --- a/homeassistant/components/octoprint/config_flow.py +++ b/homeassistant/components/octoprint/config_flow.py @@ -160,9 +160,9 @@ async def async_step_auth_failed(self, user_input): """Handle api fetch failure.""" return self.async_abort(reason="auth_failed") - async def async_step_import(self, user_input): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Handle import.""" - return await self.async_step_user(user_input) + return await self.async_step_user(import_data) async def async_step_zeroconf( self, discovery_info: zeroconf.ZeroconfServiceInfo diff --git a/homeassistant/components/opentherm_gw/config_flow.py b/homeassistant/components/opentherm_gw/config_flow.py index 1ebf462a5c7ebe..c1d1caa2fb0c82 100644 --- a/homeassistant/components/opentherm_gw/config_flow.py +++ b/homeassistant/components/opentherm_gw/config_flow.py @@ -92,15 +92,15 @@ async def async_step_user( """Handle manual initiation of the config flow.""" return await self.async_step_init(user_input) - async def async_step_import(self, import_config): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import an OpenTherm Gateway device as a config entry. This flow is triggered by `async_setup` for configured devices. """ formatted_config = { - CONF_NAME: import_config.get(CONF_NAME, import_config[CONF_ID]), - CONF_DEVICE: import_config[CONF_DEVICE], - CONF_ID: import_config[CONF_ID], + CONF_NAME: import_data.get(CONF_NAME, import_data[CONF_ID]), + CONF_DEVICE: import_data[CONF_DEVICE], + CONF_ID: import_data[CONF_ID], } return await self.async_step_init(info=formatted_config) diff --git a/homeassistant/components/sabnzbd/config_flow.py b/homeassistant/components/sabnzbd/config_flow.py index 944c3f2936cd88..2637659e91a98a 100644 --- a/homeassistant/components/sabnzbd/config_flow.py +++ b/homeassistant/components/sabnzbd/config_flow.py @@ -65,7 +65,7 @@ async def async_step_user( errors=errors, ) - async def async_step_import(self, import_data): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import sabnzbd config from configuration.yaml.""" protocol = "https://" if import_data[CONF_SSL] else "http://" import_data[CONF_URL] = ( diff --git a/homeassistant/components/spider/config_flow.py b/homeassistant/components/spider/config_flow.py index f3076c0c28d202..0c305adbc394b5 100644 --- a/homeassistant/components/spider/config_flow.py +++ b/homeassistant/components/spider/config_flow.py @@ -82,6 +82,6 @@ async def async_step_user( errors=errors, ) - async def async_step_import(self, import_data): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import spider config from configuration.yaml.""" return await self.async_step_user(import_data) diff --git a/homeassistant/components/tellduslive/config_flow.py b/homeassistant/components/tellduslive/config_flow.py index 6d68c37d82145a..6b5e7150d67fba 100644 --- a/homeassistant/components/tellduslive/config_flow.py +++ b/homeassistant/components/tellduslive/config_flow.py @@ -125,14 +125,14 @@ async def async_step_discovery(self, discovery_info): return await self.async_step_user() - async def async_step_import(self, user_input): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a config entry.""" if self._async_current_entries(): return self.async_abort(reason="already_setup") - self._scan_interval = user_input[KEY_SCAN_INTERVAL] - if user_input[CONF_HOST] != DOMAIN: - self._hosts.append(user_input[CONF_HOST]) + self._scan_interval = import_data[KEY_SCAN_INTERVAL] + if import_data[CONF_HOST] != DOMAIN: + self._hosts.append(import_data[CONF_HOST]) if not await self.hass.async_add_executor_job( os.path.isfile, self.hass.config.path(TELLDUS_CONFIG_FILE) @@ -144,7 +144,7 @@ async def async_step_import(self, user_input): ) host = next(iter(conf)) - if user_input[CONF_HOST] != host: + if import_data[CONF_HOST] != host: return await self.async_step_user() host = CLOUD_NAME if host == "tellduslive" else host From de8bbaadd17a3011fe0b9875b2f66f82ddb6f278 Mon Sep 17 00:00:00 2001 From: Antoine Reversat Date: Tue, 27 Aug 2024 10:26:18 -0400 Subject: [PATCH 05/67] Fix review comments in fglair (#124710) * Replace if len() == 0 with if not * Replace list + filter with list comprehensions * Move consts that are only used in one module to said module --- .../components/fujitsu_fglair/climate.py | 52 +++++++++++++++---- .../components/fujitsu_fglair/config_flow.py | 2 +- .../components/fujitsu_fglair/const.py | 39 -------------- .../components/fujitsu_fglair/coordinator.py | 10 ++-- .../components/fujitsu_fglair/test_climate.py | 2 +- 5 files changed, 49 insertions(+), 56 deletions(-) diff --git a/homeassistant/components/fujitsu_fglair/climate.py b/homeassistant/components/fujitsu_fglair/climate.py index 558f4b73a18998..726096eab1a9e4 100644 --- a/homeassistant/components/fujitsu_fglair/climate.py +++ b/homeassistant/components/fujitsu_fglair/climate.py @@ -2,9 +2,23 @@ from typing import Any -from ayla_iot_unofficial.fujitsu_hvac import Capability, FujitsuHVAC +from ayla_iot_unofficial.fujitsu_hvac import ( + Capability, + FanSpeed, + FujitsuHVAC, + OpMode, + SwingMode, +) from homeassistant.components.climate import ( + FAN_AUTO, + FAN_HIGH, + FAN_LOW, + FAN_MEDIUM, + SWING_BOTH, + SWING_HORIZONTAL, + SWING_OFF, + SWING_VERTICAL, ClimateEntity, ClimateEntityFeature, HVACMode, @@ -16,17 +30,35 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity from . import FGLairConfigEntry -from .const import ( - DOMAIN, - FUJI_TO_HA_FAN, - FUJI_TO_HA_HVAC, - FUJI_TO_HA_SWING, - HA_TO_FUJI_FAN, - HA_TO_FUJI_HVAC, - HA_TO_FUJI_SWING, -) +from .const import DOMAIN from .coordinator import FGLairCoordinator +HA_TO_FUJI_FAN = { + FAN_LOW: FanSpeed.LOW, + FAN_MEDIUM: FanSpeed.MEDIUM, + FAN_HIGH: FanSpeed.HIGH, + FAN_AUTO: FanSpeed.AUTO, +} +FUJI_TO_HA_FAN = {value: key for key, value in HA_TO_FUJI_FAN.items()} + +HA_TO_FUJI_HVAC = { + HVACMode.OFF: OpMode.OFF, + HVACMode.HEAT: OpMode.HEAT, + HVACMode.COOL: OpMode.COOL, + HVACMode.HEAT_COOL: OpMode.AUTO, + HVACMode.DRY: OpMode.DRY, + HVACMode.FAN_ONLY: OpMode.FAN, +} +FUJI_TO_HA_HVAC = {value: key for key, value in HA_TO_FUJI_HVAC.items()} + +HA_TO_FUJI_SWING = { + SWING_OFF: SwingMode.OFF, + SWING_VERTICAL: SwingMode.SWING_VERTICAL, + SWING_HORIZONTAL: SwingMode.SWING_HORIZONTAL, + SWING_BOTH: SwingMode.SWING_BOTH, +} +FUJI_TO_HA_SWING = {value: key for key, value in HA_TO_FUJI_SWING.items()} + async def async_setup_entry( hass: HomeAssistant, diff --git a/homeassistant/components/fujitsu_fglair/config_flow.py b/homeassistant/components/fujitsu_fglair/config_flow.py index db1975298a8273..5021e495656ef1 100644 --- a/homeassistant/components/fujitsu_fglair/config_flow.py +++ b/homeassistant/components/fujitsu_fglair/config_flow.py @@ -70,7 +70,7 @@ async def async_step_user( self._abort_if_unique_id_configured() errors = await self._async_validate_credentials(user_input) - if len(errors) == 0: + if not errors: return self.async_create_entry( title=f"FGLair ({user_input[CONF_USERNAME]})", data=user_input, diff --git a/homeassistant/components/fujitsu_fglair/const.py b/homeassistant/components/fujitsu_fglair/const.py index 0e93361f20b4de..a9d485281a351e 100644 --- a/homeassistant/components/fujitsu_fglair/const.py +++ b/homeassistant/components/fujitsu_fglair/const.py @@ -6,19 +6,6 @@ FGLAIR_APP_ID, FGLAIR_APP_SECRET, ) -from ayla_iot_unofficial.fujitsu_hvac import FanSpeed, OpMode, SwingMode - -from homeassistant.components.climate import ( - FAN_AUTO, - FAN_HIGH, - FAN_LOW, - FAN_MEDIUM, - SWING_BOTH, - SWING_HORIZONTAL, - SWING_OFF, - SWING_VERTICAL, - HVACMode, -) API_TIMEOUT = 10 API_REFRESH = timedelta(minutes=5) @@ -26,29 +13,3 @@ DOMAIN = "fujitsu_fglair" CONF_EUROPE = "is_europe" - -HA_TO_FUJI_FAN = { - FAN_LOW: FanSpeed.LOW, - FAN_MEDIUM: FanSpeed.MEDIUM, - FAN_HIGH: FanSpeed.HIGH, - FAN_AUTO: FanSpeed.AUTO, -} -FUJI_TO_HA_FAN = {value: key for key, value in HA_TO_FUJI_FAN.items()} - -HA_TO_FUJI_HVAC = { - HVACMode.OFF: OpMode.OFF, - HVACMode.HEAT: OpMode.HEAT, - HVACMode.COOL: OpMode.COOL, - HVACMode.HEAT_COOL: OpMode.AUTO, - HVACMode.DRY: OpMode.DRY, - HVACMode.FAN_ONLY: OpMode.FAN, -} -FUJI_TO_HA_HVAC = {value: key for key, value in HA_TO_FUJI_HVAC.items()} - -HA_TO_FUJI_SWING = { - SWING_OFF: SwingMode.OFF, - SWING_VERTICAL: SwingMode.SWING_VERTICAL, - SWING_HORIZONTAL: SwingMode.SWING_HORIZONTAL, - SWING_BOTH: SwingMode.SWING_BOTH, -} -FUJI_TO_HA_SWING = {value: key for key, value in HA_TO_FUJI_SWING.items()} diff --git a/homeassistant/components/fujitsu_fglair/coordinator.py b/homeassistant/components/fujitsu_fglair/coordinator.py index 902464bdd800fa..eac3cfd6ce5908 100644 --- a/homeassistant/components/fujitsu_fglair/coordinator.py +++ b/homeassistant/components/fujitsu_fglair/coordinator.py @@ -47,12 +47,12 @@ async def _async_update_data(self) -> dict[str, FujitsuHVAC]: except AylaAuthError as e: raise ConfigEntryAuthFailed("Credentials expired for Ayla IoT API") from e - if len(listening_entities) == 0: - devices = list(filter(lambda x: isinstance(x, FujitsuHVAC), devices)) + if not listening_entities: + devices = [dev for dev in devices if isinstance(dev, FujitsuHVAC)] else: - devices = list( - filter(lambda x: x.device_serial_number in listening_entities, devices) - ) + devices = [ + dev for dev in devices if dev.device_serial_number in listening_entities + ] try: for dev in devices: diff --git a/tests/components/fujitsu_fglair/test_climate.py b/tests/components/fujitsu_fglair/test_climate.py index fd016e4e226b45..daddc83a871963 100644 --- a/tests/components/fujitsu_fglair/test_climate.py +++ b/tests/components/fujitsu_fglair/test_climate.py @@ -18,7 +18,7 @@ SWING_BOTH, HVACMode, ) -from homeassistant.components.fujitsu_fglair.const import ( +from homeassistant.components.fujitsu_fglair.climate import ( HA_TO_FUJI_FAN, HA_TO_FUJI_HVAC, HA_TO_FUJI_SWING, From bcfc7ea48198cc95782399dee2fd68534ef762d5 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:36:07 +0200 Subject: [PATCH 06/67] Cleanup unused import in google config flow (#124711) --- homeassistant/components/google/config_flow.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/homeassistant/components/google/config_flow.py b/homeassistant/components/google/config_flow.py index 726af854f754e7..98424ef24f55c1 100644 --- a/homeassistant/components/google/config_flow.py +++ b/homeassistant/components/google/config_flow.py @@ -94,18 +94,6 @@ def extra_authorize_data(self) -> dict[str, Any]: "prompt": "consent", } - async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: - """Import existing auth into a new config entry.""" - if self._async_current_entries(): - return self.async_abort(reason="single_instance_allowed") - implementations = await config_entry_oauth2_flow.async_get_implementations( - self.hass, self.DOMAIN - ) - assert len(implementations) == 1 - self.flow_impl = list(implementations.values())[0] - self.external_data = import_data - return await super().async_step_creation(import_data) - async def async_step_auth( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: From c1c158c0aa84fe91f862f33aeddcbfdd0929a11b Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:48:04 +0200 Subject: [PATCH 07/67] Adjust docstring in airvisual_pro config flow (#124712) --- homeassistant/components/airvisual_pro/config_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/airvisual_pro/config_flow.py b/homeassistant/components/airvisual_pro/config_flow.py index da0cca2e6a2914..db83411b4a45f5 100644 --- a/homeassistant/components/airvisual_pro/config_flow.py +++ b/homeassistant/components/airvisual_pro/config_flow.py @@ -81,7 +81,7 @@ def __init__(self) -> None: self._reauth_entry: ConfigEntry | None = None async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: - """Import a config entry from configuration.yaml.""" + """Import a config entry from `airvisual` integration (see #83882).""" return await self.async_step_user(import_data) async def async_step_reauth( From 1936aeccb99a6897616892e3304c2f1cfd3ce6e2 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 27 Aug 2024 18:01:00 +0200 Subject: [PATCH 08/67] Add a test for async_converse (#124697) --- .../components/conversation/models.py | 11 ++++++ .../conversation/test_agent_manager.py | 34 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/components/conversation/test_agent_manager.py diff --git a/homeassistant/components/conversation/models.py b/homeassistant/components/conversation/models.py index 902b52483e0df1..724e520e6dfe56 100644 --- a/homeassistant/components/conversation/models.py +++ b/homeassistant/components/conversation/models.py @@ -23,11 +23,22 @@ class ConversationInput: """User input to be processed.""" text: str + """User spoken text.""" + context: Context + """Context of the request.""" + conversation_id: str | None + """Unique identifier for the conversation.""" + device_id: str | None + """Unique identifier for the device.""" + language: str + """Language of the request.""" + agent_id: str | None = None + """Agent to use for processing.""" @dataclass(slots=True) diff --git a/tests/components/conversation/test_agent_manager.py b/tests/components/conversation/test_agent_manager.py new file mode 100644 index 00000000000000..47b58a522a8fbd --- /dev/null +++ b/tests/components/conversation/test_agent_manager.py @@ -0,0 +1,34 @@ +"""Test agent manager.""" + +from unittest.mock import patch + +from homeassistant.components.conversation import ConversationResult, async_converse +from homeassistant.core import Context, HomeAssistant +from homeassistant.helpers.intent import IntentResponse + + +async def test_async_converse(hass: HomeAssistant, init_components) -> None: + """Test the async_converse method.""" + context = Context() + with patch( + "homeassistant.components.conversation.default_agent.DefaultAgent.async_process", + return_value=ConversationResult(response=IntentResponse(language="test lang")), + ) as mock_process: + await async_converse( + hass, + text="test command", + conversation_id="test id", + context=context, + language="test lang", + agent_id="conversation.home_assistant", + device_id="test device id", + ) + + assert mock_process.called + conversation_input = mock_process.call_args[0][0] + assert conversation_input.text == "test command" + assert conversation_input.conversation_id == "test id" + assert conversation_input.context is context + assert conversation_input.language == "test lang" + assert conversation_input.agent_id == "conversation.home_assistant" + assert conversation_input.device_id == "test device id" From 0dc1eb87573292594e116483c0b9d3350916634f Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:41:27 +0200 Subject: [PATCH 09/67] Cleanup unused import in zwave_js config flow (#124716) --- .../components/zwave_js/config_flow.py | 12 --- tests/components/zwave_js/test_config_flow.py | 98 ------------------- 2 files changed, 110 deletions(-) diff --git a/homeassistant/components/zwave_js/config_flow.py b/homeassistant/components/zwave_js/config_flow.py index 6d9f88d93f1e68..3e979b224ae776 100644 --- a/homeassistant/components/zwave_js/config_flow.py +++ b/homeassistant/components/zwave_js/config_flow.py @@ -366,18 +366,6 @@ def async_get_options_flow( """Return the options flow.""" return OptionsFlowHandler(config_entry) - async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: - """Handle imported data. - - This step will be used when importing data - during Z-Wave to Z-Wave JS migration. - """ - # Note that the data comes from the zwave integration. - # So we don't use our constants here. - self.s0_legacy_key = import_data.get("network_key") - self.usb_path = import_data.get("usb_path") - return await self.async_step_user() - async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: diff --git a/tests/components/zwave_js/test_config_flow.py b/tests/components/zwave_js/test_config_flow.py index fe16f38257a45e..a3affb6b97794c 100644 --- a/tests/components/zwave_js/test_config_flow.py +++ b/tests/components/zwave_js/test_config_flow.py @@ -2726,104 +2726,6 @@ async def test_options_addon_not_installed( assert client.disconnect.call_count == 1 -@pytest.mark.parametrize("discovery_info", [{"config": ADDON_DISCOVERY_INFO}]) -async def test_import_addon_installed( - hass: HomeAssistant, - supervisor, - addon_installed, - addon_options, - set_addon_options, - start_addon, - get_addon_discovery_info, - serial_port, -) -> None: - """Test import step while add-on already installed on Supervisor.""" - serial_port.device = "/test/imported" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data={"usb_path": "/test/imported", "network_key": "imported123"}, - ) - - assert result["type"] is FlowResultType.FORM - assert result["step_id"] == "on_supervisor" - - result = await hass.config_entries.flow.async_configure( - result["flow_id"], {"use_addon": True} - ) - - assert result["type"] is FlowResultType.FORM - assert result["step_id"] == "configure_addon" - - # the default input should be the imported data - default_input = result["data_schema"]({}) - - assert default_input == { - "usb_path": "/test/imported", - "s0_legacy_key": "imported123", - "s2_access_control_key": "", - "s2_authenticated_key": "", - "s2_unauthenticated_key": "", - "lr_s2_access_control_key": "", - "lr_s2_authenticated_key": "", - } - - result = await hass.config_entries.flow.async_configure( - result["flow_id"], default_input - ) - - assert set_addon_options.call_args == call( - hass, - "core_zwave_js", - { - "options": { - "device": "/test/imported", - "s0_legacy_key": "imported123", - "s2_access_control_key": "", - "s2_authenticated_key": "", - "s2_unauthenticated_key": "", - "lr_s2_access_control_key": "", - "lr_s2_authenticated_key": "", - } - }, - ) - - assert result["type"] is FlowResultType.SHOW_PROGRESS - assert result["step_id"] == "start_addon" - - with ( - patch( - "homeassistant.components.zwave_js.async_setup", return_value=True - ) as mock_setup, - patch( - "homeassistant.components.zwave_js.async_setup_entry", - return_value=True, - ) as mock_setup_entry, - ): - await hass.async_block_till_done() - result = await hass.config_entries.flow.async_configure(result["flow_id"]) - await hass.async_block_till_done() - - assert start_addon.call_args == call(hass, "core_zwave_js") - - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == TITLE - assert result["data"] == { - "url": "ws://host1:3001", - "usb_path": "/test/imported", - "s0_legacy_key": "imported123", - "s2_access_control_key": "", - "s2_authenticated_key": "", - "s2_unauthenticated_key": "", - "lr_s2_access_control_key": "", - "lr_s2_authenticated_key": "", - "use_addon": True, - "integration_created_addon": False, - } - assert len(mock_setup.mock_calls) == 1 - assert len(mock_setup_entry.mock_calls) == 1 - - async def test_zeroconf(hass: HomeAssistant) -> None: """Test zeroconf discovery.""" From 55c42fde88c7a6989a8489b755375fef92360f35 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 27 Aug 2024 19:05:49 +0200 Subject: [PATCH 10/67] Improve validation of entity service schemas (#124102) * Improve validation of entity service schemas * Update tests/helpers/test_entity_platform.py Co-authored-by: Joost Lekkerkerker --------- Co-authored-by: Joost Lekkerkerker --- homeassistant/helpers/config_validation.py | 23 ++++++++++++- homeassistant/helpers/service.py | 13 ++------ tests/helpers/test_config_validation.py | 24 ++++++++++++++ tests/helpers/test_entity_component.py | 38 +++++++++++----------- tests/helpers/test_entity_platform.py | 38 ++++++++++++---------- 5 files changed, 87 insertions(+), 49 deletions(-) diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index d7a5d5ae8a183e..2904efb75e9f82 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -1305,9 +1305,28 @@ def platform_only_config_schema(domain: str) -> Callable[[dict], dict]: _HAS_ENTITY_SERVICE_FIELD = has_at_least_one_key(*ENTITY_SERVICE_FIELDS) +def is_entity_service_schema(validator: VolSchemaType) -> bool: + """Check if the passed validator is an entity schema validator. + + The validator must be either of: + - A validator returned by cv._make_entity_service_schema + - A validator returned by cv._make_entity_service_schema, wrapped in a vol.Schema + - A validator returned by cv._make_entity_service_schema, wrapped in a vol.All + Nesting is allowed. + """ + if hasattr(validator, "_entity_service_schema"): + return True + if isinstance(validator, (vol.All)): + return any(is_entity_service_schema(val) for val in validator.validators) + if isinstance(validator, (vol.Schema)): + return is_entity_service_schema(validator.schema) + + return False + + def _make_entity_service_schema(schema: dict, extra: int) -> VolSchemaType: """Create an entity service schema.""" - return vol.All( + validator = vol.All( vol.Schema( { # The frontend stores data here. Don't use in core. @@ -1319,6 +1338,8 @@ def _make_entity_service_schema(schema: dict, extra: int) -> VolSchemaType: ), _HAS_ENTITY_SERVICE_FIELD, ) + setattr(validator, "_entity_service_schema", True) + return validator BASE_ENTITY_SCHEMA = _make_entity_service_schema({}, vol.PREVENT_EXTRA) diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 0551b5289c548d..573073f380916a 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -1267,17 +1267,8 @@ def async_register_entity_service( # Do a sanity check to check this is a valid entity service schema, # the check could be extended to require All/Any to have sub schema(s) # with all entity service fields - elif ( - # Don't check All/Any - not isinstance(schema, (vol.All, vol.Any)) - # Don't check All/Any wrapped in schema - and not isinstance(schema.schema, (vol.All, vol.Any)) - and any(key not in schema.schema for key in cv.ENTITY_SERVICE_FIELDS) - ): - raise HomeAssistantError( - "The schema does not include all required keys: " - f"{", ".join(str(key) for key in cv.ENTITY_SERVICE_FIELDS)}" - ) + elif not cv.is_entity_service_schema(schema): + raise HomeAssistantError("The schema is not an entity service schema") service_func: str | HassJob[..., Any] service_func = func if isinstance(func, str) else HassJob(func) diff --git a/tests/helpers/test_config_validation.py b/tests/helpers/test_config_validation.py index 973f504df08edf..57c712e2f10d05 100644 --- a/tests/helpers/test_config_validation.py +++ b/tests/helpers/test_config_validation.py @@ -1805,3 +1805,27 @@ def _mock_validator_schema(real_func, *args): "string": [hass.loop_thread_id], } validator_calls = {} + + +async def test_is_entity_service_schema( + hass: HomeAssistant, +) -> None: + """Test cv.is_entity_service_schema.""" + for schema in ( + vol.Schema({"some": str}), + vol.All(vol.Schema({"some": str})), + vol.Any(vol.Schema({"some": str})), + vol.Any(cv.make_entity_service_schema({"some": str})), + ): + assert cv.is_entity_service_schema(schema) is False + + for schema in ( + cv.make_entity_service_schema({"some": str}), + vol.Schema(cv.make_entity_service_schema({"some": str})), + vol.Schema(vol.All(cv.make_entity_service_schema({"some": str}))), + vol.Schema(vol.Schema(cv.make_entity_service_schema({"some": str}))), + vol.All(cv.make_entity_service_schema({"some": str})), + vol.All(vol.All(cv.make_entity_service_schema({"some": str}))), + vol.All(vol.Schema(cv.make_entity_service_schema({"some": str}))), + ): + assert cv.is_entity_service_schema(schema) is True diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index 5ce0292c2ec5fa..8f4ece09a1734c 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -23,7 +23,7 @@ callback, ) from homeassistant.exceptions import HomeAssistantError, PlatformNotReady -from homeassistant.helpers import discovery +from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers.entity_component import EntityComponent, async_update_entity from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -559,28 +559,28 @@ def appender(**kwargs): async def test_register_entity_service_non_entity_service_schema( hass: HomeAssistant, ) -> None: - """Test attempting to register a service with an incomplete schema.""" + """Test attempting to register a service with a non entity service schema.""" component = EntityComponent(_LOGGER, DOMAIN, hass) - with pytest.raises( - HomeAssistantError, - match=( - "The schema does not include all required keys: entity_id, device_id, area_id, " - "floor_id, label_id" - ), + for schema in ( + vol.Schema({"some": str}), + vol.All(vol.Schema({"some": str})), + vol.Any(vol.Schema({"some": str})), ): - component.async_register_entity_service( - "hello", vol.Schema({"some": str}), Mock() + with pytest.raises( + HomeAssistantError, + match=("The schema is not an entity service schema"), + ): + component.async_register_entity_service("hello", schema, Mock()) + + for idx, schema in enumerate( + ( + cv.make_entity_service_schema({"some": str}), + vol.Schema(cv.make_entity_service_schema({"some": str})), + vol.All(cv.make_entity_service_schema({"some": str})), ) - - # The check currently does not recurse into vol.All or vol.Any allowing these - # non-compliant schemas to pass - component.async_register_entity_service( - "hello", vol.All(vol.Schema({"some": str})), Mock() - ) - component.async_register_entity_service( - "hello", vol.Any(vol.Schema({"some": str})), Mock() - ) + ): + component.async_register_entity_service(f"test_service_{idx}", schema, Mock()) async def test_register_entity_service_response_data(hass: HomeAssistant) -> None: diff --git a/tests/helpers/test_entity_platform.py b/tests/helpers/test_entity_platform.py index 2cc3348626cbd0..2b0598cfe9d856 100644 --- a/tests/helpers/test_entity_platform.py +++ b/tests/helpers/test_entity_platform.py @@ -23,6 +23,7 @@ from homeassistant.exceptions import HomeAssistantError, PlatformNotReady from homeassistant.helpers import ( area_registry as ar, + config_validation as cv, device_registry as dr, entity_platform, entity_registry as er, @@ -1812,31 +1813,32 @@ def handle_service(entity, *_): async def test_register_entity_service_non_entity_service_schema( hass: HomeAssistant, ) -> None: - """Test attempting to register a service with an incomplete schema.""" + """Test attempting to register a service with a non entity service schema.""" entity_platform = MockEntityPlatform( hass, domain="mock_integration", platform_name="mock_platform", platform=None ) - with pytest.raises( - HomeAssistantError, - match=( - "The schema does not include all required keys: entity_id, device_id, area_id, " - "floor_id, label_id" - ), + for schema in ( + vol.Schema({"some": str}), + vol.All(vol.Schema({"some": str})), + vol.Any(vol.Schema({"some": str})), + ): + with pytest.raises( + HomeAssistantError, + match="The schema is not an entity service schema", + ): + entity_platform.async_register_entity_service("hello", schema, Mock()) + + for idx, schema in enumerate( + ( + cv.make_entity_service_schema({"some": str}), + vol.Schema(cv.make_entity_service_schema({"some": str})), + vol.All(cv.make_entity_service_schema({"some": str})), + ) ): entity_platform.async_register_entity_service( - "hello", - vol.Schema({"some": str}), - Mock(), + f"test_service_{idx}", schema, Mock() ) - # The check currently does not recurse into vol.All or vol.Any allowing these - # non-compliant schemas to pass - entity_platform.async_register_entity_service( - "hello", vol.All(vol.Schema({"some": str})), Mock() - ) - entity_platform.async_register_entity_service( - "hello", vol.Any(vol.Schema({"some": str})), Mock() - ) @pytest.mark.parametrize("update_before_add", [True, False]) From 52b6f00363e4dd25702f3413b3645358bf5bbfdf Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 27 Aug 2024 19:07:04 +0200 Subject: [PATCH 11/67] Adjust name of Google Translate TTS provider (#124688) --- homeassistant/components/google_translate/tts.py | 4 ++-- tests/components/google_translate/test_tts.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/google_translate/tts.py b/homeassistant/components/google_translate/tts.py index 221c99e7c20d72..13e0ca4c2738ba 100644 --- a/homeassistant/components/google_translate/tts.py +++ b/homeassistant/components/google_translate/tts.py @@ -74,7 +74,7 @@ def __init__(self, config_entry: ConfigEntry, lang: str, tld: str) -> None: else: self._lang = lang self._tld = tld - self._attr_name = f"Google {self._lang} {self._tld}" + self._attr_name = f"Google Translate {self._lang} {self._tld}" self._attr_unique_id = config_entry.entry_id @property @@ -130,7 +130,7 @@ def __init__(self, hass: HomeAssistant, lang: str, tld: str) -> None: else: self._lang = lang self._tld = tld - self.name = "Google" + self.name = "Google Translate" @property def default_language(self) -> str: diff --git a/tests/components/google_translate/test_tts.py b/tests/components/google_translate/test_tts.py index 95313df6140eaa..1f199a5db97807 100644 --- a/tests/components/google_translate/test_tts.py +++ b/tests/components/google_translate/test_tts.py @@ -103,7 +103,7 @@ async def mock_config_entry_setup(hass: HomeAssistant, config: dict[str, Any]) - "mock_config_entry_setup", "speak", { - ATTR_ENTITY_ID: "tts.google_en_com", + ATTR_ENTITY_ID: "tts.google_translate_en_com", tts.ATTR_MEDIA_PLAYER_ENTITY_ID: "media_player.something", tts.ATTR_MESSAGE: "There is a person at the front door.", }, @@ -160,7 +160,7 @@ async def test_tts_service( "mock_config_entry_setup", "speak", { - ATTR_ENTITY_ID: "tts.google_de_com", + ATTR_ENTITY_ID: "tts.google_translate_de_com", tts.ATTR_MEDIA_PLAYER_ENTITY_ID: "media_player.something", tts.ATTR_MESSAGE: "There is a person at the front door.", }, @@ -216,7 +216,7 @@ async def test_service_say_german_config( "mock_config_entry_setup", "speak", { - ATTR_ENTITY_ID: "tts.google_en_com", + ATTR_ENTITY_ID: "tts.google_translate_en_com", tts.ATTR_MEDIA_PLAYER_ENTITY_ID: "media_player.something", tts.ATTR_MESSAGE: "There is a person at the front door.", tts.ATTR_LANGUAGE: "de", @@ -273,7 +273,7 @@ async def test_service_say_german_service( "mock_config_entry_setup", "speak", { - ATTR_ENTITY_ID: "tts.google_en_co_uk", + ATTR_ENTITY_ID: "tts.google_translate_en_co_uk", tts.ATTR_MEDIA_PLAYER_ENTITY_ID: "media_player.something", tts.ATTR_MESSAGE: "There is a person at the front door.", }, @@ -329,7 +329,7 @@ async def test_service_say_en_uk_config( "mock_config_entry_setup", "speak", { - ATTR_ENTITY_ID: "tts.google_en_com", + ATTR_ENTITY_ID: "tts.google_translate_en_com", tts.ATTR_MEDIA_PLAYER_ENTITY_ID: "media_player.something", tts.ATTR_MESSAGE: "There is a person at the front door.", tts.ATTR_LANGUAGE: "en-uk", @@ -386,7 +386,7 @@ async def test_service_say_en_uk_service( "mock_config_entry_setup", "speak", { - ATTR_ENTITY_ID: "tts.google_en_com", + ATTR_ENTITY_ID: "tts.google_translate_en_com", tts.ATTR_MEDIA_PLAYER_ENTITY_ID: "media_player.something", tts.ATTR_MESSAGE: "There is a person at the front door.", tts.ATTR_OPTIONS: {"tld": "co.uk"}, @@ -443,7 +443,7 @@ async def test_service_say_en_couk( "mock_config_entry_setup", "speak", { - ATTR_ENTITY_ID: "tts.google_en_com", + ATTR_ENTITY_ID: "tts.google_translate_en_com", tts.ATTR_MEDIA_PLAYER_ENTITY_ID: "media_player.something", tts.ATTR_MESSAGE: "There is a person at the front door.", }, From e2d84f9a58b773de3b28d2f9c55593faffdad475 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 27 Aug 2024 19:07:35 +0200 Subject: [PATCH 12/67] Add support for multiple otbr config entries (#124289) * Add support for multiple otbr config entries * Fix test * Drop useless fixture * Address review comments * Change unique id from xa to id * Improve error text * Store data in ConfigEntry.runtime_data * Remove useless function --- homeassistant/components/otbr/__init__.py | 43 ++- homeassistant/components/otbr/config_flow.py | 89 +++-- homeassistant/components/otbr/const.py | 8 - .../components/otbr/silabs_multiprotocol.py | 21 +- homeassistant/components/otbr/strings.json | 1 + homeassistant/components/otbr/util.py | 38 +- .../components/otbr/websocket_api.py | 102 +++--- tests/components/otbr/__init__.py | 1 + tests/components/otbr/conftest.py | 5 +- tests/components/otbr/test_config_flow.py | 334 ++++++++++++++++-- tests/components/otbr/test_init.py | 45 ++- .../otbr/test_silabs_multiprotocol.py | 21 +- tests/components/otbr/test_util.py | 33 +- 13 files changed, 565 insertions(+), 176 deletions(-) diff --git a/homeassistant/components/otbr/__init__.py b/homeassistant/components/otbr/__init__.py index 3e53358a16255d..4b95be1d40d678 100644 --- a/homeassistant/components/otbr/__init__.py +++ b/homeassistant/components/otbr/__init__.py @@ -2,6 +2,8 @@ from __future__ import annotations +import logging + import aiohttp import python_otbr_api @@ -14,22 +16,28 @@ from homeassistant.helpers.typing import ConfigType from . import websocket_api -from .const import DATA_OTBR, DOMAIN -from .util import OTBRData, update_issues +from .const import DOMAIN +from .util import ( + GetBorderAgentIdNotSupported, + OTBRData, + update_issues, + update_unique_id, +) + +_LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) +type OTBRConfigEntry = ConfigEntry[OTBRData] + async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Open Thread Border Router component.""" websocket_api.async_setup(hass) - if len(config_entries := hass.config_entries.async_entries(DOMAIN)): - for config_entry in config_entries[1:]: - await hass.config_entries.async_remove(config_entry.entry_id) return True -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +async def async_setup_entry(hass: HomeAssistant, entry: OTBRConfigEntry) -> bool: """Set up an Open Thread Border Router config entry.""" api = python_otbr_api.OTBR(entry.data["url"], async_get_clientsession(hass), 10) @@ -38,13 +46,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: border_agent_id = await otbrdata.get_border_agent_id() dataset_tlvs = await otbrdata.get_active_dataset_tlvs() extended_address = await otbrdata.get_extended_address() - except ( - HomeAssistantError, - aiohttp.ClientError, - TimeoutError, - ) as err: - raise ConfigEntryNotReady("Unable to connect") from err - if border_agent_id is None: + except GetBorderAgentIdNotSupported: ir.async_create_issue( hass, DOMAIN, @@ -55,6 +57,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: translation_key="get_get_border_agent_id_unsupported", ) return False + except ( + HomeAssistantError, + aiohttp.ClientError, + TimeoutError, + ) as err: + raise ConfigEntryNotReady("Unable to connect") from err + await update_unique_id(hass, entry, border_agent_id) if dataset_tlvs: await update_issues(hass, otbrdata, dataset_tlvs) await async_add_dataset( @@ -66,18 +75,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ) entry.async_on_unload(entry.add_update_listener(async_reload_entry)) - - hass.data[DATA_OTBR] = otbrdata + entry.runtime_data = otbrdata return True -async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: OTBRConfigEntry) -> bool: """Unload a config entry.""" - hass.data.pop(DATA_OTBR) return True -async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: +async def async_reload_entry(hass: HomeAssistant, entry: OTBRConfigEntry) -> None: """Handle an options update.""" await hass.config_entries.async_reload(entry.entry_id) diff --git a/homeassistant/components/otbr/config_flow.py b/homeassistant/components/otbr/config_flow.py index 8cffc0a99e6df4..c1747981b07deb 100644 --- a/homeassistant/components/otbr/config_flow.py +++ b/homeassistant/components/otbr/config_flow.py @@ -4,7 +4,7 @@ from contextlib import suppress import logging -from typing import cast +from typing import TYPE_CHECKING, cast import aiohttp import python_otbr_api @@ -33,9 +33,16 @@ get_allowed_channel, ) +if TYPE_CHECKING: + from . import OTBRConfigEntry + _LOGGER = logging.getLogger(__name__) +class AlreadyConfigured(HomeAssistantError): + """Raised when the router is already configured.""" + + def _is_yellow(hass: HomeAssistant) -> bool: """Return True if Home Assistant is running on a Home Assistant Yellow.""" try: @@ -70,9 +77,8 @@ class OTBRConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 - async def _connect_and_set_dataset(self, otbr_url: str) -> None: + async def _set_dataset(self, api: python_otbr_api.OTBR, otbr_url: str) -> None: """Connect to the OTBR and create or apply a dataset if it doesn't have one.""" - api = python_otbr_api.OTBR(otbr_url, async_get_clientsession(self.hass), 10) if await api.get_active_dataset_tlvs() is None: allowed_channel = await get_allowed_channel(self.hass, otbr_url) @@ -89,7 +95,9 @@ async def _connect_and_set_dataset(self, otbr_url: str) -> None: await api.set_active_dataset_tlvs(bytes.fromhex(thread_dataset_tlv)) else: _LOGGER.debug( - "not importing TLV with channel %s", thread_dataset_channel + "not importing TLV with channel %s for %s", + thread_dataset_channel, + otbr_url, ) pan_id = generate_random_pan_id() await api.create_active_dataset( @@ -101,27 +109,65 @@ async def _connect_and_set_dataset(self, otbr_url: str) -> None: ) await api.set_enabled(True) + async def _is_border_agent_id_configured(self, border_agent_id: bytes) -> bool: + """Return True if another config entry's OTBR has the same border agent id.""" + config_entry: OTBRConfigEntry + for config_entry in self.hass.config_entries.async_loaded_entries(DOMAIN): + data = config_entry.runtime_data + try: + other_border_agent_id = await data.get_border_agent_id() + except HomeAssistantError: + _LOGGER.debug( + "Could not read border agent id from %s", data.url, exc_info=True + ) + continue + _LOGGER.debug( + "border agent id for existing url %s: %s", + data.url, + other_border_agent_id.hex(), + ) + if border_agent_id == other_border_agent_id: + return True + return False + + async def _connect_and_configure_router(self, otbr_url: str) -> bytes: + """Connect to the router and configure it if needed. + + Will raise if the router's border agent id is in use by another config entry. + Returns the router's border agent id. + """ + api = python_otbr_api.OTBR(otbr_url, async_get_clientsession(self.hass), 10) + border_agent_id = await api.get_border_agent_id() + _LOGGER.debug("border agent id for url %s: %s", otbr_url, border_agent_id.hex()) + + if await self._is_border_agent_id_configured(border_agent_id): + raise AlreadyConfigured + + await self._set_dataset(api, otbr_url) + + return border_agent_id + async def async_step_user( self, user_input: dict[str, str] | None = None ) -> ConfigFlowResult: """Set up by user.""" - if self._async_current_entries(): - return self.async_abort(reason="single_instance_allowed") - errors = {} if user_input is not None: url = user_input[CONF_URL].rstrip("/") try: - await self._connect_and_set_dataset(url) + border_agent_id = await self._connect_and_configure_router(url) + except AlreadyConfigured: + errors["base"] = "already_configured" except ( python_otbr_api.OTBRError, aiohttp.ClientError, TimeoutError, - ): + ) as exc: + _LOGGER.debug("Failed to communicate with OTBR@%s: %s", url, exc) errors["base"] = "cannot_connect" else: - await self.async_set_unique_id(DOMAIN) + await self.async_set_unique_id(border_agent_id.hex()) return self.async_create_entry( title="Open Thread Border Router", data={CONF_URL: url}, @@ -140,34 +186,35 @@ async def async_step_hassio( url = f"http://{config['host']}:{config['port']}" config_entry_data = {"url": url} - if self._async_in_progress(include_uninitialized=True): - # We currently don't handle multiple config entries, abort if hassio - # discovers multiple addons with otbr support - return self.async_abort(reason="single_instance_allowed") - if current_entries := self._async_current_entries(): for current_entry in current_entries: if current_entry.source != SOURCE_HASSIO: continue current_url = yarl.URL(current_entry.data["url"]) - if ( + if not (unique_id := current_entry.unique_id): # The first version did not set a unique_id # so if the entry does not have a unique_id # we have to assume it's the first version - current_entry.unique_id - and (current_entry.unique_id != discovery_info.uuid) + # This check can be removed in HA Core 2025.9 + unique_id = discovery_info.uuid + if ( + unique_id != discovery_info.uuid or current_url.host != config["host"] or current_url.port == config["port"] ): continue # Update URL with the new port self.hass.config_entries.async_update_entry( - current_entry, data=config_entry_data + current_entry, + data=config_entry_data, + unique_id=unique_id, # Remove in HA Core 2025.9 ) - return self.async_abort(reason="single_instance_allowed") + return self.async_abort(reason="already_configured") try: - await self._connect_and_set_dataset(url) + await self._connect_and_configure_router(url) + except AlreadyConfigured: + return self.async_abort(reason="already_configured") except ( python_otbr_api.OTBRError, aiohttp.ClientError, diff --git a/homeassistant/components/otbr/const.py b/homeassistant/components/otbr/const.py index cf1678466a44af..c38b3cc125097c 100644 --- a/homeassistant/components/otbr/const.py +++ b/homeassistant/components/otbr/const.py @@ -2,14 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - -from homeassistant.util.hass_dict import HassKey - -if TYPE_CHECKING: - from .util import OTBRData - DOMAIN = "otbr" -DATA_OTBR: HassKey[OTBRData] = HassKey(DOMAIN) DEFAULT_CHANNEL = 15 diff --git a/homeassistant/components/otbr/silabs_multiprotocol.py b/homeassistant/components/otbr/silabs_multiprotocol.py index b3a711968fda9d..d97e6811e6d19e 100644 --- a/homeassistant/components/otbr/silabs_multiprotocol.py +++ b/homeassistant/components/otbr/silabs_multiprotocol.py @@ -5,7 +5,7 @@ from collections.abc import Callable, Coroutine from functools import wraps import logging -from typing import Any, Concatenate +from typing import TYPE_CHECKING, Any, Concatenate import aiohttp from python_otbr_api import tlv_parser @@ -18,9 +18,12 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError -from .const import DATA_OTBR, DOMAIN +from .const import DOMAIN from .util import OTBRData +if TYPE_CHECKING: + from . import OTBRConfigEntry + _LOGGER = logging.getLogger(__name__) @@ -45,15 +48,13 @@ async def async_get_otbr_data_wrapper( hass: HomeAssistant, *args: _P.args, **kwargs: _P.kwargs ) -> _R | _R_Def: """Fetch OTBR data and pass to orig_func.""" - if DATA_OTBR not in hass.data: - return retval - - data = hass.data[DATA_OTBR] - - if not is_multiprotocol_url(data.url): - return retval + config_entry: OTBRConfigEntry + for config_entry in hass.config_entries.async_loaded_entries(DOMAIN): + data = config_entry.runtime_data + if is_multiprotocol_url(data.url): + return await orig_func(hass, data, *args, **kwargs) - return await orig_func(hass, data, *args, **kwargs) + return retval return async_get_otbr_data_wrapper diff --git a/homeassistant/components/otbr/strings.json b/homeassistant/components/otbr/strings.json index 838ebeb5b8cb73..bc7812c1db777a 100644 --- a/homeassistant/components/otbr/strings.json +++ b/homeassistant/components/otbr/strings.json @@ -9,6 +9,7 @@ } }, "error": { + "already_configured": "The Thread border router is already configured", "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" }, "abort": { diff --git a/homeassistant/components/otbr/util.py b/homeassistant/components/otbr/util.py index d426ca9ba17aa7..351e23c7736a08 100644 --- a/homeassistant/components/otbr/util.py +++ b/homeassistant/components/otbr/util.py @@ -7,7 +7,7 @@ from functools import wraps import logging import random -from typing import Any, Concatenate, cast +from typing import TYPE_CHECKING, Any, Concatenate, cast import aiohttp import python_otbr_api @@ -22,12 +22,16 @@ multi_pan_addon_using_device, ) from homeassistant.components.homeassistant_yellow import RADIO_DEVICE as YELLOW_RADIO +from homeassistant.config_entries import SOURCE_USER from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import issue_registry as ir from .const import DOMAIN +if TYPE_CHECKING: + from . import OTBRConfigEntry + _LOGGER = logging.getLogger(__name__) INFO_URL_SKY_CONNECT = ( @@ -48,6 +52,10 @@ ) +class GetBorderAgentIdNotSupported(HomeAssistantError): + """Raised from python_otbr_api.GetBorderAgentIdNotSupportedError.""" + + def compose_default_network_name(pan_id: int) -> str: """Generate a default network name.""" return f"ha-thread-{pan_id:04x}" @@ -83,7 +91,7 @@ class OTBRData: entry_id: str @_handle_otbr_error - async def factory_reset(self) -> None: + async def factory_reset(self, hass: HomeAssistant) -> None: """Reset the router.""" try: await self.api.factory_reset() @@ -92,14 +100,19 @@ async def factory_reset(self) -> None: "OTBR does not support factory reset, attempting to delete dataset" ) await self.delete_active_dataset() + await update_unique_id( + hass, + hass.config_entries.async_get_entry(self.entry_id), + await self.get_border_agent_id(), + ) @_handle_otbr_error - async def get_border_agent_id(self) -> bytes | None: + async def get_border_agent_id(self) -> bytes: """Get the border agent ID or None if not supported by the router.""" try: return await self.api.get_border_agent_id() - except python_otbr_api.GetBorderAgentIdNotSupportedError: - return None + except python_otbr_api.GetBorderAgentIdNotSupportedError as exc: + raise GetBorderAgentIdNotSupported from exc @_handle_otbr_error async def set_enabled(self, enabled: bool) -> None: @@ -258,3 +271,18 @@ async def update_issues( """Raise or clear repair issues related to network settings.""" await _warn_on_channel_collision(hass, otbrdata, dataset_tlvs) _warn_on_default_network_settings(hass, otbrdata, dataset_tlvs) + + +async def update_unique_id( + hass: HomeAssistant, entry: OTBRConfigEntry | None, border_agent_id: bytes +) -> None: + """Update the config entry's unique_id if not matching.""" + border_agent_id_hex = border_agent_id.hex() + if entry and entry.source == SOURCE_USER and entry.unique_id != border_agent_id_hex: + _LOGGER.debug( + "Updating unique_id of entry %s from %s to %s", + entry.entry_id, + entry.unique_id, + border_agent_id_hex, + ) + hass.config_entries.async_update_entry(entry, unique_id=border_agent_id_hex) diff --git a/homeassistant/components/otbr/websocket_api.py b/homeassistant/components/otbr/websocket_api.py index 577f9cc381d811..2bcd0da8f16c50 100644 --- a/homeassistant/components/otbr/websocket_api.py +++ b/homeassistant/components/otbr/websocket_api.py @@ -2,7 +2,7 @@ from collections.abc import Callable, Coroutine from functools import wraps -from typing import Any, cast +from typing import TYPE_CHECKING, Any, cast import python_otbr_api from python_otbr_api import PENDING_DATASET_DELAY_TIMER, tlv_parser @@ -17,7 +17,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError -from .const import DATA_OTBR, DEFAULT_CHANNEL, DOMAIN +from .const import DEFAULT_CHANNEL, DOMAIN from .util import ( OTBRData, compose_default_network_name, @@ -26,6 +26,9 @@ update_issues, ) +if TYPE_CHECKING: + from . import OTBRConfigEntry + @callback def async_setup(hass: HomeAssistant) -> None: @@ -47,41 +50,45 @@ async def websocket_info( hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict ) -> None: """Get OTBR info.""" - if DATA_OTBR not in hass.data: + config_entries: list[OTBRConfigEntry] + config_entries = hass.config_entries.async_loaded_entries(DOMAIN) + + if not config_entries: connection.send_error(msg["id"], "not_loaded", "No OTBR API loaded") return - data = hass.data[DATA_OTBR] + response: dict[str, dict[str, Any]] = {} - try: - border_agent_id = await data.get_border_agent_id() - dataset = await data.get_active_dataset() - dataset_tlvs = await data.get_active_dataset_tlvs() - extended_address = (await data.get_extended_address()).hex() - except HomeAssistantError as exc: - connection.send_error(msg["id"], "otbr_info_failed", str(exc)) - return + for config_entry in config_entries: + data = config_entry.runtime_data + try: + border_agent_id = await data.get_border_agent_id() + dataset = await data.get_active_dataset() + dataset_tlvs = await data.get_active_dataset_tlvs() + extended_address = (await data.get_extended_address()).hex() + except HomeAssistantError as exc: + connection.send_error(msg["id"], "otbr_info_failed", str(exc)) + return - # The border agent ID is checked when the OTBR config entry is setup, - # we can assert it's not None - assert border_agent_id is not None - - extended_pan_id = ( - dataset.extended_pan_id.lower() if dataset and dataset.extended_pan_id else None - ) - connection.send_result( - msg["id"], - { - extended_address: { - "active_dataset_tlvs": dataset_tlvs.hex() if dataset_tlvs else None, - "border_agent_id": border_agent_id.hex(), - "channel": dataset.channel if dataset else None, - "extended_address": extended_address, - "extended_pan_id": extended_pan_id, - "url": data.url, - } - }, - ) + # The border agent ID is checked when the OTBR config entry is setup, + # we can assert it's not None + assert border_agent_id is not None + + extended_pan_id = ( + dataset.extended_pan_id.lower() + if dataset and dataset.extended_pan_id + else None + ) + response[extended_address] = { + "active_dataset_tlvs": dataset_tlvs.hex() if dataset_tlvs else None, + "border_agent_id": border_agent_id.hex(), + "channel": dataset.channel if dataset else None, + "extended_address": extended_address, + "extended_pan_id": extended_pan_id, + "url": data.url, + } + + connection.send_result(msg["id"], response) def async_get_otbr_data( @@ -99,22 +106,29 @@ async def async_check_extended_address_func( hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict ) -> None: """Fetch OTBR data and pass to orig_func.""" - if DATA_OTBR not in hass.data: + config_entries: list[OTBRConfigEntry] + config_entries = hass.config_entries.async_loaded_entries(DOMAIN) + + if not config_entries: connection.send_error(msg["id"], "not_loaded", "No OTBR API loaded") return - data = hass.data[DATA_OTBR] - - try: - extended_address = await data.get_extended_address() - except HomeAssistantError as exc: - connection.send_error(msg["id"], "get_extended_address_failed", str(exc)) - return - if extended_address.hex() != msg["extended_address"]: - connection.send_error(msg["id"], "unknown_router", "") + for config_entry in config_entries: + data = config_entry.runtime_data + try: + extended_address = await data.get_extended_address() + except HomeAssistantError as exc: + connection.send_error( + msg["id"], "get_extended_address_failed", str(exc) + ) + return + if extended_address.hex() != msg["extended_address"]: + continue + + await orig_func(hass, connection, msg, data) return - await orig_func(hass, connection, msg, data) + connection.send_error(msg["id"], "unknown_router", "") return async_check_extended_address_func @@ -144,7 +158,7 @@ async def websocket_create_network( return try: - await data.factory_reset() + await data.factory_reset(hass) except HomeAssistantError as exc: connection.send_error(msg["id"], "factory_reset_failed", str(exc)) return diff --git a/tests/components/otbr/__init__.py b/tests/components/otbr/__init__.py index 2c9daa127c2832..7d52318b477f83 100644 --- a/tests/components/otbr/__init__.py +++ b/tests/components/otbr/__init__.py @@ -31,6 +31,7 @@ TEST_BORDER_AGENT_EXTENDED_ADDRESS = bytes.fromhex("AEEB2F594B570BBF") TEST_BORDER_AGENT_ID = bytes.fromhex("230C6A1AC57F6F4BE262ACF32E5EF52C") +TEST_BORDER_AGENT_ID_2 = bytes.fromhex("230C6A1AC57F6F4BE262ACF32E5EF52D") ROUTER_DISCOVERY_HASS = { "type_": "_meshcop._udp.local.", diff --git a/tests/components/otbr/conftest.py b/tests/components/otbr/conftest.py index 3811ff66ebb224..5ab3e4421830ac 100644 --- a/tests/components/otbr/conftest.py +++ b/tests/components/otbr/conftest.py @@ -77,16 +77,18 @@ async def otbr_config_entry_multipan_fixture( get_active_dataset_tlvs: AsyncMock, get_border_agent_id: AsyncMock, get_extended_address: AsyncMock, -) -> None: +) -> str: """Mock Open Thread Border Router config entry.""" config_entry = MockConfigEntry( data=CONFIG_ENTRY_DATA_MULTIPAN, domain=otbr.DOMAIN, options={}, title="Open Thread Border Router", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) assert await hass.config_entries.async_setup(config_entry.entry_id) + return config_entry.entry_id @pytest.fixture(name="otbr_config_entry_thread") @@ -102,6 +104,7 @@ async def otbr_config_entry_thread_fixture( domain=otbr.DOMAIN, options={}, title="Open Thread Border Router", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) assert await hass.config_entries.async_setup(config_entry.entry_id) diff --git a/tests/components/otbr/test_config_flow.py b/tests/components/otbr/test_config_flow.py index c4972bb5f836ca..edd92591b1bce9 100644 --- a/tests/components/otbr/test_config_flow.py +++ b/tests/components/otbr/test_config_flow.py @@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType -from . import DATASET_CH15, DATASET_CH16 +from . import DATASET_CH15, DATASET_CH16, TEST_BORDER_AGENT_ID, TEST_BORDER_AGENT_ID_2 from tests.common import MockConfigEntry, MockModule, mock_integration from tests.test_util.aiohttp import AiohttpClientMocker @@ -57,12 +57,91 @@ def addon_info_fixture(): "http://custom_url:1234//", ], ) +@pytest.mark.usefixtures( + "get_active_dataset_tlvs", + "get_border_agent_id", +) async def test_user_flow( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, url: str ) -> None: """Test the user flow.""" + await _finish_user_flow(hass, url) + + +@pytest.mark.usefixtures( + "get_active_dataset_tlvs", + "get_extended_address", +) +async def test_user_flow_additional_entry( + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker +) -> None: + """Test more than a single entry is allowed.""" + url1 = "http://custom_url:1234" + url2 = "http://custom_url_2:1234" + aioclient_mock.get(f"{url1}/node/ba-id", json=TEST_BORDER_AGENT_ID.hex()) + aioclient_mock.get(f"{url2}/node/ba-id", json=TEST_BORDER_AGENT_ID_2.hex()) + + mock_integration(hass, MockModule("hassio")) + + # Setup a config entry + config_entry = MockConfigEntry( + data={"url": url2}, + domain=otbr.DOMAIN, + options={}, + title="Open Thread Border Router", + unique_id=TEST_BORDER_AGENT_ID_2.hex(), + ) + config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(config_entry.entry_id) + + # Do a user flow + await _finish_user_flow(hass) + + +@pytest.mark.usefixtures( + "get_active_dataset_tlvs", + "get_extended_address", +) +async def test_user_flow_additional_entry_fail_get_address( + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + caplog: pytest.LogCaptureFixture, +) -> None: + """Test more than a single entry is allowed. + + This tets the behavior when we can't read the extended address from the existing + config entry. + """ + url1 = "http://custom_url:1234" + url2 = "http://custom_url_2:1234" + aioclient_mock.get(f"{url2}/node/ba-id", json=TEST_BORDER_AGENT_ID_2.hex()) + + mock_integration(hass, MockModule("hassio")) + + # Setup a config entry + config_entry = MockConfigEntry( + data={"url": url2}, + domain=otbr.DOMAIN, + options={}, + title="Open Thread Border Router", + unique_id=TEST_BORDER_AGENT_ID_2.hex(), + ) + config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(config_entry.entry_id) + + # Do a user flow + aioclient_mock.clear_requests() + aioclient_mock.get(f"{url1}/node/ba-id", json=TEST_BORDER_AGENT_ID.hex()) + aioclient_mock.get(f"{url2}/node/ba-id", status=HTTPStatus.NOT_FOUND) + await _finish_user_flow(hass) + assert f"Could not read border agent id from {url2}" in caplog.text + + +async def _finish_user_flow( + hass: HomeAssistant, url: str = "http://custom_url:1234" +) -> None: + """Finish a user flow.""" stripped_url = "http://custom_url:1234" - aioclient_mock.get(f"{stripped_url}/node/dataset/active", text="aa") result = await hass.config_entries.flow.async_init( otbr.DOMAIN, context={"source": "user"} ) @@ -88,13 +167,56 @@ async def test_user_flow( assert result["options"] == {} assert len(mock_setup_entry.mock_calls) == 1 - config_entry = hass.config_entries.async_entries(otbr.DOMAIN)[0] + config_entry = result["result"] assert config_entry.data == expected_data assert config_entry.options == {} assert config_entry.title == "Open Thread Border Router" - assert config_entry.unique_id == otbr.DOMAIN + assert config_entry.unique_id == TEST_BORDER_AGENT_ID.hex() + + +@pytest.mark.usefixtures( + "get_active_dataset_tlvs", + "get_border_agent_id", + "get_extended_address", +) +async def test_user_flow_additional_entry_same_address( + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker +) -> None: + """Test more than a single entry is allowed.""" + mock_integration(hass, MockModule("hassio")) + + # Setup a config entry + config_entry = MockConfigEntry( + data={"url": "http://custom_url:1234"}, + domain=otbr.DOMAIN, + options={}, + title="Open Thread Border Router", + unique_id=TEST_BORDER_AGENT_ID.hex(), + ) + config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(config_entry.entry_id) + # Start user flow + url = "http://custom_url:1234" + aioclient_mock.get(f"{url}/node/dataset/active", text="aa") + result = await hass.config_entries.flow.async_init( + otbr.DOMAIN, context={"source": "user"} + ) + assert result["type"] is FlowResultType.FORM + assert result["errors"] == {} + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + { + "url": url, + }, + ) + assert result["type"] is FlowResultType.FORM + assert result["errors"] == {"base": "already_configured"} + + +@pytest.mark.usefixtures("get_border_agent_id") async def test_user_flow_router_not_setup( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: @@ -158,10 +280,11 @@ async def test_user_flow_router_not_setup( assert config_entry.data == expected_data assert config_entry.options == {} assert config_entry.title == "Open Thread Border Router" - assert config_entry.unique_id == otbr.DOMAIN + assert config_entry.unique_id == TEST_BORDER_AGENT_ID.hex() -async def test_user_flow_404( +@pytest.mark.usefixtures("get_border_agent_id") +async def test_user_flow_get_dataset_404( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the user flow.""" @@ -192,7 +315,30 @@ async def test_user_flow_404( aiohttp.ClientError, ], ) -async def test_user_flow_connect_error(hass: HomeAssistant, error) -> None: +async def test_user_flow_get_ba_id_connect_error( + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, error +) -> None: + """Test the user flow.""" + await _test_user_flow_connect_error(hass, "get_border_agent_id", error) + + +@pytest.mark.usefixtures("get_border_agent_id") +@pytest.mark.parametrize( + "error", + [ + TimeoutError, + python_otbr_api.OTBRError, + aiohttp.ClientError, + ], +) +async def test_user_flow_get_dataset_connect_error( + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, error +) -> None: + """Test the user flow.""" + await _test_user_flow_connect_error(hass, "get_active_dataset_tlvs", error) + + +async def _test_user_flow_connect_error(hass: HomeAssistant, func, error) -> None: """Test the user flow.""" result = await hass.config_entries.flow.async_init( otbr.DOMAIN, context={"source": "user"} @@ -201,7 +347,7 @@ async def test_user_flow_connect_error(hass: HomeAssistant, error) -> None: assert result["type"] is FlowResultType.FORM assert result["errors"] == {} - with patch("python_otbr_api.OTBR.get_active_dataset_tlvs", side_effect=error): + with patch(f"python_otbr_api.OTBR.{func}", side_effect=error): result = await hass.config_entries.flow.async_configure( result["flow_id"], { @@ -212,6 +358,7 @@ async def test_user_flow_connect_error(hass: HomeAssistant, error) -> None: assert result["errors"] == {"base": "cannot_connect"} +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, addon_info ) -> None: @@ -244,6 +391,7 @@ async def test_hassio_discovery_flow( assert config_entry.unique_id == HASSIO_DATA.uuid +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_yellow( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, addon_info ) -> None: @@ -301,6 +449,7 @@ async def test_hassio_discovery_flow_yellow( ), ], ) +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_sky_connect( device: str, title: str, @@ -346,6 +495,7 @@ async def test_hassio_discovery_flow_sky_connect( assert config_entry.unique_id == HASSIO_DATA.uuid +@pytest.mark.usefixtures("get_active_dataset_tlvs", "get_extended_address") async def test_hassio_discovery_flow_2x_addons( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, addon_info ) -> None: @@ -354,6 +504,8 @@ async def test_hassio_discovery_flow_2x_addons( url2 = "http://core-silabs-multiprotocol_2:8081" aioclient_mock.get(f"{url1}/node/dataset/active", text="aa") aioclient_mock.get(f"{url2}/node/dataset/active", text="bb") + aioclient_mock.get(f"{url1}/node/ba-id", json=TEST_BORDER_AGENT_ID.hex()) + aioclient_mock.get(f"{url2}/node/ba-id", json=TEST_BORDER_AGENT_ID_2.hex()) async def _addon_info(hass: HomeAssistant, slug: str) -> dict[str, Any]: await asyncio.sleep(0) @@ -387,18 +539,107 @@ async def _addon_info(hass: HomeAssistant, slug: str) -> dict[str, Any]: addon_info.side_effect = _addon_info - with patch( - "homeassistant.components.otbr.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result1 = await hass.config_entries.flow.async_init( - otbr.DOMAIN, context={"source": "hassio"}, data=HASSIO_DATA - ) - result2 = await hass.config_entries.flow.async_init( - otbr.DOMAIN, context={"source": "hassio"}, data=HASSIO_DATA_2 - ) + result1 = await hass.config_entries.flow.async_init( + otbr.DOMAIN, context={"source": "hassio"}, data=HASSIO_DATA + ) + result2 = await hass.config_entries.flow.async_init( + otbr.DOMAIN, context={"source": "hassio"}, data=HASSIO_DATA_2 + ) - results = [result1, result2] + results = [result1, result2] + + expected_data = { + "url": f"http://{HASSIO_DATA.config['host']}:{HASSIO_DATA.config['port']}", + } + expected_data_2 = { + "url": f"http://{HASSIO_DATA_2.config['host']}:{HASSIO_DATA_2.config['port']}", + } + + assert results[0]["type"] is FlowResultType.CREATE_ENTRY + assert ( + results[0]["title"] == "Home Assistant SkyConnect (Silicon Labs Multiprotocol)" + ) + assert results[0]["data"] == expected_data + assert results[0]["options"] == {} + + assert results[1]["type"] is FlowResultType.CREATE_ENTRY + assert ( + results[1]["title"] == "Home Assistant SkyConnect (Silicon Labs Multiprotocol)" + ) + assert results[1]["data"] == expected_data_2 + assert results[1]["options"] == {} + + assert len(hass.config_entries.async_entries(otbr.DOMAIN)) == 2 + + config_entry = hass.config_entries.async_entries(otbr.DOMAIN)[0] + assert config_entry.data == expected_data + assert config_entry.options == {} + assert ( + config_entry.title == "Home Assistant SkyConnect (Silicon Labs Multiprotocol)" + ) + assert config_entry.unique_id == HASSIO_DATA.uuid + + config_entry = hass.config_entries.async_entries(otbr.DOMAIN)[1] + assert config_entry.data == expected_data_2 + assert config_entry.options == {} + assert ( + config_entry.title == "Home Assistant SkyConnect (Silicon Labs Multiprotocol)" + ) + assert config_entry.unique_id == HASSIO_DATA_2.uuid + + +@pytest.mark.usefixtures("get_active_dataset_tlvs", "get_extended_address") +async def test_hassio_discovery_flow_2x_addons_same_ext_address( + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, addon_info +) -> None: + """Test the hassio discovery flow when the user has 2 addons with otbr support.""" + url1 = "http://core-silabs-multiprotocol:8081" + url2 = "http://core-silabs-multiprotocol_2:8081" + aioclient_mock.get(f"{url1}/node/dataset/active", text="aa") + aioclient_mock.get(f"{url2}/node/dataset/active", text="bb") + aioclient_mock.get(f"{url1}/node/ba-id", json=TEST_BORDER_AGENT_ID.hex()) + aioclient_mock.get(f"{url2}/node/ba-id", json=TEST_BORDER_AGENT_ID.hex()) + + async def _addon_info(hass: HomeAssistant, slug: str) -> dict[str, Any]: + await asyncio.sleep(0) + if slug == "otbr": + return { + "available": True, + "hostname": None, + "options": { + "device": ( + "/dev/serial/by-id/usb-Nabu_Casa_SkyConnect_v1.0_" + "9e2adbd75b8beb119fe564a0f320645d-if00-port0" + ) + }, + "state": None, + "update_available": False, + "version": None, + } + return { + "available": True, + "hostname": None, + "options": { + "device": ( + "/dev/serial/by-id/usb-Nabu_Casa_SkyConnect_v1.0_" + "9e2adbd75b8beb119fe564a0f320645d-if00-port1" + ) + }, + "state": None, + "update_available": False, + "version": None, + } + + addon_info.side_effect = _addon_info + + result1 = await hass.config_entries.flow.async_init( + otbr.DOMAIN, context={"source": "hassio"}, data=HASSIO_DATA + ) + result2 = await hass.config_entries.flow.async_init( + otbr.DOMAIN, context={"source": "hassio"}, data=HASSIO_DATA_2 + ) + + results = [result1, result2] expected_data = { "url": f"http://{HASSIO_DATA.config['host']}:{HASSIO_DATA.config['port']}", @@ -411,9 +652,8 @@ async def _addon_info(hass: HomeAssistant, slug: str) -> dict[str, Any]: assert results[0]["data"] == expected_data assert results[0]["options"] == {} assert results[1]["type"] is FlowResultType.ABORT - assert results[1]["reason"] == "single_instance_allowed" + assert results[1]["reason"] == "already_configured" assert len(hass.config_entries.async_entries(otbr.DOMAIN)) == 1 - assert len(mock_setup_entry.mock_calls) == 1 config_entry = hass.config_entries.async_entries(otbr.DOMAIN)[0] assert config_entry.data == expected_data @@ -424,6 +664,7 @@ async def _addon_info(hass: HomeAssistant, slug: str) -> dict[str, Any]: assert config_entry.unique_id == HASSIO_DATA.uuid +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_router_not_setup( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, addon_info ) -> None: @@ -481,6 +722,7 @@ async def test_hassio_discovery_flow_router_not_setup( assert config_entry.unique_id == HASSIO_DATA.uuid +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_router_not_setup_has_preferred( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, addon_info ) -> None: @@ -533,6 +775,7 @@ async def test_hassio_discovery_flow_router_not_setup_has_preferred( assert config_entry.unique_id == HASSIO_DATA.uuid +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_router_not_setup_has_preferred_2( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, @@ -596,6 +839,7 @@ async def test_hassio_discovery_flow_router_not_setup_has_preferred_2( assert config_entry.unique_id == HASSIO_DATA.uuid +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_404( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: @@ -610,6 +854,7 @@ async def test_hassio_discovery_flow_404( assert result["reason"] == "unknown" +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_new_port_missing_unique_id( hass: HomeAssistant, ) -> None: @@ -633,7 +878,7 @@ async def test_hassio_discovery_flow_new_port_missing_unique_id( ) assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "single_instance_allowed" + assert result["reason"] == "already_configured" expected_data = { "url": f"http://{HASSIO_DATA.config['host']}:{HASSIO_DATA.config['port']}", @@ -642,6 +887,7 @@ async def test_hassio_discovery_flow_new_port_missing_unique_id( assert config_entry.data == expected_data +@pytest.mark.usefixtures("get_border_agent_id") async def test_hassio_discovery_flow_new_port(hass: HomeAssistant) -> None: """Test the port can be updated.""" mock_integration(hass, MockModule("hassio")) @@ -664,7 +910,7 @@ async def test_hassio_discovery_flow_new_port(hass: HomeAssistant) -> None: ) assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "single_instance_allowed" + assert result["reason"] == "already_configured" expected_data = { "url": f"http://{HASSIO_DATA.config['host']}:{HASSIO_DATA.config['port']}", @@ -673,6 +919,12 @@ async def test_hassio_discovery_flow_new_port(hass: HomeAssistant) -> None: assert config_entry.data == expected_data +@pytest.mark.usefixtures( + "addon_info", + "get_active_dataset_tlvs", + "get_border_agent_id", + "get_extended_address", +) async def test_hassio_discovery_flow_new_port_other_addon(hass: HomeAssistant) -> None: """Test the port is not updated if we get data for another addon hosting OTBR.""" mock_integration(hass, MockModule("hassio")) @@ -691,22 +943,34 @@ async def test_hassio_discovery_flow_new_port_other_addon(hass: HomeAssistant) - otbr.DOMAIN, context={"source": "hassio"}, data=HASSIO_DATA ) - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "single_instance_allowed" + # Another entry will be created + assert result["type"] is FlowResultType.CREATE_ENTRY - # Make sure the data was not updated + # Make sure the data of the existing entry was not updated expected_data = { "url": f"http://openthread_border_router:{HASSIO_DATA.config['port']+1}", } - config_entry = hass.config_entries.async_entries(otbr.DOMAIN)[0] + config_entry = hass.config_entries.async_get_entry(config_entry.entry_id) assert config_entry.data == expected_data -@pytest.mark.parametrize(("source", "data"), [("hassio", HASSIO_DATA), ("user", None)]) -async def test_config_flow_single_entry( - hass: HomeAssistant, source: str, data: Any +@pytest.mark.parametrize( + ("source", "data", "expected_result"), + [ + ("hassio", HASSIO_DATA, FlowResultType.CREATE_ENTRY), + ("user", None, FlowResultType.FORM), + ], +) +@pytest.mark.usefixtures( + "addon_info", + "get_active_dataset_tlvs", + "get_border_agent_id", + "get_extended_address", +) +async def test_config_flow_additional_entry( + hass: HomeAssistant, source: str, data: Any, expected_result: FlowResultType ) -> None: - """Test only a single entry is allowed.""" + """Test more than a single entry is allowed.""" mock_integration(hass, MockModule("hassio")) # Setup the config entry @@ -719,13 +983,11 @@ async def test_config_flow_single_entry( config_entry.add_to_hass(hass) with patch( - "homeassistant.components.homeassistant_yellow.async_setup_entry", + "homeassistant.components.otbr.async_setup_entry", return_value=True, - ) as mock_setup_entry: + ): result = await hass.config_entries.flow.async_init( otbr.DOMAIN, context={"source": source}, data=data ) - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "single_instance_allowed" - mock_setup_entry.assert_not_called() + assert result["type"] is expected_result diff --git a/tests/components/otbr/test_init.py b/tests/components/otbr/test_init.py index 86bab71cbdab79..ca1cbd6483b616 100644 --- a/tests/components/otbr/test_init.py +++ b/tests/components/otbr/test_init.py @@ -11,6 +11,7 @@ from homeassistant.components import otbr, thread from homeassistant.components.thread import discovery +from homeassistant.config_entries import SOURCE_HASSIO, SOURCE_USER from homeassistant.core import HomeAssistant from homeassistant.helpers import issue_registry as ir from homeassistant.setup import async_setup_component @@ -18,7 +19,6 @@ from . import ( BASE_URL, CONFIG_ENTRY_DATA_MULTIPAN, - CONFIG_ENTRY_DATA_THREAD, DATASET_CH15, DATASET_CH16, DATASET_INSECURE_NW_KEY, @@ -71,6 +71,7 @@ async def mock_add_service_listener(type_: str, listener: Any): domain=otbr.DOMAIN, options={}, title="My OTBR", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) @@ -138,6 +139,7 @@ async def test_import_share_radio_channel_collision( domain=otbr.DOMAIN, options={}, title="My OTBR", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) with ( @@ -177,6 +179,7 @@ async def test_import_share_radio_no_channel_collision( domain=otbr.DOMAIN, options={}, title="My OTBR", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) with ( @@ -214,6 +217,7 @@ async def test_import_insecure_dataset( domain=otbr.DOMAIN, options={}, title="My OTBR", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) with ( @@ -252,6 +256,7 @@ async def test_config_entry_not_ready( domain=otbr.DOMAIN, options={}, title="My OTBR", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) get_active_dataset_tlvs.side_effect = error @@ -268,6 +273,7 @@ async def test_border_agent_id_not_supported( domain=otbr.DOMAIN, options={}, title="My OTBR", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) get_border_agent_id.side_effect = python_otbr_api.GetBorderAgentIdNotSupportedError @@ -281,6 +287,7 @@ async def test_config_entry_update(hass: HomeAssistant) -> None: domain=otbr.DOMAIN, options={}, title="My OTBR", + unique_id=TEST_BORDER_AGENT_EXTENDED_ADDRESS.hex(), ) config_entry.add_to_hass(hass) mock_api = MagicMock() @@ -314,25 +321,33 @@ async def test_remove_entry( await hass.config_entries.async_remove(config_entry.entry_id) -async def test_remove_extra_entries( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker +@pytest.mark.parametrize( + ("source", "unique_id", "updated_unique_id"), + [ + (SOURCE_HASSIO, None, None), + (SOURCE_HASSIO, "abcd", "abcd"), + (SOURCE_USER, None, TEST_BORDER_AGENT_ID.hex()), + (SOURCE_USER, "abcd", TEST_BORDER_AGENT_ID.hex()), + ], +) +async def test_update_unique_id( + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + source: str, + unique_id: str | None, + updated_unique_id: str | None, ) -> None: - """Test we remove additional config entries.""" + """Test we update the unique id if extended address has changed.""" - config_entry1 = MockConfigEntry( + config_entry = MockConfigEntry( data=CONFIG_ENTRY_DATA_MULTIPAN, domain=otbr.DOMAIN, options={}, + source=source, title="Open Thread Border Router", + unique_id=unique_id, ) - config_entry2 = MockConfigEntry( - data=CONFIG_ENTRY_DATA_THREAD, - domain=otbr.DOMAIN, - options={}, - title="Open Thread Border Router", - ) - config_entry1.add_to_hass(hass) - config_entry2.add_to_hass(hass) - assert len(hass.config_entries.async_entries(otbr.DOMAIN)) == 2 + config_entry.add_to_hass(hass) assert await async_setup_component(hass, otbr.DOMAIN, {}) - assert len(hass.config_entries.async_entries(otbr.DOMAIN)) == 1 + config_entry = hass.config_entries.async_get_entry(config_entry.entry_id) + assert config_entry.unique_id == updated_unique_id diff --git a/tests/components/otbr/test_silabs_multiprotocol.py b/tests/components/otbr/test_silabs_multiprotocol.py index e842f40ad4c596..01b1ab63f56cb5 100644 --- a/tests/components/otbr/test_silabs_multiprotocol.py +++ b/tests/components/otbr/test_silabs_multiprotocol.py @@ -5,7 +5,6 @@ import pytest from python_otbr_api import ActiveDataSet, tlv_parser -from homeassistant.components import otbr from homeassistant.components.otbr import ( silabs_multiprotocol as otbr_silabs_multiprotocol, ) @@ -127,10 +126,11 @@ async def test_async_change_channel_no_otbr(hass: HomeAssistant) -> None: async def test_async_change_channel_non_matching_url( - hass: HomeAssistant, otbr_config_entry_multipan + hass: HomeAssistant, otbr_config_entry_multipan: str ) -> None: """Test async_change_channel when otbr is not configured.""" - hass.data[otbr.DATA_OTBR].url = OTBR_NON_MULTIPAN_URL + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) + config_entry.runtime_data.url = OTBR_NON_MULTIPAN_URL with patch("python_otbr_api.OTBR.set_channel") as mock_set_channel: await otbr_silabs_multiprotocol.async_change_channel(hass, 16, delay=0) mock_set_channel.assert_not_awaited() @@ -184,10 +184,11 @@ async def test_async_get_channel_no_otbr(hass: HomeAssistant) -> None: async def test_async_get_channel_non_matching_url( - hass: HomeAssistant, otbr_config_entry_multipan + hass: HomeAssistant, otbr_config_entry_multipan: str ) -> None: """Test async_change_channel when otbr is not configured.""" - hass.data[otbr.DATA_OTBR].url = OTBR_NON_MULTIPAN_URL + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) + config_entry.runtime_data.url = OTBR_NON_MULTIPAN_URL with patch("python_otbr_api.OTBR.get_active_dataset") as mock_get_active_dataset: assert await otbr_silabs_multiprotocol.async_get_channel(hass) is None mock_get_active_dataset.assert_not_awaited() @@ -198,10 +199,11 @@ async def test_async_get_channel_non_matching_url( [(OTBR_MULTIPAN_URL, True), (OTBR_NON_MULTIPAN_URL, False)], ) async def test_async_using_multipan( - hass: HomeAssistant, otbr_config_entry_multipan, url: str, expected: bool + hass: HomeAssistant, otbr_config_entry_multipan: str, url: str, expected: bool ) -> None: """Test async_change_channel when otbr is not configured.""" - hass.data[otbr.DATA_OTBR].url = url + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) + config_entry.runtime_data.url = url assert await otbr_silabs_multiprotocol.async_using_multipan(hass) is expected @@ -213,8 +215,9 @@ async def test_async_using_multipan_no_otbr(hass: HomeAssistant) -> None: async def test_async_using_multipan_non_matching_url( - hass: HomeAssistant, otbr_config_entry_multipan + hass: HomeAssistant, otbr_config_entry_multipan: str ) -> None: """Test async_change_channel when otbr is not configured.""" - hass.data[otbr.DATA_OTBR].url = OTBR_NON_MULTIPAN_URL + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) + config_entry.runtime_data.url = OTBR_NON_MULTIPAN_URL assert await otbr_silabs_multiprotocol.async_using_multipan(hass) is False diff --git a/tests/components/otbr/test_util.py b/tests/components/otbr/test_util.py index ec325b8819e896..0ed3041bea84ce 100644 --- a/tests/components/otbr/test_util.py +++ b/tests/components/otbr/test_util.py @@ -1,6 +1,6 @@ """Test OTBR Utility functions.""" -from unittest.mock import patch +from unittest.mock import AsyncMock, patch import pytest import python_otbr_api @@ -31,24 +31,37 @@ async def test_get_allowed_channel( assert await otbr.util.get_allowed_channel(hass, OTBR_NON_MULTIPAN_URL) is None -async def test_factory_reset(hass: HomeAssistant, otbr_config_entry_multipan) -> None: +async def test_factory_reset( + hass: HomeAssistant, + otbr_config_entry_multipan: str, + get_border_agent_id: AsyncMock, +) -> None: """Test factory_reset.""" + new_ba_id = b"new_ba_id" + get_border_agent_id.return_value = new_ba_id + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) + assert config_entry.unique_id != new_ba_id.hex() with ( patch("python_otbr_api.OTBR.factory_reset") as factory_reset_mock, patch( "python_otbr_api.OTBR.delete_active_dataset" ) as delete_active_dataset_mock, ): - await hass.data[otbr.DATA_OTBR].factory_reset() + await config_entry.runtime_data.factory_reset(hass) delete_active_dataset_mock.assert_not_called() factory_reset_mock.assert_called_once_with() + # Check the unique_id is updated + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) + assert config_entry.unique_id == new_ba_id.hex() + async def test_factory_reset_not_supported( - hass: HomeAssistant, otbr_config_entry_multipan + hass: HomeAssistant, otbr_config_entry_multipan: str ) -> None: """Test factory_reset.""" + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) with ( patch( "python_otbr_api.OTBR.factory_reset", @@ -58,16 +71,17 @@ async def test_factory_reset_not_supported( "python_otbr_api.OTBR.delete_active_dataset" ) as delete_active_dataset_mock, ): - await hass.data[otbr.DATA_OTBR].factory_reset() + await config_entry.runtime_data.factory_reset(hass) delete_active_dataset_mock.assert_called_once_with() factory_reset_mock.assert_called_once_with() async def test_factory_reset_error_1( - hass: HomeAssistant, otbr_config_entry_multipan + hass: HomeAssistant, otbr_config_entry_multipan: str ) -> None: """Test factory_reset.""" + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) with ( patch( "python_otbr_api.OTBR.factory_reset", @@ -80,16 +94,17 @@ async def test_factory_reset_error_1( HomeAssistantError, ), ): - await hass.data[otbr.DATA_OTBR].factory_reset() + await config_entry.runtime_data.factory_reset(hass) delete_active_dataset_mock.assert_not_called() factory_reset_mock.assert_called_once_with() async def test_factory_reset_error_2( - hass: HomeAssistant, otbr_config_entry_multipan + hass: HomeAssistant, otbr_config_entry_multipan: str ) -> None: """Test factory_reset.""" + config_entry = hass.config_entries.async_get_entry(otbr_config_entry_multipan) with ( patch( "python_otbr_api.OTBR.factory_reset", @@ -103,7 +118,7 @@ async def test_factory_reset_error_2( HomeAssistantError, ), ): - await hass.data[otbr.DATA_OTBR].factory_reset() + await config_entry.runtime_data.factory_reset(hass) delete_active_dataset_mock.assert_called_once_with() factory_reset_mock.assert_called_once_with() From ea04269c49f4711813a9328022721cf4e22f89ab Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:48:39 +0200 Subject: [PATCH 13/67] Improve test coverage for nextcloud (#123148) * add first data driven tests * remove unused mock * test unique_id migration * test errors during setup * test error during data update * test update entity * system_versionis always available * make use of snapshot_platform helper * use parametrize test for coordinator update errors * apply suggestions * don't touch internals on coordinator tests * rework to use async_get_or_create instead of mock_registry --- homeassistant/components/nextcloud/update.py | 12 +- tests/components/nextcloud/__init__.py | 37 + tests/components/nextcloud/conftest.py | 10 +- tests/components/nextcloud/const.py | 182 + .../snapshots/test_binary_sensor.ambr | 277 ++ .../nextcloud/snapshots/test_config_flow.ambr | 4 +- .../nextcloud/snapshots/test_sensor.ambr | 3973 +++++++++++++++++ .../nextcloud/snapshots/test_update.ambr | 57 + .../nextcloud/test_binary_sensor.py | 33 + .../components/nextcloud/test_config_flow.py | 35 +- .../components/nextcloud/test_coordinator.py | 69 + tests/components/nextcloud/test_init.py | 95 + tests/components/nextcloud/test_sensor.py | 31 + tests/components/nextcloud/test_update.py | 80 + 14 files changed, 4855 insertions(+), 40 deletions(-) create mode 100644 tests/components/nextcloud/const.py create mode 100644 tests/components/nextcloud/snapshots/test_binary_sensor.ambr create mode 100644 tests/components/nextcloud/snapshots/test_sensor.ambr create mode 100644 tests/components/nextcloud/snapshots/test_update.ambr create mode 100644 tests/components/nextcloud/test_binary_sensor.py create mode 100644 tests/components/nextcloud/test_coordinator.py create mode 100644 tests/components/nextcloud/test_init.py create mode 100644 tests/components/nextcloud/test_sensor.py create mode 100644 tests/components/nextcloud/test_update.py diff --git a/homeassistant/components/nextcloud/update.py b/homeassistant/components/nextcloud/update.py index 8c292e1bba288c..5b9de52ad1d51a 100644 --- a/homeassistant/components/nextcloud/update.py +++ b/homeassistant/components/nextcloud/update.py @@ -32,12 +32,12 @@ class NextcloudUpdateSensor(NextcloudEntity, UpdateEntity): """Represents a Nextcloud update entity.""" @property - def installed_version(self) -> str | None: + def installed_version(self) -> str: """Version installed and in use.""" - return self.coordinator.data.get("system_version") + return self.coordinator.data["system_version"] @property - def latest_version(self) -> str | None: + def latest_version(self) -> str: """Latest version available for install.""" return self.coordinator.data.get( "update_available_version", self.installed_version @@ -46,7 +46,5 @@ def latest_version(self) -> str | None: @property def release_url(self) -> str | None: """URL to the full release notes of the latest version available.""" - if self.latest_version: - ver = "-".join(self.latest_version.split(".")[:3]) - return f"https://nextcloud.com/changelog/#{ver}" - return None + ver = "-".join(self.latest_version.split(".")[:3]) + return f"https://nextcloud.com/changelog/#{ver}" diff --git a/tests/components/nextcloud/__init__.py b/tests/components/nextcloud/__init__.py index e2102ed8c25071..4bc5a0416505ba 100644 --- a/tests/components/nextcloud/__init__.py +++ b/tests/components/nextcloud/__init__.py @@ -1 +1,38 @@ """Tests for the Nextcloud integration.""" + +from unittest.mock import Mock, patch + +from homeassistant.components.nextcloud.const import DOMAIN +from homeassistant.const import CONF_URL +from homeassistant.core import HomeAssistant + +from .const import MOCKED_ENTRY_ID + +from tests.common import MockConfigEntry + + +def mock_config_entry(config: dict) -> MockConfigEntry: + """Return a mocked config entry.""" + return MockConfigEntry( + domain=DOMAIN, title=config[CONF_URL], data=config, entry_id=MOCKED_ENTRY_ID + ) + + +async def init_integration( + hass: HomeAssistant, config: dict, data: dict +) -> MockConfigEntry: + """Set up the nextcloud integration.""" + entry = mock_config_entry(config) + entry.add_to_hass(hass) + + with ( + patch( + "homeassistant.components.nextcloud.NextcloudMonitor", + ) as mock_nextcloud_monitor, + ): + mock_nextcloud_monitor.update = Mock(return_value=True) + mock_nextcloud_monitor.return_value.data = data + assert await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + + return entry diff --git a/tests/components/nextcloud/conftest.py b/tests/components/nextcloud/conftest.py index cf3eda55fe15a3..3234e3773b8b5e 100644 --- a/tests/components/nextcloud/conftest.py +++ b/tests/components/nextcloud/conftest.py @@ -1,19 +1,11 @@ """Fixtrues for the Nextcloud integration tests.""" from collections.abc import Generator -from unittest.mock import AsyncMock, Mock, patch +from unittest.mock import AsyncMock, patch import pytest -@pytest.fixture -def mock_nextcloud_monitor() -> Mock: - """Mock of NextcloudMonitor.""" - return Mock( - update=Mock(return_value=True), - ) - - @pytest.fixture def mock_setup_entry() -> Generator[AsyncMock]: """Override async_setup_entry.""" diff --git a/tests/components/nextcloud/const.py b/tests/components/nextcloud/const.py new file mode 100644 index 00000000000000..2d328292b6f5b1 --- /dev/null +++ b/tests/components/nextcloud/const.py @@ -0,0 +1,182 @@ +"""Constants for nextcloud tests.""" + +from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME, CONF_VERIFY_SSL + +MOCKED_ENTRY_ID = "1234567890abcdef" + +VALID_CONFIG = { + CONF_URL: "https://my.nc_url.local", + CONF_USERNAME: "nc_user", + CONF_PASSWORD: "nc_pass", + CONF_VERIFY_SSL: True, +} + +NC_DATA = { + "nextcloud": { + "system": { + "version": "28.0.4.1", + "theme": "", + "enable_avatars": "yes", + "enable_previews": "yes", + "memcache.local": "\\OC\\Memcache\\APCu", + "memcache.distributed": "none", + "filelocking.enabled": "yes", + "memcache.locking": "none", + "debug": "no", + "freespace": 32769138688, + "cpuload": [2.06640625, 1.58447265625, 1.45263671875], + "mem_total": 30728192, + "mem_free": 6753280, + "swap_total": 10484736, + "swap_free": 10484736, + "apps": { + "num_installed": 41, + "num_updates_available": 0, + "app_updates": [], + }, + "update": {"lastupdatedat": 1713048517, "available": False}, + }, + "storage": { + "num_users": 2, + "num_files": 6783, + "num_storages": 4, + "num_storages_local": 1, + "num_storages_home": 2, + "num_storages_other": 1, + }, + "shares": { + "num_shares": 2, + "num_shares_user": 0, + "num_shares_groups": 0, + "num_shares_link": 2, + "num_shares_mail": 0, + "num_shares_room": 0, + "num_shares_link_no_password": 2, + "num_fed_shares_sent": 0, + "num_fed_shares_received": 1, + "permissions_3_17": 1, + "permissions_3_31": 1, + }, + }, + "server": { + "webserver": "Apache/2.4.57 (Debian)", + "php": { + "version": "8.2.18", + "memory_limit": 536870912, + "max_execution_time": 3600, + "upload_max_filesize": 536870912, + "opcache_revalidate_freq": 60, + "opcache": { + "opcache_enabled": True, + "cache_full": False, + "restart_pending": False, + "restart_in_progress": False, + "memory_usage": { + "used_memory": 72027112, + "free_memory": 62190616, + "wasted_memory": 0, + "current_wasted_percentage": 0, + }, + "interned_strings_usage": { + "buffer_size": 33554432, + "used_memory": 12630360, + "free_memory": 20924072, + "number_of_strings": 69242, + }, + "opcache_statistics": { + "num_cached_scripts": 1406, + "num_cached_keys": 2654, + "max_cached_keys": 16229, + "hits": 9739971, + "start_time": 1722222008, + "last_restart_time": 0, + "oom_restarts": 0, + "hash_restarts": 0, + "manual_restarts": 0, + "misses": 1406, + "blacklist_misses": 0, + "blacklist_miss_ratio": 0, + "opcache_hit_rate": 99.9855667222406, + }, + "jit": { + "enabled": True, + "on": True, + "kind": 5, + "opt_level": 5, + "opt_flags": 6, + "buffer_size": 134217712, + "buffer_free": 133190688, + }, + }, + "apcu": { + "cache": { + "num_slots": 4099, + "ttl": 0, + "num_hits": 590911, + "num_misses": 55250, + "num_inserts": 55421, + "num_entries": 102, + "expunges": 0, + "start_time": 1722222008, + "mem_size": 175296, + "memory_type": "mmap", + }, + "sma": {"num_seg": 1, "seg_size": 33554312, "avail_mem": 33342368}, + }, + "extensions": [ + "Core", + "date", + "libxml", + "openssl", + "pcre", + "sqlite3", + "zlib", + "ctype", + "curl", + "dom", + "fileinfo", + "filter", + "hash", + "iconv", + "json", + "mbstring", + "SPL", + "session", + "PDO", + "pdo_sqlite", + "standard", + "posix", + "random", + "Reflection", + "Phar", + "SimpleXML", + "tokenizer", + "xml", + "xmlreader", + "xmlwriter", + "mysqlnd", + "apache2handler", + "apcu", + "bcmath", + "exif", + "ftp", + "gd", + "gmp", + "imagick", + "intl", + "ldap", + "memcached", + "pcntl", + "pdo_mysql", + "pdo_pgsql", + "redis", + "sodium", + "sysvsem", + "zip", + "Zend OPcache", + ], + }, + "database": {"type": "sqlite3", "version": "3.40.1", "size": "4784128"}, + }, + "activeUsers": {"last5minutes": 0, "last1hour": 0, "last24hours": 0}, +} diff --git a/tests/components/nextcloud/snapshots/test_binary_sensor.ambr b/tests/components/nextcloud/snapshots/test_binary_sensor.ambr new file mode 100644 index 00000000000000..1831419af520f8 --- /dev/null +++ b/tests/components/nextcloud/snapshots/test_binary_sensor.ambr @@ -0,0 +1,277 @@ +# serializer version: 1 +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_avatars_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.my_nc_url_local_avatars_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Avatars enabled', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_enable_avatars', + 'unique_id': '1234567890abcdef#system_enable_avatars', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_avatars_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Avatars enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.my_nc_url_local_avatars_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_debug_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.my_nc_url_local_debug_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Debug enabled', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_debug', + 'unique_id': '1234567890abcdef#system_debug', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_debug_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Debug enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.my_nc_url_local_debug_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_filelocking_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.my_nc_url_local_filelocking_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Filelocking enabled', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_filelocking_enabled', + 'unique_id': '1234567890abcdef#system_filelocking.enabled', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_filelocking_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Filelocking enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.my_nc_url_local_filelocking_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_jit_active-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.my_nc_url_local_jit_active', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'JIT active', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_jit_on', + 'unique_id': '1234567890abcdef#jit_on', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_jit_active-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local JIT active', + }), + 'context': , + 'entity_id': 'binary_sensor.my_nc_url_local_jit_active', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_jit_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.my_nc_url_local_jit_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'JIT enabled', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_jit_enabled', + 'unique_id': '1234567890abcdef#jit_enabled', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_jit_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local JIT enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.my_nc_url_local_jit_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_previews_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.my_nc_url_local_previews_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Previews enabled', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_enable_previews', + 'unique_id': '1234567890abcdef#system_enable_previews', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[binary_sensor.my_nc_url_local_previews_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Previews enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.my_nc_url_local_previews_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- diff --git a/tests/components/nextcloud/snapshots/test_config_flow.ambr b/tests/components/nextcloud/snapshots/test_config_flow.ambr index 06c4ce216db37a..e87db0a25c0d54 100644 --- a/tests/components/nextcloud/snapshots/test_config_flow.ambr +++ b/tests/components/nextcloud/snapshots/test_config_flow.ambr @@ -2,7 +2,7 @@ # name: test_reauth dict({ 'password': 'other_password', - 'url': 'nc_url', + 'url': 'https://my.nc_url.local', 'username': 'other_user', 'verify_ssl': True, }) @@ -10,7 +10,7 @@ # name: test_user_create_entry dict({ 'password': 'nc_pass', - 'url': 'nc_url', + 'url': 'https://my.nc_url.local', 'username': 'nc_user', 'verify_ssl': True, }) diff --git a/tests/components/nextcloud/snapshots/test_sensor.ambr b/tests/components/nextcloud/snapshots/test_sensor.ambr new file mode 100644 index 00000000000000..c49ba3496dabbf --- /dev/null +++ b/tests/components/nextcloud/snapshots/test_sensor.ambr @@ -0,0 +1,3973 @@ +# serializer version: 1 +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_active_users_last_5_minutes-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_active_users_last_5_minutes', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of active users last 5 minutes', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_activeusers_last5minutes', + 'unique_id': '1234567890abcdef#activeUsers_last5minutes', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_active_users_last_5_minutes-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of active users last 5 minutes', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_active_users_last_5_minutes', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_active_users_last_day-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_active_users_last_day', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of active users last day', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_activeusers_last24hours', + 'unique_id': '1234567890abcdef#activeUsers_last24hours', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_active_users_last_day-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of active users last day', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_active_users_last_day', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_active_users_last_hour-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_active_users_last_hour', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of active users last hour', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_activeusers_last1hour', + 'unique_id': '1234567890abcdef#activeUsers_last1hour', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_active_users_last_hour-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of active users last hour', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_active_users_last_hour', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_files-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_amount_of_files', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of files', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_storage_num_files', + 'unique_id': '1234567890abcdef#storage_num_files', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_files-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of files', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_files', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '6783', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_group_shares-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_group_shares', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of group shares', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_shares_groups', + 'unique_id': '1234567890abcdef#shares_num_shares_groups', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_group_shares-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of group shares', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_group_shares', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_link_shares-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_link_shares', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of link shares', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_shares_link', + 'unique_id': '1234567890abcdef#shares_num_shares_link', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_link_shares-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of link shares', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_link_shares', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_local_storages-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_local_storages', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of local storages', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_storage_num_storages_local', + 'unique_id': '1234567890abcdef#storage_num_storages_local', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_local_storages-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of local storages', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_local_storages', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_mail_shares-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_mail_shares', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of mail shares', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_shares_mail', + 'unique_id': '1234567890abcdef#shares_num_shares_mail', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_mail_shares-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of mail shares', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_mail_shares', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_other_storages-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_other_storages', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of other storages', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_storage_num_storages_other', + 'unique_id': '1234567890abcdef#storage_num_storages_other', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_other_storages-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of other storages', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_other_storages', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_passwordless_link_shares-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_passwordless_link_shares', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of passwordless link shares', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_shares_link_no_password', + 'unique_id': '1234567890abcdef#shares_num_shares_link_no_password', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_passwordless_link_shares-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of passwordless link shares', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_passwordless_link_shares', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_room_shares-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_room_shares', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of room shares', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_shares_room', + 'unique_id': '1234567890abcdef#shares_num_shares_room', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_room_shares-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of room shares', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_room_shares', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_shares-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_amount_of_shares', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of shares', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_shares', + 'unique_id': '1234567890abcdef#shares_num_shares', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_shares-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of shares', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_shares', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_shares_received-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_shares_received', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of shares received', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_fed_shares_received', + 'unique_id': '1234567890abcdef#shares_num_fed_shares_received', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_shares_received-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of shares received', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_shares_received', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_shares_sent-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_shares_sent', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of shares sent', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_fed_shares_sent', + 'unique_id': '1234567890abcdef#shares_num_fed_shares_sent', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_shares_sent-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of shares sent', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_shares_sent', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_storages-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_amount_of_storages', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of storages', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_storage_num_storages', + 'unique_id': '1234567890abcdef#storage_num_storages', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_storages-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of storages', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_storages', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '4', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_storages_at_home-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_storages_at_home', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of storages at home', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_storage_num_storages_home', + 'unique_id': '1234567890abcdef#storage_num_storages_home', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_storages_at_home-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of storages at home', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_storages_at_home', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_user-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_amount_of_user', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of user', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_storage_num_users', + 'unique_id': '1234567890abcdef#storage_num_users', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_user-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of user', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_user', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_user_shares-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_user_shares', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Amount of user shares', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_shares_num_shares_user', + 'unique_id': '1234567890abcdef#shares_num_shares_user', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_amount_of_user_shares-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Amount of user shares', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_amount_of_user_shares', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_apps_installed-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_apps_installed', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Apps installed', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_apps_num_installed', + 'unique_id': '1234567890abcdef#system_apps_num_installed', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_apps_installed-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Apps installed', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_apps_installed', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '41', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_expunges-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_expunges', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache expunges', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_expunges', + 'unique_id': '1234567890abcdef#cache_expunges', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_expunges-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache expunges', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_expunges', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_memory_type', + 'unique_id': '1234567890abcdef#cache_memory_type', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache memory', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'mmap', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_memory_size-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_memory_size', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Cache memory size', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_mem_size', + 'unique_id': '1234567890abcdef#cache_mem_size', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_memory_size-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Cache memory size', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_memory_size', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0.175296', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_entires-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_entires', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache number of entires', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_num_entries', + 'unique_id': '1234567890abcdef#cache_num_entries', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_entires-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache number of entires', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_entires', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '102', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_hits-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_hits', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache number of hits', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_num_hits', + 'unique_id': '1234567890abcdef#cache_num_hits', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_hits-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache number of hits', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_hits', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '590911', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_inserts-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_inserts', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache number of inserts', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_num_inserts', + 'unique_id': '1234567890abcdef#cache_num_inserts', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_inserts-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache number of inserts', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_inserts', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '55421', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_misses-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_misses', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache number of misses', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_num_misses', + 'unique_id': '1234567890abcdef#cache_num_misses', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_misses-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache number of misses', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_misses', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '55250', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_slots-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_slots', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache number of slots', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_num_slots', + 'unique_id': '1234567890abcdef#cache_num_slots', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_number_of_slots-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache number of slots', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_number_of_slots', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '4099', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_start_time-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_start_time', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Cache start time', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_start_time', + 'unique_id': '1234567890abcdef#cache_start_time', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_start_time-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'timestamp', + 'friendly_name': 'my.nc_url.local Cache start time', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_start_time', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2024-07-29T03:00:08+00:00', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_ttl-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_cache_ttl', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cache ttl', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_cache_ttl', + 'unique_id': '1234567890abcdef#cache_ttl', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cache_ttl-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Cache ttl', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cache_ttl', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cpu_load_last_15_minutes-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_cpu_load_last_15_minutes', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'CPU Load last 15 minutes', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_cpuload_15', + 'unique_id': '1234567890abcdef#system_cpuload_15', + 'unit_of_measurement': 'load', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cpu_load_last_15_minutes-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local CPU Load last 15 minutes', + 'unit_of_measurement': 'load', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cpu_load_last_15_minutes', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1.45263671875', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cpu_load_last_1_minute-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_cpu_load_last_1_minute', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'CPU Load last 1 minute', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_cpuload_1', + 'unique_id': '1234567890abcdef#system_cpuload_1', + 'unit_of_measurement': 'load', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cpu_load_last_1_minute-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local CPU Load last 1 minute', + 'unit_of_measurement': 'load', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cpu_load_last_1_minute', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2.06640625', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cpu_load_last_5_minutes-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_cpu_load_last_5_minutes', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'CPU Load last 5 minutes', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_cpuload_5', + 'unique_id': '1234567890abcdef#system_cpuload_5', + 'unit_of_measurement': 'load', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_cpu_load_last_5_minutes-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local CPU Load last 5 minutes', + 'unit_of_measurement': 'load', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_cpu_load_last_5_minutes', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1.58447265625', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_database_size-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_database_size', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Database size', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_database_size', + 'unique_id': '1234567890abcdef#database_size', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_database_size-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Database size', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_database_size', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '4.784128', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_database_type-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_database_type', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Database type', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_database_type', + 'unique_id': '1234567890abcdef#database_type', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_database_type-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Database type', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_database_type', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'sqlite3', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_database_version-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_database_version', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Database version', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_database_version', + 'unique_id': '1234567890abcdef#database_version', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_database_version-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Database version', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_database_version', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '3.40.1', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_free_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_free_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Free memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_mem_free', + 'unique_id': '1234567890abcdef#system_mem_free', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_free_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Free memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_free_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '6.75328', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_free_space-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_free_space', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Free space', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_freespace', + 'unique_id': '1234567890abcdef#system_freespace', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_free_space-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Free space', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_free_space', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '32.769138688', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_free_swap_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_free_swap_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Free swap memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_swap_free', + 'unique_id': '1234567890abcdef#system_swap_free', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_free_swap_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Free swap memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_free_swap_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '10.484736', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_buffer_size-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_interned_buffer_size', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Interned buffer size', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_interned_strings_usage_buffer_size', + 'unique_id': '1234567890abcdef#interned_strings_usage_buffer_size', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_buffer_size-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Interned buffer size', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_interned_buffer_size', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '33.554432', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_free_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_interned_free_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Interned free memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_interned_strings_usage_free_memory', + 'unique_id': '1234567890abcdef#interned_strings_usage_free_memory', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_free_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Interned free memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_interned_free_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '20.924072', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_number_of_strings-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_interned_number_of_strings', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Interned number of strings', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_interned_strings_usage_number_of_strings', + 'unique_id': '1234567890abcdef#interned_strings_usage_number_of_strings', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_number_of_strings-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Interned number of strings', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_interned_number_of_strings', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '69242', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_used_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_interned_used_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Interned used memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_interned_strings_usage_used_memory', + 'unique_id': '1234567890abcdef#interned_strings_usage_used_memory', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_interned_used_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Interned used memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_interned_used_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '12.63036', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_buffer_free-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_jit_buffer_free', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'JIT buffer free', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_jit_buffer_free', + 'unique_id': '1234567890abcdef#jit_buffer_free', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_buffer_free-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local JIT buffer free', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_jit_buffer_free', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '133.190688', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_buffer_size-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_jit_buffer_size', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'JIT buffer size', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_jit_buffer_size', + 'unique_id': '1234567890abcdef#jit_buffer_size', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_buffer_size-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local JIT buffer size', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_jit_buffer_size', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '134.217712', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_kind-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_jit_kind', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'JIT kind', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_jit_kind', + 'unique_id': '1234567890abcdef#jit_kind', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_kind-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local JIT kind', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_jit_kind', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '5', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_opt_flags-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_jit_opt_flags', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'JIT opt flags', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_jit_opt_flags', + 'unique_id': '1234567890abcdef#jit_opt_flags', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_opt_flags-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local JIT opt flags', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_jit_opt_flags', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '6', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_opt_level-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_jit_opt_level', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'JIT opt level', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_jit_opt_level', + 'unique_id': '1234567890abcdef#jit_opt_level', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_jit_opt_level-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local JIT opt level', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_jit_opt_level', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '5', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_blacklist_miss_ratio-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_blacklist_miss_ratio', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache blacklist miss ratio', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_blacklist_miss_ratio', + 'unique_id': '1234567890abcdef#opcache_statistics_blacklist_miss_ratio', + 'unit_of_measurement': '%', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_blacklist_miss_ratio-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache blacklist miss ratio', + 'state_class': , + 'unit_of_measurement': '%', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_blacklist_miss_ratio', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_blacklist_misses-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_blacklist_misses', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache blacklist misses', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_blacklist_misses', + 'unique_id': '1234567890abcdef#opcache_statistics_blacklist_misses', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_blacklist_misses-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache blacklist misses', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_blacklist_misses', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_cached_keys-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_cached_keys', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache cached keys', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_num_cached_keys', + 'unique_id': '1234567890abcdef#opcache_statistics_num_cached_keys', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_cached_keys-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache cached keys', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_cached_keys', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2654', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_cached_scripts-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_cached_scripts', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache cached scripts', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_num_cached_scripts', + 'unique_id': '1234567890abcdef#opcache_statistics_num_cached_scripts', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_cached_scripts-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache cached scripts', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_cached_scripts', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1406', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_current_wasted_percentage-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_current_wasted_percentage', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache current wasted percentage', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_opcache_memory_usage_current_wasted_percentage', + 'unique_id': '1234567890abcdef#server_php_opcache_memory_usage_current_wasted_percentage', + 'unit_of_measurement': '%', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_current_wasted_percentage-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache current wasted percentage', + 'unit_of_measurement': '%', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_current_wasted_percentage', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_free_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_free_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Opcache free memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_opcache_memory_usage_free_memory', + 'unique_id': '1234567890abcdef#server_php_opcache_memory_usage_free_memory', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_free_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Opcache free memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_free_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '62.190616', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_hash_restarts-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_hash_restarts', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache hash restarts', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_hash_restarts', + 'unique_id': '1234567890abcdef#opcache_statistics_hash_restarts', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_hash_restarts-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache hash restarts', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_hash_restarts', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_hit_rate-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_hit_rate', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache hit rate', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_opcache_hit_rate', + 'unique_id': '1234567890abcdef#opcache_statistics_opcache_hit_rate', + 'unit_of_measurement': '%', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_hit_rate-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache hit rate', + 'unit_of_measurement': '%', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_hit_rate', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '99.9855667222406', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_hits-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_hits', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache hits', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_hits', + 'unique_id': '1234567890abcdef#opcache_statistics_hits', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_hits-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache hits', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_hits', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '9739971', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_last_restart_time-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_last_restart_time', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Opcache last restart time', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_last_restart_time', + 'unique_id': '1234567890abcdef#opcache_statistics_last_restart_time', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_last_restart_time-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'timestamp', + 'friendly_name': 'my.nc_url.local Opcache last restart time', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_last_restart_time', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1970-01-01T00:00:00+00:00', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_manual_restarts-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_manual_restarts', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache manual restarts', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_manual_restarts', + 'unique_id': '1234567890abcdef#opcache_statistics_manual_restarts', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_manual_restarts-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache manual restarts', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_manual_restarts', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_max_cached_keys-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_max_cached_keys', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache max cached keys', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_max_cached_keys', + 'unique_id': '1234567890abcdef#opcache_statistics_max_cached_keys', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_max_cached_keys-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache max cached keys', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_max_cached_keys', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '16229', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_misses-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_misses', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache misses', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_misses', + 'unique_id': '1234567890abcdef#opcache_statistics_misses', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_misses-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache misses', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_misses', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1406', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_out_of_memory_restarts-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_out_of_memory_restarts', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Opcache out of memory restarts', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_oom_restarts', + 'unique_id': '1234567890abcdef#opcache_statistics_oom_restarts', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_out_of_memory_restarts-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Opcache out of memory restarts', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_out_of_memory_restarts', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_start_time-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_start_time', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Opcache start time', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_opcache_statistics_start_time', + 'unique_id': '1234567890abcdef#opcache_statistics_start_time', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_start_time-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'timestamp', + 'friendly_name': 'my.nc_url.local Opcache start time', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_start_time', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2024-07-29T03:00:08+00:00', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_used_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_used_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Opcache used memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_opcache_memory_usage_used_memory', + 'unique_id': '1234567890abcdef#server_php_opcache_memory_usage_used_memory', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_used_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Opcache used memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_used_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '72.027112', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_wasted_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_opcache_wasted_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Opcache wasted memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_opcache_memory_usage_wasted_memory', + 'unique_id': '1234567890abcdef#server_php_opcache_memory_usage_wasted_memory', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_opcache_wasted_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Opcache wasted memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_opcache_wasted_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0.0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_max_execution_time-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_php_max_execution_time', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'PHP max execution time', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_max_execution_time', + 'unique_id': '1234567890abcdef#server_php_max_execution_time', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_max_execution_time-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'duration', + 'friendly_name': 'my.nc_url.local PHP max execution time', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_php_max_execution_time', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '3600', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_memory_limit-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_php_memory_limit', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'PHP memory limit', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_memory_limit', + 'unique_id': '1234567890abcdef#server_php_memory_limit', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_memory_limit-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local PHP memory limit', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_php_memory_limit', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '536.870912', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_upload_maximum_filesize-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_php_upload_maximum_filesize', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'PHP upload maximum filesize', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_upload_max_filesize', + 'unique_id': '1234567890abcdef#server_php_upload_max_filesize', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_upload_maximum_filesize-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local PHP upload maximum filesize', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_php_upload_maximum_filesize', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '536.870912', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_version-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_php_version', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'PHP version', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_php_version', + 'unique_id': '1234567890abcdef#server_php_version', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_php_version-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local PHP version', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_php_version', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '8.2.18', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_sma_available_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_sma_available_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'SMA available memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_sma_avail_mem', + 'unique_id': '1234567890abcdef#sma_avail_mem', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_sma_available_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local SMA available memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_sma_available_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '33.342368', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_sma_number_of_segments-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_sma_number_of_segments', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'SMA number of segments', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_sma_num_seg', + 'unique_id': '1234567890abcdef#sma_num_seg', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_sma_number_of_segments-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local SMA number of segments', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_sma_number_of_segments', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_sma_segment_size-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_sma_segment_size', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'SMA segment size', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_sma_seg_size', + 'unique_id': '1234567890abcdef#sma_seg_size', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_sma_segment_size-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local SMA segment size', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_sma_segment_size', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '33.554312', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_memcache_distributed-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_system_memcache_distributed', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'System memcache distributed', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_memcache_distributed', + 'unique_id': '1234567890abcdef#system_memcache.distributed', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_memcache_distributed-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local System memcache distributed', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_system_memcache_distributed', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'none', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_memcache_local-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_system_memcache_local', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'System memcache local', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_memcache_local', + 'unique_id': '1234567890abcdef#system_memcache.local', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_memcache_local-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local System memcache local', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_system_memcache_local', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '\\OC\\Memcache\\APCu', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_memcache_locking-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_system_memcache_locking', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'System memcache locking', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_memcache_locking', + 'unique_id': '1234567890abcdef#system_memcache.locking', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_memcache_locking-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local System memcache locking', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_system_memcache_locking', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'none', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_theme-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_system_theme', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'System theme', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_theme', + 'unique_id': '1234567890abcdef#system_theme', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_theme-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local System theme', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_system_theme', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_version-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_system_version', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'System version', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_version', + 'unique_id': '1234567890abcdef#system_version', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_system_version-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local System version', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_system_version', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '28.0.4.1', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_total_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_total_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Total memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_mem_total', + 'unique_id': '1234567890abcdef#system_mem_total', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_total_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Total memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_total_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '30.728192', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_total_swap_memory-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_total_swap_memory', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Total swap memory', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_swap_total', + 'unique_id': '1234567890abcdef#system_swap_total', + 'unit_of_measurement': , + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_total_swap_memory-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'data_size', + 'friendly_name': 'my.nc_url.local Total swap memory', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_total_swap_memory', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '10.484736', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_updates_available-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_nc_url_local_updates_available', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Updates available', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_system_apps_num_updates_available', + 'unique_id': '1234567890abcdef#system_apps_num_updates_available', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_updates_available-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Updates available', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_updates_available', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_webserver-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.my_nc_url_local_webserver', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Webserver', + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'nextcloud_server_webserver', + 'unique_id': '1234567890abcdef#server_webserver', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[sensor.my_nc_url_local_webserver-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'my.nc_url.local Webserver', + }), + 'context': , + 'entity_id': 'sensor.my_nc_url_local_webserver', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'Apache/2.4.57 (Debian)', + }) +# --- diff --git a/tests/components/nextcloud/snapshots/test_update.ambr b/tests/components/nextcloud/snapshots/test_update.ambr new file mode 100644 index 00000000000000..1ee6264c204bf9 --- /dev/null +++ b/tests/components/nextcloud/snapshots/test_update.ambr @@ -0,0 +1,57 @@ +# serializer version: 1 +# name: test_async_setup_entry[update.my_nc_url_local_none-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'update', + 'entity_category': , + 'entity_id': 'update.my_nc_url_local_none', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'nextcloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '1234567890abcdef#update', + 'unit_of_measurement': None, + }) +# --- +# name: test_async_setup_entry[update.my_nc_url_local_none-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'auto_update': False, + 'entity_picture': 'https://brands.home-assistant.io/_/nextcloud/icon.png', + 'friendly_name': 'my.nc_url.local None', + 'in_progress': False, + 'installed_version': '28.0.4.1', + 'latest_version': '28.0.4.1', + 'release_summary': None, + 'release_url': 'https://nextcloud.com/changelog/#28-0-4', + 'skipped_version': None, + 'supported_features': , + 'title': None, + }), + 'context': , + 'entity_id': 'update.my_nc_url_local_none', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/nextcloud/test_binary_sensor.py b/tests/components/nextcloud/test_binary_sensor.py new file mode 100644 index 00000000000000..ff121c53ec39f3 --- /dev/null +++ b/tests/components/nextcloud/test_binary_sensor.py @@ -0,0 +1,33 @@ +"""Tests for the Nextcloud binary sensors.""" + +from unittest.mock import patch + +import pytest +from syrupy.assertion import SnapshotAssertion + +from homeassistant.const import Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import init_integration +from .const import NC_DATA, VALID_CONFIG + +from tests.common import snapshot_platform + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_async_setup_entry( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test a successful setup entry.""" + with patch( + "homeassistant.components.nextcloud.PLATFORMS", [Platform.BINARY_SENSOR] + ): + entry = await init_integration(hass, VALID_CONFIG, NC_DATA) + + states = hass.states.async_all() + assert len(states) == 6 + + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) diff --git a/tests/components/nextcloud/test_config_flow.py b/tests/components/nextcloud/test_config_flow.py index c02516fdc99cbb..536464d5253dd6 100644 --- a/tests/components/nextcloud/test_config_flow.py +++ b/tests/components/nextcloud/test_config_flow.py @@ -1,6 +1,6 @@ """Tests for the Nextcloud config flow.""" -from unittest.mock import Mock, patch +from unittest.mock import patch from nextcloudmonitor import ( NextcloudMonitorAuthorizationError, @@ -12,24 +12,19 @@ from homeassistant.components.nextcloud.const import DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER -from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME, CONF_VERIFY_SSL +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType +from .const import VALID_CONFIG + from tests.common import MockConfigEntry pytestmark = pytest.mark.usefixtures("mock_setup_entry") -VALID_CONFIG = { - CONF_URL: "nc_url", - CONF_USERNAME: "nc_user", - CONF_PASSWORD: "nc_pass", - CONF_VERIFY_SSL: True, -} - async def test_user_create_entry( - hass: HomeAssistant, mock_nextcloud_monitor: Mock, snapshot: SnapshotAssertion + hass: HomeAssistant, snapshot: SnapshotAssertion ) -> None: """Test that the user step works.""" # start user flow @@ -85,7 +80,7 @@ async def test_user_create_entry( # test success with patch( "homeassistant.components.nextcloud.config_flow.NextcloudMonitor", - return_value=mock_nextcloud_monitor, + return_value=True, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -94,17 +89,15 @@ async def test_user_create_entry( await hass.async_block_till_done() assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == "nc_url" + assert result["title"] == "https://my.nc_url.local" assert result["data"] == snapshot -async def test_user_already_configured( - hass: HomeAssistant, mock_nextcloud_monitor: Mock -) -> None: +async def test_user_already_configured(hass: HomeAssistant) -> None: """Test that errors are shown when duplicates are added.""" entry = MockConfigEntry( domain=DOMAIN, - title="nc_url", + title="https://my.nc_url.local", unique_id="nc_url", data=VALID_CONFIG, ) @@ -119,7 +112,7 @@ async def test_user_already_configured( with patch( "homeassistant.components.nextcloud.config_flow.NextcloudMonitor", - return_value=mock_nextcloud_monitor, + return_value=True, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -131,13 +124,11 @@ async def test_user_already_configured( assert result["reason"] == "already_configured" -async def test_reauth( - hass: HomeAssistant, mock_nextcloud_monitor: Mock, snapshot: SnapshotAssertion -) -> None: +async def test_reauth(hass: HomeAssistant, snapshot: SnapshotAssertion) -> None: """Test that the re-auth flow works.""" entry = MockConfigEntry( domain=DOMAIN, - title="nc_url", + title="https://my.nc_url.local", unique_id="nc_url", data=VALID_CONFIG, ) @@ -206,7 +197,7 @@ async def test_reauth( # test success with patch( "homeassistant.components.nextcloud.config_flow.NextcloudMonitor", - return_value=mock_nextcloud_monitor, + return_value=True, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/nextcloud/test_coordinator.py b/tests/components/nextcloud/test_coordinator.py new file mode 100644 index 00000000000000..91f7e7967a3c18 --- /dev/null +++ b/tests/components/nextcloud/test_coordinator.py @@ -0,0 +1,69 @@ +"""Tests for the Nextcloud coordinator.""" + +from unittest.mock import Mock, patch + +from freezegun.api import FrozenDateTimeFactory +from nextcloudmonitor import ( + NextcloudMonitor, + NextcloudMonitorAuthorizationError, + NextcloudMonitorConnectionError, + NextcloudMonitorError, + NextcloudMonitorRequestError, +) +import pytest + +from homeassistant.components.nextcloud.const import DEFAULT_SCAN_INTERVAL +from homeassistant.const import STATE_UNAVAILABLE +from homeassistant.core import HomeAssistant + +from . import mock_config_entry +from .const import NC_DATA, VALID_CONFIG + +from tests.common import async_fire_time_changed + + +@pytest.mark.parametrize( + ("error"), + [ + (NextcloudMonitorAuthorizationError), + (NextcloudMonitorConnectionError), + (NextcloudMonitorRequestError), + ], +) +async def test_data_update( + hass: HomeAssistant, freezer: FrozenDateTimeFactory, error: NextcloudMonitorError +) -> None: + """Test a coordinator data updates.""" + entry = mock_config_entry(VALID_CONFIG) + entry.add_to_hass(hass) + + with ( + patch( + "homeassistant.components.nextcloud.NextcloudMonitor", spec=NextcloudMonitor + ) as mock_nextcloud_monitor, + ): + mock_nextcloud_monitor.return_value.update = Mock( + return_value=True, + side_effect=[None, error, None], + ) + mock_nextcloud_monitor.return_value.data = NC_DATA + assert await hass.config_entries.async_setup(entry.entry_id) + + # Test successful setup and first data fetch + await hass.async_block_till_done(wait_background_tasks=True) + states = hass.states.async_all() + assert (state != STATE_UNAVAILABLE for state in states) + + # Test states get unavailable on error + freezer.tick(DEFAULT_SCAN_INTERVAL) + async_fire_time_changed(hass) + await hass.async_block_till_done(wait_background_tasks=True) + states = hass.states.async_all() + assert (state == STATE_UNAVAILABLE for state in states) + + # Test successful data fetch + freezer.tick(DEFAULT_SCAN_INTERVAL) + async_fire_time_changed(hass) + await hass.async_block_till_done(wait_background_tasks=True) + states = hass.states.async_all() + assert (state != STATE_UNAVAILABLE for state in states) diff --git a/tests/components/nextcloud/test_init.py b/tests/components/nextcloud/test_init.py new file mode 100644 index 00000000000000..70c8f545c6b95b --- /dev/null +++ b/tests/components/nextcloud/test_init.py @@ -0,0 +1,95 @@ +"""Tests for the Nextcloud init.""" + +from unittest.mock import Mock, patch + +from nextcloudmonitor import ( + NextcloudMonitorAuthorizationError, + NextcloudMonitorConnectionError, + NextcloudMonitorError, + NextcloudMonitorRequestError, +) +import pytest + +from homeassistant.components.nextcloud.const import DOMAIN +from homeassistant.config_entries import ConfigEntryState +from homeassistant.const import CONF_URL, Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import init_integration, mock_config_entry +from .const import MOCKED_ENTRY_ID, NC_DATA, VALID_CONFIG + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_async_setup_entry( + hass: HomeAssistant, +) -> None: + """Test a successful setup entry.""" + assert await init_integration(hass, VALID_CONFIG, NC_DATA) + + +async def test_unique_id_migration( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, +) -> None: + """Test migration of unique ids to stable ones.""" + + object_id = "my_nc_url_local_system_version" + entity_id = f"{Platform.SENSOR}.{object_id}" + + entry = mock_config_entry(VALID_CONFIG) + entry.add_to_hass(hass) + + entity = entity_registry.async_get_or_create( + Platform.SENSOR, + DOMAIN, + f"{VALID_CONFIG[CONF_URL]}#nextcloud_system_version", + suggested_object_id=object_id, + config_entry=entry, + ) + + # test old unique id + assert entity.entity_id == entity_id + assert entity.unique_id == f"{VALID_CONFIG[CONF_URL]}#nextcloud_system_version" + + with ( + patch( + "homeassistant.components.nextcloud.NextcloudMonitor" + ) as mock_nextcloud_monitor, + ): + mock_nextcloud_monitor.update = Mock(return_value=True) + mock_nextcloud_monitor.return_value.data = NC_DATA + await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + + # test migrated unique id + reg_entry = entity_registry.async_get(entity_id) + assert reg_entry.unique_id == f"{MOCKED_ENTRY_ID}#system_version" + + +@pytest.mark.parametrize( + ("exception", "expcted_entry_state"), + [ + (NextcloudMonitorAuthorizationError, ConfigEntryState.SETUP_ERROR), + (NextcloudMonitorConnectionError, ConfigEntryState.SETUP_RETRY), + (NextcloudMonitorRequestError, ConfigEntryState.SETUP_RETRY), + ], +) +async def test_setup_entry_errors( + hass: HomeAssistant, + exception: NextcloudMonitorError, + expcted_entry_state: ConfigEntryState, +) -> None: + """Test a successful setup entry.""" + + entry = mock_config_entry(VALID_CONFIG) + entry.add_to_hass(hass) + + with ( + patch( + "homeassistant.components.nextcloud.NextcloudMonitor", side_effect=exception + ), + ): + await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + assert entry.state == expcted_entry_state diff --git a/tests/components/nextcloud/test_sensor.py b/tests/components/nextcloud/test_sensor.py new file mode 100644 index 00000000000000..1ea2c87db114bd --- /dev/null +++ b/tests/components/nextcloud/test_sensor.py @@ -0,0 +1,31 @@ +"""Tests for the Nextcloud sensors.""" + +from unittest.mock import patch + +import pytest +from syrupy.assertion import SnapshotAssertion + +from homeassistant.const import Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import init_integration +from .const import NC_DATA, VALID_CONFIG + +from tests.common import snapshot_platform + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_async_setup_entry( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test a successful setup entry.""" + with patch("homeassistant.components.nextcloud.PLATFORMS", [Platform.SENSOR]): + entry = await init_integration(hass, VALID_CONFIG, NC_DATA) + + states = hass.states.async_all() + assert len(states) == 80 + + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) diff --git a/tests/components/nextcloud/test_update.py b/tests/components/nextcloud/test_update.py new file mode 100644 index 00000000000000..d47c9f1df530cb --- /dev/null +++ b/tests/components/nextcloud/test_update.py @@ -0,0 +1,80 @@ +"""Tests for the Nextcloud update entity.""" + +from copy import deepcopy +from unittest.mock import patch + +import pytest +from syrupy.assertion import SnapshotAssertion + +from homeassistant.const import STATE_OFF, STATE_ON, Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import init_integration +from .const import NC_DATA, VALID_CONFIG + +from tests.common import snapshot_platform + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_async_setup_entry( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test a successful setup entry.""" + with patch("homeassistant.components.nextcloud.PLATFORMS", [Platform.UPDATE]): + entry = await init_integration(hass, VALID_CONFIG, NC_DATA) + + states = hass.states.async_all() + assert len(states) == 1 + + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + +async def test_setup_entity_without_update( + hass: HomeAssistant, snapshot: SnapshotAssertion +) -> None: + """Test update entity is created w/o available update.""" + with patch("homeassistant.components.nextcloud.PLATFORMS", [Platform.UPDATE]): + await init_integration(hass, VALID_CONFIG, NC_DATA) + + states = hass.states.async_all() + assert len(states) == 1 + assert states[0].state == STATE_OFF + assert states[0].attributes["installed_version"] == "28.0.4.1" + assert states[0].attributes["latest_version"] == "28.0.4.1" + assert ( + states[0].attributes["release_url"] == "https://nextcloud.com/changelog/#28-0-4" + ) + + +async def test_setup_entity_with_update( + hass: HomeAssistant, snapshot: SnapshotAssertion +) -> None: + """Test update entity is created with available update.""" + data = deepcopy(NC_DATA) + data["nextcloud"]["system"]["update"]["available"] = True + data["nextcloud"]["system"]["update"]["available_version"] = "30.0.0.0" + with patch("homeassistant.components.nextcloud.PLATFORMS", [Platform.UPDATE]): + await init_integration(hass, VALID_CONFIG, data) + + states = hass.states.async_all() + assert len(states) == 1 + assert states[0].state == STATE_ON + assert states[0].attributes["installed_version"] == "28.0.4.1" + assert states[0].attributes["latest_version"] == "30.0.0.0" + assert ( + states[0].attributes["release_url"] == "https://nextcloud.com/changelog/#30-0-0" + ) + + +async def test_setup_no_entity(hass: HomeAssistant) -> None: + """Test no update entity is created, when no data available.""" + data = deepcopy(NC_DATA) + data["nextcloud"]["system"].pop("update") # only nc<28.0.0 + with patch("homeassistant.components.nextcloud.PLATFORMS", [Platform.UPDATE]): + await init_integration(hass, VALID_CONFIG, data) + + states = hass.states.async_all() + assert len(states) == 0 From 9e762fa2223bd4c1610785108b7afa29f220b292 Mon Sep 17 00:00:00 2001 From: IceBotYT <34712694+IceBotYT@users.noreply.github.com> Date: Tue, 27 Aug 2024 13:53:00 -0400 Subject: [PATCH 14/67] Bump Nice G.O. to 0.3.5 (#124667) * Bump Nice G.O. to 0.3.1 * Bump to 0.3.5 --- homeassistant/components/nice_go/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/nice_go/manifest.json b/homeassistant/components/nice_go/manifest.json index c2ff8370e2a1b7..45dd3c8b5b4e13 100644 --- a/homeassistant/components/nice_go/manifest.json +++ b/homeassistant/components/nice_go/manifest.json @@ -6,5 +6,5 @@ "documentation": "https://www.home-assistant.io/integrations/nice_go", "iot_class": "cloud_push", "loggers": ["nice-go"], - "requirements": ["nice-go==0.3.0"] + "requirements": ["nice-go==0.3.5"] } diff --git a/requirements_all.txt b/requirements_all.txt index 370012e3e1573b..784f2e65c00b74 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1429,7 +1429,7 @@ nextdns==3.2.0 nibe==2.11.0 # homeassistant.components.nice_go -nice-go==0.3.0 +nice-go==0.3.5 # homeassistant.components.niko_home_control niko-home-control==0.2.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index fd934a4f929ced..293aa62a4d8b55 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1186,7 +1186,7 @@ nextdns==3.2.0 nibe==2.11.0 # homeassistant.components.nice_go -nice-go==0.3.0 +nice-go==0.3.5 # homeassistant.components.nfandroidtv notifications-android-tv==0.1.5 From dd0c353afbb1282da55f061c89910a8edf1a823e Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 27 Aug 2024 22:28:54 +0200 Subject: [PATCH 15/67] Fix nice_go integration tests (#124736) --- tests/components/nice_go/conftest.py | 3 ++- tests/components/nice_go/snapshots/test_diagnostics.ambr | 1 - tests/components/nice_go/test_diagnostics.py | 4 +++- tests/components/nice_go/test_init.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/components/nice_go/conftest.py b/tests/components/nice_go/conftest.py index 31b21083c05208..9ed3d0d19cf755 100644 --- a/tests/components/nice_go/conftest.py +++ b/tests/components/nice_go/conftest.py @@ -1,6 +1,7 @@ """Common fixtures for the Nice G.O. tests.""" from collections.abc import Generator +from datetime import datetime from unittest.mock import AsyncMock, patch from nice_go import Barrier, BarrierState, ConnectionState @@ -71,7 +72,7 @@ def mock_config_entry() -> MockConfigEntry: CONF_EMAIL: "test-email", CONF_PASSWORD: "test-password", CONF_REFRESH_TOKEN: "test-refresh-token", - CONF_REFRESH_TOKEN_CREATION_TIME: 1722184160.738171, + CONF_REFRESH_TOKEN_CREATION_TIME: datetime.now().timestamp(), }, version=1, unique_id="test-email", diff --git a/tests/components/nice_go/snapshots/test_diagnostics.ambr b/tests/components/nice_go/snapshots/test_diagnostics.ambr index abd3b3103d1d71..6f9428ed2462b6 100644 --- a/tests/components/nice_go/snapshots/test_diagnostics.ambr +++ b/tests/components/nice_go/snapshots/test_diagnostics.ambr @@ -26,7 +26,6 @@ 'email': '**REDACTED**', 'password': '**REDACTED**', 'refresh_token': '**REDACTED**', - 'refresh_token_creation_time': 1722184160.738171, }), 'disabled_by': None, 'domain': 'nice_go', diff --git a/tests/components/nice_go/test_diagnostics.py b/tests/components/nice_go/test_diagnostics.py index 1c88c6a8dc6a42..f91f5748792032 100644 --- a/tests/components/nice_go/test_diagnostics.py +++ b/tests/components/nice_go/test_diagnostics.py @@ -26,4 +26,6 @@ async def test_entry_diagnostics( result = await get_diagnostics_for_config_entry( hass, hass_client, mock_config_entry ) - assert result == snapshot(exclude=props("created_at", "modified_at")) + assert result == snapshot( + exclude=props("created_at", "modified_at", "refresh_token_creation_time") + ) diff --git a/tests/components/nice_go/test_init.py b/tests/components/nice_go/test_init.py index 249622d23b0ecb..5568a7ea62aa36 100644 --- a/tests/components/nice_go/test_init.py +++ b/tests/components/nice_go/test_init.py @@ -110,7 +110,7 @@ async def test_update_refresh_token( assert mock_nice_go.authenticate.call_count == 0 mock_nice_go.authenticate.return_value = "new-refresh-token" - freezer.tick(timedelta(days=30)) + freezer.tick(timedelta(days=30, seconds=1)) async_fire_time_changed(hass) assert await hass.config_entries.async_reload(mock_config_entry.entry_id) await hass.async_block_till_done() From 467749eb579e8bd7e57ad96c677eee21485d10b8 Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Tue, 27 Aug 2024 23:48:13 +0300 Subject: [PATCH 16/67] Fix Shelly sleepy RPC setup if device is already awake (#124734) --- homeassistant/components/shelly/__init__.py | 5 ++ .../components/shelly/coordinator.py | 12 +++-- tests/components/shelly/test_init.py | 46 +++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 1d3f67220fa284..e0d9d17d55d452 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -290,6 +290,11 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ShellyConfigEntry) ) runtime_data.rpc = ShellyRpcCoordinator(hass, entry, device) runtime_data.rpc.async_setup(runtime_data.platforms) + # Try to connect to the device, if we reached here from config flow + # and user woke up the device when adding it, we can continue setup + # otherwise we will wait for the device to wake up + if sleep_period: + await runtime_data.rpc.async_device_online("setup") else: # Restore sensors for sleeping device LOGGER.debug("Setting up offline RPC device %s", entry.title) diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 03dcdedbb6f526..918dd9207658b7 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -173,7 +173,7 @@ async def _async_device_connect_task(self) -> bool: await self.device.initialize() update_device_fw_info(self.hass, self.device, self.entry) except DeviceConnectionError as err: - LOGGER.error( + LOGGER.debug( "Error connecting to Shelly device %s, error: %r", self.name, err ) return False @@ -480,15 +480,17 @@ def __init__( self._connect_task: asyncio.Task | None = None entry.async_on_unload(entry.add_update_listener(self._async_update_listener)) - async def async_device_online(self) -> None: + async def async_device_online(self, source: str) -> None: """Handle device going online.""" if not self.sleep_period: await self.async_request_refresh() elif not self._came_online_once or not self.device.initialized: LOGGER.debug( - "Sleepy device %s is online, trying to poll and configure", self.name + "Sleepy device %s is online (source: %s), trying to poll and configure", + self.name, + source, ) - # Zeroconf told us the device is online, try to poll + # Source told us the device is online, try to poll # the device and if possible, set up the outbound # websocket so the device will send us updates # instead of relying on polling it fast enough before @@ -847,7 +849,7 @@ async def async_reconnect_soon(hass: HomeAssistant, entry: ShellyConfigEntry) -> ): entry.async_create_background_task( hass, - coordinator.async_device_online(), + coordinator.async_device_online("zeroconf"), "reconnect soon", eager_start=True, ) diff --git a/tests/components/shelly/test_init.py b/tests/components/shelly/test_init.py index 46698c23c0a6de..b5516485501424 100644 --- a/tests/components/shelly/test_init.py +++ b/tests/components/shelly/test_init.py @@ -310,6 +310,52 @@ async def test_sleeping_rpc_device_online_new_firmware( assert entry.data["sleep_period"] == 1500 +async def test_sleeping_rpc_device_online_during_setup( + hass: HomeAssistant, + mock_rpc_device: Mock, + monkeypatch: pytest.MonkeyPatch, + caplog: pytest.LogCaptureFixture, +) -> None: + """Test sleeping device Gen2 woke up by user during setup.""" + monkeypatch.setattr(mock_rpc_device, "connected", False) + monkeypatch.setitem(mock_rpc_device.status["sys"], "wakeup_period", 1000) + await init_integration(hass, 2, sleep_period=1000) + await hass.async_block_till_done(wait_background_tasks=True) + + assert "will resume when device is online" in caplog.text + assert "is online (source: setup)" in caplog.text + assert hass.states.get("sensor.test_name_temperature") is not None + + +async def test_sleeping_rpc_device_offline_during_setup( + hass: HomeAssistant, + mock_rpc_device: Mock, + monkeypatch: pytest.MonkeyPatch, + caplog: pytest.LogCaptureFixture, +) -> None: + """Test sleeping device Gen2 woke up by user during setup.""" + monkeypatch.setattr(mock_rpc_device, "connected", False) + monkeypatch.setitem(mock_rpc_device.status["sys"], "wakeup_period", 1000) + monkeypatch.setattr( + mock_rpc_device, "initialize", AsyncMock(side_effect=DeviceConnectionError) + ) + + # Init integration, should fail since device is offline + await init_integration(hass, 2, sleep_period=1000) + await hass.async_block_till_done(wait_background_tasks=True) + + assert "will resume when device is online" in caplog.text + assert "is online (source: setup)" in caplog.text + assert hass.states.get("sensor.test_name_temperature") is None + + # Create an online event and verify that device is init successfully + monkeypatch.setattr(mock_rpc_device, "initialize", AsyncMock()) + mock_rpc_device.mock_online() + await hass.async_block_till_done(wait_background_tasks=True) + + assert hass.states.get("sensor.test_name_temperature") is not None + + @pytest.mark.parametrize( ("gen", "entity_id"), [ From 5818e2c2d44252f0222820d28b8f9c6aef613b24 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:14:41 -0400 Subject: [PATCH 17/67] Yellow firmware selection options flow (#122868) * Implement Yellow config flow for firmware selection * Use the probed firmware type when setting up Yellow * Add translation strings * Ensure (most) existing `init` tests pass * Remove multi-PAN setup config flow unit tests * Get existing config flow unit tests passing * Add unit tests for uninstalling multi-PAN and such * Consolidate entity creation for Yellow and clean up steps * Be explicit with multiple inheritance overrides * Address review comments --- .../homeassistant_yellow/__init__.py | 88 +++-- .../homeassistant_yellow/config_flow.py | 183 +++++++-- .../components/homeassistant_yellow/const.py | 3 + .../homeassistant_yellow/strings.json | 53 ++- .../homeassistant_yellow/test_config_flow.py | 346 +++++++++--------- .../homeassistant_yellow/test_init.py | 183 ++------- 6 files changed, 482 insertions(+), 374 deletions(-) diff --git a/homeassistant/components/homeassistant_yellow/__init__.py b/homeassistant/components/homeassistant_yellow/__init__.py index 14c2de2c9a1fb3..04abe5a1dcae2d 100644 --- a/homeassistant/components/homeassistant_yellow/__init__.py +++ b/homeassistant/components/homeassistant_yellow/__init__.py @@ -2,18 +2,24 @@ from __future__ import annotations +import logging + from homeassistant.components.hassio import get_os_info, is_hassio from homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon import ( check_multi_pan_addon, - get_zigbee_socket, - multi_pan_addon_using_device, +) +from homeassistant.components.homeassistant_hardware.util import ( + ApplicationType, + guess_firmware_type, ) from homeassistant.config_entries import SOURCE_HARDWARE, ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError from homeassistant.helpers import discovery_flow -from .const import RADIO_DEVICE, ZHA_HW_DISCOVERY_DATA +from .const import FIRMWARE, RADIO_DEVICE, ZHA_HW_DISCOVERY_DATA + +_LOGGER = logging.getLogger(__name__) async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: @@ -27,34 +33,26 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # The hassio integration has not yet fetched data from the supervisor raise ConfigEntryNotReady - board: str | None - if (board := os_info.get("board")) is None or board != "yellow": + if os_info.get("board") != "yellow": # Not running on a Home Assistant Yellow, Home Assistant may have been migrated hass.async_create_task(hass.config_entries.async_remove(entry.entry_id)) return False - try: - await check_multi_pan_addon(hass) - except HomeAssistantError as err: - raise ConfigEntryNotReady from err - - if not await multi_pan_addon_using_device(hass, RADIO_DEVICE): - hw_discovery_data = ZHA_HW_DISCOVERY_DATA - else: - hw_discovery_data = { - "name": "Yellow Multiprotocol", - "port": { - "path": get_zigbee_socket(), - }, - "radio_type": "ezsp", - } - - discovery_flow.async_create_flow( - hass, - "zha", - context={"source": SOURCE_HARDWARE}, - data=hw_discovery_data, - ) + firmware = ApplicationType(entry.data[FIRMWARE]) + + if firmware is ApplicationType.CPC: + try: + await check_multi_pan_addon(hass) + except HomeAssistantError as err: + raise ConfigEntryNotReady from err + + if firmware is ApplicationType.EZSP: + discovery_flow.async_create_flow( + hass, + "zha", + context={"source": SOURCE_HARDWARE}, + data=ZHA_HW_DISCOVERY_DATA, + ) return True @@ -62,3 +60,39 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" return True + + +async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: + """Migrate old entry.""" + + _LOGGER.debug( + "Migrating from version %s.%s", config_entry.version, config_entry.minor_version + ) + + if config_entry.version == 1: + if config_entry.minor_version == 1: + # Add-on startup with type service get started before Core, always (e.g. the + # Multi-Protocol add-on). Probing the firmware would interfere with the add-on, + # so we can't safely probe here. Instead, we must make an educated guess! + firmware_guess = await guess_firmware_type(hass, RADIO_DEVICE) + + new_data = {**config_entry.data} + new_data[FIRMWARE] = firmware_guess.firmware_type.value + + hass.config_entries.async_update_entry( + config_entry, + data=new_data, + version=1, + minor_version=2, + ) + + _LOGGER.debug( + "Migration to version %s.%s successful", + config_entry.version, + config_entry.minor_version, + ) + + return True + + # This means the user has downgraded from a future version + return False diff --git a/homeassistant/components/homeassistant_yellow/config_flow.py b/homeassistant/components/homeassistant_yellow/config_flow.py index d2212a968db123..ce6475ceb3c25b 100644 --- a/homeassistant/components/homeassistant_yellow/config_flow.py +++ b/homeassistant/components/homeassistant_yellow/config_flow.py @@ -2,11 +2,13 @@ from __future__ import annotations +from abc import ABC, abstractmethod import asyncio import logging -from typing import Any +from typing import Any, final import aiohttp +from universal_silabs_flasher.const import ApplicationType import voluptuous as vol from homeassistant.components.hassio import ( @@ -15,12 +17,25 @@ async_reboot_host, async_set_yellow_settings, ) -from homeassistant.components.homeassistant_hardware import silabs_multiprotocol_addon -from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult +from homeassistant.components.homeassistant_hardware.firmware_config_flow import ( + BaseFirmwareConfigFlow, + BaseFirmwareOptionsFlow, +) +from homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon import ( + OptionsFlowHandler as MultiprotocolOptionsFlowHandler, + SerialPortSettings as MultiprotocolSerialPortSettings, +) +from homeassistant.config_entries import ( + SOURCE_HARDWARE, + ConfigEntry, + ConfigFlowResult, + OptionsFlow, +) from homeassistant.core import callback -from homeassistant.helpers import selector +from homeassistant.helpers import discovery_flow, selector -from .const import DOMAIN, ZHA_HW_DISCOVERY_DATA +from .const import DOMAIN, FIRMWARE, RADIO_DEVICE, ZHA_DOMAIN, ZHA_HW_DISCOVERY_DATA +from .hardware import BOARD_NAME _LOGGER = logging.getLogger(__name__) @@ -33,18 +48,30 @@ ) -class HomeAssistantYellowConfigFlow(ConfigFlow, domain=DOMAIN): +class HomeAssistantYellowConfigFlow(BaseFirmwareConfigFlow, domain=DOMAIN): """Handle a config flow for Home Assistant Yellow.""" VERSION = 1 + MINOR_VERSION = 2 + + def __init__(self, *args: Any, **kwargs: Any) -> None: + """Instantiate config flow.""" + super().__init__(*args, **kwargs) + + self._device = RADIO_DEVICE @staticmethod @callback def async_get_options_flow( config_entry: ConfigEntry, - ) -> HomeAssistantYellowOptionsFlow: + ) -> OptionsFlow: """Return the options flow.""" - return HomeAssistantYellowOptionsFlow(config_entry) + firmware_type = ApplicationType(config_entry.data[FIRMWARE]) + + if firmware_type is ApplicationType.CPC: + return HomeAssistantYellowMultiPanOptionsFlowHandler(config_entry) + + return HomeAssistantYellowOptionsFlowHandler(config_entry) async def async_step_system( self, data: dict[str, Any] | None = None @@ -53,30 +80,56 @@ async def async_step_system( if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") - return self.async_create_entry(title="Home Assistant Yellow", data={}) + # We do not actually use any portion of `BaseFirmwareConfigFlow` beyond this + await self._probe_firmware_type() + + # Kick off ZHA hardware discovery automatically if Zigbee firmware is running + if self._probed_firmware_type is ApplicationType.EZSP: + discovery_flow.async_create_flow( + self.hass, + ZHA_DOMAIN, + context={"source": SOURCE_HARDWARE}, + data=ZHA_HW_DISCOVERY_DATA, + ) + + return self._async_flow_finished() + + def _async_flow_finished(self) -> ConfigFlowResult: + """Create the config entry.""" + assert self._probed_firmware_type is not None + + return self.async_create_entry( + title=BOARD_NAME, + data={ + # Assume the firmware type is EZSP if we cannot probe it + FIRMWARE: (self._probed_firmware_type or ApplicationType.EZSP).value, + }, + ) -class HomeAssistantYellowOptionsFlow(silabs_multiprotocol_addon.OptionsFlowHandler): - """Handle an option flow for Home Assistant Yellow.""" +class BaseHomeAssistantYellowOptionsFlow(OptionsFlow, ABC): + """Base Home Assistant Yellow options flow shared between firmware and multi-PAN.""" _hw_settings: dict[str, bool] | None = None + @abstractmethod + async def async_step_main_menu(self, _: None = None) -> ConfigFlowResult: + """Show the main menu.""" + + @final + async def async_step_init( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: + """Manage the options flow.""" + return await self.async_step_main_menu() + + @final async def async_step_on_supervisor( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Handle logic when on Supervisor host.""" return await self.async_step_main_menu() - async def async_step_main_menu(self, _: None = None) -> ConfigFlowResult: - """Show the main menu.""" - return self.async_show_menu( - step_id="main_menu", - menu_options=[ - "hardware_settings", - "multipan_settings", - ], - ) - async def async_step_hardware_settings( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: @@ -133,18 +186,36 @@ async def async_step_reboot_later( """Reboot later.""" return self.async_create_entry(data={}) + +class HomeAssistantYellowMultiPanOptionsFlowHandler( + BaseHomeAssistantYellowOptionsFlow, MultiprotocolOptionsFlowHandler +): + """Handle a multi-PAN options flow for Home Assistant Yellow.""" + + async def async_step_main_menu(self, _: None = None) -> ConfigFlowResult: + """Show the main menu.""" + return self.async_show_menu( + step_id="main_menu", + menu_options=[ + "hardware_settings", + "multipan_settings", + ], + ) + async def async_step_multipan_settings( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Handle multipan settings.""" - return await super().async_step_on_supervisor(user_input) + return await MultiprotocolOptionsFlowHandler.async_step_on_supervisor( + self, user_input + ) async def _async_serial_port_settings( self, - ) -> silabs_multiprotocol_addon.SerialPortSettings: + ) -> MultiprotocolSerialPortSettings: """Return the radio serial port settings.""" - return silabs_multiprotocol_addon.SerialPortSettings( - device="/dev/ttyAMA1", + return MultiprotocolSerialPortSettings( + device=RADIO_DEVICE, baudrate="115200", flow_control=True, ) @@ -163,4 +234,64 @@ def _zha_name(self) -> str: def _hardware_name(self) -> str: """Return the name of the hardware.""" - return "Home Assistant Yellow" + return BOARD_NAME + + async def async_step_flashing_complete( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: + """Finish flashing and update the config entry.""" + self.hass.config_entries.async_update_entry( + entry=self.config_entry, + data={ + **self.config_entry.data, + FIRMWARE: ApplicationType.EZSP.value, + }, + ) + + return await super().async_step_flashing_complete(user_input) + + +class HomeAssistantYellowOptionsFlowHandler( + BaseHomeAssistantYellowOptionsFlow, BaseFirmwareOptionsFlow +): + """Handle a firmware options flow for Home Assistant Yellow.""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + """Instantiate options flow.""" + super().__init__(*args, **kwargs) + + self._hardware_name = BOARD_NAME + self._device = RADIO_DEVICE + + # Regenerate the translation placeholders + self._get_translation_placeholders() + + async def async_step_main_menu(self, _: None = None) -> ConfigFlowResult: + """Show the main menu.""" + return self.async_show_menu( + step_id="main_menu", + menu_options=[ + "hardware_settings", + "firmware_settings", + ], + ) + + async def async_step_firmware_settings( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: + """Handle firmware configuration settings.""" + return await super().async_step_pick_firmware() + + def _async_flow_finished(self) -> ConfigFlowResult: + """Create the config entry.""" + assert self._probed_firmware_type is not None + + self.hass.config_entries.async_update_entry( + entry=self.config_entry, + data={ + **self.config_entry.data, + FIRMWARE: self._probed_firmware_type.value, + }, + ) + + return self.async_create_entry(title="", data={}) diff --git a/homeassistant/components/homeassistant_yellow/const.py b/homeassistant/components/homeassistant_yellow/const.py index 8f1f9a4c2b8135..79753ae9b9ec75 100644 --- a/homeassistant/components/homeassistant_yellow/const.py +++ b/homeassistant/components/homeassistant_yellow/const.py @@ -12,3 +12,6 @@ }, "radio_type": "efr32", } + +FIRMWARE = "firmware" +ZHA_DOMAIN = "zha" diff --git a/homeassistant/components/homeassistant_yellow/strings.json b/homeassistant/components/homeassistant_yellow/strings.json index 95442d315003ac..fd3be3586b1b59 100644 --- a/homeassistant/components/homeassistant_yellow/strings.json +++ b/homeassistant/components/homeassistant_yellow/strings.json @@ -42,6 +42,7 @@ "main_menu": { "menu_options": { "hardware_settings": "[%key:component::homeassistant_yellow::options::step::hardware_settings::title%]", + "firmware_settings": "Switch between Zigbee or Thread firmware.", "multipan_settings": "Configure IEEE 802.15.4 radio multiprotocol support" } }, @@ -79,6 +80,46 @@ "start_flasher_addon": { "title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::start_flasher_addon::title%]", "description": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::start_flasher_addon::description%]" + }, + "pick_firmware": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::description%]", + "menu_options": { + "pick_firmware_thread": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::menu_options::pick_firmware_thread%]", + "pick_firmware_zigbee": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::menu_options::pick_firmware_zigbee%]" + } + }, + "install_zigbee_flasher_addon": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_zigbee_flasher_addon::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_zigbee_flasher_addon::description%]" + }, + "run_zigbee_flasher_addon": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::run_zigbee_flasher_addon::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::run_zigbee_flasher_addon::description%]" + }, + "zigbee_flasher_failed": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::zigbee_flasher_failed::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::zigbee_flasher_failed::description%]" + }, + "confirm_zigbee": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]" + }, + "install_otbr_addon": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::description%]" + }, + "start_otbr_addon": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::description%]" + }, + "otbr_failed": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::description%]" + }, + "confirm_otbr": { + "title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_otbr::title%]", + "description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_otbr::description%]" } }, "error": { @@ -93,11 +134,19 @@ "not_hassio": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::abort::not_hassio%]", "read_hw_settings_error": "Failed to read hardware settings", "write_hw_settings_error": "Failed to write hardware settings", - "zha_migration_failed": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::abort::zha_migration_failed%]" + "zha_migration_failed": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::abort::zha_migration_failed%]", + "not_hassio_thread": "[%key:component::homeassistant_hardware::firmware_picker::options::abort::not_hassio_thread%]", + "otbr_addon_already_running": "[%key:component::homeassistant_hardware::firmware_picker::options::abort::otbr_addon_already_running%]", + "zha_still_using_stick": "[%key:component::homeassistant_hardware::firmware_picker::options::abort::zha_still_using_stick%]", + "otbr_still_using_stick": "[%key:component::homeassistant_hardware::firmware_picker::options::abort::otbr_still_using_stick%]" }, "progress": { "install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]", - "start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]" + "start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]", + "start_otbr_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]", + "install_zigbee_flasher_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_zigbee_flasher_addon%]", + "run_zigbee_flasher_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::run_zigbee_flasher_addon%]", + "uninstall_zigbee_flasher_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::uninstall_zigbee_flasher_addon%]" } } } diff --git a/tests/components/homeassistant_yellow/test_config_flow.py b/tests/components/homeassistant_yellow/test_config_flow.py index 95d7df89c9d535..949e58e61b6601 100644 --- a/tests/components/homeassistant_yellow/test_config_flow.py +++ b/tests/components/homeassistant_yellow/test_config_flow.py @@ -6,8 +6,17 @@ import pytest from homeassistant.components.hassio import DOMAIN as HASSIO_DOMAIN -from homeassistant.components.homeassistant_yellow.const import DOMAIN -from homeassistant.components.zha import DOMAIN as ZHA_DOMAIN +from homeassistant.components.hassio.addon_manager import AddonInfo, AddonState +from homeassistant.components.homeassistant_hardware.firmware_config_flow import ( + STEP_PICK_FIRMWARE_ZIGBEE, +) +from homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon import ( + CONF_DISABLE_MULTI_PAN, + get_flasher_addon_manager, + get_multiprotocol_addon_manager, +) +from homeassistant.components.homeassistant_hardware.util import ApplicationType +from homeassistant.components.homeassistant_yellow.const import DOMAIN, RADIO_DEVICE from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType from homeassistant.setup import async_setup_component @@ -57,22 +66,28 @@ async def test_config_flow(hass: HomeAssistant) -> None: mock_integration(hass, MockModule("hassio")) await async_setup_component(hass, HASSIO_DOMAIN, {}) - with patch( - "homeassistant.components.homeassistant_yellow.async_setup_entry", - return_value=True, - ) as mock_setup_entry: + with ( + patch( + "homeassistant.components.homeassistant_yellow.async_setup_entry", + return_value=True, + ) as mock_setup_entry, + patch( + "homeassistant.components.homeassistant_hardware.firmware_config_flow.probe_silabs_firmware_type", + return_value=ApplicationType.EZSP, + ), + ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "system"} ) assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "Home Assistant Yellow" - assert result["data"] == {} + assert result["data"] == {"firmware": "ezsp"} assert result["options"] == {} assert len(mock_setup_entry.mock_calls) == 1 config_entry = hass.config_entries.async_entries(DOMAIN)[0] - assert config_entry.data == {} + assert config_entry.data == {"firmware": "ezsp"} assert config_entry.options == {} assert config_entry.title == "Home Assistant Yellow" @@ -84,10 +99,12 @@ async def test_config_flow_single_entry(hass: HomeAssistant) -> None: # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) @@ -104,165 +121,6 @@ async def test_config_flow_single_entry(hass: HomeAssistant) -> None: mock_setup_entry.assert_not_called() -async def test_option_flow_install_multi_pan_addon( - hass: HomeAssistant, - addon_store_info, - addon_info, - install_addon, - set_addon_options, - start_addon, -) -> None: - """Test installing the multi pan addon.""" - mock_integration(hass, MockModule("hassio")) - await async_setup_component(hass, HASSIO_DOMAIN, {}) - - # Setup the config entry - config_entry = MockConfigEntry( - data={}, - domain=DOMAIN, - options={}, - title="Home Assistant Yellow", - ) - config_entry.add_to_hass(hass) - - result = await hass.config_entries.options.async_init(config_entry.entry_id) - assert result["type"] is FlowResultType.MENU - - with patch( - "homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.is_hassio", - side_effect=Mock(return_value=True), - ): - result = await hass.config_entries.options.async_configure( - result["flow_id"], - {"next_step_id": "multipan_settings"}, - ) - assert result["type"] is FlowResultType.FORM - assert result["step_id"] == "addon_not_installed" - - result = await hass.config_entries.options.async_configure( - result["flow_id"], - user_input={ - "enable_multi_pan": True, - }, - ) - assert result["type"] is FlowResultType.SHOW_PROGRESS - assert result["step_id"] == "install_addon" - assert result["progress_action"] == "install_addon" - - await hass.async_block_till_done() - install_addon.assert_called_once_with(hass, "core_silabs_multiprotocol") - - result = await hass.config_entries.options.async_configure(result["flow_id"]) - assert result["type"] is FlowResultType.SHOW_PROGRESS - assert result["step_id"] == "start_addon" - set_addon_options.assert_called_once_with( - hass, - "core_silabs_multiprotocol", - { - "options": { - "autoflash_firmware": True, - "device": "/dev/ttyAMA1", - "baudrate": "115200", - "flow_control": True, - } - }, - ) - - await hass.async_block_till_done() - start_addon.assert_called_once_with(hass, "core_silabs_multiprotocol") - - result = await hass.config_entries.options.async_configure(result["flow_id"]) - assert result["type"] is FlowResultType.CREATE_ENTRY - - -async def test_option_flow_install_multi_pan_addon_zha( - hass: HomeAssistant, - addon_store_info, - addon_info, - install_addon, - set_addon_options, - start_addon, -) -> None: - """Test installing the multi pan addon when a zha config entry exists.""" - mock_integration(hass, MockModule("hassio")) - await async_setup_component(hass, HASSIO_DOMAIN, {}) - - # Setup the config entry - config_entry = MockConfigEntry( - data={}, - domain=DOMAIN, - options={}, - title="Home Assistant Yellow", - ) - config_entry.add_to_hass(hass) - - zha_config_entry = MockConfigEntry( - data={"device": {"path": "/dev/ttyAMA1"}, "radio_type": "ezsp"}, - domain=ZHA_DOMAIN, - options={}, - title="Yellow", - ) - zha_config_entry.add_to_hass(hass) - - result = await hass.config_entries.options.async_init(config_entry.entry_id) - assert result["type"] is FlowResultType.MENU - - with patch( - "homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.is_hassio", - side_effect=Mock(return_value=True), - ): - result = await hass.config_entries.options.async_configure( - result["flow_id"], - {"next_step_id": "multipan_settings"}, - ) - assert result["type"] is FlowResultType.FORM - assert result["step_id"] == "addon_not_installed" - - result = await hass.config_entries.options.async_configure( - result["flow_id"], - user_input={ - "enable_multi_pan": True, - }, - ) - assert result["type"] is FlowResultType.SHOW_PROGRESS - assert result["step_id"] == "install_addon" - assert result["progress_action"] == "install_addon" - - await hass.async_block_till_done() - install_addon.assert_called_once_with(hass, "core_silabs_multiprotocol") - - result = await hass.config_entries.options.async_configure(result["flow_id"]) - assert result["type"] is FlowResultType.SHOW_PROGRESS - assert result["step_id"] == "start_addon" - set_addon_options.assert_called_once_with( - hass, - "core_silabs_multiprotocol", - { - "options": { - "autoflash_firmware": True, - "device": "/dev/ttyAMA1", - "baudrate": "115200", - "flow_control": True, - } - }, - ) - # Check the ZHA config entry data is updated - assert zha_config_entry.data == { - "device": { - "path": "socket://core-silabs-multiprotocol:9999", - "baudrate": 115200, - "flow_control": None, - }, - "radio_type": "ezsp", - } - - await hass.async_block_till_done() - start_addon.assert_called_once_with(hass, "core_silabs_multiprotocol") - - result = await hass.config_entries.options.async_configure(result["flow_id"]) - assert result["type"] is FlowResultType.CREATE_ENTRY - - @pytest.mark.parametrize( ("reboot_menu_choice", "reboot_calls"), [("reboot_now", 1), ("reboot_later", 0)], @@ -281,10 +139,12 @@ async def test_option_flow_led_settings( # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) @@ -327,10 +187,12 @@ async def test_option_flow_led_settings_unchanged( # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) @@ -359,10 +221,12 @@ async def test_option_flow_led_settings_fail_1(hass: HomeAssistant) -> None: # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) @@ -391,10 +255,12 @@ async def test_option_flow_led_settings_fail_2( # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) @@ -418,3 +284,139 @@ async def test_option_flow_led_settings_fail_2( ) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "write_hw_settings_error" + + +async def test_firmware_options_flow(hass: HomeAssistant) -> None: + """Test the firmware options flow for Yellow.""" + mock_integration(hass, MockModule("hassio")) + await async_setup_component(hass, HASSIO_DOMAIN, {}) + + config_entry = MockConfigEntry( + data={"firmware": ApplicationType.SPINEL}, + domain=DOMAIN, + options={}, + title="Home Assistant Yellow", + version=1, + minor_version=2, + ) + config_entry.add_to_hass(hass) + + # First step is confirmation + result = await hass.config_entries.options.async_init(config_entry.entry_id) + assert result["type"] is FlowResultType.MENU + assert result["step_id"] == "main_menu" + assert "firmware_settings" in result["menu_options"] + + # Pick firmware settings + result = await hass.config_entries.options.async_configure( + result["flow_id"], + user_input={"next_step_id": "firmware_settings"}, + ) + + assert result["step_id"] == "pick_firmware" + assert result["description_placeholders"]["firmware_type"] == "spinel" + assert result["description_placeholders"]["model"] == "Home Assistant Yellow" + + async def mock_async_step_pick_firmware_zigbee(self, data): + return await self.async_step_confirm_zigbee(user_input={}) + + with patch( + "homeassistant.components.homeassistant_hardware.firmware_config_flow.BaseFirmwareOptionsFlow.async_step_pick_firmware_zigbee", + autospec=True, + side_effect=mock_async_step_pick_firmware_zigbee, + ): + result = await hass.config_entries.options.async_configure( + result["flow_id"], + user_input={"next_step_id": STEP_PICK_FIRMWARE_ZIGBEE}, + ) + + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["result"] is True + + assert config_entry.data == { + "firmware": "ezsp", + } + + +async def test_options_flow_multipan_uninstall(hass: HomeAssistant) -> None: + """Test options flow for when multi-PAN firmware is installed.""" + mock_integration(hass, MockModule("hassio")) + await async_setup_component(hass, HASSIO_DOMAIN, {}) + + config_entry = MockConfigEntry( + data={"firmware": ApplicationType.CPC}, + domain=DOMAIN, + options={}, + title="Home Assistant Yellow", + version=1, + minor_version=2, + ) + config_entry.add_to_hass(hass) + + # Multi-PAN addon is running + mock_multipan_manager = Mock(spec_set=await get_multiprotocol_addon_manager(hass)) + mock_multipan_manager.async_get_addon_info.return_value = AddonInfo( + available=True, + hostname=None, + options={"device": RADIO_DEVICE}, + state=AddonState.RUNNING, + update_available=False, + version="1.0.0", + ) + + mock_flasher_manager = Mock(spec_set=get_flasher_addon_manager(hass)) + mock_flasher_manager.async_get_addon_info.return_value = AddonInfo( + available=True, + hostname=None, + options={}, + state=AddonState.NOT_RUNNING, + update_available=False, + version="1.0.0", + ) + + with ( + patch( + "homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.get_multiprotocol_addon_manager", + return_value=mock_multipan_manager, + ), + patch( + "homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.get_flasher_addon_manager", + return_value=mock_flasher_manager, + ), + patch( + "homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.is_hassio", + return_value=True, + ), + ): + result = await hass.config_entries.options.async_init(config_entry.entry_id) + assert result["type"] is FlowResultType.MENU + assert result["step_id"] == "main_menu" + assert "multipan_settings" in result["menu_options"] + + # Pick multi-PAN settings + result = await hass.config_entries.options.async_configure( + result["flow_id"], + user_input={"next_step_id": "multipan_settings"}, + ) + + # Pick the uninstall option + result = await hass.config_entries.options.async_configure( + result["flow_id"], + user_input={"next_step_id": "uninstall_addon"}, + ) + + # Check the box + result = await hass.config_entries.options.async_configure( + result["flow_id"], user_input={CONF_DISABLE_MULTI_PAN: True} + ) + + # Finish the flow + result = await hass.config_entries.options.async_configure(result["flow_id"]) + await hass.async_block_till_done(wait_background_tasks=True) + result = await hass.config_entries.options.async_configure(result["flow_id"]) + await hass.async_block_till_done(wait_background_tasks=True) + result = await hass.config_entries.options.async_configure(result["flow_id"]) + assert result["type"] is FlowResultType.CREATE_ENTRY + + # We've reverted the firmware back to Zigbee + assert config_entry.data["firmware"] == "ezsp" diff --git a/tests/components/homeassistant_yellow/test_init.py b/tests/components/homeassistant_yellow/test_init.py index ec3ba4e700569e..5d534dad1e7876 100644 --- a/tests/components/homeassistant_yellow/test_init.py +++ b/tests/components/homeassistant_yellow/test_init.py @@ -6,10 +6,14 @@ from homeassistant.components import zha from homeassistant.components.hassio import DOMAIN as HASSIO_DOMAIN -from homeassistant.components.hassio.handler import HassioAPIError +from homeassistant.components.homeassistant_hardware.util import ( + ApplicationType, + FirmwareGuess, +) from homeassistant.components.homeassistant_yellow.const import DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry, MockModule, mock_integration @@ -27,10 +31,12 @@ async def test_setup_entry( # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) with ( @@ -42,6 +48,14 @@ async def test_setup_entry( "homeassistant.components.onboarding.async_is_onboarded", return_value=onboarded, ), + patch( + "homeassistant.components.homeassistant_yellow.guess_firmware_type", + return_value=FirmwareGuess( # Nothing is setup + is_running=False, + firmware_type=ApplicationType.EZSP, + source="unknown", + ), + ), ): assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done(wait_background_tasks=True) @@ -74,118 +88,12 @@ async def test_setup_zha(hass: HomeAssistant, addon_store_info) -> None: # Setup the config entry config_entry = MockConfigEntry( - data={}, - domain=DOMAIN, - options={}, - title="Home Assistant Yellow", - ) - config_entry.add_to_hass(hass) - with ( - patch( - "homeassistant.components.homeassistant_yellow.get_os_info", - return_value={"board": "yellow"}, - ) as mock_get_os_info, - patch( - "homeassistant.components.onboarding.async_is_onboarded", return_value=False - ), - ): - assert await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done(wait_background_tasks=True) - assert len(mock_get_os_info.mock_calls) == 1 - - # Finish setting up ZHA - zha_flows = hass.config_entries.flow.async_progress_by_handler("zha") - assert len(zha_flows) == 1 - assert zha_flows[0]["step_id"] == "choose_formation_strategy" - - await hass.config_entries.flow.async_configure( - zha_flows[0]["flow_id"], - user_input={"next_step_id": zha.config_flow.FORMATION_REUSE_SETTINGS}, - ) - await hass.async_block_till_done() - - config_entry = hass.config_entries.async_entries("zha")[0] - assert config_entry.data == { - "device": { - "baudrate": 115200, - "flow_control": "hardware", - "path": "/dev/ttyAMA1", - }, - "radio_type": "ezsp", - } - assert config_entry.options == {} - assert config_entry.title == "Yellow" - - -async def test_setup_zha_multipan( - hass: HomeAssistant, addon_info, addon_running -) -> None: - """Test zha gets the right config.""" - mock_integration(hass, MockModule("hassio")) - await async_setup_component(hass, HASSIO_DOMAIN, {}) - - addon_info.return_value["options"]["device"] = "/dev/ttyAMA1" - - # Setup the config entry - config_entry = MockConfigEntry( - data={}, - domain=DOMAIN, - options={}, - title="Home Assistant Yellow", - ) - config_entry.add_to_hass(hass) - with ( - patch( - "homeassistant.components.homeassistant_yellow.get_os_info", - return_value={"board": "yellow"}, - ) as mock_get_os_info, - patch( - "homeassistant.components.onboarding.async_is_onboarded", return_value=False - ), - ): - assert await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done(wait_background_tasks=True) - assert len(mock_get_os_info.mock_calls) == 1 - - # Finish setting up ZHA - zha_flows = hass.config_entries.flow.async_progress_by_handler("zha") - assert len(zha_flows) == 1 - assert zha_flows[0]["step_id"] == "choose_formation_strategy" - - await hass.config_entries.flow.async_configure( - zha_flows[0]["flow_id"], - user_input={"next_step_id": zha.config_flow.FORMATION_REUSE_SETTINGS}, - ) - await hass.async_block_till_done() - - config_entry = hass.config_entries.async_entries("zha")[0] - assert config_entry.data == { - "device": { - "baudrate": 115200, - "flow_control": None, - "path": "socket://core-silabs-multiprotocol:9999", - }, - "radio_type": "ezsp", - } - assert config_entry.options == {} - assert config_entry.title == "Yellow Multiprotocol" - - -async def test_setup_zha_multipan_other_device( - hass: HomeAssistant, addon_info, addon_running -) -> None: - """Test zha gets the right config.""" - mock_integration(hass, MockModule("hassio")) - await async_setup_component(hass, HASSIO_DOMAIN, {}) - - addon_info.return_value["options"]["device"] = "/dev/not_yellow_radio" - - # Setup the config entry - config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) with ( @@ -229,10 +137,12 @@ async def test_setup_entry_no_hassio(hass: HomeAssistant) -> None: """Test setup of a config entry without hassio.""" # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) assert len(hass.config_entries.async_entries()) == 1 @@ -254,10 +164,12 @@ async def test_setup_entry_wrong_board(hass: HomeAssistant) -> None: # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) assert len(hass.config_entries.async_entries()) == 1 @@ -280,10 +192,12 @@ async def test_setup_entry_wait_hassio(hass: HomeAssistant) -> None: # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.EZSP}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) with patch( @@ -303,14 +217,15 @@ async def test_setup_entry_addon_info_fails( """Test setup of a config entry when fetching addon info fails.""" mock_integration(hass, MockModule("hassio")) await async_setup_component(hass, HASSIO_DOMAIN, {}) - addon_store_info.side_effect = HassioAPIError("Boom") # Setup the config entry config_entry = MockConfigEntry( - data={}, + data={"firmware": ApplicationType.CPC}, domain=DOMAIN, options={}, title="Home Assistant Yellow", + version=1, + minor_version=2, ) config_entry.add_to_hass(hass) with ( @@ -319,41 +234,15 @@ async def test_setup_entry_addon_info_fails( return_value={"board": "yellow"}, ), patch( - "homeassistant.components.onboarding.async_is_onboarded", return_value=False - ), - ): - assert not await hass.config_entries.async_setup(config_entry.entry_id) - - await hass.async_block_till_done() - assert config_entry.state is ConfigEntryState.SETUP_RETRY - - -async def test_setup_entry_addon_not_running( - hass: HomeAssistant, addon_installed, start_addon -) -> None: - """Test the addon is started if it is not running.""" - mock_integration(hass, MockModule("hassio")) - await async_setup_component(hass, HASSIO_DOMAIN, {}) - - # Setup the config entry - config_entry = MockConfigEntry( - data={}, - domain=DOMAIN, - options={}, - title="Home Assistant Yellow", - ) - config_entry.add_to_hass(hass) - with ( - patch( - "homeassistant.components.homeassistant_yellow.get_os_info", - return_value={"board": "yellow"}, + "homeassistant.components.onboarding.async_is_onboarded", + return_value=False, ), patch( - "homeassistant.components.onboarding.async_is_onboarded", return_value=False + "homeassistant.components.homeassistant_yellow.check_multi_pan_addon", + side_effect=HomeAssistantError("Boom"), ), ): assert not await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done() + await hass.async_block_till_done() assert config_entry.state is ConfigEntryState.SETUP_RETRY - start_addon.assert_called_once() From ca17c70109ac26959b9bcb48ea222ba54e00fbf2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 11:42:42 -1000 Subject: [PATCH 18/67] Remove socketio constraints (#124730) We have been stuck on an old version of socketio for a few years now due to https://github.com/jkeljo/sisyphus-control/issues/6 and no solution has been reached. The constraint is blocking any integration from using socketio 4.x servers as the old version only supports socketio 3.x servers which have reached EOL (https://socket.io/docs/v3/) --- homeassistant/package_constraints.txt | 6 ------ script/gen_requirements_all.py | 6 ------ 2 files changed, 12 deletions(-) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index ed1a1f8805904e..b652484e6754be 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -109,12 +109,6 @@ hyperframe>=5.2.0 # Ensure we run compatible with musllinux build env numpy==1.26.0 -# Prevent dependency conflicts between sisyphus-control and aioambient -# until upper bounds for sisyphus-control have been updated -# https://github.com/jkeljo/sisyphus-control/issues/6 -python-engineio>=3.13.1,<4.0 -python-socketio>=4.6.0,<5.0 - # Constrain multidict to avoid typing issues # https://github.com/home-assistant/core/pull/67046 multidict>=6.0.2 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 6ce97468699f0c..e8fdce6fa15f55 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -130,12 +130,6 @@ # Ensure we run compatible with musllinux build env numpy==1.26.0 -# Prevent dependency conflicts between sisyphus-control and aioambient -# until upper bounds for sisyphus-control have been updated -# https://github.com/jkeljo/sisyphus-control/issues/6 -python-engineio>=3.13.1,<4.0 -python-socketio>=4.6.0,<5.0 - # Constrain multidict to avoid typing issues # https://github.com/home-assistant/core/pull/67046 multidict>=6.0.2 From fa084143ef2c9a3d7ae3f33a2cd96bac6787fb5a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 11:58:11 -1000 Subject: [PATCH 19/67] Bump dbus-fast to 2.24.0 (#124737) changelog: https://github.com/Bluetooth-Devices/dbus-fast/compare/v2.23.0...v2.24.0 --- homeassistant/components/bluetooth/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index 93b07cb120cdca..027e2450bb47a0 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -19,7 +19,7 @@ "bluetooth-adapters==0.19.4", "bluetooth-auto-recovery==1.4.2", "bluetooth-data-tools==1.20.0", - "dbus-fast==2.23.0", + "dbus-fast==2.24.0", "habluetooth==3.3.2" ] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index b652484e6754be..3695317f064019 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -23,7 +23,7 @@ cached-ipaddress==0.5.0 certifi>=2021.5.30 ciso8601==2.3.1 cryptography==43.0.0 -dbus-fast==2.23.0 +dbus-fast==2.24.0 fnv-hash-fast==1.0.2 ha-av==10.1.1 ha-ffmpeg==3.2.0 diff --git a/requirements_all.txt b/requirements_all.txt index 784f2e65c00b74..24be22033ae1a9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -703,7 +703,7 @@ datadog==0.15.0 datapoint==0.9.9 # homeassistant.components.bluetooth -dbus-fast==2.23.0 +dbus-fast==2.24.0 # homeassistant.components.debugpy debugpy==1.8.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 293aa62a4d8b55..49354157ea56e2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -599,7 +599,7 @@ datadog==0.15.0 datapoint==0.9.9 # homeassistant.components.bluetooth -dbus-fast==2.23.0 +dbus-fast==2.24.0 # homeassistant.components.debugpy debugpy==1.8.1 From e84d9e21f7a5e4d68a70029fe34bae2079b240f7 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:15:41 +1200 Subject: [PATCH 20/67] Handle single state requests from ESPHome (#124660) Co-authored-by: J. Nick Koston --- homeassistant/components/esphome/manager.py | 14 ++++++++++- tests/components/esphome/conftest.py | 14 ++++++++++- tests/components/esphome/test_manager.py | 28 +++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/esphome/manager.py b/homeassistant/components/esphome/manager.py index 7629d1fa9cd57a..93e8d7b5bc2065 100644 --- a/homeassistant/components/esphome/manager.py +++ b/homeassistant/components/esphome/manager.py @@ -329,6 +329,15 @@ def async_on_state_subscription( entity_id, attribute, hass.states.get(entity_id) ) + @callback + def async_on_state_request( + self, entity_id: str, attribute: str | None = None + ) -> None: + """Forward state for requested entity.""" + self._send_home_assistant_state( + entity_id, attribute, self.hass.states.get(entity_id) + ) + def _handle_pipeline_finished(self) -> None: self.entry_data.async_set_assist_pipeline_state(False) @@ -526,7 +535,10 @@ async def _on_connnect(self) -> None: cli.subscribe_states(entry_data.async_update_state) cli.subscribe_service_calls(self.async_on_service_call) - cli.subscribe_home_assistant_states(self.async_on_state_subscription) + cli.subscribe_home_assistant_states( + self.async_on_state_subscription, + self.async_on_state_request, + ) entry_data.async_save_to_store() _async_check_firmware_version(hass, device_info, api_version) diff --git a/tests/components/esphome/conftest.py b/tests/components/esphome/conftest.py index ea4099560cd9e2..b3966875a318fb 100644 --- a/tests/components/esphome/conftest.py +++ b/tests/components/esphome/conftest.py @@ -205,6 +205,7 @@ def __init__( self.home_assistant_state_subscription_callback: Callable[ [str, str | None], None ] + self.home_assistant_state_request_callback: Callable[[str, str | None], None] self.voice_assistant_handle_start_callback: Callable[ [str, int, VoiceAssistantAudioSettings, str | None], Coroutine[Any, Any, int | None], @@ -268,9 +269,11 @@ async def mock_connect_error(self, exc: Exception) -> None: def set_home_assistant_state_subscription_callback( self, on_state_sub: Callable[[str, str | None], None], + on_state_request: Callable[[str, str | None], None], ) -> None: """Set the state call callback.""" self.home_assistant_state_subscription_callback = on_state_sub + self.home_assistant_state_request_callback = on_state_request def mock_home_assistant_state_subscription( self, entity_id: str, attribute: str | None @@ -278,6 +281,12 @@ def mock_home_assistant_state_subscription( """Mock a state subscription.""" self.home_assistant_state_subscription_callback(entity_id, attribute) + def mock_home_assistant_state_request( + self, entity_id: str, attribute: str | None + ) -> None: + """Mock a state request.""" + self.home_assistant_state_request_callback(entity_id, attribute) + def set_subscribe_voice_assistant_callbacks( self, handle_start: Callable[ @@ -378,9 +387,12 @@ def _subscribe_service_calls( def _subscribe_home_assistant_states( on_state_sub: Callable[[str, str | None], None], + on_state_request: Callable[[str, str | None], None], ) -> None: """Subscribe to home assistant states.""" - mock_device.set_home_assistant_state_subscription_callback(on_state_sub) + mock_device.set_home_assistant_state_subscription_callback( + on_state_sub, on_state_request + ) def _subscribe_voice_assistant( *, diff --git a/tests/components/esphome/test_manager.py b/tests/components/esphome/test_manager.py index 9d2a906466e9bf..a14c83bf265653 100644 --- a/tests/components/esphome/test_manager.py +++ b/tests/components/esphome/test_manager.py @@ -721,6 +721,34 @@ async def test_state_subscription( assert mock_client.send_home_assistant_state.mock_calls == [] +async def test_state_request( + mock_client: APIClient, + hass: HomeAssistant, + mock_esphome_device: Callable[ + [APIClient, list[EntityInfo], list[UserService], list[EntityState]], + Awaitable[MockESPHomeDevice], + ], +) -> None: + """Test ESPHome requests state change.""" + device: MockESPHomeDevice = await mock_esphome_device( + mock_client=mock_client, + entity_info=[], + user_service=[], + states=[], + ) + await hass.async_block_till_done() + hass.states.async_set("binary_sensor.test", "on", {"bool": True, "float": 3.0}) + device.mock_home_assistant_state_request("binary_sensor.test", None) + await hass.async_block_till_done() + assert mock_client.send_home_assistant_state.mock_calls == [ + call("binary_sensor.test", None, "on") + ] + mock_client.send_home_assistant_state.reset_mock() + hass.states.async_set("binary_sensor.test", "off", {"bool": False, "float": 5.0}) + await hass.async_block_till_done() + assert mock_client.send_home_assistant_state.mock_calls == [] + + async def test_debug_logging( mock_client: APIClient, hass: HomeAssistant, From 136f0e423e3324f5eade78aab984109f27cb7945 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 12:33:17 -1000 Subject: [PATCH 21/67] Bump aioambient to 2024.08.0 (#124729) --- homeassistant/components/ambient_network/manifest.json | 2 +- homeassistant/components/ambient_station/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/ambient_network/manifest.json b/homeassistant/components/ambient_network/manifest.json index 553adb240b063a..4800ffcb29db01 100644 --- a/homeassistant/components/ambient_network/manifest.json +++ b/homeassistant/components/ambient_network/manifest.json @@ -7,5 +7,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "loggers": ["aioambient"], - "requirements": ["aioambient==2024.01.0"] + "requirements": ["aioambient==2024.08.0"] } diff --git a/homeassistant/components/ambient_station/manifest.json b/homeassistant/components/ambient_station/manifest.json index 046ab9f73e988d..a14de5f37c55d6 100644 --- a/homeassistant/components/ambient_station/manifest.json +++ b/homeassistant/components/ambient_station/manifest.json @@ -7,5 +7,5 @@ "integration_type": "hub", "iot_class": "cloud_push", "loggers": ["aioambient"], - "requirements": ["aioambient==2024.01.0"] + "requirements": ["aioambient==2024.08.0"] } diff --git a/requirements_all.txt b/requirements_all.txt index 24be22033ae1a9..ddf4463d693bf9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -183,7 +183,7 @@ aioairzone==0.8.2 # homeassistant.components.ambient_network # homeassistant.components.ambient_station -aioambient==2024.01.0 +aioambient==2024.08.0 # homeassistant.components.apcupsd aioapcaccess==0.4.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 49354157ea56e2..e7c74ccf4005f4 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -171,7 +171,7 @@ aioairzone==0.8.2 # homeassistant.components.ambient_network # homeassistant.components.ambient_station -aioambient==2024.01.0 +aioambient==2024.08.0 # homeassistant.components.apcupsd aioapcaccess==0.4.2 From 5bd17c91985592c5e5a7284bb08ac0e086e5bc8f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 12:34:30 -1000 Subject: [PATCH 22/67] Bump aioshelly to 11.3.0 (#124741) --- homeassistant/components/shelly/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/shelly/manifest.json b/homeassistant/components/shelly/manifest.json index da3bbc4bb6edef..a384255705c975 100644 --- a/homeassistant/components/shelly/manifest.json +++ b/homeassistant/components/shelly/manifest.json @@ -9,7 +9,7 @@ "iot_class": "local_push", "loggers": ["aioshelly"], "quality_scale": "platinum", - "requirements": ["aioshelly==11.2.4"], + "requirements": ["aioshelly==11.3.0"], "zeroconf": [ { "type": "_http._tcp.local.", diff --git a/requirements_all.txt b/requirements_all.txt index ddf4463d693bf9..031baffc60f1f8 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -359,7 +359,7 @@ aioruuvigateway==0.1.0 aiosenz==1.0.0 # homeassistant.components.shelly -aioshelly==11.2.4 +aioshelly==11.3.0 # homeassistant.components.skybell aioskybell==22.7.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index e7c74ccf4005f4..5c860c386db071 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -341,7 +341,7 @@ aioruuvigateway==0.1.0 aiosenz==1.0.0 # homeassistant.components.shelly -aioshelly==11.2.4 +aioshelly==11.3.0 # homeassistant.components.skybell aioskybell==22.7.0 From 1b304e60d926ceffbe79e25c5065af233fc4c059 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 12:53:48 -1000 Subject: [PATCH 23/67] Disable sisyphus integration (#124742) --- homeassistant/components/sisyphus/__init__.py | 3 ++- homeassistant/components/sisyphus/manifest.json | 1 + homeassistant/components/sisyphus/media_player.py | 3 ++- homeassistant/components/sisyphus/ruff.toml | 5 +++++ requirements_all.txt | 3 --- 5 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 homeassistant/components/sisyphus/ruff.toml diff --git a/homeassistant/components/sisyphus/__init__.py b/homeassistant/components/sisyphus/__init__.py index da8d670d412472..1fc440f260dfa6 100644 --- a/homeassistant/components/sisyphus/__init__.py +++ b/homeassistant/components/sisyphus/__init__.py @@ -1,9 +1,10 @@ """Support for controlling Sisyphus Kinetic Art Tables.""" +# mypy: ignore-errors import asyncio import logging -from sisyphus_control import Table +# from sisyphus_control import Table import voluptuous as vol from homeassistant.const import CONF_HOST, CONF_NAME, EVENT_HOMEASSISTANT_STOP, Platform diff --git a/homeassistant/components/sisyphus/manifest.json b/homeassistant/components/sisyphus/manifest.json index dbb40344d66f3e..f1d90cebbd3da2 100644 --- a/homeassistant/components/sisyphus/manifest.json +++ b/homeassistant/components/sisyphus/manifest.json @@ -2,6 +2,7 @@ "domain": "sisyphus", "name": "Sisyphus", "codeowners": ["@jkeljo"], + "disabled": "This integration is disabled because it uses an old version of socketio.", "documentation": "https://www.home-assistant.io/integrations/sisyphus", "iot_class": "local_push", "loggers": ["sisyphus_control"], diff --git a/homeassistant/components/sisyphus/media_player.py b/homeassistant/components/sisyphus/media_player.py index 3884a83928a4ea..0248bbeac32407 100644 --- a/homeassistant/components/sisyphus/media_player.py +++ b/homeassistant/components/sisyphus/media_player.py @@ -1,10 +1,11 @@ """Support for track controls on the Sisyphus Kinetic Art Table.""" +# mypy: ignore-errors from __future__ import annotations import aiohttp -from sisyphus_control import Track +# from sisyphus_control import Track from homeassistant.components.media_player import ( MediaPlayerEntity, MediaPlayerEntityFeature, diff --git a/homeassistant/components/sisyphus/ruff.toml b/homeassistant/components/sisyphus/ruff.toml new file mode 100644 index 00000000000000..38f6f586aefe12 --- /dev/null +++ b/homeassistant/components/sisyphus/ruff.toml @@ -0,0 +1,5 @@ +extend = "../../../pyproject.toml" + +lint.extend-ignore = [ + "F821" +] diff --git a/requirements_all.txt b/requirements_all.txt index 031baffc60f1f8..53f7ed084806ee 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2618,9 +2618,6 @@ simplepush==2.2.3 # homeassistant.components.simplisafe simplisafe-python==2024.01.0 -# homeassistant.components.sisyphus -sisyphus-control==3.1.3 - # homeassistant.components.slack slackclient==2.5.0 From 3533ac163c4fe8e62254d7f66a3c8519ea332e78 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:57:08 -0400 Subject: [PATCH 24/67] Remove unnecessary assertion for the Yellow firmware type (#124747) --- homeassistant/components/homeassistant_yellow/config_flow.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/homeassistant/components/homeassistant_yellow/config_flow.py b/homeassistant/components/homeassistant_yellow/config_flow.py index ce6475ceb3c25b..1f4d150e49b556 100644 --- a/homeassistant/components/homeassistant_yellow/config_flow.py +++ b/homeassistant/components/homeassistant_yellow/config_flow.py @@ -96,8 +96,6 @@ async def async_step_system( def _async_flow_finished(self) -> ConfigFlowResult: """Create the config entry.""" - assert self._probed_firmware_type is not None - return self.async_create_entry( title=BOARD_NAME, data={ From 8fee1975b40e1b06e3d9b6152a23e9426e875c15 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 27 Aug 2024 19:26:46 -0500 Subject: [PATCH 25/67] Bump pyspeex-noise to 1.0.2 (#124721) Co-authored-by: TheJulianJES --- homeassistant/components/assist_pipeline/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/assist_pipeline/manifest.json b/homeassistant/components/assist_pipeline/manifest.json index c22b7391d33008..1b93ecd9eef37c 100644 --- a/homeassistant/components/assist_pipeline/manifest.json +++ b/homeassistant/components/assist_pipeline/manifest.json @@ -7,5 +7,5 @@ "integration_type": "system", "iot_class": "local_push", "quality_scale": "internal", - "requirements": ["pymicro-vad==1.0.1", "pyspeex-noise==1.0.0"] + "requirements": ["pymicro-vad==1.0.1", "pyspeex-noise==1.0.2"] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 3695317f064019..79c846d6c11fad 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -49,7 +49,7 @@ pymicro-vad==1.0.1 PyNaCl==1.5.0 pyOpenSSL==24.2.1 pyserial==3.5 -pyspeex-noise==1.0.0 +pyspeex-noise==1.0.2 python-slugify==8.0.4 PyTurboJPEG==1.7.1 pyudev==0.24.1 diff --git a/requirements_all.txt b/requirements_all.txt index 53f7ed084806ee..78028cf31d4373 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2229,7 +2229,7 @@ pysoma==0.0.12 pyspcwebgw==0.7.0 # homeassistant.components.assist_pipeline -pyspeex-noise==1.0.0 +pyspeex-noise==1.0.2 # homeassistant.components.squeezebox pysqueezebox==0.7.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 5c860c386db071..18c9dea0cf7db0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1783,7 +1783,7 @@ pysoma==0.0.12 pyspcwebgw==0.7.0 # homeassistant.components.assist_pipeline -pyspeex-noise==1.0.0 +pyspeex-noise==1.0.2 # homeassistant.components.squeezebox pysqueezebox==0.7.1 From e447d8302479dc91ccd12e08fb801d199d76fa48 Mon Sep 17 00:00:00 2001 From: functionpointer Date: Wed, 28 Aug 2024 03:04:08 +0200 Subject: [PATCH 26/67] Use ssl util in Tibber (#123369) Tibber: Use homeassistant.util.ssl --- homeassistant/components/tibber/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/tibber/__init__.py b/homeassistant/components/tibber/__init__.py index 3d63098b2e9047..ce05b8070f6c8d 100644 --- a/homeassistant/components/tibber/__init__.py +++ b/homeassistant/components/tibber/__init__.py @@ -18,7 +18,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType -from homeassistant.util import dt as dt_util +from homeassistant.util import dt as dt_util, ssl as ssl_util from .const import DATA_HASS_CONFIG, DOMAIN from .services import async_setup_services @@ -47,6 +47,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: access_token=entry.data[CONF_ACCESS_TOKEN], websession=async_get_clientsession(hass), time_zone=dt_util.get_default_time_zone(), + ssl=ssl_util.get_default_context(), ) hass.data[DOMAIN] = tibber_connection From 16dd6b1712f55a19dece113e0a8d32da2d3d0309 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 15:12:52 -1000 Subject: [PATCH 27/67] Disable control4 integration (#124746) --- homeassistant/components/control4/__init__.py | 8 +++++--- homeassistant/components/control4/config_flow.py | 9 ++++++--- homeassistant/components/control4/director_utils.py | 8 ++++---- homeassistant/components/control4/light.py | 7 ++++--- homeassistant/components/control4/manifest.json | 1 + homeassistant/components/control4/media_player.py | 7 ++++--- homeassistant/components/control4/ruff.toml | 5 +++++ requirements_all.txt | 3 --- requirements_test_all.txt | 3 --- tests/components/control4/ruff.toml | 5 +++++ tests/components/control4/test_config_flow.py | 10 ++++++---- 11 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 homeassistant/components/control4/ruff.toml create mode 100644 tests/components/control4/ruff.toml diff --git a/homeassistant/components/control4/__init__.py b/homeassistant/components/control4/__init__.py index a3d0cebd1fc72d..d4432a83c8452b 100644 --- a/homeassistant/components/control4/__init__.py +++ b/homeassistant/components/control4/__init__.py @@ -1,5 +1,7 @@ """The Control4 integration.""" +# mypy: ignore-errors + from __future__ import annotations import json @@ -7,10 +9,10 @@ from typing import Any from aiohttp import client_exceptions -from pyControl4.account import C4Account -from pyControl4.director import C4Director -from pyControl4.error_handling import BadCredentials +# from pyControl4.account import C4Account +# from pyControl4.director import C4Director +# from pyControl4.error_handling import BadCredentials from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_HOST, diff --git a/homeassistant/components/control4/config_flow.py b/homeassistant/components/control4/config_flow.py index aa7839b4383d34..40652767019f6f 100644 --- a/homeassistant/components/control4/config_flow.py +++ b/homeassistant/components/control4/config_flow.py @@ -1,14 +1,17 @@ """Config flow for Control4 integration.""" +# mypy: ignore-errors + from __future__ import annotations import logging from typing import Any from aiohttp.client_exceptions import ClientError -from pyControl4.account import C4Account -from pyControl4.director import C4Director -from pyControl4.error_handling import NotFound, Unauthorized + +# from pyControl4.account import C4Account +# from pyControl4.director import C4Director +# from pyControl4.error_handling import NotFound, Unauthorized import voluptuous as vol from homeassistant.config_entries import ( diff --git a/homeassistant/components/control4/director_utils.py b/homeassistant/components/control4/director_utils.py index 10e9486ee89d66..92ca9f9d61524d 100644 --- a/homeassistant/components/control4/director_utils.py +++ b/homeassistant/components/control4/director_utils.py @@ -1,13 +1,13 @@ """Provides data updates from the Control4 controller for platforms.""" +# mypy: ignore-errors from collections import defaultdict import logging from typing import Any -from pyControl4.account import C4Account -from pyControl4.director import C4Director -from pyControl4.error_handling import BadToken - +# from pyControl4.account import C4Account +# from pyControl4.director import C4Director +# from pyControl4.error_handling import BadToken from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME from homeassistant.core import HomeAssistant diff --git a/homeassistant/components/control4/light.py b/homeassistant/components/control4/light.py index d7cfd44dc43a0c..4d20f966cc2a6c 100644 --- a/homeassistant/components/control4/light.py +++ b/homeassistant/components/control4/light.py @@ -1,5 +1,7 @@ """Platform for Control4 Lights.""" +# mypy: ignore-errors + from __future__ import annotations import asyncio @@ -7,9 +9,8 @@ import logging from typing import Any -from pyControl4.error_handling import C4Exception -from pyControl4.light import C4Light - +# from pyControl4.error_handling import C4Exception +# from pyControl4.light import C4Light from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_TRANSITION, diff --git a/homeassistant/components/control4/manifest.json b/homeassistant/components/control4/manifest.json index 765f0dce78ced4..7c846617bf02a3 100644 --- a/homeassistant/components/control4/manifest.json +++ b/homeassistant/components/control4/manifest.json @@ -3,6 +3,7 @@ "name": "Control4", "codeowners": ["@lawtancool"], "config_flow": true, + "disabled": "This integration is disabled because it uses an old version of socketio.", "documentation": "https://www.home-assistant.io/integrations/control4", "iot_class": "local_polling", "loggers": ["pyControl4"], diff --git a/homeassistant/components/control4/media_player.py b/homeassistant/components/control4/media_player.py index 72aa44faaed5f0..21c26fa1152c6c 100644 --- a/homeassistant/components/control4/media_player.py +++ b/homeassistant/components/control4/media_player.py @@ -1,5 +1,7 @@ """Platform for Control4 Rooms Media Players.""" +# mypy: ignore-errors + from __future__ import annotations from dataclasses import dataclass @@ -8,9 +10,8 @@ import logging from typing import Any -from pyControl4.error_handling import C4Exception -from pyControl4.room import C4Room - +# from pyControl4.error_handling import C4Exception +# from pyControl4.room import C4Room from homeassistant.components.media_player import ( MediaPlayerDeviceClass, MediaPlayerEntity, diff --git a/homeassistant/components/control4/ruff.toml b/homeassistant/components/control4/ruff.toml new file mode 100644 index 00000000000000..38f6f586aefe12 --- /dev/null +++ b/homeassistant/components/control4/ruff.toml @@ -0,0 +1,5 @@ +extend = "../../../pyproject.toml" + +lint.extend-ignore = [ + "F821" +] diff --git a/requirements_all.txt b/requirements_all.txt index 78028cf31d4373..f29766ad260284 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1685,9 +1685,6 @@ pyAtome==0.1.1 # homeassistant.components.hdmi_cec pyCEC==0.5.2 -# homeassistant.components.control4 -pyControl4==1.1.0 - # homeassistant.components.duotecno pyDuotecno==2024.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 18c9dea0cf7db0..68460b9ec9875a 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1368,9 +1368,6 @@ py-synologydsm-api==2.5.2 # homeassistant.components.hdmi_cec pyCEC==0.5.2 -# homeassistant.components.control4 -pyControl4==1.1.0 - # homeassistant.components.duotecno pyDuotecno==2024.5.1 diff --git a/tests/components/control4/ruff.toml b/tests/components/control4/ruff.toml new file mode 100644 index 00000000000000..38f6f586aefe12 --- /dev/null +++ b/tests/components/control4/ruff.toml @@ -0,0 +1,5 @@ +extend = "../../../pyproject.toml" + +lint.extend-ignore = [ + "F821" +] diff --git a/tests/components/control4/test_config_flow.py b/tests/components/control4/test_config_flow.py index 9a1b392f61ccf5..01456cc05980ce 100644 --- a/tests/components/control4/test_config_flow.py +++ b/tests/components/control4/test_config_flow.py @@ -1,11 +1,13 @@ """Test the Control4 config flow.""" +# mypy: ignore-errors from unittest.mock import AsyncMock, patch -from pyControl4.account import C4Account -from pyControl4.director import C4Director -from pyControl4.error_handling import Unauthorized +import pytest +# from pyControl4.account import C4Account +# from pyControl4.director import C4Director +# from pyControl4.error_handling import Unauthorized from homeassistant import config_entries from homeassistant.components.control4.const import DEFAULT_SCAN_INTERVAL, DOMAIN from homeassistant.const import ( @@ -16,7 +18,6 @@ ) from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType - from tests.common import MockConfigEntry @@ -41,6 +42,7 @@ def _get_mock_c4_director(): return c4_director_mock +@pytest.skip(allow_module_level=True) async def test_form(hass: HomeAssistant) -> None: """Test we get the form.""" From 9d3895d69a919ed45cf2b8b80da43a1bf890bcbe Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 15:36:00 -1000 Subject: [PATCH 28/67] Bump yalexs to 8.5.4 (#124672) --- homeassistant/components/august/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/august/mocks.py | 5 +---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/august/manifest.json b/homeassistant/components/august/manifest.json index 42f5dfd8409dc0..a20ec5a2205f62 100644 --- a/homeassistant/components/august/manifest.json +++ b/homeassistant/components/august/manifest.json @@ -28,5 +28,5 @@ "documentation": "https://www.home-assistant.io/integrations/august", "iot_class": "cloud_push", "loggers": ["pubnub", "yalexs"], - "requirements": ["yalexs==8.4.2", "yalexs-ble==2.4.3"] + "requirements": ["yalexs==8.5.4", "yalexs-ble==2.4.3"] } diff --git a/requirements_all.txt b/requirements_all.txt index f29766ad260284..8bac05a047ab58 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2968,7 +2968,7 @@ yalesmartalarmclient==0.4.0 yalexs-ble==2.4.3 # homeassistant.components.august -yalexs==8.4.2 +yalexs==8.5.4 # homeassistant.components.yeelight yeelight==0.7.14 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 68460b9ec9875a..71f4a1ea012b29 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2351,7 +2351,7 @@ yalesmartalarmclient==0.4.0 yalexs-ble==2.4.3 # homeassistant.components.august -yalexs==8.4.2 +yalexs==8.5.4 # homeassistant.components.yeelight yeelight==0.7.14 diff --git a/tests/components/august/mocks.py b/tests/components/august/mocks.py index c2ab8ce743c15b..43cc4957445be9 100644 --- a/tests/components/august/mocks.py +++ b/tests/components/august/mocks.py @@ -82,10 +82,7 @@ async def _mock_setup_august( ) entry.add_to_hass(hass) with ( - patch( - "yalexs.manager.data.async_create_pubnub", - return_value=AsyncMock(), - ), + patch.object(pubnub_mock, "run"), patch("yalexs.manager.data.AugustPubNub", return_value=pubnub_mock), ): assert await hass.config_entries.async_setup(entry.entry_id) From e720a14dc484bd523e8a9121faaf1ecf29b9f1f9 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Wed, 28 Aug 2024 07:49:05 +0200 Subject: [PATCH 29/67] Cleanup removed `schema` option from mqtt vacuum platform (#124722) --- homeassistant/components/mqtt/vacuum.py | 30 +------- tests/components/mqtt/test_legacy_vacuum.py | 83 --------------------- tests/components/mqtt/test_vacuum.py | 27 ------- 3 files changed, 3 insertions(+), 137 deletions(-) delete mode 100644 tests/components/mqtt/test_legacy_vacuum.py diff --git a/homeassistant/components/mqtt/vacuum.py b/homeassistant/components/mqtt/vacuum.py index c9898465184963..87d6c9dd7446e6 100644 --- a/homeassistant/components/mqtt/vacuum.py +++ b/homeassistant/components/mqtt/vacuum.py @@ -1,10 +1,5 @@ """Support for MQTT vacuums.""" -# The legacy schema for MQTT vacuum was deprecated with HA Core 2023.8.0 -# and was removed with HA Core 2024.2.0 -# The use of the schema attribute with MQTT vacuum was deprecated with HA Core 2024.2 -# the attribute will be remove with HA Core 2024.8 - from __future__ import annotations import logging @@ -38,15 +33,12 @@ from . import subscription from .config import MQTT_BASE_SCHEMA -from .const import CONF_COMMAND_TOPIC, CONF_RETAIN, CONF_SCHEMA, CONF_STATE_TOPIC +from .const import CONF_COMMAND_TOPIC, CONF_RETAIN, CONF_STATE_TOPIC from .mixins import MqttEntity, async_setup_entity_entry_helper from .models import ReceiveMessage from .schemas import MQTT_ENTITY_COMMON_SCHEMA from .util import valid_publish_topic -LEGACY = "legacy" -STATE = "state" - BATTERY = "battery_level" FAN_SPEED = "fan_speed" STATE = "state" @@ -149,7 +141,7 @@ def services_to_strings( MQTT_VACUUM_DOCS_URL = "https://www.home-assistant.io/integrations/vacuum.mqtt/" -VACUUM_BASE_SCHEMA = MQTT_BASE_SCHEMA.extend( +PLATFORM_SCHEMA_MODERN = MQTT_BASE_SCHEMA.extend( { vol.Optional(CONF_FAN_SPEED_LIST, default=[]): vol.All( cv.ensure_list, [cv.string] @@ -173,26 +165,10 @@ def services_to_strings( ), vol.Optional(CONF_COMMAND_TOPIC): valid_publish_topic, vol.Optional(CONF_RETAIN, default=DEFAULT_RETAIN): cv.boolean, - vol.Optional(CONF_SCHEMA): vol.All(vol.Lower, vol.Any(LEGACY, STATE)), } ).extend(MQTT_ENTITY_COMMON_SCHEMA.schema) -DISCOVERY_SCHEMA = vol.All( - VACUUM_BASE_SCHEMA.extend({}, extra=vol.ALLOW_EXTRA), - # Do not fail a config is the schema option is still present, - # De option was deprecated with HA Core 2024.2 and removed with HA Core 2024.8. - # As we allow extra options, and we will remove this check silently - # with HA Core 2025.8.0, we will only warn, - # if a adiscovery config still uses this option. - cv.removed(CONF_SCHEMA, raise_if_present=False), -) - -PLATFORM_SCHEMA_MODERN = vol.All( - VACUUM_BASE_SCHEMA, - # The schema options was removed with HA Core 2024.8, - # the cleanup is planned for HA Core 2025.8. - cv.removed(CONF_SCHEMA, raise_if_present=True), -) +DISCOVERY_SCHEMA = PLATFORM_SCHEMA_MODERN.extend({}, extra=vol.ALLOW_EXTRA) async def async_setup_entry( diff --git a/tests/components/mqtt/test_legacy_vacuum.py b/tests/components/mqtt/test_legacy_vacuum.py deleted file mode 100644 index 9b45b65d2cc4cc..00000000000000 --- a/tests/components/mqtt/test_legacy_vacuum.py +++ /dev/null @@ -1,83 +0,0 @@ -"""The tests for the Legacy Mqtt vacuum platform.""" - -# The legacy schema for MQTT vacuum was deprecated with HA Core 2023.8.0 -# and was removed with HA Core 2024.2.0 -# cleanup is planned with HA Core 2025.2 - -import json - -import pytest - -from homeassistant.components import mqtt, vacuum -from homeassistant.core import HomeAssistant -from homeassistant.helpers.typing import DiscoveryInfoType - -from tests.common import async_fire_mqtt_message -from tests.typing import MqttMockHAClientGenerator - -DEFAULT_CONFIG = {mqtt.DOMAIN: {vacuum.DOMAIN: {"name": "test"}}} - - -@pytest.mark.parametrize( - ("hass_config", "removed"), - [ - ({mqtt.DOMAIN: {vacuum.DOMAIN: {"name": "test", "schema": "legacy"}}}, True), - ({mqtt.DOMAIN: {vacuum.DOMAIN: {"name": "test"}}}, False), - ({mqtt.DOMAIN: {vacuum.DOMAIN: {"name": "test", "schema": "state"}}}, True), - ], -) -async def test_removed_support_yaml( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, - removed: bool, -) -> None: - """Test that the removed support validation for the legacy schema works.""" - assert await mqtt_mock_entry() - entity = hass.states.get("vacuum.test") - - if removed: - assert entity is None - assert ( - "The 'schema' option has been removed, " - "please remove it from your configuration" in caplog.text - ) - else: - assert entity is not None - - -@pytest.mark.parametrize( - ("config", "removed"), - [ - ({"name": "test", "schema": "legacy"}, True), - ({"name": "test"}, False), - ({"name": "test", "schema": "state"}, True), - ], -) -async def test_removed_support_discovery( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, - config: DiscoveryInfoType, - removed: bool, -) -> None: - """Test that the removed support validation for the legacy schema works.""" - assert await mqtt_mock_entry() - - config_payload = json.dumps(config) - async_fire_mqtt_message(hass, "homeassistant/vacuum/test/config", config_payload) - await hass.async_block_till_done() - - entity = hass.states.get("vacuum.test") - assert entity is not None - - if removed: - assert ( - "The 'schema' option has been removed, " - "please remove it from your configuration" in caplog.text - ) - else: - assert ( - "The 'schema' option has been removed, " - "please remove it from your configuration" not in caplog.text - ) diff --git a/tests/components/mqtt/test_vacuum.py b/tests/components/mqtt/test_vacuum.py index 7fc4ff981fd88d..fbffe062261049 100644 --- a/tests/components/mqtt/test_vacuum.py +++ b/tests/components/mqtt/test_vacuum.py @@ -2,7 +2,6 @@ from copy import deepcopy import json -import logging from typing import Any from unittest.mock import patch @@ -102,32 +101,6 @@ ) -async def test_warning_schema_option( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, -) -> None: - """Test the warning on use of deprecated schema option.""" - await mqtt_mock_entry() - # Send discovery message with deprecated schema option - async_fire_mqtt_message( - hass, - f"homeassistant/{vacuum.DOMAIN}/bla/config", - '{"name": "test", "schema": "state", "o": {"name": "Bla2MQTT", "sw": "0.99", "url":"https://example.com/support"}}', - ) - await hass.async_block_till_done() - await hass.async_block_till_done(wait_background_tasks=True) - - state = hass.states.get("vacuum.test") - # We do not fail if the schema option is still in the payload, but we log an error - assert state is not None - with caplog.at_level(logging.WARNING): - assert ( - "The 'schema' option has been removed, " - "please remove it from your configuration" in caplog.text - ) - - @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) async def test_default_supported_features( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator From 42388450e1cc293e18af1e2305ba734f6f6da011 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 19:54:28 -1000 Subject: [PATCH 30/67] Restore control4 integration (#124750) * Revert "Disable control4 integration (#124746)" This reverts commit 16dd6b1712f55a19dece113e0a8d32da2d3d0309. * Restore control4 integration reverts #124746 and updates the lib instead changelog: https://github.com/lawtancool/pyControl4/compare/v1.1.0...v1.1.3 Note that there is no release yet, see https://github.com/lawtancool/pyControl4/pull/32 * Apply suggestions from code review --- homeassistant/components/control4/__init__.py | 8 +++----- homeassistant/components/control4/config_flow.py | 9 +++------ homeassistant/components/control4/director_utils.py | 8 ++++---- homeassistant/components/control4/light.py | 7 +++---- homeassistant/components/control4/manifest.json | 3 +-- homeassistant/components/control4/media_player.py | 7 +++---- homeassistant/components/control4/ruff.toml | 5 ----- requirements_all.txt | 3 +++ requirements_test_all.txt | 3 +++ tests/components/control4/ruff.toml | 5 ----- tests/components/control4/test_config_flow.py | 10 ++++------ 11 files changed, 27 insertions(+), 41 deletions(-) delete mode 100644 homeassistant/components/control4/ruff.toml delete mode 100644 tests/components/control4/ruff.toml diff --git a/homeassistant/components/control4/__init__.py b/homeassistant/components/control4/__init__.py index d4432a83c8452b..a3d0cebd1fc72d 100644 --- a/homeassistant/components/control4/__init__.py +++ b/homeassistant/components/control4/__init__.py @@ -1,7 +1,5 @@ """The Control4 integration.""" -# mypy: ignore-errors - from __future__ import annotations import json @@ -9,10 +7,10 @@ from typing import Any from aiohttp import client_exceptions +from pyControl4.account import C4Account +from pyControl4.director import C4Director +from pyControl4.error_handling import BadCredentials -# from pyControl4.account import C4Account -# from pyControl4.director import C4Director -# from pyControl4.error_handling import BadCredentials from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_HOST, diff --git a/homeassistant/components/control4/config_flow.py b/homeassistant/components/control4/config_flow.py index 40652767019f6f..aa7839b4383d34 100644 --- a/homeassistant/components/control4/config_flow.py +++ b/homeassistant/components/control4/config_flow.py @@ -1,17 +1,14 @@ """Config flow for Control4 integration.""" -# mypy: ignore-errors - from __future__ import annotations import logging from typing import Any from aiohttp.client_exceptions import ClientError - -# from pyControl4.account import C4Account -# from pyControl4.director import C4Director -# from pyControl4.error_handling import NotFound, Unauthorized +from pyControl4.account import C4Account +from pyControl4.director import C4Director +from pyControl4.error_handling import NotFound, Unauthorized import voluptuous as vol from homeassistant.config_entries import ( diff --git a/homeassistant/components/control4/director_utils.py b/homeassistant/components/control4/director_utils.py index 92ca9f9d61524d..10e9486ee89d66 100644 --- a/homeassistant/components/control4/director_utils.py +++ b/homeassistant/components/control4/director_utils.py @@ -1,13 +1,13 @@ """Provides data updates from the Control4 controller for platforms.""" -# mypy: ignore-errors from collections import defaultdict import logging from typing import Any -# from pyControl4.account import C4Account -# from pyControl4.director import C4Director -# from pyControl4.error_handling import BadToken +from pyControl4.account import C4Account +from pyControl4.director import C4Director +from pyControl4.error_handling import BadToken + from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME from homeassistant.core import HomeAssistant diff --git a/homeassistant/components/control4/light.py b/homeassistant/components/control4/light.py index 4d20f966cc2a6c..d7cfd44dc43a0c 100644 --- a/homeassistant/components/control4/light.py +++ b/homeassistant/components/control4/light.py @@ -1,7 +1,5 @@ """Platform for Control4 Lights.""" -# mypy: ignore-errors - from __future__ import annotations import asyncio @@ -9,8 +7,9 @@ import logging from typing import Any -# from pyControl4.error_handling import C4Exception -# from pyControl4.light import C4Light +from pyControl4.error_handling import C4Exception +from pyControl4.light import C4Light + from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_TRANSITION, diff --git a/homeassistant/components/control4/manifest.json b/homeassistant/components/control4/manifest.json index 7c846617bf02a3..3088ebf8672fe4 100644 --- a/homeassistant/components/control4/manifest.json +++ b/homeassistant/components/control4/manifest.json @@ -3,11 +3,10 @@ "name": "Control4", "codeowners": ["@lawtancool"], "config_flow": true, - "disabled": "This integration is disabled because it uses an old version of socketio.", "documentation": "https://www.home-assistant.io/integrations/control4", "iot_class": "local_polling", "loggers": ["pyControl4"], - "requirements": ["pyControl4==1.1.0"], + "requirements": ["pyControl4==1.2.0"], "ssdp": [ { "st": "c4:director" diff --git a/homeassistant/components/control4/media_player.py b/homeassistant/components/control4/media_player.py index 21c26fa1152c6c..72aa44faaed5f0 100644 --- a/homeassistant/components/control4/media_player.py +++ b/homeassistant/components/control4/media_player.py @@ -1,7 +1,5 @@ """Platform for Control4 Rooms Media Players.""" -# mypy: ignore-errors - from __future__ import annotations from dataclasses import dataclass @@ -10,8 +8,9 @@ import logging from typing import Any -# from pyControl4.error_handling import C4Exception -# from pyControl4.room import C4Room +from pyControl4.error_handling import C4Exception +from pyControl4.room import C4Room + from homeassistant.components.media_player import ( MediaPlayerDeviceClass, MediaPlayerEntity, diff --git a/homeassistant/components/control4/ruff.toml b/homeassistant/components/control4/ruff.toml deleted file mode 100644 index 38f6f586aefe12..00000000000000 --- a/homeassistant/components/control4/ruff.toml +++ /dev/null @@ -1,5 +0,0 @@ -extend = "../../../pyproject.toml" - -lint.extend-ignore = [ - "F821" -] diff --git a/requirements_all.txt b/requirements_all.txt index 8bac05a047ab58..4633f0b093c560 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1685,6 +1685,9 @@ pyAtome==0.1.1 # homeassistant.components.hdmi_cec pyCEC==0.5.2 +# homeassistant.components.control4 +pyControl4==1.2.0 + # homeassistant.components.duotecno pyDuotecno==2024.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 71f4a1ea012b29..8688b7a6dccd0d 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1368,6 +1368,9 @@ py-synologydsm-api==2.5.2 # homeassistant.components.hdmi_cec pyCEC==0.5.2 +# homeassistant.components.control4 +pyControl4==1.2.0 + # homeassistant.components.duotecno pyDuotecno==2024.5.1 diff --git a/tests/components/control4/ruff.toml b/tests/components/control4/ruff.toml deleted file mode 100644 index 38f6f586aefe12..00000000000000 --- a/tests/components/control4/ruff.toml +++ /dev/null @@ -1,5 +0,0 @@ -extend = "../../../pyproject.toml" - -lint.extend-ignore = [ - "F821" -] diff --git a/tests/components/control4/test_config_flow.py b/tests/components/control4/test_config_flow.py index 01456cc05980ce..9a1b392f61ccf5 100644 --- a/tests/components/control4/test_config_flow.py +++ b/tests/components/control4/test_config_flow.py @@ -1,13 +1,11 @@ """Test the Control4 config flow.""" -# mypy: ignore-errors from unittest.mock import AsyncMock, patch -import pytest +from pyControl4.account import C4Account +from pyControl4.director import C4Director +from pyControl4.error_handling import Unauthorized -# from pyControl4.account import C4Account -# from pyControl4.director import C4Director -# from pyControl4.error_handling import Unauthorized from homeassistant import config_entries from homeassistant.components.control4.const import DEFAULT_SCAN_INTERVAL, DOMAIN from homeassistant.const import ( @@ -18,6 +16,7 @@ ) from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType + from tests.common import MockConfigEntry @@ -42,7 +41,6 @@ def _get_mock_c4_director(): return c4_director_mock -@pytest.skip(allow_module_level=True) async def test_form(hass: HomeAssistant) -> None: """Test we get the form.""" From 4108b7ada65a27877d67758371de0f34aca02fb7 Mon Sep 17 00:00:00 2001 From: Sergey Dudanov Date: Wed, 28 Aug 2024 10:45:40 +0400 Subject: [PATCH 31/67] Remove unused normalized units from unit converters (#122797) remove unused normalized units in unit converters --- homeassistant/util/unit_conversion.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/homeassistant/util/unit_conversion.py b/homeassistant/util/unit_conversion.py index 2b9f73afab7e1f..d5586704fc5388 100644 --- a/homeassistant/util/unit_conversion.py +++ b/homeassistant/util/unit_conversion.py @@ -68,7 +68,6 @@ class BaseUnitConverter: """Define the format of a conversion utility.""" UNIT_CLASS: str - NORMALIZED_UNIT: str | None VALID_UNITS: set[str | None] _UNIT_CONVERSION: dict[str | None, float] @@ -125,7 +124,6 @@ class DataRateConverter(BaseUnitConverter): """Utility to convert data rate values.""" UNIT_CLASS = "data_rate" - NORMALIZED_UNIT = UnitOfDataRate.BITS_PER_SECOND # Units in terms of bits _UNIT_CONVERSION: dict[str | None, float] = { UnitOfDataRate.BITS_PER_SECOND: 1, @@ -147,7 +145,6 @@ class DistanceConverter(BaseUnitConverter): """Utility to convert distance values.""" UNIT_CLASS = "distance" - NORMALIZED_UNIT = UnitOfLength.METERS _UNIT_CONVERSION: dict[str | None, float] = { UnitOfLength.METERS: 1, UnitOfLength.MILLIMETERS: 1 / _MM_TO_M, @@ -174,7 +171,6 @@ class ConductivityConverter(BaseUnitConverter): """Utility to convert electric current values.""" UNIT_CLASS = "conductivity" - NORMALIZED_UNIT = UnitOfConductivity.MICROSIEMENS _UNIT_CONVERSION: dict[str | None, float] = { UnitOfConductivity.MICROSIEMENS: 1, UnitOfConductivity.MILLISIEMENS: 1e-3, @@ -187,7 +183,6 @@ class ElectricCurrentConverter(BaseUnitConverter): """Utility to convert electric current values.""" UNIT_CLASS = "electric_current" - NORMALIZED_UNIT = UnitOfElectricCurrent.AMPERE _UNIT_CONVERSION: dict[str | None, float] = { UnitOfElectricCurrent.AMPERE: 1, UnitOfElectricCurrent.MILLIAMPERE: 1e3, @@ -199,7 +194,6 @@ class ElectricPotentialConverter(BaseUnitConverter): """Utility to convert electric potential values.""" UNIT_CLASS = "voltage" - NORMALIZED_UNIT = UnitOfElectricPotential.VOLT _UNIT_CONVERSION: dict[str | None, float] = { UnitOfElectricPotential.VOLT: 1, UnitOfElectricPotential.MILLIVOLT: 1e3, @@ -214,7 +208,6 @@ class EnergyConverter(BaseUnitConverter): """Utility to convert energy values.""" UNIT_CLASS = "energy" - NORMALIZED_UNIT = UnitOfEnergy.KILO_WATT_HOUR _UNIT_CONVERSION: dict[str | None, float] = { UnitOfEnergy.WATT_HOUR: 1 * 1000, UnitOfEnergy.KILO_WATT_HOUR: 1, @@ -235,7 +228,6 @@ class InformationConverter(BaseUnitConverter): """Utility to convert information values.""" UNIT_CLASS = "information" - NORMALIZED_UNIT = UnitOfInformation.BITS # Units in terms of bits _UNIT_CONVERSION: dict[str | None, float] = { UnitOfInformation.BITS: 1, @@ -267,7 +259,6 @@ class MassConverter(BaseUnitConverter): """Utility to convert mass values.""" UNIT_CLASS = "mass" - NORMALIZED_UNIT = UnitOfMass.GRAMS _UNIT_CONVERSION: dict[str | None, float] = { UnitOfMass.MICROGRAMS: 1 * 1000 * 1000, UnitOfMass.MILLIGRAMS: 1 * 1000, @@ -292,7 +283,6 @@ class PowerConverter(BaseUnitConverter): """Utility to convert power values.""" UNIT_CLASS = "power" - NORMALIZED_UNIT = UnitOfPower.WATT _UNIT_CONVERSION: dict[str | None, float] = { UnitOfPower.WATT: 1, UnitOfPower.KILO_WATT: 1 / 1000, @@ -307,7 +297,6 @@ class PressureConverter(BaseUnitConverter): """Utility to convert pressure values.""" UNIT_CLASS = "pressure" - NORMALIZED_UNIT = UnitOfPressure.PA _UNIT_CONVERSION: dict[str | None, float] = { UnitOfPressure.PA: 1, UnitOfPressure.HPA: 1 / 100, @@ -338,7 +327,6 @@ class SpeedConverter(BaseUnitConverter): """Utility to convert speed values.""" UNIT_CLASS = "speed" - NORMALIZED_UNIT = UnitOfSpeed.METERS_PER_SECOND _UNIT_CONVERSION: dict[str | None, float] = { UnitOfVolumetricFlux.INCHES_PER_DAY: _DAYS_TO_SECS / _IN_TO_M, UnitOfVolumetricFlux.INCHES_PER_HOUR: _HRS_TO_SECS / _IN_TO_M, @@ -433,7 +421,6 @@ class TemperatureConverter(BaseUnitConverter): """Utility to convert temperature values.""" UNIT_CLASS = "temperature" - NORMALIZED_UNIT = UnitOfTemperature.CELSIUS VALID_UNITS = { UnitOfTemperature.CELSIUS, UnitOfTemperature.FAHRENHEIT, @@ -564,7 +551,6 @@ class UnitlessRatioConverter(BaseUnitConverter): """Utility to convert unitless ratios.""" UNIT_CLASS = "unitless" - NORMALIZED_UNIT = None _UNIT_CONVERSION: dict[str | None, float] = { None: 1, CONCENTRATION_PARTS_PER_BILLION: 1000000000, @@ -581,7 +567,6 @@ class VolumeConverter(BaseUnitConverter): """Utility to convert volume values.""" UNIT_CLASS = "volume" - NORMALIZED_UNIT = UnitOfVolume.CUBIC_METERS # Units in terms of m³ _UNIT_CONVERSION: dict[str | None, float] = { UnitOfVolume.LITERS: 1 / _L_TO_CUBIC_METER, @@ -607,7 +592,6 @@ class VolumeFlowRateConverter(BaseUnitConverter): """Utility to convert volume values.""" UNIT_CLASS = "volume_flow_rate" - NORMALIZED_UNIT = UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR # Units in terms of m³/h _UNIT_CONVERSION: dict[str | None, float] = { UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR: 1, @@ -630,7 +614,6 @@ class DurationConverter(BaseUnitConverter): """Utility to convert duration values.""" UNIT_CLASS = "duration" - NORMALIZED_UNIT = UnitOfTime.SECONDS _UNIT_CONVERSION: dict[str | None, float] = { UnitOfTime.MICROSECONDS: 1000000, UnitOfTime.MILLISECONDS: 1000, From a63c5e67257c6b2c1f06692edb62f945db7c7d08 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 21:00:20 -1000 Subject: [PATCH 32/67] Cache shelly coordinator properties that never change (#124756) --- homeassistant/components/shelly/coordinator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 918dd9207658b7..012f6b43dc7512 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -6,6 +6,7 @@ from collections.abc import Callable, Coroutine from dataclasses import dataclass from datetime import timedelta +from functools import cached_property from typing import Any, cast from aioshelly.ble import async_ensure_ble_enabled, async_stop_scanner @@ -120,12 +121,12 @@ def __init__( hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop) ) - @property + @cached_property def model(self) -> str: """Model of the device.""" return cast(str, self.entry.data["model"]) - @property + @cached_property def mac(self) -> str: """Mac address of the device.""" return cast(str, self.entry.unique_id) From f9bf7f7e05f7e7719b3a65ec993ef66eed245d5f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Aug 2024 21:00:31 -1000 Subject: [PATCH 33/67] Small cleanups to shelly (#124758) --- homeassistant/components/shelly/entity.py | 6 +++--- homeassistant/components/shelly/number.py | 8 ++++---- homeassistant/components/shelly/sensor.py | 8 +++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index 980a39feaba914..aea060e09e2ed2 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -488,7 +488,7 @@ def available(self) -> bool: @property def attribute_value(self) -> StateType: """Value of sensor.""" - if callable(self.entity_description.value): + if self.entity_description.value is not None: self._last_value = self.entity_description.value( self.block_coordinator.device.status, self._last_value ) @@ -518,7 +518,7 @@ def __init__( id_key = key.split(":")[-1] self._id = int(id_key) if id_key.isnumeric() else None - if callable(description.unit): + if description.unit is not None: self._attr_native_unit_of_measurement = description.unit( coordinator.device.config[key] ) @@ -544,7 +544,7 @@ def sub_status(self) -> Any: @property def attribute_value(self) -> StateType: """Value of sensor.""" - if callable(self.entity_description.value): + if self.entity_description.value is not None: # using "get" here since subkey might not exist (e.g. "errors" sub_key) self._last_value = self.entity_description.value( self.status.get(self.entity_description.sub_key), self._last_value diff --git a/homeassistant/components/shelly/number.py b/homeassistant/components/shelly/number.py index 67c33faf1506c1..1e0f5b020ac865 100644 --- a/homeassistant/components/shelly/number.py +++ b/homeassistant/components/shelly/number.py @@ -207,17 +207,17 @@ def __init__( """Initialize sensor.""" super().__init__(coordinator, key, attribute, description) - if callable(description.max_fn): + if description.max_fn is not None: self._attr_native_max_value = description.max_fn( coordinator.device.config[key] ) - if callable(description.min_fn): + if description.min_fn is not None: self._attr_native_min_value = description.min_fn( coordinator.device.config[key] ) - if callable(description.step_fn): + if description.step_fn is not None: self._attr_native_step = description.step_fn(coordinator.device.config[key]) - if callable(description.mode_fn): + if description.mode_fn is not None: self._attr_mode = description.mode_fn(coordinator.device.config[key]) @property diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 0d782f46c2486c..1ef174119e4a2d 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -1266,13 +1266,15 @@ def __init__( @property def native_value(self) -> StateType: """Return value of sensor.""" + attribute_value = self.attribute_value + if not self.option_map: - return self.attribute_value + return attribute_value - if not isinstance(self.attribute_value, str): + if not isinstance(attribute_value, str): return None - return self.option_map[self.attribute_value] + return self.option_map[attribute_value] class BlockSleepingSensor(ShellySleepingBlockAttributeEntity, RestoreSensor): From 1add00a68daf0a966f7491a0455589e9d9eed947 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 09:25:56 +0200 Subject: [PATCH 34/67] Deduplicate STT mocks (#124754) --- tests/components/assist_pipeline/conftest.py | 76 ++-------- tests/components/assist_pipeline/test_init.py | 26 ++-- .../assist_pipeline/test_pipeline.py | 6 +- .../assist_pipeline/test_websocket.py | 2 +- tests/components/stt/common.py | 89 +++++++++++- tests/components/stt/test_init.py | 137 +++++------------- 6 files changed, 147 insertions(+), 189 deletions(-) diff --git a/tests/components/assist_pipeline/conftest.py b/tests/components/assist_pipeline/conftest.py index b7bf83a7ed0a0c..c03874c16af71b 100644 --- a/tests/components/assist_pipeline/conftest.py +++ b/tests/components/assist_pipeline/conftest.py @@ -36,6 +36,7 @@ mock_integration, mock_platform, ) +from tests.components.stt.common import MockSTTProvider, MockSTTProviderEntity _TRANSCRIPT = "test transcript" @@ -47,67 +48,6 @@ def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> None: """Mock the TTS cache dir with empty dir.""" -class BaseProvider: - """Mock STT provider.""" - - _supported_languages = ["en-US"] - - def __init__(self, text: str) -> None: - """Init test provider.""" - self.text = text - self.received: list[bytes] = [] - - @property - def supported_languages(self) -> list[str]: - """Return a list of supported languages.""" - return self._supported_languages - - @property - def supported_formats(self) -> list[stt.AudioFormats]: - """Return a list of supported formats.""" - return [stt.AudioFormats.WAV] - - @property - def supported_codecs(self) -> list[stt.AudioCodecs]: - """Return a list of supported codecs.""" - return [stt.AudioCodecs.PCM] - - @property - def supported_bit_rates(self) -> list[stt.AudioBitRates]: - """Return a list of supported bitrates.""" - return [stt.AudioBitRates.BITRATE_16] - - @property - def supported_sample_rates(self) -> list[stt.AudioSampleRates]: - """Return a list of supported samplerates.""" - return [stt.AudioSampleRates.SAMPLERATE_16000] - - @property - def supported_channels(self) -> list[stt.AudioChannels]: - """Return a list of supported channels.""" - return [stt.AudioChannels.CHANNEL_MONO] - - async def async_process_audio_stream( - self, metadata: stt.SpeechMetadata, stream: AsyncIterable[bytes] - ) -> stt.SpeechResult: - """Process an audio stream.""" - async for data in stream: - if not data: - break - self.received.append(data) - return stt.SpeechResult(self.text, stt.SpeechResultState.SUCCESS) - - -class MockSttProvider(BaseProvider, stt.Provider): - """Mock provider.""" - - -class MockSttProviderEntity(BaseProvider, stt.SpeechToTextEntity): - """Mock provider entity.""" - - _attr_name = "Mock STT" - - class MockTTSProvider(tts.Provider): """Mock TTS provider.""" @@ -166,15 +106,17 @@ async def mock_tts_provider() -> MockTTSProvider: @pytest.fixture -async def mock_stt_provider() -> MockSttProvider: +async def mock_stt_provider() -> MockSTTProvider: """Mock STT provider.""" - return MockSttProvider(_TRANSCRIPT) + return MockSTTProvider(supported_languages=["en-US"], text=_TRANSCRIPT) @pytest.fixture -def mock_stt_provider_entity() -> MockSttProviderEntity: +def mock_stt_provider_entity() -> MockSTTProviderEntity: """Test provider entity fixture.""" - return MockSttProviderEntity(_TRANSCRIPT) + entity = MockSTTProviderEntity(supported_languages=["en-US"], text=_TRANSCRIPT) + entity._attr_name = "Mock STT" + return entity class MockSttPlatform(MockPlatform): @@ -290,8 +232,8 @@ def config_flow_fixture(hass: HomeAssistant) -> Generator[None]: @pytest.fixture async def init_supporting_components( hass: HomeAssistant, - mock_stt_provider: MockSttProvider, - mock_stt_provider_entity: MockSttProviderEntity, + mock_stt_provider: MockSTTProvider, + mock_stt_provider_entity: MockSTTProviderEntity, mock_tts_provider: MockTTSProvider, mock_wake_word_provider_entity: MockWakeWordEntity, mock_wake_word_provider_entity2: MockWakeWordEntity2, diff --git a/tests/components/assist_pipeline/test_init.py b/tests/components/assist_pipeline/test_init.py index 04edab7131f646..31cc1268098c21 100644 --- a/tests/components/assist_pipeline/test_init.py +++ b/tests/components/assist_pipeline/test_init.py @@ -22,8 +22,8 @@ from .conftest import ( BYTES_ONE_SECOND, - MockSttProvider, - MockSttProviderEntity, + MockSTTProvider, + MockSTTProviderEntity, MockTTSProvider, MockWakeWordEntity, make_10ms_chunk, @@ -47,7 +47,7 @@ def process_events(events: list[assist_pipeline.PipelineEvent]) -> list[dict]: async def test_pipeline_from_audio_stream_auto( hass: HomeAssistant, - mock_stt_provider_entity: MockSttProviderEntity, + mock_stt_provider_entity: MockSTTProviderEntity, init_components, snapshot: SnapshotAssertion, ) -> None: @@ -88,7 +88,7 @@ async def audio_data(): async def test_pipeline_from_audio_stream_legacy( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, init_components, snapshot: SnapshotAssertion, ) -> None: @@ -153,7 +153,7 @@ async def audio_data(): async def test_pipeline_from_audio_stream_entity( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - mock_stt_provider_entity: MockSttProviderEntity, + mock_stt_provider_entity: MockSTTProviderEntity, init_components, snapshot: SnapshotAssertion, ) -> None: @@ -218,7 +218,7 @@ async def audio_data(): async def test_pipeline_from_audio_stream_no_stt( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, init_components, snapshot: SnapshotAssertion, ) -> None: @@ -281,7 +281,7 @@ async def audio_data(): async def test_pipeline_from_audio_stream_unknown_pipeline( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, init_components, snapshot: SnapshotAssertion, ) -> None: @@ -319,7 +319,7 @@ async def audio_data(): async def test_pipeline_from_audio_stream_wake_word( hass: HomeAssistant, - mock_stt_provider_entity: MockSttProviderEntity, + mock_stt_provider_entity: MockSTTProviderEntity, mock_wake_word_provider_entity: MockWakeWordEntity, init_components, snapshot: SnapshotAssertion, @@ -395,7 +395,7 @@ async def audio_data(): async def test_pipeline_save_audio( hass: HomeAssistant, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, mock_wake_word_provider_entity: MockWakeWordEntity, init_supporting_components, snapshot: SnapshotAssertion, @@ -474,7 +474,7 @@ async def audio_data(): async def test_pipeline_saved_audio_with_device_id( hass: HomeAssistant, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, mock_wake_word_provider_entity: MockWakeWordEntity, init_supporting_components, snapshot: SnapshotAssertion, @@ -529,7 +529,7 @@ async def audio_data(): async def test_pipeline_saved_audio_write_error( hass: HomeAssistant, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, mock_wake_word_provider_entity: MockWakeWordEntity, init_supporting_components, snapshot: SnapshotAssertion, @@ -578,7 +578,7 @@ async def audio_data(): async def test_pipeline_saved_audio_empty_queue( hass: HomeAssistant, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, mock_wake_word_provider_entity: MockWakeWordEntity, init_supporting_components, snapshot: SnapshotAssertion, @@ -641,7 +641,7 @@ def proc_wrapper(run_recording_dir, queue): async def test_wake_word_detection_aborted( hass: HomeAssistant, - mock_stt_provider: MockSttProvider, + mock_stt_provider: MockSTTProvider, mock_wake_word_provider_entity: MockWakeWordEntity, init_components, pipeline_data: assist_pipeline.pipeline.PipelineData, diff --git a/tests/components/assist_pipeline/test_pipeline.py b/tests/components/assist_pipeline/test_pipeline.py index ef5d5edff9e722..50d0fc9bed8244 100644 --- a/tests/components/assist_pipeline/test_pipeline.py +++ b/tests/components/assist_pipeline/test_pipeline.py @@ -26,7 +26,7 @@ from homeassistant.setup import async_setup_component from . import MANY_LANGUAGES -from .conftest import MockSttProviderEntity, MockTTSProvider +from .conftest import MockSTTProviderEntity, MockTTSProvider from tests.common import flush_store @@ -398,7 +398,7 @@ async def test_default_pipeline_no_stt_tts( @pytest.mark.usefixtures("init_supporting_components") async def test_default_pipeline( hass: HomeAssistant, - mock_stt_provider_entity: MockSttProviderEntity, + mock_stt_provider_entity: MockSTTProviderEntity, mock_tts_provider: MockTTSProvider, ha_language: str, ha_country: str | None, @@ -441,7 +441,7 @@ async def test_default_pipeline( @pytest.mark.usefixtures("init_supporting_components") async def test_default_pipeline_unsupported_stt_language( - hass: HomeAssistant, mock_stt_provider_entity: MockSttProviderEntity + hass: HomeAssistant, mock_stt_provider_entity: MockSTTProviderEntity ) -> None: """Test async_get_pipeline.""" with patch.object(mock_stt_provider_entity, "_supported_languages", ["smurfish"]): diff --git a/tests/components/assist_pipeline/test_websocket.py b/tests/components/assist_pipeline/test_websocket.py index f1f68d4a42358d..e339ee74fbb8d6 100644 --- a/tests/components/assist_pipeline/test_websocket.py +++ b/tests/components/assist_pipeline/test_websocket.py @@ -743,7 +743,7 @@ async def test_stt_stream_failed( client = await hass_ws_client(hass) with patch( - "tests.components.assist_pipeline.conftest.MockSttProviderEntity.async_process_audio_stream", + "tests.components.assist_pipeline.conftest.MockSTTProviderEntity.async_process_audio_stream", side_effect=RuntimeError, ): await client.send_json_auto_id( diff --git a/tests/components/stt/common.py b/tests/components/stt/common.py index e6c36c5b3508d3..f964fca6b67727 100644 --- a/tests/components/stt/common.py +++ b/tests/components/stt/common.py @@ -2,11 +2,22 @@ from __future__ import annotations -from collections.abc import Callable, Coroutine +from collections.abc import AsyncIterable, Callable, Coroutine from pathlib import Path from typing import Any -from homeassistant.components.stt import Provider +from homeassistant.components.stt import ( + AudioBitRates, + AudioChannels, + AudioCodecs, + AudioFormats, + AudioSampleRates, + Provider, + SpeechMetadata, + SpeechResult, + SpeechResultState, + SpeechToTextEntity, +) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -14,6 +25,80 @@ from tests.common import MockPlatform, mock_platform +TEST_DOMAIN = "test" + + +class BaseProvider: + """Mock STT provider.""" + + fail_process_audio = False + + def __init__( + self, *, supported_languages: list[str] | None = None, text: str = "test_result" + ) -> None: + """Init test provider.""" + self._supported_languages = supported_languages or ["de", "de-CH", "en"] + self.calls: list[tuple[SpeechMetadata, AsyncIterable[bytes]]] = [] + self.received: list[bytes] = [] + self.text = text + + @property + def supported_languages(self) -> list[str]: + """Return a list of supported languages.""" + return self._supported_languages + + @property + def supported_formats(self) -> list[AudioFormats]: + """Return a list of supported formats.""" + return [AudioFormats.WAV, AudioFormats.OGG] + + @property + def supported_codecs(self) -> list[AudioCodecs]: + """Return a list of supported codecs.""" + return [AudioCodecs.PCM, AudioCodecs.OPUS] + + @property + def supported_bit_rates(self) -> list[AudioBitRates]: + """Return a list of supported bitrates.""" + return [AudioBitRates.BITRATE_16] + + @property + def supported_sample_rates(self) -> list[AudioSampleRates]: + """Return a list of supported samplerates.""" + return [AudioSampleRates.SAMPLERATE_16000] + + @property + def supported_channels(self) -> list[AudioChannels]: + """Return a list of supported channels.""" + return [AudioChannels.CHANNEL_MONO] + + async def async_process_audio_stream( + self, metadata: SpeechMetadata, stream: AsyncIterable[bytes] + ) -> SpeechResult: + """Process an audio stream.""" + self.calls.append((metadata, stream)) + async for data in stream: + if not data: + break + self.received.append(data) + if self.fail_process_audio: + return SpeechResult(None, SpeechResultState.ERROR) + + return SpeechResult(self.text, SpeechResultState.SUCCESS) + + +class MockSTTProvider(BaseProvider, Provider): + """Mock provider.""" + + url_path = TEST_DOMAIN + + +class MockSTTProviderEntity(BaseProvider, SpeechToTextEntity): + """Mock provider entity.""" + + url_path = "stt.test" + _attr_name = "test" + class MockSTTPlatform(MockPlatform): """Help to set up test stt service.""" diff --git a/tests/components/stt/test_init.py b/tests/components/stt/test_init.py index 5c98b0f8d57119..92225123995a6c 100644 --- a/tests/components/stt/test_init.py +++ b/tests/components/stt/test_init.py @@ -1,6 +1,6 @@ """Test STT component setup.""" -from collections.abc import AsyncIterable, Generator, Iterable +from collections.abc import Generator, Iterable from contextlib import ExitStack from http import HTTPStatus from pathlib import Path @@ -10,16 +10,6 @@ from homeassistant.components.stt import ( DOMAIN, - AudioBitRates, - AudioChannels, - AudioCodecs, - AudioFormats, - AudioSampleRates, - Provider, - SpeechMetadata, - SpeechResult, - SpeechResultState, - SpeechToTextEntity, async_default_engine, async_get_provider, async_get_speech_to_text_engine, @@ -29,7 +19,13 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.setup import async_setup_component -from .common import mock_stt_entity_platform, mock_stt_platform +from .common import ( + TEST_DOMAIN, + MockSTTProvider, + MockSTTProviderEntity, + mock_stt_entity_platform, + mock_stt_platform, +) from tests.common import ( MockConfigEntry, @@ -41,82 +37,17 @@ ) from tests.typing import ClientSessionGenerator, WebSocketGenerator -TEST_DOMAIN = "test" - - -class BaseProvider: - """Mock provider.""" - - fail_process_audio = False - - def __init__(self) -> None: - """Init test provider.""" - self.calls: list[tuple[SpeechMetadata, AsyncIterable[bytes]]] = [] - - @property - def supported_languages(self) -> list[str]: - """Return a list of supported languages.""" - return ["de", "de-CH", "en"] - - @property - def supported_formats(self) -> list[AudioFormats]: - """Return a list of supported formats.""" - return [AudioFormats.WAV, AudioFormats.OGG] - - @property - def supported_codecs(self) -> list[AudioCodecs]: - """Return a list of supported codecs.""" - return [AudioCodecs.PCM, AudioCodecs.OPUS] - - @property - def supported_bit_rates(self) -> list[AudioBitRates]: - """Return a list of supported bitrates.""" - return [AudioBitRates.BITRATE_16] - - @property - def supported_sample_rates(self) -> list[AudioSampleRates]: - """Return a list of supported samplerates.""" - return [AudioSampleRates.SAMPLERATE_16000] - - @property - def supported_channels(self) -> list[AudioChannels]: - """Return a list of supported channels.""" - return [AudioChannels.CHANNEL_MONO] - - async def async_process_audio_stream( - self, metadata: SpeechMetadata, stream: AsyncIterable[bytes] - ) -> SpeechResult: - """Process an audio stream.""" - self.calls.append((metadata, stream)) - if self.fail_process_audio: - return SpeechResult(None, SpeechResultState.ERROR) - - return SpeechResult("test_result", SpeechResultState.SUCCESS) - - -class MockProvider(BaseProvider, Provider): - """Mock provider.""" - - url_path = TEST_DOMAIN - - -class MockProviderEntity(BaseProvider, SpeechToTextEntity): - """Mock provider entity.""" - - url_path = "stt.test" - _attr_name = "test" - @pytest.fixture -def mock_provider() -> MockProvider: +def mock_provider() -> MockSTTProvider: """Test provider fixture.""" - return MockProvider() + return MockSTTProvider() @pytest.fixture -def mock_provider_entity() -> MockProviderEntity: +def mock_provider_entity() -> MockSTTProviderEntity: """Test provider entity fixture.""" - return MockProviderEntity() + return MockSTTProviderEntity() class STTFlow(ConfigFlow): @@ -148,14 +79,14 @@ async def setup_fixture( hass: HomeAssistant, tmp_path: Path, request: pytest.FixtureRequest, -) -> MockProvider | MockProviderEntity: +) -> MockSTTProvider | MockSTTProviderEntity: """Set up the test environment.""" - provider: MockProvider | MockProviderEntity + provider: MockSTTProvider | MockSTTProviderEntity if request.param == "mock_setup": - provider = MockProvider() + provider = MockSTTProvider() await mock_setup(hass, tmp_path, provider) elif request.param == "mock_config_entry_setup": - provider = MockProviderEntity() + provider = MockSTTProviderEntity() await mock_config_entry_setup(hass, tmp_path, provider) else: raise RuntimeError("Invalid setup fixture") @@ -166,7 +97,7 @@ async def setup_fixture( async def mock_setup( hass: HomeAssistant, tmp_path: Path, - mock_provider: MockProvider, + mock_provider: MockSTTProvider, ) -> None: """Set up a test provider.""" mock_stt_platform( @@ -182,7 +113,7 @@ async def mock_setup( async def mock_config_entry_setup( hass: HomeAssistant, tmp_path: Path, - mock_provider_entity: MockProviderEntity, + mock_provider_entity: MockSTTProviderEntity, test_domain: str = TEST_DOMAIN, ) -> MockConfigEntry: """Set up a test provider via config entry.""" @@ -234,7 +165,7 @@ async def async_setup_entry_platform( async def test_get_provider_info( hass: HomeAssistant, hass_client: ClientSessionGenerator, - setup: MockProvider | MockProviderEntity, + setup: MockSTTProvider | MockSTTProviderEntity, ) -> None: """Test engine that doesn't exist.""" client = await hass_client() @@ -256,7 +187,7 @@ async def test_get_provider_info( async def test_non_existing_provider( hass: HomeAssistant, hass_client: ClientSessionGenerator, - setup: MockProvider | MockProviderEntity, + setup: MockSTTProvider | MockSTTProviderEntity, ) -> None: """Test streaming to engine that doesn't exist.""" client = await hass_client() @@ -282,7 +213,7 @@ async def test_non_existing_provider( async def test_stream_audio( hass: HomeAssistant, hass_client: ClientSessionGenerator, - setup: MockProvider | MockProviderEntity, + setup: MockSTTProvider | MockSTTProviderEntity, ) -> None: """Test streaming audio and getting response.""" client = await hass_client() @@ -343,7 +274,7 @@ async def test_metadata_errors( header: str | None, status: int, error: str, - setup: MockProvider | MockProviderEntity, + setup: MockSTTProvider | MockSTTProviderEntity, ) -> None: """Test metadata errors.""" client = await hass_client() @@ -359,7 +290,7 @@ async def test_metadata_errors( async def test_get_provider( hass: HomeAssistant, tmp_path: Path, - mock_provider: MockProvider, + mock_provider: MockSTTProvider, ) -> None: """Test we can get STT providers.""" await mock_setup(hass, tmp_path, mock_provider) @@ -370,7 +301,7 @@ async def test_get_provider( async def test_config_entry_unload( - hass: HomeAssistant, tmp_path: Path, mock_provider_entity: MockProviderEntity + hass: HomeAssistant, tmp_path: Path, mock_provider_entity: MockSTTProviderEntity ) -> None: """Test we can unload config entry.""" config_entry = await mock_config_entry_setup(hass, tmp_path, mock_provider_entity) @@ -382,7 +313,7 @@ async def test_config_entry_unload( async def test_restore_state( hass: HomeAssistant, tmp_path: Path, - mock_provider_entity: MockProviderEntity, + mock_provider_entity: MockSTTProviderEntity, ) -> None: """Test we restore state in the integration.""" entity_id = f"{DOMAIN}.{TEST_DOMAIN}" @@ -409,7 +340,7 @@ async def test_restore_state( async def test_ws_list_engines( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - setup: MockProvider | MockProviderEntity, + setup: MockSTTProvider | MockSTTProviderEntity, engine_id: str, extra_data: dict[str, str], ) -> None: @@ -491,7 +422,7 @@ async def test_default_engine_none(hass: HomeAssistant, tmp_path: Path) -> None: async def test_default_engine( hass: HomeAssistant, tmp_path: Path, - mock_provider: MockProvider, + mock_provider: MockSTTProvider, ) -> None: """Test async_default_engine.""" mock_stt_platform( @@ -507,7 +438,7 @@ async def test_default_engine( async def test_default_engine_entity( - hass: HomeAssistant, tmp_path: Path, mock_provider_entity: MockProviderEntity + hass: HomeAssistant, tmp_path: Path, mock_provider_entity: MockSTTProviderEntity ) -> None: """Test async_default_engine.""" await mock_config_entry_setup(hass, tmp_path, mock_provider_entity) @@ -519,8 +450,8 @@ async def test_default_engine_entity( async def test_default_engine_prefer_entity( hass: HomeAssistant, tmp_path: Path, - mock_provider_entity: MockProviderEntity, - mock_provider: MockProvider, + mock_provider_entity: MockSTTProviderEntity, + mock_provider: MockSTTProvider, config_flow_test_domains: str, ) -> None: """Test async_default_engine. @@ -558,7 +489,7 @@ async def test_default_engine_prefer_entity( async def test_default_engine_prefer_cloud_entity( hass: HomeAssistant, tmp_path: Path, - mock_provider: MockProvider, + mock_provider: MockSTTProvider, config_flow_test_domains: str, ) -> None: """Test async_default_engine. @@ -569,7 +500,7 @@ async def test_default_engine_prefer_cloud_entity( """ await mock_setup(hass, tmp_path, mock_provider) for domain in config_flow_test_domains: - entity = MockProviderEntity() + entity = MockSTTProviderEntity() entity.url_path = f"stt.{domain}" entity._attr_name = f"{domain} STT entity" await mock_config_entry_setup(hass, tmp_path, entity, test_domain=domain) @@ -589,7 +520,7 @@ async def test_default_engine_prefer_cloud_entity( async def test_get_engine_legacy( - hass: HomeAssistant, tmp_path: Path, mock_provider: MockProvider + hass: HomeAssistant, tmp_path: Path, mock_provider: MockSTTProvider ) -> None: """Test async_get_speech_to_text_engine.""" mock_stt_platform( @@ -614,7 +545,7 @@ async def test_get_engine_legacy( async def test_get_engine_entity( - hass: HomeAssistant, tmp_path: Path, mock_provider_entity: MockProviderEntity + hass: HomeAssistant, tmp_path: Path, mock_provider_entity: MockSTTProviderEntity ) -> None: """Test async_get_speech_to_text_engine.""" await mock_config_entry_setup(hass, tmp_path, mock_provider_entity) From b085ac929698a89be508a0fdda39dce997c6d9c4 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:48:17 +0200 Subject: [PATCH 35/67] Standardize import step variable name in geonetnz_volcano (#124699) --- .../geonetnz_volcano/config_flow.py | 4 +-- .../geonetnz_volcano/test_config_flow.py | 30 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/geonetnz_volcano/config_flow.py b/homeassistant/components/geonetnz_volcano/config_flow.py index 12c7157b7e41c0..45a074d215c34e 100644 --- a/homeassistant/components/geonetnz_volcano/config_flow.py +++ b/homeassistant/components/geonetnz_volcano/config_flow.py @@ -47,9 +47,9 @@ async def _show_form(self, errors=None): step_id="user", data_schema=data_schema, errors=errors or {} ) - async def async_step_import(self, import_config): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a config entry from configuration.yaml.""" - return await self.async_step_user(import_config) + return await self.async_step_user(import_data) async def async_step_user( self, user_input: dict[str, Any] | None = None diff --git a/tests/components/geonetnz_volcano/test_config_flow.py b/tests/components/geonetnz_volcano/test_config_flow.py index b074bdffa20a11..110fb3b0a9ea3e 100644 --- a/tests/components/geonetnz_volcano/test_config_flow.py +++ b/tests/components/geonetnz_volcano/test_config_flow.py @@ -3,7 +3,8 @@ from datetime import timedelta from unittest.mock import patch -from homeassistant.components.geonetnz_volcano import config_flow +from homeassistant.components.geonetnz_volcano import DOMAIN +from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.const import ( CONF_LATITUDE, CONF_LONGITUDE, @@ -20,19 +21,18 @@ async def test_duplicate_error(hass: HomeAssistant, config_entry) -> None: conf = {CONF_LATITUDE: -41.2, CONF_LONGITUDE: 174.7, CONF_RADIUS: 25} config_entry.add_to_hass(hass) - flow = config_flow.GeonetnzVolcanoFlowHandler() - flow.hass = hass - result = await flow.async_step_user(user_input=conf) + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_USER}, data=conf + ) assert result["errors"] == {"base": "already_configured"} async def test_show_form(hass: HomeAssistant) -> None: """Test that the form is served with no input.""" - flow = config_flow.GeonetnzVolcanoFlowHandler() - flow.hass = hass - - result = await flow.async_step_user(user_input=None) + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_USER}, data=None + ) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" @@ -48,9 +48,6 @@ async def test_step_import(hass: HomeAssistant) -> None: CONF_SCAN_INTERVAL: timedelta(minutes=4), } - flow = config_flow.GeonetnzVolcanoFlowHandler() - flow.hass = hass - with ( patch( "homeassistant.components.geonetnz_volcano.async_setup_entry", @@ -60,7 +57,9 @@ async def test_step_import(hass: HomeAssistant) -> None: "homeassistant.components.geonetnz_volcano.async_setup", return_value=True ), ): - result = await flow.async_step_import(import_config=conf) + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_IMPORT}, data=conf + ) assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "-41.2, 174.7" assert result["data"] == { @@ -78,9 +77,6 @@ async def test_step_user(hass: HomeAssistant) -> None: hass.config.longitude = 174.7 conf = {CONF_RADIUS: 25} - flow = config_flow.GeonetnzVolcanoFlowHandler() - flow.hass = hass - with ( patch( "homeassistant.components.geonetnz_volcano.async_setup_entry", @@ -90,7 +86,9 @@ async def test_step_user(hass: HomeAssistant) -> None: "homeassistant.components.geonetnz_volcano.async_setup", return_value=True ), ): - result = await flow.async_step_user(user_input=conf) + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_USER}, data=conf + ) assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "-41.2, 174.7" assert result["data"] == { From 1f3c99dff39712de3bf354ae5fb5506c3dbc7db2 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:51:25 +0200 Subject: [PATCH 36/67] Standardize import step variable name in cert_expiry (#124696) --- homeassistant/components/cert_expiry/config_flow.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/cert_expiry/config_flow.py b/homeassistant/components/cert_expiry/config_flow.py index 8f937ef61ea71c..22d443c700dd64 100644 --- a/homeassistant/components/cert_expiry/config_flow.py +++ b/homeassistant/components/cert_expiry/config_flow.py @@ -95,12 +95,9 @@ async def async_step_user( errors=self._errors, ) - async def async_step_import( - self, - user_input: Mapping[str, Any] | None = None, - ) -> ConfigFlowResult: + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a config entry. Only host was required in the yaml file all other fields are optional """ - return await self.async_step_user(user_input) + return await self.async_step_user(import_data) From bcc66c9a86b9ed09d7fadaae51fa7f88698adac9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:51:49 +0200 Subject: [PATCH 37/67] Standardize import step variable name (part 5) (#124698) * Standardize import step variable name (part 5) * Revert point * Adjust soma tests --- .../components/enocean/config_flow.py | 8 +-- homeassistant/components/heos/config_flow.py | 4 +- .../components/smartthings/config_flow.py | 4 +- homeassistant/components/soma/config_flow.py | 4 +- .../components/songpal/config_flow.py | 8 +-- .../components/yeelight/config_flow.py | 12 ++-- tests/components/soma/test_config_flow.py | 56 +++++++++++-------- 7 files changed, 54 insertions(+), 42 deletions(-) diff --git a/homeassistant/components/enocean/config_flow.py b/homeassistant/components/enocean/config_flow.py index b68026a34ba7f9..3105b3ab59558f 100644 --- a/homeassistant/components/enocean/config_flow.py +++ b/homeassistant/components/enocean/config_flow.py @@ -22,17 +22,17 @@ def __init__(self) -> None: self.dongle_path = None self.discovery_info = None - async def async_step_import(self, data=None): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a yaml configuration.""" - if not await self.validate_enocean_conf(data): + if not await self.validate_enocean_conf(import_data): LOGGER.warning( "Cannot import yaml configuration: %s is not a valid dongle path", - data[CONF_DEVICE], + import_data[CONF_DEVICE], ) return self.async_abort(reason="invalid_dongle_path") - return self.create_enocean_entry(data) + return self.create_enocean_entry(import_data) async def async_step_user( self, user_input: dict[str, Any] | None = None diff --git a/homeassistant/components/heos/config_flow.py b/homeassistant/components/heos/config_flow.py index 968f677df23ac1..57ed51a3c05c47 100644 --- a/homeassistant/components/heos/config_flow.py +++ b/homeassistant/components/heos/config_flow.py @@ -43,9 +43,9 @@ async def async_step_ssdp( # Show selection form return self.async_show_form(step_id="user") - async def async_step_import(self, user_input=None): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Occurs when an entry is setup through config.""" - host = user_input[CONF_HOST] + host = import_data[CONF_HOST] # raise_on_progress is False here in case ssdp discovers # heos first which would block the import await self.async_set_unique_id(DOMAIN, raise_on_progress=False) diff --git a/homeassistant/components/smartthings/config_flow.py b/homeassistant/components/smartthings/config_flow.py index 9072683328d51f..df5b7a8acfaf30 100644 --- a/homeassistant/components/smartthings/config_flow.py +++ b/homeassistant/components/smartthings/config_flow.py @@ -54,9 +54,9 @@ def __init__(self) -> None: self.location_id = None self.endpoints_initialized = False - async def async_step_import(self, user_input=None): + async def async_step_import(self, import_data: None) -> ConfigFlowResult: """Occurs when a previously entry setup fails and is re-initiated.""" - return await self.async_step_user(user_input) + return await self.async_step_user(import_data) async def async_step_user( self, user_input: dict[str, Any] | None = None diff --git a/homeassistant/components/soma/config_flow.py b/homeassistant/components/soma/config_flow.py index 23aabf5a5e05d6..586567611f7d51 100644 --- a/homeassistant/components/soma/config_flow.py +++ b/homeassistant/components/soma/config_flow.py @@ -67,8 +67,8 @@ async def async_step_creation(self, user_input=None): _LOGGER.error("Connection to SOMA Connect failed with KeyError") return self.async_abort(reason="connection_error") - async def async_step_import(self, user_input=None): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Handle flow start from existing config section.""" if self._async_current_entries(): return self.async_abort(reason="already_setup") - return await self.async_step_creation(user_input) + return await self.async_step_creation(import_data) diff --git a/homeassistant/components/songpal/config_flow.py b/homeassistant/components/songpal/config_flow.py index 0724646a5940dd..9ccf7a8f19c67a 100644 --- a/homeassistant/components/songpal/config_flow.py +++ b/homeassistant/components/songpal/config_flow.py @@ -126,10 +126,10 @@ async def async_step_ssdp( return await self.async_step_init() - async def async_step_import(self, user_input=None): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import a config entry.""" - name = user_input.get(CONF_NAME) - endpoint = user_input.get(CONF_ENDPOINT) + name = import_data.get(CONF_NAME) + endpoint = import_data.get(CONF_ENDPOINT) parsed_url = urlparse(endpoint) # Try to connect to test the endpoint @@ -146,4 +146,4 @@ async def async_step_import(self, user_input=None): self.conf = SongpalConfig(name, parsed_url.hostname, endpoint) - return await self.async_step_init(user_input) + return await self.async_step_init(import_data) diff --git a/homeassistant/components/yeelight/config_flow.py b/homeassistant/components/yeelight/config_flow.py index b4bb7da9a22a89..1b36fba59df208 100644 --- a/homeassistant/components/yeelight/config_flow.py +++ b/homeassistant/components/yeelight/config_flow.py @@ -244,21 +244,21 @@ async def async_step_pick_device(self, user_input=None): data_schema=vol.Schema({vol.Required(CONF_DEVICE): vol.In(devices_name)}), ) - async def async_step_import(self, user_input=None): + async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Handle import step.""" - host = user_input[CONF_HOST] + host = import_data[CONF_HOST] try: await self._async_try_connect(host, raise_on_progress=False) except CannotConnect: _LOGGER.error("Failed to import %s: cannot connect", host) return self.async_abort(reason="cannot_connect") - if CONF_NIGHTLIGHT_SWITCH_TYPE in user_input: - user_input[CONF_NIGHTLIGHT_SWITCH] = ( - user_input.pop(CONF_NIGHTLIGHT_SWITCH_TYPE) + if CONF_NIGHTLIGHT_SWITCH_TYPE in import_data: + import_data[CONF_NIGHTLIGHT_SWITCH] = ( + import_data.pop(CONF_NIGHTLIGHT_SWITCH_TYPE) == NIGHTLIGHT_SWITCH_TYPE_LIGHT ) self._abort_if_unique_id_configured() - return self.async_create_entry(title=user_input[CONF_NAME], data=user_input) + return self.async_create_entry(title=import_data[CONF_NAME], data=import_data) async def _async_try_connect(self, host, raise_on_progress=True): """Set up with options.""" diff --git a/tests/components/soma/test_config_flow.py b/tests/components/soma/test_config_flow.py index 8b8548bfe3eba7..67109e37c6db65 100644 --- a/tests/components/soma/test_config_flow.py +++ b/tests/components/soma/test_config_flow.py @@ -5,7 +5,8 @@ from api.soma_api import SomaApi from requests import RequestException -from homeassistant.components.soma import DOMAIN, config_flow +from homeassistant.components.soma import DOMAIN +from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -17,57 +18,66 @@ async def test_form(hass: HomeAssistant) -> None: """Test user form showing.""" - flow = config_flow.SomaFlowHandler() - flow.hass = hass - result = await flow.async_step_user() + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_USER} + ) assert result["type"] is FlowResultType.FORM async def test_import_abort(hass: HomeAssistant) -> None: """Test configuration from YAML aborting with existing entity.""" - flow = config_flow.SomaFlowHandler() - flow.hass = hass MockConfigEntry(domain=DOMAIN).add_to_hass(hass) - result = await flow.async_step_import() + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_IMPORT} + ) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_setup" async def test_import_create(hass: HomeAssistant) -> None: """Test configuration from YAML.""" - flow = config_flow.SomaFlowHandler() - flow.hass = hass with patch.object(SomaApi, "list_devices", return_value={"result": "success"}): - result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_IMPORT}, + data={"host": MOCK_HOST, "port": MOCK_PORT}, + ) assert result["type"] is FlowResultType.CREATE_ENTRY async def test_error_status(hass: HomeAssistant) -> None: """Test Connect successfully returning error status.""" - flow = config_flow.SomaFlowHandler() - flow.hass = hass with patch.object(SomaApi, "list_devices", return_value={"result": "error"}): - result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_IMPORT}, + data={"host": MOCK_HOST, "port": MOCK_PORT}, + ) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "result_error" async def test_key_error(hass: HomeAssistant) -> None: """Test Connect returning empty string.""" - flow = config_flow.SomaFlowHandler() - flow.hass = hass + with patch.object(SomaApi, "list_devices", return_value={}): - result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_IMPORT}, + data={"host": MOCK_HOST, "port": MOCK_PORT}, + ) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "connection_error" async def test_exception(hass: HomeAssistant) -> None: """Test if RequestException fires when no connection can be made.""" - flow = config_flow.SomaFlowHandler() - flow.hass = hass with patch.object(SomaApi, "list_devices", side_effect=RequestException()): - result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_IMPORT}, + data={"host": MOCK_HOST, "port": MOCK_PORT}, + ) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "connection_error" @@ -75,8 +85,10 @@ async def test_exception(hass: HomeAssistant) -> None: async def test_full_flow(hass: HomeAssistant) -> None: """Check classic use case.""" hass.data[DOMAIN] = {} - flow = config_flow.SomaFlowHandler() - flow.hass = hass with patch.object(SomaApi, "list_devices", return_value={"result": "success"}): - result = await flow.async_step_user({"host": MOCK_HOST, "port": MOCK_PORT}) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_USER}, + data={"host": MOCK_HOST, "port": MOCK_PORT}, + ) assert result["type"] is FlowResultType.CREATE_ENTRY From e9830f0835e2b9fe7cdbd8c4ede7ccba3b416917 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Wed, 28 Aug 2024 11:13:37 +0200 Subject: [PATCH 38/67] Bump reolink_aio to 0.9.8 (#124763) --- homeassistant/components/reolink/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/reolink/manifest.json b/homeassistant/components/reolink/manifest.json index 9671a4b4fc14b8..b90f7f4a045f27 100644 --- a/homeassistant/components/reolink/manifest.json +++ b/homeassistant/components/reolink/manifest.json @@ -18,5 +18,5 @@ "documentation": "https://www.home-assistant.io/integrations/reolink", "iot_class": "local_push", "loggers": ["reolink_aio"], - "requirements": ["reolink-aio==0.9.7"] + "requirements": ["reolink-aio==0.9.8"] } diff --git a/requirements_all.txt b/requirements_all.txt index 4633f0b093c560..3e4fedbc15b5e6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2504,7 +2504,7 @@ renault-api==0.2.5 renson-endura-delta==1.7.1 # homeassistant.components.reolink -reolink-aio==0.9.7 +reolink-aio==0.9.8 # homeassistant.components.idteck_prox rfk101py==0.0.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8688b7a6dccd0d..ab1aa13ec3cfcb 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1986,7 +1986,7 @@ renault-api==0.2.5 renson-endura-delta==1.7.1 # homeassistant.components.reolink -reolink-aio==0.9.7 +reolink-aio==0.9.8 # homeassistant.components.rflink rflink==0.0.66 From c772c4a2d524b90c48e76a7db67f4751250e09f8 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 11:15:26 +0200 Subject: [PATCH 39/67] Allow specifying icons for service sections (#124656) * Allow specifying icons for service sections * Improve kitchen_sink example --- .../components/kitchen_sink/__init__.py | 22 ++++++++++++- .../components/kitchen_sink/icons.json | 8 +++++ .../components/kitchen_sink/services.yaml | 32 +++++++++++++++++++ .../components/kitchen_sink/strings.json | 30 +++++++++++++++++ homeassistant/helpers/icon.py | 26 +++++++++++++-- script/hassfest/icons.py | 19 ++++++++++- tests/components/kitchen_sink/test_init.py | 22 +++++++++++++ tests/helpers/test_icon.py | 4 +-- 8 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 homeassistant/components/kitchen_sink/services.yaml diff --git a/homeassistant/components/kitchen_sink/__init__.py b/homeassistant/components/kitchen_sink/__init__.py index 94dfca77410533..2c3887bb3837f2 100644 --- a/homeassistant/components/kitchen_sink/__init__.py +++ b/homeassistant/components/kitchen_sink/__init__.py @@ -9,6 +9,8 @@ import datetime from random import random +import voluptuous as vol + from homeassistant.components.recorder import DOMAIN as RECORDER_DOMAIN, get_instance from homeassistant.components.recorder.models import StatisticData, StatisticMetaData from homeassistant.components.recorder.statistics import ( @@ -18,7 +20,7 @@ ) from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import Platform, UnitOfEnergy, UnitOfTemperature, UnitOfVolume -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.typing import ConfigType @@ -40,6 +42,15 @@ CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) +SCHEMA_SERVICE_TEST_SERVICE_1 = vol.Schema( + { + vol.Required("field_1"): vol.Coerce(int), + vol.Required("field_2"): vol.In(["off", "auto", "cool"]), + vol.Optional("field_3"): vol.Coerce(int), + vol.Optional("field_4"): vol.In(["forwards", "reverse"]), + } +) + async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the demo environment.""" @@ -48,6 +59,15 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: DOMAIN, context={"source": SOURCE_IMPORT}, data={} ) ) + + @callback + def service_handler(call: ServiceCall | None = None) -> None: + """Do nothing.""" + + hass.services.async_register( + DOMAIN, "test_service_1", service_handler, SCHEMA_SERVICE_TEST_SERVICE_1 + ) + return True diff --git a/homeassistant/components/kitchen_sink/icons.json b/homeassistant/components/kitchen_sink/icons.json index 2947cfa7ec5c4c..565d595d9c7aa7 100644 --- a/homeassistant/components/kitchen_sink/icons.json +++ b/homeassistant/components/kitchen_sink/icons.json @@ -7,5 +7,13 @@ } } } + }, + "services": { + "test_service_1": { + "service": "mdi:flask", + "sections": { + "advanced_fields": "mdi:test-tube" + } + } } } diff --git a/homeassistant/components/kitchen_sink/services.yaml b/homeassistant/components/kitchen_sink/services.yaml new file mode 100644 index 00000000000000..c65495095dc7ba --- /dev/null +++ b/homeassistant/components/kitchen_sink/services.yaml @@ -0,0 +1,32 @@ +test_service_1: + fields: + field_1: + required: true + selector: + number: + min: 0 + max: 60 + unit_of_measurement: seconds + field_2: + required: true + selector: + select: + options: + - "off" + - "auto" + - "cool" + advanced_fields: + collapsed: true + fields: + field_3: + selector: + number: + min: 0 + max: 24 + unit_of_measurement: hours + field_4: + selector: + select: + options: + - "forward" + - "reverse" diff --git a/homeassistant/components/kitchen_sink/strings.json b/homeassistant/components/kitchen_sink/strings.json index c25964ab2ab540..b10534eac00a08 100644 --- a/homeassistant/components/kitchen_sink/strings.json +++ b/homeassistant/components/kitchen_sink/strings.json @@ -71,5 +71,35 @@ "title": "This is not a fixable problem", "description": "This issue is never going to give up." } + }, + "services": { + "test_service_1": { + "name": "Test service 1", + "description": "Fake service for testing", + "fields": { + "field_1": { + "name": "Field 1", + "description": "Number of seconds" + }, + "field_2": { + "name": "Field 2", + "description": "Mode" + }, + "field_3": { + "name": "Field 3", + "description": "Number of hours" + }, + "field_4": { + "name": "Field 4", + "description": "Direction" + } + }, + "sections": { + "advanced_fields": { + "name": "Advanced options", + "description": "Some very advanced things" + } + } + } } } diff --git a/homeassistant/helpers/icon.py b/homeassistant/helpers/icon.py index e759719f6673a3..ce8205eb915218 100644 --- a/homeassistant/helpers/icon.py +++ b/homeassistant/helpers/icon.py @@ -7,7 +7,7 @@ from functools import lru_cache import logging import pathlib -from typing import Any +from typing import Any, cast from homeassistant.core import HomeAssistant, callback from homeassistant.loader import Integration, async_get_integrations @@ -21,12 +21,34 @@ _LOGGER = logging.getLogger(__name__) +def convert_shorthand_service_icon( + value: str | dict[str, str | dict[str, str]], +) -> dict[str, str | dict[str, str]]: + """Convert shorthand service icon to dict.""" + if isinstance(value, str): + return {"service": value} + return value + + +def _load_icons_file( + icons_file: pathlib.Path, +) -> dict[str, Any]: + """Load and parse an icons.json file.""" + icons = load_json_object(icons_file) + if "services" not in icons: + return icons + services = cast(dict[str, str | dict[str, str | dict[str, str]]], icons["services"]) + for service, service_icons in services.items(): + services[service] = convert_shorthand_service_icon(service_icons) + return icons + + def _load_icons_files( icons_files: dict[str, pathlib.Path], ) -> dict[str, dict[str, Any]]: """Load and parse icons.json files.""" return { - component: load_json_object(icons_file) + component: _load_icons_file(icons_file) for component, icons_file in icons_files.items() } diff --git a/script/hassfest/icons.py b/script/hassfest/icons.py index 10f666b9013115..92d42efb842614 100644 --- a/script/hassfest/icons.py +++ b/script/hassfest/icons.py @@ -9,6 +9,7 @@ from voluptuous.humanize import humanize_error import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.icon import convert_shorthand_service_icon from .model import Config, Integration from .translations import translation_key_validator @@ -60,6 +61,22 @@ def ensure_not_same_as_default(value: dict) -> dict: ) +SERVICE_ICONS_SCHEMA = cv.schema_with_slug_keys( + vol.All( + convert_shorthand_service_icon, + vol.Schema( + { + vol.Optional("service"): icon_value_validator, + vol.Optional("sections"): cv.schema_with_slug_keys( + icon_value_validator, slug_validator=translation_key_validator + ), + } + ), + ), + slug_validator=translation_key_validator, +) + + def icon_schema(integration_type: str, no_entity_platform: bool) -> vol.Schema: """Create an icon schema.""" @@ -91,7 +108,7 @@ def icon_schema_slug(marker: type[vol.Marker]) -> dict[vol.Marker, Any]: {str: {"fix_flow": DATA_ENTRY_ICONS_SCHEMA}} ), vol.Optional("options"): DATA_ENTRY_ICONS_SCHEMA, - vol.Optional("services"): state_validator, + vol.Optional("services"): SERVICE_ICONS_SCHEMA, } ) diff --git a/tests/components/kitchen_sink/test_init.py b/tests/components/kitchen_sink/test_init.py index 0575141bb3bd69..b832577a48a502 100644 --- a/tests/components/kitchen_sink/test_init.py +++ b/tests/components/kitchen_sink/test_init.py @@ -5,6 +5,7 @@ from unittest.mock import ANY import pytest +import voluptuous as vol from homeassistant.components.kitchen_sink import DOMAIN from homeassistant.components.recorder import get_instance @@ -324,3 +325,24 @@ async def test_issues_created( }, ] } + + +async def test_service( + hass: HomeAssistant, +) -> None: + """Test we can call the service.""" + assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) + + with pytest.raises(vol.error.MultipleInvalid): + await hass.services.async_call(DOMAIN, "test_service_1", blocking=True) + + await hass.services.async_call( + DOMAIN, "test_service_1", {"field_1": 1, "field_2": "auto"}, blocking=True + ) + + await hass.services.async_call( + DOMAIN, + "test_service_1", + {"field_1": 1, "field_2": "auto", "field_3": 1, "field_4": "forwards"}, + blocking=True, + ) diff --git a/tests/helpers/test_icon.py b/tests/helpers/test_icon.py index 732f9971ac0936..e0dc89f53223fe 100644 --- a/tests/helpers/test_icon.py +++ b/tests/helpers/test_icon.py @@ -101,7 +101,7 @@ async def test_get_icons(hass: HomeAssistant) -> None: # Test services icons are available icons = await icon.async_get_icons(hass, "services") assert len(icons) == 1 - assert icons["switch"]["turn_off"] == "mdi:toggle-switch-variant-off" + assert icons["switch"]["turn_off"] == {"service": "mdi:toggle-switch-variant-off"} # Ensure icons file for platform isn't loaded, as that isn't supported icons = await icon.async_get_icons(hass, "entity") @@ -126,7 +126,7 @@ async def test_get_icons(hass: HomeAssistant) -> None: icons = await icon.async_get_icons(hass, "services") assert len(icons) == 2 - assert icons["test_package"]["enable_god_mode"] == "mdi:shield" + assert icons["test_package"]["enable_god_mode"] == {"service": "mdi:shield"} # Load another one hass.config.components.add("test_embedded") From 10b3119b4a6eca9f1e2449758062b606b81961e6 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Wed, 28 Aug 2024 11:27:34 +0200 Subject: [PATCH 40/67] Use Position instead of Angle for TiltOnlyDevice in motion blinds (#123521) Use Position instead of Angle for TiltOnlyBlinds --- .../components/motion_blinds/cover.py | 56 ++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/motion_blinds/cover.py b/homeassistant/components/motion_blinds/cover.py index 72b78915badffb..e60e7fa0ae8653 100644 --- a/homeassistant/components/motion_blinds/cover.py +++ b/homeassistant/components/motion_blinds/cover.py @@ -330,23 +330,63 @@ def current_cover_position(self) -> None: """Return current position of cover.""" return None + @property + def current_cover_tilt_position(self) -> int | None: + """Return current angle of cover. + + None is unknown, 0 is closed/minimum tilt, 100 is fully open/maximum tilt. + """ + if self._blind.position is None: + if self._blind.angle is None: + return None + return self._blind.angle * 100 / 180 + + return self._blind.position + @property def is_closed(self) -> bool | None: """Return if the cover is closed or not.""" - if self._blind.angle is None: - return None - return self._blind.angle == 0 + if self._blind.position is None: + if self._blind.angle is None: + return None + return self._blind.angle == 0 + + return self._blind.position == 0 + + async def async_open_cover_tilt(self, **kwargs: Any) -> None: + """Open the cover tilt.""" + async with self._api_lock: + await self.hass.async_add_executor_job(self._blind.Open) + + async def async_close_cover_tilt(self, **kwargs: Any) -> None: + """Close the cover tilt.""" + async with self._api_lock: + await self.hass.async_add_executor_job(self._blind.Close) + + async def async_set_cover_tilt_position(self, **kwargs: Any) -> None: + """Move the cover tilt to a specific position.""" + angle = kwargs[ATTR_TILT_POSITION] + if self._blind.position is None: + angle = angle * 180 / 100 + async with self._api_lock: + await self.hass.async_add_executor_job(self._blind.Set_angle, angle) + else: + async with self._api_lock: + await self.hass.async_add_executor_job(self._blind.Set_position, angle) async def async_set_absolute_position(self, **kwargs): """Move the cover to a specific absolute position (see TDBU).""" angle = kwargs.get(ATTR_TILT_POSITION) - if angle is not None: + if angle is None: + return + + if self._blind.position is None: angle = angle * 180 / 100 async with self._api_lock: - await self.hass.async_add_executor_job( - self._blind.Set_angle, - angle, - ) + await self.hass.async_add_executor_job(self._blind.Set_angle, angle) + else: + async with self._api_lock: + await self.hass.async_add_executor_job(self._blind.Set_position, angle) class MotionTDBUDevice(MotionBaseDevice): From 41e66edd14bdbdbb9a8e837db4b9df7dff300051 Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Wed, 28 Aug 2024 12:31:30 +0200 Subject: [PATCH 41/67] Set default name for KNX outgoing telegram source (#124439) --- homeassistant/components/knx/telegrams.py | 4 +++- tests/components/knx/test_telegrams.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/knx/telegrams.py b/homeassistant/components/knx/telegrams.py index a96d841a07d8f5..f4b31fd11f950c 100644 --- a/homeassistant/components/knx/telegrams.py +++ b/homeassistant/components/knx/telegrams.py @@ -9,7 +9,7 @@ from xknx.dpt import DPTArray, DPTBase, DPTBinary from xknx.dpt.dpt import DPTComplexData, DPTEnumData from xknx.exceptions import XKNXException -from xknx.telegram import Telegram +from xknx.telegram import Telegram, TelegramDirection from xknx.telegram.apci import GroupValueResponse, GroupValueWrite from homeassistant.core import HomeAssistant @@ -119,6 +119,8 @@ def telegram_to_dict(self, telegram: Telegram) -> TelegramDict: device := self.project.devices.get(f"{telegram.source_address}") ) is not None: src_name = f"{device['manufacturer_name']} {device['name']}" + elif telegram.direction is TelegramDirection.OUTGOING: + src_name = "Home Assistant" if isinstance(telegram.payload, (GroupValueWrite, GroupValueResponse)): payload_data = telegram.payload.value.value diff --git a/tests/components/knx/test_telegrams.py b/tests/components/knx/test_telegrams.py index 2eda718f5aca49..69e3208879c275 100644 --- a/tests/components/knx/test_telegrams.py +++ b/tests/components/knx/test_telegrams.py @@ -39,7 +39,7 @@ "dpt_name": None, "payload": [1, 2, 3, 4], "source": "0.0.0", - "source_name": "", + "source_name": "Home Assistant", "telegramtype": "GroupValueWrite", "timestamp": MOCK_TIMESTAMP, "unit": None, From 8504a16e836645f8b2cf6b505dd9631aba951145 Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Wed, 28 Aug 2024 12:34:28 +0200 Subject: [PATCH 42/67] Use KNX group address format from project (#124084) --- homeassistant/components/knx/__init__.py | 1 + homeassistant/components/knx/project.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/knx/__init__.py b/homeassistant/components/knx/__init__.py index a401ee2ccac8d0..01d5294639c91c 100644 --- a/homeassistant/components/knx/__init__.py +++ b/homeassistant/components/knx/__init__.py @@ -297,6 +297,7 @@ def __init__( self.config_store = KNXConfigStore(hass=hass, config_entry=entry) self.xknx = XKNX( + address_format=self.project.get_address_format(), connection_config=self.connection_config(), rate_limit=self.entry.data[CONF_KNX_RATE_LIMIT], state_updater=self.entry.data[CONF_KNX_STATE_UPDATER], diff --git a/homeassistant/components/knx/project.py b/homeassistant/components/knx/project.py index b5bafe0072489f..04cac68aab076b 100644 --- a/homeassistant/components/knx/project.py +++ b/homeassistant/components/knx/project.py @@ -8,12 +8,13 @@ from xknx import XKNX from xknx.dpt import DPTBase -from xknx.telegram.address import DeviceAddressableType +from xknx.telegram.address import DeviceAddressableType, GroupAddress, GroupAddressType from xknxproject import XKNXProj from xknxproject.models import ( Device, DPTType, GroupAddress as GroupAddressModel, + GroupAddressStyle as XknxProjectGroupAddressStyle, KNXProject as KNXProjectModel, ProjectInfo, ) @@ -90,6 +91,7 @@ async def load_project( if project := data or await self._store.async_load(): self.devices = project["devices"] self.info = project["info"] + GroupAddress.address_format = self.get_address_format() xknx.group_address_dpt.clear() xknx_ga_dict: dict[DeviceAddressableType, DPTType] = {} @@ -133,3 +135,13 @@ async def remove_project_file(self) -> None: async def get_knxproject(self) -> KNXProjectModel | None: """Load the project file from local storage.""" return await self._store.async_load() + + def get_address_format(self) -> GroupAddressType: + """Return the address format for group addresses used in the project.""" + if self.info: + match self.info["group_address_style"]: + case XknxProjectGroupAddressStyle.TWOLEVEL.value: + return GroupAddressType.SHORT + case XknxProjectGroupAddressStyle.FREE.value: + return GroupAddressType.FREE + return GroupAddressType.LONG From d1681fac72b335420e2a483717881ecb2c79d5e0 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Wed, 28 Aug 2024 12:54:30 +0200 Subject: [PATCH 43/67] Improve mediabrowser names for DUO lens Reolink cameras (#124766) * Improve playback of DUO lens cameras like TrackMix * fix styling * Adjust tests accordingly --- .../components/reolink/media_source.py | 25 +++++++++++++------ tests/components/reolink/test_media_source.py | 21 ++++++++-------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/reolink/media_source.py b/homeassistant/components/reolink/media_source.py index ae865b77913eb4..3c5d60030a3659 100644 --- a/homeassistant/components/reolink/media_source.py +++ b/homeassistant/components/reolink/media_source.py @@ -174,10 +174,7 @@ async def _async_generate_root(self) -> BrowseMediaSource: if len(ch_id) > 3: ch = host.api.channel_for_uid(ch_id) - if ( - host.api.api_version("recReplay", int(ch)) < 1 - or not host.api.hdd_info - ): + if not host.api.supported(int(ch), "replay") or not host.api.hdd_info: # playback stream not supported by this camera or no storage installed continue @@ -281,12 +278,16 @@ async def _async_generate_resolution_select( config_entry_id, channel, "sub" ) + title = host.api.camera_name(channel) + if host.api.model in DUAL_LENS_MODELS: + title = f"{host.api.camera_name(channel)} lens {channel}" + return BrowseMediaSource( domain=DOMAIN, identifier=f"RESs|{config_entry_id}|{channel}", media_class=MediaClass.CHANNEL, media_content_type=MediaType.PLAYLIST, - title=host.api.camera_name(channel), + title=title, can_play=False, can_expand=True, children=children, @@ -328,12 +329,16 @@ async def _async_generate_camera_days( for day in status.days ] + title = f"{host.api.camera_name(channel)} {res_name(stream)}" + if host.api.model in DUAL_LENS_MODELS: + title = f"{host.api.camera_name(channel)} lens {channel} {res_name(stream)}" + return BrowseMediaSource( domain=DOMAIN, identifier=f"DAYS|{config_entry_id}|{channel}|{stream}", media_class=MediaClass.CHANNEL, media_content_type=MediaType.PLAYLIST, - title=f"{host.api.camera_name(channel)} {res_name(stream)}", + title=title, can_play=False, can_expand=True, children=children, @@ -388,12 +393,18 @@ async def _async_generate_camera_files( ) ) + title = ( + f"{host.api.camera_name(channel)} {res_name(stream)} {year}/{month}/{day}" + ) + if host.api.model in DUAL_LENS_MODELS: + title = f"{host.api.camera_name(channel)} lens {channel} {res_name(stream)} {year}/{month}/{day}" + return BrowseMediaSource( domain=DOMAIN, identifier=f"FILES|{config_entry_id}|{channel}|{stream}", media_class=MediaClass.CHANNEL, media_content_type=MediaType.PLAYLIST, - title=f"{host.api.camera_name(channel)} {res_name(stream)} {year}/{month}/{day}", + title=title, can_play=False, can_expand=True, children=children, diff --git a/tests/components/reolink/test_media_source.py b/tests/components/reolink/test_media_source.py index cbc9bf51705634..31985bd10f73fa 100644 --- a/tests/components/reolink/test_media_source.py +++ b/tests/components/reolink/test_media_source.py @@ -130,7 +130,7 @@ async def test_browsing( ) -> None: """Test browsing the Reolink three.""" entry_id = config_entry.entry_id - reolink_connect.api_version.return_value = 1 + reolink_connect.supported.return_value = 1 reolink_connect.model = "Reolink TrackMix PoE" with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]): @@ -162,7 +162,7 @@ async def test_browsing( browse_res_AT_sub_id = f"RES|{entry_id}|{TEST_CHANNEL}|autotrack_sub" browse_res_AT_main_id = f"RES|{entry_id}|{TEST_CHANNEL}|autotrack_main" assert browse.domain == DOMAIN - assert browse.title == TEST_NVR_NAME + assert browse.title == f"{TEST_NVR_NAME} lens 0" assert browse.identifier == browse_resolution_id assert browse.children[0].identifier == browse_res_sub_id assert browse.children[1].identifier == browse_res_main_id @@ -178,19 +178,19 @@ async def test_browsing( browse = await async_browse_media(hass, f"{URI_SCHEME}{DOMAIN}/{browse_res_sub_id}") assert browse.domain == DOMAIN - assert browse.title == f"{TEST_NVR_NAME} Low res." + assert browse.title == f"{TEST_NVR_NAME} lens 0 Low res." browse = await async_browse_media( hass, f"{URI_SCHEME}{DOMAIN}/{browse_res_AT_sub_id}" ) assert browse.domain == DOMAIN - assert browse.title == f"{TEST_NVR_NAME} Autotrack low res." + assert browse.title == f"{TEST_NVR_NAME} lens 0 Autotrack low res." browse = await async_browse_media( hass, f"{URI_SCHEME}{DOMAIN}/{browse_res_AT_main_id}" ) assert browse.domain == DOMAIN - assert browse.title == f"{TEST_NVR_NAME} Autotrack high res." + assert browse.title == f"{TEST_NVR_NAME} lens 0 Autotrack high res." browse = await async_browse_media( hass, f"{URI_SCHEME}{DOMAIN}/{browse_res_main_id}" @@ -200,7 +200,7 @@ async def test_browsing( browse_day_0_id = f"DAY|{entry_id}|{TEST_CHANNEL}|{TEST_STREAM}|{TEST_YEAR}|{TEST_MONTH}|{TEST_DAY}" browse_day_1_id = f"DAY|{entry_id}|{TEST_CHANNEL}|{TEST_STREAM}|{TEST_YEAR}|{TEST_MONTH}|{TEST_DAY2}" assert browse.domain == DOMAIN - assert browse.title == f"{TEST_NVR_NAME} High res." + assert browse.title == f"{TEST_NVR_NAME} lens 0 High res." assert browse.identifier == browse_days_id assert browse.children[0].identifier == browse_day_0_id assert browse.children[1].identifier == browse_day_1_id @@ -220,7 +220,8 @@ async def test_browsing( browse_file_id = f"FILE|{entry_id}|{TEST_CHANNEL}|{TEST_STREAM}|{TEST_FILE_NAME}" assert browse.domain == DOMAIN assert ( - browse.title == f"{TEST_NVR_NAME} High res. {TEST_YEAR}/{TEST_MONTH}/{TEST_DAY}" + browse.title + == f"{TEST_NVR_NAME} lens 0 High res. {TEST_YEAR}/{TEST_MONTH}/{TEST_DAY}" ) assert browse.identifier == browse_files_id assert browse.children[0].identifier == browse_file_id @@ -272,7 +273,7 @@ async def test_browsing_rec_playback_unsupported( config_entry: MockConfigEntry, ) -> None: """Test browsing a Reolink camera which does not support playback of recordings.""" - reolink_connect.api_version.return_value = 0 + reolink_connect.supported.return_value = 0 with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]): assert await hass.config_entries.async_setup(config_entry.entry_id) @@ -293,7 +294,7 @@ async def test_browsing_errors( config_entry: MockConfigEntry, ) -> None: """Test browsing a Reolink camera errors.""" - reolink_connect.api_version.return_value = 1 + reolink_connect.supported.return_value = 1 with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]): assert await hass.config_entries.async_setup(config_entry.entry_id) @@ -312,7 +313,7 @@ async def test_browsing_not_loaded( config_entry: MockConfigEntry, ) -> None: """Test browsing a Reolink camera integration which is not loaded.""" - reolink_connect.api_version.return_value = 1 + reolink_connect.supported.return_value = 1 with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]): assert await hass.config_entries.async_setup(config_entry.entry_id) From 0a942423376f2d18c6a03169e905faa818faf1a9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:56:22 +0200 Subject: [PATCH 44/67] Improve config flow type hints in vesync (#124351) --- .../components/vesync/config_flow.py | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/vesync/config_flow.py b/homeassistant/components/vesync/config_flow.py index 15f9f548e35473..6115cb9ee76664 100644 --- a/homeassistant/components/vesync/config_flow.py +++ b/homeassistant/components/vesync/config_flow.py @@ -1,40 +1,42 @@ """Config flow utilities.""" -from collections import OrderedDict +from typing import Any from pyvesync import VeSync import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import callback +import homeassistant.helpers.config_validation as cv from .const import DOMAIN +DATA_SCHEMA = vol.Schema( + { + vol.Required(CONF_USERNAME): cv.string, + vol.Required(CONF_PASSWORD): cv.string, + } +) + class VeSyncFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow.""" VERSION = 1 - def __init__(self) -> None: - """Instantiate config flow.""" - self._username = None - self._password = None - self.data_schema = OrderedDict() - self.data_schema[vol.Required(CONF_USERNAME)] = str - self.data_schema[vol.Required(CONF_PASSWORD)] = str - @callback - def _show_form(self, errors=None): + def _show_form(self, errors: dict[str, str] | None = None) -> ConfigFlowResult: """Show form to the user.""" return self.async_show_form( step_id="user", - data_schema=vol.Schema(self.data_schema), + data_schema=DATA_SCHEMA, errors=errors if errors else {}, ) - async def async_step_user(self, user_input=None): + async def async_step_user( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: """Handle a flow start.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -42,15 +44,15 @@ async def async_step_user(self, user_input=None): if not user_input: return self._show_form() - self._username = user_input[CONF_USERNAME] - self._password = user_input[CONF_PASSWORD] + username = user_input[CONF_USERNAME] + password = user_input[CONF_PASSWORD] - manager = VeSync(self._username, self._password) + manager = VeSync(username, password) login = await self.hass.async_add_executor_job(manager.login) if not login: return self._show_form(errors={"base": "invalid_auth"}) return self.async_create_entry( - title=self._username, - data={CONF_USERNAME: self._username, CONF_PASSWORD: self._password}, + title=username, + data={CONF_USERNAME: username, CONF_PASSWORD: password}, ) From 35d318818a030453d619604d982f0fd67d5bb15f Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:59:12 +0200 Subject: [PATCH 45/67] Improve config flow type hints in sense (#124350) --- homeassistant/components/sense/config_flow.py | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/sense/config_flow.py b/homeassistant/components/sense/config_flow.py index dab80b99e1a5f7..222c6b30f79a83 100644 --- a/homeassistant/components/sense/config_flow.py +++ b/homeassistant/components/sense/config_flow.py @@ -3,7 +3,7 @@ from collections.abc import Mapping from functools import partial import logging -from typing import Any +from typing import TYPE_CHECKING, Any from sense_energy import ( ASyncSenseable, @@ -34,13 +34,12 @@ class SenseConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 - def __init__(self): + def __init__(self) -> None: """Init Config .""" - self._gateway = None - self._auth_data = {} - super().__init__() + self._gateway: ASyncSenseable | None = None + self._auth_data: dict[str, Any] = {} - async def validate_input(self, data): + async def validate_input(self, data: Mapping[str, Any]) -> None: """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. @@ -59,6 +58,8 @@ async def validate_input(self, data): client_session=client_session, ) ) + if TYPE_CHECKING: + assert self._gateway self._gateway.rate_limit = ACTIVE_UPDATE_RATE await self._gateway.authenticate( self._auth_data[CONF_EMAIL], self._auth_data[CONF_PASSWORD] @@ -79,7 +80,9 @@ async def create_entry_from_data(self): return self.async_update_reload_and_abort(existing_entry, data=self._auth_data) - async def validate_input_and_create_entry(self, user_input, errors): + async def validate_input_and_create_entry( + self, user_input: Mapping[str, Any], errors: dict[str, str] + ) -> ConfigFlowResult | None: """Validate the input and create the entry from the data.""" try: await self.validate_input(user_input) @@ -118,9 +121,11 @@ async def async_step_validation(self, user_input=None): errors=errors, ) - async def async_step_user(self, user_input=None): + async def async_step_user( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: """Handle the initial step.""" - errors = {} + errors: dict[str, str] = {} if user_input is not None: if result := await self.validate_input_and_create_entry(user_input, errors): return result @@ -136,9 +141,11 @@ async def async_step_reauth( self._auth_data = dict(entry_data) return await self.async_step_reauth_validate(entry_data) - async def async_step_reauth_validate(self, user_input=None): + async def async_step_reauth_validate( + self, user_input: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauth and validation.""" - errors = {} + errors: dict[str, str] = {} if user_input is not None: if result := await self.validate_input_and_create_entry(user_input, errors): return result From 18b49a6f621e8f06296b3c307fd6d7fe4ef25bef Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:59:53 +0200 Subject: [PATCH 46/67] Cleanup unused import in solarlog config flow (#124713) --- .../components/solarlog/config_flow.py | 17 -------- tests/components/solarlog/test_config_flow.py | 41 +++---------------- 2 files changed, 6 insertions(+), 52 deletions(-) diff --git a/homeassistant/components/solarlog/config_flow.py b/homeassistant/components/solarlog/config_flow.py index 7824c98cf5d32c..4587cb7d886525 100644 --- a/homeassistant/components/solarlog/config_flow.py +++ b/homeassistant/components/solarlog/config_flow.py @@ -101,23 +101,6 @@ async def async_step_user(self, user_input=None) -> ConfigFlowResult: errors=self._errors, ) - async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: - """Import a config entry.""" - - user_input = { - CONF_HOST: DEFAULT_HOST, - CONF_NAME: DEFAULT_NAME, - "extended_data": False, - **import_data, - } - - user_input[CONF_HOST] = self._parse_url(user_input[CONF_HOST]) - - if self._host_in_configuration_exists(user_input[CONF_HOST]): - return self.async_abort(reason="already_configured") - - return await self.async_step_user(user_input) - async def async_step_reconfigure( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: diff --git a/tests/components/solarlog/test_config_flow.py b/tests/components/solarlog/test_config_flow.py index f71282a7c9b300..b06f2ac0587c17 100644 --- a/tests/components/solarlog/test_config_flow.py +++ b/tests/components/solarlog/test_config_flow.py @@ -7,7 +7,7 @@ from homeassistant import config_entries from homeassistant.components.solarlog import config_flow -from homeassistant.components.solarlog.const import DEFAULT_HOST, DOMAIN +from homeassistant.components.solarlog.const import DOMAIN from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -123,35 +123,6 @@ async def test_form_exceptions( assert result["data"]["extended_data"] is False -async def test_import(hass: HomeAssistant, test_connect) -> None: - """Test import step.""" - flow = init_config_flow(hass) - - # import with only host - result = await flow.async_step_import({CONF_HOST: HOST}) - await hass.async_block_till_done() - - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == "solarlog" - assert result["data"][CONF_HOST] == HOST - - # import with only name - result = await flow.async_step_import({CONF_NAME: NAME}) - await hass.async_block_till_done() - - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == "solarlog_test_1_2_3" - assert result["data"][CONF_HOST] == DEFAULT_HOST - - # import with host and name - result = await flow.async_step_import({CONF_HOST: HOST, CONF_NAME: NAME}) - await hass.async_block_till_done() - - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == "solarlog_test_1_2_3" - assert result["data"][CONF_HOST] == HOST - - async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None: """Test we abort if the device is already setup.""" flow = init_config_flow(hass) @@ -160,11 +131,11 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None ).add_to_hass(hass) # Should fail, same HOST different NAME (default) - result = await flow.async_step_import( + result = await flow.async_step_user( {CONF_HOST: HOST, CONF_NAME: "solarlog_test_7_8_9", "extended_data": False} ) - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "already_configured" + assert result["type"] is FlowResultType.FORM + assert result["errors"] == {CONF_HOST: "already_configured"} # Should fail, same HOST and NAME result = await flow.async_step_user({CONF_HOST: HOST, CONF_NAME: NAME}) @@ -172,7 +143,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None assert result["errors"] == {CONF_HOST: "already_configured"} # SHOULD pass, diff HOST (without http://), different NAME - result = await flow.async_step_import( + result = await flow.async_step_user( {CONF_HOST: "2.2.2.2", CONF_NAME: "solarlog_test_7_8_9", "extended_data": False} ) assert result["type"] is FlowResultType.CREATE_ENTRY @@ -180,7 +151,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None assert result["data"][CONF_HOST] == "http://2.2.2.2" # SHOULD pass, diff HOST, same NAME - result = await flow.async_step_import( + result = await flow.async_step_user( {CONF_HOST: "http://2.2.2.2", CONF_NAME: NAME, "extended_data": False} ) await hass.async_block_till_done() From 8ff8ed7f76002966e23a1742552426a3f5265fa6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:00:10 +0200 Subject: [PATCH 47/67] Cleanup unused import in upb config flow (#124694) * Cleanup unused import in upb config flow * More cleanup --- homeassistant/components/upb/config_flow.py | 12 ------- tests/components/upb/test_config_flow.py | 39 --------------------- 2 files changed, 51 deletions(-) diff --git a/homeassistant/components/upb/config_flow.py b/homeassistant/components/upb/config_flow.py index 6efd3a685edd0b..d9f111049fd909 100644 --- a/homeassistant/components/upb/config_flow.py +++ b/homeassistant/components/upb/config_flow.py @@ -79,10 +79,6 @@ class UPBConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 - def __init__(self) -> None: - """Initialize the UPB config flow.""" - self.importing = False - async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: @@ -105,9 +101,6 @@ async def async_step_user( await self.async_set_unique_id(network_id) self._abort_if_unique_id_configured() - if self.importing: - return self.async_create_entry(title=info["title"], data=user_input) - return self.async_create_entry( title=info["title"], data={ @@ -120,11 +113,6 @@ async def async_step_user( step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - async def async_step_import(self, user_input): - """Handle import.""" - self.importing = True - return await self.async_step_user(user_input) - def _url_already_configured(self, url): """See if we already have a UPB PIM matching user input configured.""" existing_hosts = { diff --git a/tests/components/upb/test_config_flow.py b/tests/components/upb/test_config_flow.py index 5f28f1d9b17994..59a4e97d22b460 100644 --- a/tests/components/upb/test_config_flow.py +++ b/tests/components/upb/test_config_flow.py @@ -114,42 +114,3 @@ async def test_form_user_with_already_configured(hass: HomeAssistant) -> None: assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "already_configured" await hass.async_block_till_done() - - -async def test_form_import(hass: HomeAssistant) -> None: - """Test we get the form with import source.""" - - with ( - mocked_upb(), - patch( - "homeassistant.components.upb.async_setup_entry", return_value=True - ) as mock_setup_entry, - ): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data={"host": "tcp://42.4.2.42", "file_path": "upb.upe"}, - ) - await hass.async_block_till_done() - - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == "UPB" - - assert result["data"] == {"host": "tcp://42.4.2.42", "file_path": "upb.upe"} - assert len(mock_setup_entry.mock_calls) == 1 - - -async def test_form_junk_input(hass: HomeAssistant) -> None: - """Test we get the form with import source.""" - - with mocked_upb(): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data={"foo": "goo", "goo": "foo"}, - ) - - assert result["type"] is FlowResultType.FORM - assert result["errors"] == {"base": "unknown"} - - await hass.async_block_till_done() From d4ae592a85a0b3b631605dce27c0ceb34c14aa46 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:00:30 +0200 Subject: [PATCH 48/67] Improve config flow type hints in sms (#124352) * Improve config flow type hints in sms * Drop async_step_import --- homeassistant/components/sms/config_flow.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/sms/config_flow.py b/homeassistant/components/sms/config_flow.py index aec9674da9d8fe..d2188a94632a49 100644 --- a/homeassistant/components/sms/config_flow.py +++ b/homeassistant/components/sms/config_flow.py @@ -1,11 +1,12 @@ """Config flow for SMS integration.""" import logging +from typing import Any import gammu import voluptuous as vol -from homeassistant.config_entries import ConfigFlow +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_DEVICE from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError @@ -26,7 +27,7 @@ ) -async def get_imei_from_config(hass: HomeAssistant, data): +async def get_imei_from_config(hass: HomeAssistant, data: dict[str, Any]) -> str: """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. @@ -56,7 +57,9 @@ class SMSFlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 - async def async_step_user(self, user_input=None): + async def async_step_user( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: """Handle the initial step.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") @@ -79,10 +82,6 @@ async def async_step_user(self, user_input=None): step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - async def async_step_import(self, user_input): - """Handle import.""" - return await self.async_step_user(user_input) - class CannotConnect(HomeAssistantError): """Error to indicate we cannot connect.""" From 51a5a78eb5c48af93525ffc9233d7abfbe8b4703 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:01:00 +0200 Subject: [PATCH 49/67] Standardize reauth step variable name in config flows (#124760) --- .../components/devolo_home_network/config_flow.py | 6 ++++-- homeassistant/components/ezviz/config_flow.py | 2 +- homeassistant/components/frontier_silicon/config_flow.py | 6 ++++-- homeassistant/components/hydrawise/config_flow.py | 2 +- homeassistant/components/justnimbus/config_flow.py | 2 +- homeassistant/components/jvc_projector/config_flow.py | 2 +- homeassistant/components/kitchen_sink/config_flow.py | 5 ++++- homeassistant/components/lidarr/config_flow.py | 2 +- homeassistant/components/mikrotik/config_flow.py | 4 +++- homeassistant/components/octoprint/config_flow.py | 8 +++++--- homeassistant/components/osoenergy/config_flow.py | 4 ++-- homeassistant/components/radarr/config_flow.py | 4 +++- homeassistant/components/simplisafe/config_flow.py | 4 +++- homeassistant/components/tailwind/config_flow.py | 4 +++- homeassistant/components/tessie/config_flow.py | 2 +- homeassistant/components/thethingsnetwork/config_flow.py | 2 +- homeassistant/components/tuya/config_flow.py | 4 +++- homeassistant/components/volvooncall/config_flow.py | 2 +- 18 files changed, 42 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/devolo_home_network/config_flow.py b/homeassistant/components/devolo_home_network/config_flow.py index 63d86d46e8a77e..fca724716938f2 100644 --- a/homeassistant/components/devolo_home_network/config_flow.py +++ b/homeassistant/components/devolo_home_network/config_flow.py @@ -112,10 +112,12 @@ async def async_step_zeroconf_confirm( description_placeholders={"host_name": title}, ) - async def async_step_reauth(self, data: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauthentication.""" if entry := self.hass.config_entries.async_get_entry(self.context["entry_id"]): - self.context[CONF_HOST] = data[CONF_IP_ADDRESS] + self.context[CONF_HOST] = entry_data[CONF_IP_ADDRESS] self.context["title_placeholders"][PRODUCT] = ( entry.runtime_data.device.product ) diff --git a/homeassistant/components/ezviz/config_flow.py b/homeassistant/components/ezviz/config_flow.py index 2b47b120cf8bf9..66425c675cc106 100644 --- a/homeassistant/components/ezviz/config_flow.py +++ b/homeassistant/components/ezviz/config_flow.py @@ -319,7 +319,7 @@ async def async_step_confirm( ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle a flow for reauthentication with password.""" diff --git a/homeassistant/components/frontier_silicon/config_flow.py b/homeassistant/components/frontier_silicon/config_flow.py index 103323ff5758dc..8a3c5fe086f884 100644 --- a/homeassistant/components/frontier_silicon/config_flow.py +++ b/homeassistant/components/frontier_silicon/config_flow.py @@ -172,9 +172,11 @@ async def async_step_confirm( step_id="confirm", description_placeholders={"name": self._name} ) - async def async_step_reauth(self, config: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" - self._webfsapi_url = config[CONF_WEBFSAPI_URL] + self._webfsapi_url = entry_data[CONF_WEBFSAPI_URL] self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] diff --git a/homeassistant/components/hydrawise/config_flow.py b/homeassistant/components/hydrawise/config_flow.py index ab9ebbb065d6c6..a5e7d616fcf1ae 100644 --- a/homeassistant/components/hydrawise/config_flow.py +++ b/homeassistant/components/hydrawise/config_flow.py @@ -90,7 +90,7 @@ def _show_form(self, error_type: str | None = None) -> ConfigFlowResult: ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth after updating config to username/password.""" self.reauth_entry = self.hass.config_entries.async_get_entry( diff --git a/homeassistant/components/justnimbus/config_flow.py b/homeassistant/components/justnimbus/config_flow.py index 0520c558266629..8c816c1ac1b1ec 100644 --- a/homeassistant/components/justnimbus/config_flow.py +++ b/homeassistant/components/justnimbus/config_flow.py @@ -77,7 +77,7 @@ async def async_step_user( ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" self.reauth_entry = self.hass.config_entries.async_get_entry( diff --git a/homeassistant/components/jvc_projector/config_flow.py b/homeassistant/components/jvc_projector/config_flow.py index 7fbfb17a976281..253aa640f718c8 100644 --- a/homeassistant/components/jvc_projector/config_flow.py +++ b/homeassistant/components/jvc_projector/config_flow.py @@ -74,7 +74,7 @@ async def async_step_user( ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth on password authentication error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( diff --git a/homeassistant/components/kitchen_sink/config_flow.py b/homeassistant/components/kitchen_sink/config_flow.py index 2e05db71b8947e..9a0b78c80e607d 100644 --- a/homeassistant/components/kitchen_sink/config_flow.py +++ b/homeassistant/components/kitchen_sink/config_flow.py @@ -2,6 +2,7 @@ from __future__ import annotations +from collections.abc import Mapping from typing import Any import voluptuous as vol @@ -41,7 +42,9 @@ async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResu return self.async_create_entry(title="Kitchen Sink", data=import_data) - async def async_step_reauth(self, data): + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Reauth step.""" return await self.async_step_reauth_confirm() diff --git a/homeassistant/components/lidarr/config_flow.py b/homeassistant/components/lidarr/config_flow.py index 05d6900bb41063..bc7a40c976ee7a 100644 --- a/homeassistant/components/lidarr/config_flow.py +++ b/homeassistant/components/lidarr/config_flow.py @@ -29,7 +29,7 @@ def __init__(self) -> None: self.entry: LidarrConfigEntry | None = None async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) diff --git a/homeassistant/components/mikrotik/config_flow.py b/homeassistant/components/mikrotik/config_flow.py index fe0d020d373795..6035565acf1d34 100644 --- a/homeassistant/components/mikrotik/config_flow.py +++ b/homeassistant/components/mikrotik/config_flow.py @@ -83,7 +83,9 @@ async def async_step_user( errors=errors, ) - async def async_step_reauth(self, data: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] diff --git a/homeassistant/components/octoprint/config_flow.py b/homeassistant/components/octoprint/config_flow.py index 8e4257ab821784..706670738a6adc 100644 --- a/homeassistant/components/octoprint/config_flow.py +++ b/homeassistant/components/octoprint/config_flow.py @@ -215,13 +215,15 @@ async def async_step_ssdp( return await self.async_step_user() - async def async_step_reauth(self, config: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle reauthorization request from Octoprint.""" - self._reauth_data = dict(config) + self._reauth_data = dict(entry_data) self.context.update( { - "title_placeholders": {CONF_HOST: config[CONF_HOST]}, + "title_placeholders": {CONF_HOST: entry_data[CONF_HOST]}, } ) diff --git a/homeassistant/components/osoenergy/config_flow.py b/homeassistant/components/osoenergy/config_flow.py index e0afc5292aee9a..0642250e9ed8f7 100644 --- a/homeassistant/components/osoenergy/config_flow.py +++ b/homeassistant/components/osoenergy/config_flow.py @@ -69,9 +69,9 @@ async def get_user_email(self, subscription_key: str) -> str | None: return None async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Re Authenticate a user.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) - data = {CONF_API_KEY: user_input[CONF_API_KEY]} + data = {CONF_API_KEY: entry_data[CONF_API_KEY]} return await self.async_step_user(data) diff --git a/homeassistant/components/radarr/config_flow.py b/homeassistant/components/radarr/config_flow.py index 3bf0796a9a8b8f..c748c63e992d35 100644 --- a/homeassistant/components/radarr/config_flow.py +++ b/homeassistant/components/radarr/config_flow.py @@ -26,7 +26,9 @@ class RadarrConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 entry: RadarrConfigEntry | None = None - async def async_step_reauth(self, _: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) diff --git a/homeassistant/components/simplisafe/config_flow.py b/homeassistant/components/simplisafe/config_flow.py index c0d98c5644fd21..6fdbd351a299e3 100644 --- a/homeassistant/components/simplisafe/config_flow.py +++ b/homeassistant/components/simplisafe/config_flow.py @@ -69,7 +69,9 @@ def async_get_options_flow( """Define the config flow to handle options.""" return SimpliSafeOptionsFlowHandler(config_entry) - async def async_step_reauth(self, config: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle configuration by re-auth.""" self._reauth = True return await self.async_step_user() diff --git a/homeassistant/components/tailwind/config_flow.py b/homeassistant/components/tailwind/config_flow.py index 1cb946252664b3..13682a3e9c40a9 100644 --- a/homeassistant/components/tailwind/config_flow.py +++ b/homeassistant/components/tailwind/config_flow.py @@ -144,7 +144,9 @@ async def async_step_zeroconf_confirm( errors=errors, ) - async def async_step_reauth(self, _: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle initiation of re-authentication with a Tailwind device.""" self.reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] diff --git a/homeassistant/components/tessie/config_flow.py b/homeassistant/components/tessie/config_flow.py index 1cbc070e463b22..bee518ce95fda3 100644 --- a/homeassistant/components/tessie/config_flow.py +++ b/homeassistant/components/tessie/config_flow.py @@ -66,7 +66,7 @@ async def async_step_user( ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle re-auth.""" self._reauth_entry = self.hass.config_entries.async_get_entry( diff --git a/homeassistant/components/thethingsnetwork/config_flow.py b/homeassistant/components/thethingsnetwork/config_flow.py index cbb780e70647ff..7480e4cb1d922c 100644 --- a/homeassistant/components/thethingsnetwork/config_flow.py +++ b/homeassistant/components/thethingsnetwork/config_flow.py @@ -89,7 +89,7 @@ async def async_step_user( return self.async_show_form(step_id="user", data_schema=schema, errors=errors) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle a flow initialized by a reauth event.""" diff --git a/homeassistant/components/tuya/config_flow.py b/homeassistant/components/tuya/config_flow.py index bdef321de7ac48..104c3b7c9fa174 100644 --- a/homeassistant/components/tuya/config_flow.py +++ b/homeassistant/components/tuya/config_flow.py @@ -146,7 +146,9 @@ async def async_step_scan( data=entry_data, ) - async def async_step_reauth(self, _: Mapping[str, Any]) -> ConfigFlowResult: + async def async_step_reauth( + self, entry_data: Mapping[str, Any] + ) -> ConfigFlowResult: """Handle initiation of re-authentication with Tuya.""" self.__reauth_entry = self.hass.config_entries.async_get_entry( self.context["entry_id"] diff --git a/homeassistant/components/volvooncall/config_flow.py b/homeassistant/components/volvooncall/config_flow.py index 80358a28cedc4d..b3a1745351b807 100644 --- a/homeassistant/components/volvooncall/config_flow.py +++ b/homeassistant/components/volvooncall/config_flow.py @@ -107,7 +107,7 @@ async def async_step_user( ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" self._reauth_entry = self.hass.config_entries.async_get_entry( From 274d98f4d73712dac2b5df4bf025a1a322cf17a5 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:02:21 +0200 Subject: [PATCH 50/67] Standardize reauth step variable name in permobil (#124764) --- homeassistant/components/permobil/config_flow.py | 11 +++-------- tests/components/permobil/test_config_flow.py | 3 +++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/permobil/config_flow.py b/homeassistant/components/permobil/config_flow.py index cb47640e55f7f5..f7f247a412eeae 100644 --- a/homeassistant/components/permobil/config_flow.py +++ b/homeassistant/components/permobil/config_flow.py @@ -161,17 +161,12 @@ async def async_step_email_code( return self.async_create_entry(title=self.data[CONF_EMAIL], data=self.data) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" - reauth_entry = self.hass.config_entries.async_get_entry( - self.context["entry_id"] - ) - assert reauth_entry - try: - email: str = reauth_entry.data[CONF_EMAIL] - region: str = reauth_entry.data[CONF_REGION] + email: str = entry_data[CONF_EMAIL] + region: str = entry_data[CONF_REGION] self.p_api.set_email(email) self.p_api.set_region(region) self.data = { diff --git a/tests/components/permobil/test_config_flow.py b/tests/components/permobil/test_config_flow.py index ea39e678459f71..4474340f811dca 100644 --- a/tests/components/permobil/test_config_flow.py +++ b/tests/components/permobil/test_config_flow.py @@ -287,6 +287,7 @@ async def test_config_flow_reauth_success( result = await hass.config_entries.flow.async_init( config_flow.DOMAIN, context={"source": "reauth", "entry_id": mock_entry.entry_id}, + data=mock_entry.data, ) assert result["type"] is FlowResultType.FORM @@ -329,6 +330,7 @@ async def test_config_flow_reauth_fail_invalid_code( result = await hass.config_entries.flow.async_init( config_flow.DOMAIN, context={"source": "reauth", "entry_id": mock_entry.entry_id}, + data=mock_entry.data, ) assert result["type"] is FlowResultType.FORM @@ -366,6 +368,7 @@ async def test_config_flow_reauth_fail_code_request( result = await hass.config_entries.flow.async_init( config_flow.DOMAIN, context={"source": "reauth", "entry_id": reauth_entry.entry_id}, + data=mock_entry.data, ) assert result["type"] is FlowResultType.ABORT From 14eec2e57ab43b39df072b1de3d72cae66d89f2b Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:08:26 +0200 Subject: [PATCH 51/67] Add start_reauth helper method to MockConfigEntry (#124767) * Add start_reauth helper method to MockConfigEntry * Two more --- tests/common.py | 15 ++++++++++- tests/components/abode/test_config_flow.py | 13 ++++----- .../components/airvisual/test_config_flow.py | 10 +++---- .../airvisual_pro/test_config_flow.py | 16 ++++------- tests/components/august/test_config_flow.py | 8 ++---- tests/components/awair/test_config_flow.py | 14 +++------- tests/components/axis/test_config_flow.py | 8 +----- .../azure_devops/test_config_flow.py | 27 +++++-------------- 8 files changed, 41 insertions(+), 70 deletions(-) diff --git a/tests/common.py b/tests/common.py index 893c9ffcd67b76..523bd12d5903c0 100644 --- a/tests/common.py +++ b/tests/common.py @@ -47,7 +47,7 @@ _async_get_device_automation_capabilities as async_get_device_automation_capabilities, ) from homeassistant.config import IntegrationConfigInfo, async_process_component_config -from homeassistant.config_entries import ConfigEntry, ConfigFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.const import ( DEVICE_DEFAULT_NAME, EVENT_HOMEASSISTANT_CLOSE, @@ -1054,6 +1054,19 @@ def mock_state( """ self._async_set_state(hass, state, reason) + async def start_reauth_flow(self, hass: HomeAssistant) -> ConfigFlowResult: + """Start a reauthentication flow.""" + return await hass.config_entries.flow.async_init( + self.domain, + context={ + "source": config_entries.SOURCE_REAUTH, + "entry_id": self.entry_id, + "title_placeholders": {"name": self.title}, + "unique_id": self.unique_id, + }, + data=self.data, + ) + def patch_yaml_files(files_dict, endswith=True): """Patch load_yaml with a dictionary of yaml files.""" diff --git a/tests/components/abode/test_config_flow.py b/tests/components/abode/test_config_flow.py index 265a77560f729d..a37fb8cbe33eab 100644 --- a/tests/components/abode/test_config_flow.py +++ b/tests/components/abode/test_config_flow.py @@ -12,7 +12,7 @@ from homeassistant.components.abode import config_flow from homeassistant.components.abode.const import CONF_POLLING, DOMAIN -from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -161,18 +161,15 @@ async def test_step_reauth(hass: HomeAssistant) -> None: """Test the reauth flow.""" conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} - MockConfigEntry( + entry = MockConfigEntry( domain=DOMAIN, unique_id="user@email.com", data=conf, - ).add_to_hass(hass) + ) + entry.add_to_hass(hass) with patch("homeassistant.components.abode.config_flow.Abode"): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_REAUTH}, - data=conf, - ) + result = await entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" diff --git a/tests/components/airvisual/test_config_flow.py b/tests/components/airvisual/test_config_flow.py index b9643b17c079fd..e38fc64587e526 100644 --- a/tests/components/airvisual/test_config_flow.py +++ b/tests/components/airvisual/test_config_flow.py @@ -18,7 +18,7 @@ INTEGRATION_TYPE_GEOGRAPHY_COORDS, INTEGRATION_TYPE_GEOGRAPHY_NAME, ) -from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_API_KEY, CONF_SHOW_ON_MAP from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -33,6 +33,8 @@ TEST_STATE, ) +from tests.common import MockConfigEntry + pytestmark = pytest.mark.usefixtures("mock_setup_entry") @@ -146,12 +148,10 @@ async def test_options_flow( async def test_step_reauth( - hass: HomeAssistant, config_entry, setup_config_entry + hass: HomeAssistant, config_entry: MockConfigEntry, setup_config_entry ) -> None: """Test that the reauth step works.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_REAUTH}, data=config_entry.data - ) + result = await config_entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" diff --git a/tests/components/airvisual_pro/test_config_flow.py b/tests/components/airvisual_pro/test_config_flow.py index 803a335f52c17d..9298b8cf528115 100644 --- a/tests/components/airvisual_pro/test_config_flow.py +++ b/tests/components/airvisual_pro/test_config_flow.py @@ -10,11 +10,13 @@ import pytest from homeassistant.components.airvisual_pro.const import DOMAIN -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER +from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType +from tests.common import MockConfigEntry + pytestmark = pytest.mark.usefixtures("mock_setup_entry") @@ -98,22 +100,14 @@ async def test_step_import(hass: HomeAssistant, config, setup_airvisual_pro) -> async def test_reauth( hass: HomeAssistant, config, - config_entry, + config_entry: MockConfigEntry, connect_errors, connect_mock, pro, setup_airvisual_pro, ) -> None: """Test re-auth (including errors).""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_REAUTH, - "entry_id": config_entry.entry_id, - "unique_id": config_entry.unique_id, - }, - data=config, - ) + result = await config_entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" diff --git a/tests/components/august/test_config_flow.py b/tests/components/august/test_config_flow.py index fdebb8d5c4636d..e0ccee55f10ff1 100644 --- a/tests/components/august/test_config_flow.py +++ b/tests/components/august/test_config_flow.py @@ -248,9 +248,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data - ) + result = await entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["errors"] == {} @@ -294,9 +292,7 @@ async def test_form_reauth_with_2fa(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data - ) + result = await entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["errors"] == {} diff --git a/tests/components/awair/test_config_flow.py b/tests/components/awair/test_config_flow.py index ab9f5faa425f72..ac17cf414489fd 100644 --- a/tests/components/awair/test_config_flow.py +++ b/tests/components/awair/test_config_flow.py @@ -7,7 +7,7 @@ from python_awair.exceptions import AuthError, AwairError from homeassistant.components.awair.const import DOMAIN -from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF +from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -136,11 +136,7 @@ async def test_reauth(hass: HomeAssistant, user, cloud_devices) -> None: ) mock_config.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_REAUTH, "unique_id": CLOUD_UNIQUE_ID}, - data={**CLOUD_CONFIG, CONF_ACCESS_TOKEN: "blah"}, - ) + result = await mock_config.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" assert result["errors"] == {} @@ -180,11 +176,7 @@ async def test_reauth_error(hass: HomeAssistant) -> None: ) mock_config.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_REAUTH, "unique_id": CLOUD_UNIQUE_ID}, - data={**CLOUD_CONFIG, CONF_ACCESS_TOKEN: "blah"}, - ) + result = await mock_config.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" assert result["errors"] == {} diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index 5ceb6588fbde31..8591b4583c133d 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -17,7 +17,6 @@ ) from homeassistant.config_entries import ( SOURCE_DHCP, - SOURCE_REAUTH, SOURCE_RECONFIGURE, SOURCE_SSDP, SOURCE_USER, @@ -205,12 +204,7 @@ async def test_reauth_flow_update_configuration( assert config_entry_setup.data[CONF_USERNAME] == "root" assert config_entry_setup.data[CONF_PASSWORD] == "pass" - result = await hass.config_entries.flow.async_init( - AXIS_DOMAIN, - context={"source": SOURCE_REAUTH}, - data=config_entry_setup.data, - ) - + result = await config_entry_setup.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" diff --git a/tests/components/azure_devops/test_config_flow.py b/tests/components/azure_devops/test_config_flow.py index 45dc10802b9c64..9ebc9991939f42 100644 --- a/tests/components/azure_devops/test_config_flow.py +++ b/tests/components/azure_devops/test_config_flow.py @@ -53,18 +53,14 @@ async def test_authorization_error( async def test_reauth_authorization_error( hass: HomeAssistant, + mock_config_entry: MockConfigEntry, mock_devops_client: AsyncMock, ) -> None: """Test we show user form on Azure DevOps authorization error.""" mock_devops_client.authorize.return_value = False mock_devops_client.authorized = False - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_REAUTH}, - data=FIXTURE_USER_INPUT, - ) - + result = await mock_config_entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth" @@ -108,17 +104,14 @@ async def test_connection_error( async def test_reauth_connection_error( hass: HomeAssistant, + mock_config_entry: MockConfigEntry, mock_devops_client: AsyncMock, ) -> None: """Test we show user form on Azure DevOps connection error.""" mock_devops_client.authorize.side_effect = aiohttp.ClientError mock_devops_client.authorized = False - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_REAUTH}, - data=FIXTURE_USER_INPUT, - ) + result = await mock_config_entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth" @@ -174,11 +167,7 @@ async def test_reauth_project_error( mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_REAUTH}, - data=FIXTURE_USER_INPUT, - ) + result = await mock_config_entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth" @@ -205,11 +194,7 @@ async def test_reauth_flow( mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_REAUTH}, - data=FIXTURE_USER_INPUT, - ) + result = await mock_config_entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth" From 45eebf32856d521dc70741def9bfd69b4bafb6a8 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:09:21 +0200 Subject: [PATCH 52/67] Use reauth_confirm in sharkiq (#124762) --- .../components/sharkiq/config_flow.py | 10 ++++-- homeassistant/components/sharkiq/strings.json | 2 +- tests/components/sharkiq/test_config_flow.py | 35 +++++++++++-------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/sharkiq/config_flow.py b/homeassistant/components/sharkiq/config_flow.py index 492b8f2a36527c..87367fcf093ea4 100644 --- a/homeassistant/components/sharkiq/config_flow.py +++ b/homeassistant/components/sharkiq/config_flow.py @@ -116,9 +116,15 @@ async def async_step_user( ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle re-auth if login is invalid.""" + return await self.async_step_reauth_confirm() + + async def async_step_reauth_confirm( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: + """Handle a flow initiated by reauthentication.""" errors: dict[str, str] = {} if user_input is not None: @@ -134,7 +140,7 @@ async def async_step_reauth( return self.async_abort(reason=errors["base"]) return self.async_show_form( - step_id="reauth", + step_id="reauth_confirm", data_schema=SHARKIQ_SCHEMA, errors=errors, ) diff --git a/homeassistant/components/sharkiq/strings.json b/homeassistant/components/sharkiq/strings.json index 63d4f6af48b35c..40b569e13b750e 100644 --- a/homeassistant/components/sharkiq/strings.json +++ b/homeassistant/components/sharkiq/strings.json @@ -13,7 +13,7 @@ "region": "Shark IQ uses different services in the EU. Select your region to connect to the correct service for your account." } }, - "reauth": { + "reauth_confirm": { "data": { "username": "[%key:common::config_flow::data::username%]", "password": "[%key:common::config_flow::data::password%]", diff --git a/tests/components/sharkiq/test_config_flow.py b/tests/components/sharkiq/test_config_flow.py index cf75bff1686a0e..ae037834c57e2d 100644 --- a/tests/components/sharkiq/test_config_flow.py +++ b/tests/components/sharkiq/test_config_flow.py @@ -96,18 +96,22 @@ async def test_form_error(hass: HomeAssistant, exc: Exception, base_error: str) async def test_reauth_success(hass: HomeAssistant) -> None: """Test reauth flow.""" - with patch("sharkiq.AylaApi.async_sign_in", return_value=True): - mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG) - mock_config.add_to_hass(hass) + mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG) + mock_config.add_to_hass(hass) + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID}, + data=mock_config.data, + ) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID}, - data=CONFIG, + with patch("sharkiq.AylaApi.async_sign_in", return_value=True): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], user_input=CONFIG ) - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "reauth_successful" + assert result["type"] is FlowResultType.ABORT + assert result["reason"] == "reauth_successful" @pytest.mark.parametrize( @@ -127,13 +131,16 @@ async def test_reauth( msg: str, ) -> None: """Test reauth failures.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID}, + data=CONFIG, + ) + with patch("sharkiq.AylaApi.async_sign_in", side_effect=side_effect): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID}, - data=CONFIG, + result = await hass.config_entries.flow.async_configure( + result["flow_id"], user_input=CONFIG ) - msg_value = result[msg_field] if msg_field == "errors": msg_value = msg_value.get("base") From 163795e73a4180671cf8cf0776c1c0de7074a834 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:09:45 +0200 Subject: [PATCH 53/67] Use reauth_confirm in weatherflow_cloud (#124761) --- .../components/weatherflow_cloud/config_flow.py | 10 ++++++++-- .../components/weatherflow_cloud/strings.json | 2 +- .../weatherflow_cloud/test_config_flow.py | 13 ++++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/weatherflow_cloud/config_flow.py b/homeassistant/components/weatherflow_cloud/config_flow.py index e8972c320ed147..cbb83b6f25bfdc 100644 --- a/homeassistant/components/weatherflow_cloud/config_flow.py +++ b/homeassistant/components/weatherflow_cloud/config_flow.py @@ -33,9 +33,15 @@ class WeatherFlowCloudConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle a flow for reauth.""" + return await self.async_step_reauth_confirm() + + async def async_step_reauth_confirm( + self, user_input: dict[str, Any] | None = None + ) -> ConfigFlowResult: + """Handle a flow initiated by reauthentication.""" errors = {} if user_input is not None: @@ -54,7 +60,7 @@ async def async_step_reauth( ) return self.async_show_form( - step_id="reauth", + step_id="reauth_confirm", data_schema=vol.Schema({vol.Required(CONF_API_TOKEN): str}), errors=errors, ) diff --git a/homeassistant/components/weatherflow_cloud/strings.json b/homeassistant/components/weatherflow_cloud/strings.json index df561c8b7532d3..f707cbb035383b 100644 --- a/homeassistant/components/weatherflow_cloud/strings.json +++ b/homeassistant/components/weatherflow_cloud/strings.json @@ -7,7 +7,7 @@ "api_token": "Personal api token" } }, - "reauth": { + "reauth_confirm": { "description": "Reauthenticate with WeatherFlow", "data": { "api_token": "[%key:component::weatherflow_cloud::config::step::user::data::api_token%]" diff --git a/tests/components/weatherflow_cloud/test_config_flow.py b/tests/components/weatherflow_cloud/test_config_flow.py index 7ade007ceacf71..3a1f41563fe82c 100644 --- a/tests/components/weatherflow_cloud/test_config_flow.py +++ b/tests/components/weatherflow_cloud/test_config_flow.py @@ -111,15 +111,18 @@ async def test_reauth(hass: HomeAssistant, mock_get_stations_401_error) -> None: assert not await hass.config_entries.async_setup(entry.entry_id) assert entry.state is ConfigEntryState.SETUP_ERROR - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id}, data=None - ) - assert result["type"] is FlowResultType.FORM result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id}, - data={CONF_API_TOKEN: "SAME_SAME"}, + data=entry.data, + ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "reauth_confirm" + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], user_input={CONF_API_TOKEN: "SAME_SAME"} ) assert result["reason"] == "reauth_successful" assert result["type"] is FlowResultType.ABORT + assert entry.data[CONF_API_TOKEN] == "SAME_SAME" From 633ff0ea42a327f38e54959c972bcf148dc4062c Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Wed, 28 Aug 2024 13:14:34 +0200 Subject: [PATCH 54/67] Handle KNX expose conversion exceptions and unavailable states (#124776) --- homeassistant/components/knx/expose.py | 24 +++++++++++++++------ tests/components/knx/test_expose.py | 29 ++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/knx/expose.py b/homeassistant/components/knx/expose.py index 921af6ba4a91d1..82bee48ba69a56 100644 --- a/homeassistant/components/knx/expose.py +++ b/homeassistant/components/knx/expose.py @@ -125,6 +125,8 @@ def async_remove(self) -> None: def _get_expose_value(self, state: State | None) -> bool | int | float | str | None: """Extract value from state.""" if state is None or state.state in (STATE_UNKNOWN, STATE_UNAVAILABLE): + if self.expose_default is None: + return None value = self.expose_default elif self.expose_attribute is not None: _attr = state.attributes.get(self.expose_attribute) @@ -154,12 +156,22 @@ def _get_expose_value(self, state: State | None) -> bool | int | float | str | N if value is not None and ( isinstance(self.device.sensor_value, RemoteValueSensor) ): - if issubclass(self.device.sensor_value.dpt_class, DPTNumeric): - return float(value) - if issubclass(self.device.sensor_value.dpt_class, DPTString): - # DPT 16.000 only allows up to 14 Bytes - return str(value)[:14] - return value + try: + if issubclass(self.device.sensor_value.dpt_class, DPTNumeric): + return float(value) + if issubclass(self.device.sensor_value.dpt_class, DPTString): + # DPT 16.000 only allows up to 14 Bytes + return str(value)[:14] + except (ValueError, TypeError) as err: + _LOGGER.warning( + 'Could not expose %s %s value "%s" to KNX: Conversion failed: %s', + self.entity_id, + self.expose_attribute or "state", + value, + err, + ) + return None + return value # type: ignore[no-any-return] async def _async_entity_changed(self, event: Event[EventStateChangedData]) -> None: """Handle entity change.""" diff --git a/tests/components/knx/test_expose.py b/tests/components/knx/test_expose.py index c4d0acf0ce2e64..0fd790a3e336b2 100644 --- a/tests/components/knx/test_expose.py +++ b/tests/components/knx/test_expose.py @@ -108,6 +108,11 @@ async def test_expose_attribute(hass: HomeAssistant, knx: KNXTestKit) -> None: await hass.async_block_till_done() await knx.assert_telegram_count(0) + # Ignore "unavailable" state + hass.states.async_set(entity_id, "unavailable", {attribute: None}) + await hass.async_block_till_done() + await knx.assert_telegram_count(0) + async def test_expose_attribute_with_default( hass: HomeAssistant, knx: KNXTestKit @@ -131,7 +136,7 @@ async def test_expose_attribute_with_default( await knx.receive_read("1/1/8") await knx.assert_response("1/1/8", (0,)) - # Change state to "on"; no attribute + # Change state to "on"; no attribute -> default hass.states.async_set(entity_id, "on", {}) await hass.async_block_till_done() await knx.assert_write("1/1/8", (0,)) @@ -146,6 +151,11 @@ async def test_expose_attribute_with_default( await hass.async_block_till_done() await knx.assert_no_telegram() + # Use default for "unavailable" state + hass.states.async_set(entity_id, "unavailable") + await hass.async_block_till_done() + await knx.assert_write("1/1/8", (0,)) + # Change state and attribute hass.states.async_set(entity_id, "on", {attribute: 3}) await hass.async_block_till_done() @@ -290,8 +300,18 @@ async def test_expose_value_template( assert "Error rendering value template for KNX expose" in caplog.text +@pytest.mark.parametrize( + "invalid_attribute", + [ + 101.0, + "invalid", # can't cast to float + ], +) async def test_expose_conversion_exception( - hass: HomeAssistant, caplog: pytest.LogCaptureFixture, knx: KNXTestKit + hass: HomeAssistant, + caplog: pytest.LogCaptureFixture, + knx: KNXTestKit, + invalid_attribute: str, ) -> None: """Test expose throws exception.""" @@ -313,16 +333,17 @@ async def test_expose_conversion_exception( await knx.receive_read("1/1/8") await knx.assert_response("1/1/8", (3,)) + caplog.clear() # Change attribute: Expect no exception hass.states.async_set( entity_id, "on", - {attribute: 101}, + {attribute: invalid_attribute}, ) await hass.async_block_till_done() await knx.assert_no_telegram() assert ( - 'Could not expose fake.entity fake_attribute value "101.0" to KNX:' + f'Could not expose fake.entity fake_attribute value "{invalid_attribute}" to KNX:' in caplog.text ) From a0089685dd2f98f21a0965b07fff957e8f6dfe41 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:19:58 +0200 Subject: [PATCH 55/67] Simplify aussie_broadband reauth flow (#124774) * Simplify aussie_broadband config flow * Apply suggestions from code review Co-authored-by: Joost Lekkerkerker * Update config_flow.py * Update config_flow.py --------- Co-authored-by: Joost Lekkerkerker --- .../aussie_broadband/config_flow.py | 14 +++---- .../aussie_broadband/test_config_flow.py | 39 ++++++------------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/homeassistant/components/aussie_broadband/config_flow.py b/homeassistant/components/aussie_broadband/config_flow.py index b434ab69ae526e..65507d57e8bbf3 100644 --- a/homeassistant/components/aussie_broadband/config_flow.py +++ b/homeassistant/components/aussie_broadband/config_flow.py @@ -99,15 +99,11 @@ async def async_step_reauth_confirm( } if not (errors := await self.async_auth(data)): - entry = await self.async_set_unique_id(self._reauth_username.lower()) - if entry: - self.hass.config_entries.async_update_entry( - entry, - data=data, - ) - await self.hass.config_entries.async_reload(entry.entry_id) - return self.async_abort(reason="reauth_successful") - return self.async_create_entry(title=self._reauth_username, data=data) + entry = self.hass.config_entries.async_get_entry( + self.context["entry_id"] + ) + assert entry + return self.async_update_reload_and_abort(entry, data=data) return self.async_show_form( step_id="reauth_confirm", diff --git a/tests/components/aussie_broadband/test_config_flow.py b/tests/components/aussie_broadband/test_config_flow.py index 6ee674ab0f4a46..b79ed41b251ceb 100644 --- a/tests/components/aussie_broadband/test_config_flow.py +++ b/tests/components/aussie_broadband/test_config_flow.py @@ -13,6 +13,8 @@ from .common import FAKE_DATA, FAKE_SERVICES +from tests.common import MockConfigEntry + TEST_USERNAME = FAKE_DATA[CONF_USERNAME] TEST_PASSWORD = FAKE_DATA[CONF_PASSWORD] @@ -163,39 +165,20 @@ async def test_form_network_issue(hass: HomeAssistant) -> None: async def test_reauth(hass: HomeAssistant) -> None: """Test reauth flow.""" - - # Test reauth but the entry doesn't exist - result1 = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=FAKE_DATA + mock_entry = MockConfigEntry( + domain=DOMAIN, + data=FAKE_DATA, + unique_id=FAKE_DATA[CONF_USERNAME], ) - - with ( - patch("aussiebb.asyncio.AussieBB.__init__", return_value=None), - patch("aussiebb.asyncio.AussieBB.login", return_value=True), - patch( - "aussiebb.asyncio.AussieBB.get_services", return_value=[FAKE_SERVICES[0]] - ), - patch( - "homeassistant.components.aussie_broadband.async_setup_entry", - return_value=True, - ), - ): - result2 = await hass.config_entries.flow.async_configure( - result1["flow_id"], - { - CONF_PASSWORD: TEST_PASSWORD, - }, - ) - await hass.async_block_till_done() - - assert result2["type"] is FlowResultType.CREATE_ENTRY - assert result2["title"] == TEST_USERNAME - assert result2["data"] == FAKE_DATA + mock_entry.add_to_hass(hass) # Test failed reauth result5 = await hass.config_entries.flow.async_init( DOMAIN, - context={"source": config_entries.SOURCE_REAUTH}, + context={ + "source": config_entries.SOURCE_REAUTH, + "entry_id": mock_entry.entry_id, + }, data=FAKE_DATA, ) assert result5["step_id"] == "reauth_confirm" From a0ffa69b49cdc2c57034c1640ca292e4ce4d9b12 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:29:18 +0200 Subject: [PATCH 56/67] Standardize reauth step variable name in aseko_pool_live (#124765) --- homeassistant/components/aseko_pool_live/config_flow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/aseko_pool_live/config_flow.py b/homeassistant/components/aseko_pool_live/config_flow.py index cd2f0e4ac7ff4e..ce6de3683d5545 100644 --- a/homeassistant/components/aseko_pool_live/config_flow.py +++ b/homeassistant/components/aseko_pool_live/config_flow.py @@ -101,7 +101,7 @@ async def async_store_credentials(self, info: dict[str, Any]) -> ConfigFlowResul ) async def async_step_reauth( - self, user_input: Mapping[str, Any] + self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" @@ -109,10 +109,10 @@ async def async_step_reauth( self.context["entry_id"] ) - return await self.async_step_reauth_confirm(user_input) + return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( - self, user_input: Mapping | None = None + self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Dialog that informs the user that reauth is required.""" From fce2e21c9fb3e2749568499c917d4556dacf556d Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 13:47:02 +0200 Subject: [PATCH 57/67] Update icons.json to new service schema part 1 (#124768) --- homeassistant/components/abode/icons.json | 12 +++-- homeassistant/components/adguard/icons.json | 20 +++++-- homeassistant/components/ads/icons.json | 4 +- .../components/advantage_air/icons.json | 4 +- homeassistant/components/aftership/icons.json | 8 ++- homeassistant/components/agent_dvr/icons.json | 20 +++++-- .../components/alarm_control_panel/icons.json | 28 +++++++--- .../components/alarmdecoder/icons.json | 8 ++- homeassistant/components/alert/icons.json | 12 +++-- homeassistant/components/amcrest/icons.json | 44 ++++++++++++---- homeassistant/components/androidtv/icons.json | 16 ++++-- .../components/automation/icons.json | 20 +++++-- homeassistant/components/backup/icons.json | 4 +- homeassistant/components/bayesian/icons.json | 4 +- homeassistant/components/blackbird/icons.json | 4 +- homeassistant/components/blink/icons.json | 20 +++++-- homeassistant/components/bluesound/icons.json | 16 ++++-- .../components/bluetooth_tracker/icons.json | 4 +- homeassistant/components/bond/icons.json | 28 +++++++--- homeassistant/components/bring/icons.json | 4 +- homeassistant/components/browser/icons.json | 4 +- homeassistant/components/button/icons.json | 4 +- homeassistant/components/calendar/icons.json | 12 +++-- homeassistant/components/camera/icons.json | 28 +++++++--- homeassistant/components/cast/icons.json | 4 +- homeassistant/components/channels/icons.json | 12 +++-- homeassistant/components/climate/icons.json | 40 ++++++++++---- homeassistant/components/cloud/icons.json | 8 ++- .../components/cloudflare/icons.json | 4 +- .../components/color_extractor/icons.json | 4 +- .../components/command_line/icons.json | 4 +- .../components/conversation/icons.json | 8 ++- homeassistant/components/counter/icons.json | 16 ++++-- homeassistant/components/cover/icons.json | 40 ++++++++++---- homeassistant/components/date/icons.json | 4 +- homeassistant/components/datetime/icons.json | 4 +- homeassistant/components/debugpy/icons.json | 4 +- homeassistant/components/deconz/icons.json | 12 +++-- homeassistant/components/demo/icons.json | 4 +- homeassistant/components/denonavr/icons.json | 12 +++-- .../components/device_tracker/icons.json | 4 +- homeassistant/components/dominos/icons.json | 4 +- .../components/downloader/icons.json | 4 +- homeassistant/components/duckdns/icons.json | 4 +- homeassistant/components/dynalite/icons.json | 8 ++- .../components/easyenergy/icons.json | 12 +++-- homeassistant/components/ebusd/icons.json | 4 +- homeassistant/components/ecobee/icons.json | 28 +++++++--- homeassistant/components/ecovacs/icons.json | 4 +- homeassistant/components/elgato/icons.json | 4 +- homeassistant/components/elkm1/icons.json | 52 ++++++++++++++----- .../components/energyzero/icons.json | 8 ++- .../components/environment_canada/icons.json | 4 +- .../components/envisalink/icons.json | 8 ++- homeassistant/components/epson/icons.json | 4 +- homeassistant/components/evohome/icons.json | 20 +++++-- homeassistant/components/ezviz/icons.json | 8 ++- homeassistant/components/fan/icons.json | 36 +++++++++---- homeassistant/components/ffmpeg/icons.json | 12 +++-- homeassistant/components/filter/icons.json | 4 +- homeassistant/components/flo/icons.json | 16 ++++-- homeassistant/components/flume/icons.json | 4 +- homeassistant/components/flux_led/icons.json | 12 +++-- homeassistant/components/foscam/icons.json | 8 ++- .../components/foursquare/icons.json | 4 +- homeassistant/components/freebox/icons.json | 4 +- homeassistant/components/fritz/icons.json | 16 ++++-- homeassistant/components/frontend/icons.json | 8 ++- .../components/fully_kiosk/icons.json | 12 +++-- homeassistant/components/generic/icons.json | 4 +- 70 files changed, 621 insertions(+), 207 deletions(-) diff --git a/homeassistant/components/abode/icons.json b/homeassistant/components/abode/icons.json index 00175628d9a0a4..4ce4e55cab6a92 100644 --- a/homeassistant/components/abode/icons.json +++ b/homeassistant/components/abode/icons.json @@ -7,8 +7,14 @@ } }, "services": { - "capture_image": "mdi:camera", - "change_setting": "mdi:cog", - "trigger_automation": "mdi:play" + "capture_image": { + "service": "mdi:camera" + }, + "change_setting": { + "service": "mdi:cog" + }, + "trigger_automation": { + "service": "mdi:play" + } } } diff --git a/homeassistant/components/adguard/icons.json b/homeassistant/components/adguard/icons.json index 9c5df8a4a450e9..18527c0ed9864a 100644 --- a/homeassistant/components/adguard/icons.json +++ b/homeassistant/components/adguard/icons.json @@ -66,10 +66,20 @@ } }, "services": { - "add_url": "mdi:link-plus", - "remove_url": "mdi:link-off", - "enable_url": "mdi:link-variant", - "disable_url": "mdi:link-variant-off", - "refresh": "mdi:refresh" + "add_url": { + "service": "mdi:link-plus" + }, + "remove_url": { + "service": "mdi:link-off" + }, + "enable_url": { + "service": "mdi:link-variant" + }, + "disable_url": { + "service": "mdi:link-variant-off" + }, + "refresh": { + "service": "mdi:refresh" + } } } diff --git a/homeassistant/components/ads/icons.json b/homeassistant/components/ads/icons.json index 5ab8041fe9bf15..3732f16bf1a39e 100644 --- a/homeassistant/components/ads/icons.json +++ b/homeassistant/components/ads/icons.json @@ -1,5 +1,7 @@ { "services": { - "write_data_by_name": "mdi:pencil" + "write_data_by_name": { + "service": "mdi:pencil" + } } } diff --git a/homeassistant/components/advantage_air/icons.json b/homeassistant/components/advantage_air/icons.json index a4168f440cff10..8651c9d9eaf63c 100644 --- a/homeassistant/components/advantage_air/icons.json +++ b/homeassistant/components/advantage_air/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_time_to": "mdi:timer-cog" + "set_time_to": { + "service": "mdi:timer-cog" + } } } diff --git a/homeassistant/components/aftership/icons.json b/homeassistant/components/aftership/icons.json index 1222ab0873d68b..105d3cef3ec94a 100644 --- a/homeassistant/components/aftership/icons.json +++ b/homeassistant/components/aftership/icons.json @@ -7,7 +7,11 @@ } }, "services": { - "add_tracking": "mdi:package-variant-plus", - "remove_tracking": "mdi:package-variant-minus" + "add_tracking": { + "service": "mdi:package-variant-plus" + }, + "remove_tracking": { + "service": "mdi:package-variant-minus" + } } } diff --git a/homeassistant/components/agent_dvr/icons.json b/homeassistant/components/agent_dvr/icons.json index 6550d01641e418..7dfb4a847f6301 100644 --- a/homeassistant/components/agent_dvr/icons.json +++ b/homeassistant/components/agent_dvr/icons.json @@ -1,9 +1,19 @@ { "services": { - "start_recording": "mdi:record-rec", - "stop_recording": "mdi:stop", - "enable_alerts": "mdi:bell-alert", - "disable_alerts": "mdi:bell-off", - "snapshot": "mdi:camera" + "start_recording": { + "service": "mdi:record-rec" + }, + "stop_recording": { + "service": "mdi:stop" + }, + "enable_alerts": { + "service": "mdi:bell-alert" + }, + "disable_alerts": { + "service": "mdi:bell-off" + }, + "snapshot": { + "service": "mdi:camera" + } } } diff --git a/homeassistant/components/alarm_control_panel/icons.json b/homeassistant/components/alarm_control_panel/icons.json index 915448a996201b..0295699bae950a 100644 --- a/homeassistant/components/alarm_control_panel/icons.json +++ b/homeassistant/components/alarm_control_panel/icons.json @@ -15,12 +15,26 @@ } }, "services": { - "alarm_arm_away": "mdi:shield-lock", - "alarm_arm_home": "mdi:shield-home", - "alarm_arm_night": "mdi:shield-moon", - "alarm_arm_custom_bypass": "mdi:security", - "alarm_disarm": "mdi:shield-off", - "alarm_trigger": "mdi:bell-ring", - "alarm_arm_vacation": "mdi:shield-airplane" + "alarm_arm_away": { + "service": "mdi:shield-lock" + }, + "alarm_arm_home": { + "service": "mdi:shield-home" + }, + "alarm_arm_night": { + "service": "mdi:shield-moon" + }, + "alarm_arm_custom_bypass": { + "service": "mdi:security" + }, + "alarm_disarm": { + "service": "mdi:shield-off" + }, + "alarm_trigger": { + "service": "mdi:bell-ring" + }, + "alarm_arm_vacation": { + "service": "mdi:shield-airplane" + } } } diff --git a/homeassistant/components/alarmdecoder/icons.json b/homeassistant/components/alarmdecoder/icons.json index 80835a049c8064..ccb89749d2d840 100644 --- a/homeassistant/components/alarmdecoder/icons.json +++ b/homeassistant/components/alarmdecoder/icons.json @@ -7,7 +7,11 @@ } }, "services": { - "alarm_keypress": "mdi:dialpad", - "alarm_toggle_chime": "mdi:abc" + "alarm_keypress": { + "service": "mdi:dialpad" + }, + "alarm_toggle_chime": { + "service": "mdi:abc" + } } } diff --git a/homeassistant/components/alert/icons.json b/homeassistant/components/alert/icons.json index 7f5258706d2213..5d8613ec592a3b 100644 --- a/homeassistant/components/alert/icons.json +++ b/homeassistant/components/alert/icons.json @@ -1,7 +1,13 @@ { "services": { - "toggle": "mdi:bell-ring", - "turn_off": "mdi:bell-off", - "turn_on": "mdi:bell-alert" + "toggle": { + "service": "mdi:bell-ring" + }, + "turn_off": { + "service": "mdi:bell-off" + }, + "turn_on": { + "service": "mdi:bell-alert" + } } } diff --git a/homeassistant/components/amcrest/icons.json b/homeassistant/components/amcrest/icons.json index efba49d6b56d0e..e284bc152591ad 100644 --- a/homeassistant/components/amcrest/icons.json +++ b/homeassistant/components/amcrest/icons.json @@ -1,15 +1,37 @@ { "services": { - "enable_recording": "mdi:record-rec", - "disable_recording": "mdi:stop", - "enable_audio": "mdi:volume-high", - "disable_audio": "mdi:volume-off", - "enable_motion_recording": "mdi:motion-sensor", - "disable_motion_recording": "mdi:motion-sensor-off", - "goto_preset": "mdi:pan", - "set_color_bw": "mdi:palette", - "start_tour": "mdi:panorama", - "stop_tour": "mdi:panorama-outline", - "ptz_control": "mdi:pan" + "enable_recording": { + "service": "mdi:record-rec" + }, + "disable_recording": { + "service": "mdi:stop" + }, + "enable_audio": { + "service": "mdi:volume-high" + }, + "disable_audio": { + "service": "mdi:volume-off" + }, + "enable_motion_recording": { + "service": "mdi:motion-sensor" + }, + "disable_motion_recording": { + "service": "mdi:motion-sensor-off" + }, + "goto_preset": { + "service": "mdi:pan" + }, + "set_color_bw": { + "service": "mdi:palette" + }, + "start_tour": { + "service": "mdi:panorama" + }, + "stop_tour": { + "service": "mdi:panorama-outline" + }, + "ptz_control": { + "service": "mdi:pan" + } } } diff --git a/homeassistant/components/androidtv/icons.json b/homeassistant/components/androidtv/icons.json index 0127d60a72e528..d7c646dfdfc97d 100644 --- a/homeassistant/components/androidtv/icons.json +++ b/homeassistant/components/androidtv/icons.json @@ -1,8 +1,16 @@ { "services": { - "adb_command": "mdi:console", - "download": "mdi:download", - "upload": "mdi:upload", - "learn_sendevent": "mdi:remote" + "adb_command": { + "service": "mdi:console" + }, + "download": { + "service": "mdi:download" + }, + "upload": { + "service": "mdi:upload" + }, + "learn_sendevent": { + "service": "mdi:remote" + } } } diff --git a/homeassistant/components/automation/icons.json b/homeassistant/components/automation/icons.json index 9b68825ffd1629..f1e0f26ef65a9a 100644 --- a/homeassistant/components/automation/icons.json +++ b/homeassistant/components/automation/icons.json @@ -9,10 +9,20 @@ } }, "services": { - "turn_on": "mdi:robot", - "turn_off": "mdi:robot-off", - "toggle": "mdi:robot", - "trigger": "mdi:robot", - "reload": "mdi:reload" + "turn_on": { + "service": "mdi:robot" + }, + "turn_off": { + "service": "mdi:robot-off" + }, + "toggle": { + "service": "mdi:robot" + }, + "trigger": { + "service": "mdi:robot" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/backup/icons.json b/homeassistant/components/backup/icons.json index cba4fb2283101d..bd5ff4a81eedb0 100644 --- a/homeassistant/components/backup/icons.json +++ b/homeassistant/components/backup/icons.json @@ -1,5 +1,7 @@ { "services": { - "create": "mdi:cloud-upload" + "create": { + "service": "mdi:cloud-upload" + } } } diff --git a/homeassistant/components/bayesian/icons.json b/homeassistant/components/bayesian/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/bayesian/icons.json +++ b/homeassistant/components/bayesian/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/blackbird/icons.json b/homeassistant/components/blackbird/icons.json index f080fb5f857fa3..815a45ba17426c 100644 --- a/homeassistant/components/blackbird/icons.json +++ b/homeassistant/components/blackbird/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_all_zones": "mdi:home-sound-in" + "set_all_zones": { + "service": "mdi:home-sound-in" + } } } diff --git a/homeassistant/components/blink/icons.json b/homeassistant/components/blink/icons.json index 615a3c4c6dc8ec..bea67b25f6d672 100644 --- a/homeassistant/components/blink/icons.json +++ b/homeassistant/components/blink/icons.json @@ -12,10 +12,20 @@ } }, "services": { - "record": "mdi:video-box", - "trigger_camera": "mdi:image-refresh", - "save_video": "mdi:file-video", - "save_recent_clips": "mdi:file-video", - "send_pin": "mdi:two-factor-authentication" + "record": { + "service": "mdi:video-box" + }, + "trigger_camera": { + "service": "mdi:image-refresh" + }, + "save_video": { + "service": "mdi:file-video" + }, + "save_recent_clips": { + "service": "mdi:file-video" + }, + "send_pin": { + "service": "mdi:two-factor-authentication" + } } } diff --git a/homeassistant/components/bluesound/icons.json b/homeassistant/components/bluesound/icons.json index 8c886f12dfd295..2c5e95291c1b46 100644 --- a/homeassistant/components/bluesound/icons.json +++ b/homeassistant/components/bluesound/icons.json @@ -1,8 +1,16 @@ { "services": { - "join": "mdi:link-variant", - "unjoin": "mdi:link-variant-off", - "set_sleep_timer": "mdi:sleep", - "clear_sleep_timer": "mdi:sleep-off" + "join": { + "service": "mdi:link-variant" + }, + "unjoin": { + "service": "mdi:link-variant-off" + }, + "set_sleep_timer": { + "service": "mdi:sleep" + }, + "clear_sleep_timer": { + "service": "mdi:sleep-off" + } } } diff --git a/homeassistant/components/bluetooth_tracker/icons.json b/homeassistant/components/bluetooth_tracker/icons.json index 650bf0b6d19f57..217f1240893477 100644 --- a/homeassistant/components/bluetooth_tracker/icons.json +++ b/homeassistant/components/bluetooth_tracker/icons.json @@ -1,5 +1,7 @@ { "services": { - "update": "mdi:update" + "update": { + "service": "mdi:update" + } } } diff --git a/homeassistant/components/bond/icons.json b/homeassistant/components/bond/icons.json index 35743d20e654af..48b351b1c7600a 100644 --- a/homeassistant/components/bond/icons.json +++ b/homeassistant/components/bond/icons.json @@ -96,12 +96,26 @@ } }, "services": { - "set_fan_speed_tracked_state": "mdi:fan", - "set_switch_power_tracked_state": "mdi:toggle-switch-variant", - "set_light_power_tracked_state": "mdi:lightbulb", - "set_light_brightness_tracked_state": "mdi:lightbulb-on", - "start_increasing_brightness": "mdi:brightness-7", - "start_decreasing_brightness": "mdi:brightness-1", - "stop": "mdi:stop" + "set_fan_speed_tracked_state": { + "service": "mdi:fan" + }, + "set_switch_power_tracked_state": { + "service": "mdi:toggle-switch-variant" + }, + "set_light_power_tracked_state": { + "service": "mdi:lightbulb" + }, + "set_light_brightness_tracked_state": { + "service": "mdi:lightbulb-on" + }, + "start_increasing_brightness": { + "service": "mdi:brightness-7" + }, + "start_decreasing_brightness": { + "service": "mdi:brightness-1" + }, + "stop": { + "service": "mdi:stop" + } } } diff --git a/homeassistant/components/bring/icons.json b/homeassistant/components/bring/icons.json index 1c6c3bdeca06c7..6b79fab3c9453c 100644 --- a/homeassistant/components/bring/icons.json +++ b/homeassistant/components/bring/icons.json @@ -7,6 +7,8 @@ } }, "services": { - "send_message": "mdi:cellphone-message" + "send_message": { + "service": "mdi:cellphone-message" + } } } diff --git a/homeassistant/components/browser/icons.json b/homeassistant/components/browser/icons.json index 7c971009fd7a87..680aaf14b86d82 100644 --- a/homeassistant/components/browser/icons.json +++ b/homeassistant/components/browser/icons.json @@ -1,5 +1,7 @@ { "services": { - "browse_url": "mdi:web" + "browse_url": { + "service": "mdi:web" + } } } diff --git a/homeassistant/components/button/icons.json b/homeassistant/components/button/icons.json index 71956124d7f2c2..1364fb2d056fd4 100644 --- a/homeassistant/components/button/icons.json +++ b/homeassistant/components/button/icons.json @@ -14,6 +14,8 @@ } }, "services": { - "press": "mdi:gesture-tap-button" + "press": { + "service": "mdi:gesture-tap-button" + } } } diff --git a/homeassistant/components/calendar/icons.json b/homeassistant/components/calendar/icons.json index e4e526fe75c4bd..9b8df3ec6d3f0a 100644 --- a/homeassistant/components/calendar/icons.json +++ b/homeassistant/components/calendar/icons.json @@ -9,8 +9,14 @@ } }, "services": { - "create_event": "mdi:calendar-plus", - "get_events": "mdi:calendar-month", - "list_events": "mdi:calendar-month" + "create_event": { + "service": "mdi:calendar-plus" + }, + "get_events": { + "service": "mdi:calendar-month" + }, + "list_events": { + "service": "mdi:calendar-month" + } } } diff --git a/homeassistant/components/camera/icons.json b/homeassistant/components/camera/icons.json index 37e71c80a674ef..982074cd55345c 100644 --- a/homeassistant/components/camera/icons.json +++ b/homeassistant/components/camera/icons.json @@ -8,12 +8,26 @@ } }, "services": { - "disable_motion_detection": "mdi:motion-sensor-off", - "enable_motion_detection": "mdi:motion-sensor", - "play_stream": "mdi:play", - "record": "mdi:record-rec", - "snapshot": "mdi:camera", - "turn_off": "mdi:video-off", - "turn_on": "mdi:video" + "disable_motion_detection": { + "service": "mdi:motion-sensor-off" + }, + "enable_motion_detection": { + "service": "mdi:motion-sensor" + }, + "play_stream": { + "service": "mdi:play" + }, + "record": { + "service": "mdi:record-rec" + }, + "snapshot": { + "service": "mdi:camera" + }, + "turn_off": { + "service": "mdi:video-off" + }, + "turn_on": { + "service": "mdi:video" + } } } diff --git a/homeassistant/components/cast/icons.json b/homeassistant/components/cast/icons.json index e19ea0b07b23b8..a43411eaad31a2 100644 --- a/homeassistant/components/cast/icons.json +++ b/homeassistant/components/cast/icons.json @@ -1,5 +1,7 @@ { "services": { - "show_lovelace_view": "mdi:view-dashboard" + "show_lovelace_view": { + "service": "mdi:view-dashboard" + } } } diff --git a/homeassistant/components/channels/icons.json b/homeassistant/components/channels/icons.json index cbbda1ef6232c8..ad5504a5422ce7 100644 --- a/homeassistant/components/channels/icons.json +++ b/homeassistant/components/channels/icons.json @@ -1,7 +1,13 @@ { "services": { - "seek_forward": "mdi:skip-forward", - "seek_backward": "mdi:skip-backward", - "seek_by": "mdi:timer-check-outline" + "seek_forward": { + "service": "mdi:skip-forward" + }, + "seek_backward": { + "service": "mdi:skip-backward" + }, + "seek_by": { + "service": "mdi:timer-check-outline" + } } } diff --git a/homeassistant/components/climate/icons.json b/homeassistant/components/climate/icons.json index ea6c504ce2596a..c9a8d12d01be5f 100644 --- a/homeassistant/components/climate/icons.json +++ b/homeassistant/components/climate/icons.json @@ -56,15 +56,35 @@ } }, "services": { - "set_fan_mode": "mdi:fan", - "set_humidity": "mdi:water-percent", - "set_swing_mode": "mdi:arrow-oscillating", - "set_temperature": "mdi:thermometer", - "set_aux_heat": "mdi:radiator", - "set_preset_mode": "mdi:sofa", - "set_hvac_mode": "mdi:hvac", - "turn_on": "mdi:power-on", - "turn_off": "mdi:power-off", - "toggle": "mdi:toggle-switch" + "set_fan_mode": { + "service": "mdi:fan" + }, + "set_humidity": { + "service": "mdi:water-percent" + }, + "set_swing_mode": { + "service": "mdi:arrow-oscillating" + }, + "set_temperature": { + "service": "mdi:thermometer" + }, + "set_aux_heat": { + "service": "mdi:radiator" + }, + "set_preset_mode": { + "service": "mdi:sofa" + }, + "set_hvac_mode": { + "service": "mdi:hvac" + }, + "turn_on": { + "service": "mdi:power-on" + }, + "turn_off": { + "service": "mdi:power-off" + }, + "toggle": { + "service": "mdi:toggle-switch" + } } } diff --git a/homeassistant/components/cloud/icons.json b/homeassistant/components/cloud/icons.json index 06ee7eb2f197f4..32888fa75c74a9 100644 --- a/homeassistant/components/cloud/icons.json +++ b/homeassistant/components/cloud/icons.json @@ -1,6 +1,10 @@ { "services": { - "remote_connect": "mdi:cloud", - "remote_disconnect": "mdi:cloud-off" + "remote_connect": { + "service": "mdi:cloud" + }, + "remote_disconnect": { + "service": "mdi:cloud-off" + } } } diff --git a/homeassistant/components/cloudflare/icons.json b/homeassistant/components/cloudflare/icons.json index 6bf6d773fc3dc6..2d452716c94d92 100644 --- a/homeassistant/components/cloudflare/icons.json +++ b/homeassistant/components/cloudflare/icons.json @@ -1,5 +1,7 @@ { "services": { - "update_records": "mdi:dns" + "update_records": { + "service": "mdi:dns" + } } } diff --git a/homeassistant/components/color_extractor/icons.json b/homeassistant/components/color_extractor/icons.json index 07b449ffc5423b..9dab17a9f3bc08 100644 --- a/homeassistant/components/color_extractor/icons.json +++ b/homeassistant/components/color_extractor/icons.json @@ -1,5 +1,7 @@ { "services": { - "turn_on": "mdi:lightbulb-on" + "turn_on": { + "service": "mdi:lightbulb-on" + } } } diff --git a/homeassistant/components/command_line/icons.json b/homeassistant/components/command_line/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/command_line/icons.json +++ b/homeassistant/components/command_line/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/conversation/icons.json b/homeassistant/components/conversation/icons.json index b39a1603b152ff..658783f9ae26f9 100644 --- a/homeassistant/components/conversation/icons.json +++ b/homeassistant/components/conversation/icons.json @@ -1,6 +1,10 @@ { "services": { - "process": "mdi:message-processing", - "reload": "mdi:reload" + "process": { + "service": "mdi:message-processing" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/counter/icons.json b/homeassistant/components/counter/icons.json index 1e0ef54bbb782e..59cd0bb7121a3e 100644 --- a/homeassistant/components/counter/icons.json +++ b/homeassistant/components/counter/icons.json @@ -1,8 +1,16 @@ { "services": { - "decrement": "mdi:numeric-negative-1", - "increment": "mdi:numeric-positive-1", - "reset": "mdi:refresh", - "set_value": "mdi:counter" + "decrement": { + "service": "mdi:numeric-negative-1" + }, + "increment": { + "service": "mdi:numeric-positive-1" + }, + "reset": { + "service": "mdi:refresh" + }, + "set_value": { + "service": "mdi:counter" + } } } diff --git a/homeassistant/components/cover/icons.json b/homeassistant/components/cover/icons.json index f2edaaa0893b22..91775fe634dbec 100644 --- a/homeassistant/components/cover/icons.json +++ b/homeassistant/components/cover/icons.json @@ -78,15 +78,35 @@ } }, "services": { - "close_cover": "mdi:arrow-down-box", - "close_cover_tilt": "mdi:arrow-bottom-left", - "open_cover": "mdi:arrow-up-box", - "open_cover_tilt": "mdi:arrow-top-right", - "set_cover_position": "mdi:arrow-down-box", - "set_cover_tilt_position": "mdi:arrow-top-right", - "stop_cover": "mdi:stop", - "stop_cover_tilt": "mdi:stop", - "toggle": "mdi:arrow-up-down", - "toggle_cover_tilt": "mdi:arrow-top-right-bottom-left" + "close_cover": { + "service": "mdi:arrow-down-box" + }, + "close_cover_tilt": { + "service": "mdi:arrow-bottom-left" + }, + "open_cover": { + "service": "mdi:arrow-up-box" + }, + "open_cover_tilt": { + "service": "mdi:arrow-top-right" + }, + "set_cover_position": { + "service": "mdi:arrow-down-box" + }, + "set_cover_tilt_position": { + "service": "mdi:arrow-top-right" + }, + "stop_cover": { + "service": "mdi:stop" + }, + "stop_cover_tilt": { + "service": "mdi:stop" + }, + "toggle": { + "service": "mdi:arrow-up-down" + }, + "toggle_cover_tilt": { + "service": "mdi:arrow-top-right-bottom-left" + } } } diff --git a/homeassistant/components/date/icons.json b/homeassistant/components/date/icons.json index 80ec26912854f9..b139b897210b22 100644 --- a/homeassistant/components/date/icons.json +++ b/homeassistant/components/date/icons.json @@ -5,6 +5,8 @@ } }, "services": { - "set_value": "mdi:calendar-edit" + "set_value": { + "service": "mdi:calendar-edit" + } } } diff --git a/homeassistant/components/datetime/icons.json b/homeassistant/components/datetime/icons.json index 563d03e2a8fdcc..d7e9fca8e5cf5c 100644 --- a/homeassistant/components/datetime/icons.json +++ b/homeassistant/components/datetime/icons.json @@ -5,6 +5,8 @@ } }, "services": { - "set_value": "mdi:calendar-edit" + "set_value": { + "service": "mdi:calendar-edit" + } } } diff --git a/homeassistant/components/debugpy/icons.json b/homeassistant/components/debugpy/icons.json index b3bb4dde23afd5..880863820596e8 100644 --- a/homeassistant/components/debugpy/icons.json +++ b/homeassistant/components/debugpy/icons.json @@ -1,5 +1,7 @@ { "services": { - "start": "mdi:play" + "start": { + "service": "mdi:play" + } } } diff --git a/homeassistant/components/deconz/icons.json b/homeassistant/components/deconz/icons.json index 5b22daee53f839..a7fb0859eec634 100644 --- a/homeassistant/components/deconz/icons.json +++ b/homeassistant/components/deconz/icons.json @@ -1,7 +1,13 @@ { "services": { - "configure": "mdi:cog", - "device_refresh": "mdi:refresh", - "remove_orphaned_entries": "mdi:bookmark-remove" + "configure": { + "service": "mdi:cog" + }, + "device_refresh": { + "service": "mdi:refresh" + }, + "remove_orphaned_entries": { + "service": "mdi:bookmark-remove" + } } } diff --git a/homeassistant/components/demo/icons.json b/homeassistant/components/demo/icons.json index d9e1d405490b6d..17425a6d11911f 100644 --- a/homeassistant/components/demo/icons.json +++ b/homeassistant/components/demo/icons.json @@ -75,6 +75,8 @@ } }, "services": { - "randomize_device_tracker_data": "mdi:dice-multiple" + "randomize_device_tracker_data": { + "service": "mdi:dice-multiple" + } } } diff --git a/homeassistant/components/denonavr/icons.json b/homeassistant/components/denonavr/icons.json index ec6bc0854f9008..33d7f1bd3d985b 100644 --- a/homeassistant/components/denonavr/icons.json +++ b/homeassistant/components/denonavr/icons.json @@ -1,7 +1,13 @@ { "services": { - "get_command": "mdi:console", - "set_dynamic_eq": "mdi:tune", - "update_audyssey": "mdi:waveform" + "get_command": { + "service": "mdi:console" + }, + "set_dynamic_eq": { + "service": "mdi:tune" + }, + "update_audyssey": { + "service": "mdi:waveform" + } } } diff --git a/homeassistant/components/device_tracker/icons.json b/homeassistant/components/device_tracker/icons.json index c89053701babe6..4e5b82576cf8b4 100644 --- a/homeassistant/components/device_tracker/icons.json +++ b/homeassistant/components/device_tracker/icons.json @@ -8,6 +8,8 @@ } }, "services": { - "see": "mdi:account-eye" + "see": { + "service": "mdi:account-eye" + } } } diff --git a/homeassistant/components/dominos/icons.json b/homeassistant/components/dominos/icons.json index d88bfb2542f46f..ca33ac91dfd5e4 100644 --- a/homeassistant/components/dominos/icons.json +++ b/homeassistant/components/dominos/icons.json @@ -1,5 +1,7 @@ { "services": { - "order": "mdi:pizza" + "order": { + "service": "mdi:pizza" + } } } diff --git a/homeassistant/components/downloader/icons.json b/homeassistant/components/downloader/icons.json index 2a78df93ca7af1..8f8b5bb2688d83 100644 --- a/homeassistant/components/downloader/icons.json +++ b/homeassistant/components/downloader/icons.json @@ -1,5 +1,7 @@ { "services": { - "download_file": "mdi:download" + "download_file": { + "service": "mdi:download" + } } } diff --git a/homeassistant/components/duckdns/icons.json b/homeassistant/components/duckdns/icons.json index 79ec18d13ffaec..c5d0b5329dc814 100644 --- a/homeassistant/components/duckdns/icons.json +++ b/homeassistant/components/duckdns/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_txt": "mdi:text-box-edit-outline" + "set_txt": { + "service": "mdi:text-box-edit-outline" + } } } diff --git a/homeassistant/components/dynalite/icons.json b/homeassistant/components/dynalite/icons.json index dedbb1be3acc71..27949197b538d0 100644 --- a/homeassistant/components/dynalite/icons.json +++ b/homeassistant/components/dynalite/icons.json @@ -1,6 +1,10 @@ { "services": { - "request_area_preset": "mdi:texture-box", - "request_channel_level": "mdi:satellite-uplink" + "request_area_preset": { + "service": "mdi:texture-box" + }, + "request_channel_level": { + "service": "mdi:satellite-uplink" + } } } diff --git a/homeassistant/components/easyenergy/icons.json b/homeassistant/components/easyenergy/icons.json index 90cbec17a65830..501483eb932e2a 100644 --- a/homeassistant/components/easyenergy/icons.json +++ b/homeassistant/components/easyenergy/icons.json @@ -13,8 +13,14 @@ } }, "services": { - "get_gas_prices": "mdi:gas-station", - "get_energy_usage_prices": "mdi:transmission-tower-import", - "get_energy_return_prices": "mdi:transmission-tower-export" + "get_gas_prices": { + "service": "mdi:gas-station" + }, + "get_energy_usage_prices": { + "service": "mdi:transmission-tower-import" + }, + "get_energy_return_prices": { + "service": "mdi:transmission-tower-export" + } } } diff --git a/homeassistant/components/ebusd/icons.json b/homeassistant/components/ebusd/icons.json index 642be37a43b01a..ebfa3673a0c146 100644 --- a/homeassistant/components/ebusd/icons.json +++ b/homeassistant/components/ebusd/icons.json @@ -1,5 +1,7 @@ { "services": { - "write": "mdi:pencil" + "write": { + "service": "mdi:pencil" + } } } diff --git a/homeassistant/components/ecobee/icons.json b/homeassistant/components/ecobee/icons.json index 3e736d0dc68700..f24f1f7cfe5dc8 100644 --- a/homeassistant/components/ecobee/icons.json +++ b/homeassistant/components/ecobee/icons.json @@ -1,11 +1,25 @@ { "services": { - "create_vacation": "mdi:umbrella-beach", - "delete_vacation": "mdi:umbrella-beach-outline", - "resume_program": "mdi:play", - "set_fan_min_on_time": "mdi:fan-clock", - "set_dst_mode": "mdi:sun-clock", - "set_mic_mode": "mdi:microphone", - "set_occupancy_modes": "mdi:eye-settings" + "create_vacation": { + "service": "mdi:umbrella-beach" + }, + "delete_vacation": { + "service": "mdi:umbrella-beach-outline" + }, + "resume_program": { + "service": "mdi:play" + }, + "set_fan_min_on_time": { + "service": "mdi:fan-clock" + }, + "set_dst_mode": { + "service": "mdi:sun-clock" + }, + "set_mic_mode": { + "service": "mdi:microphone" + }, + "set_occupancy_modes": { + "service": "mdi:eye-settings" + } } } diff --git a/homeassistant/components/ecovacs/icons.json b/homeassistant/components/ecovacs/icons.json index 0c7178ced84e62..6097f43a4e44de 100644 --- a/homeassistant/components/ecovacs/icons.json +++ b/homeassistant/components/ecovacs/icons.json @@ -145,6 +145,8 @@ } }, "services": { - "raw_get_positions": "mdi:map-marker-radius-outline" + "raw_get_positions": { + "service": "mdi:map-marker-radius-outline" + } } } diff --git a/homeassistant/components/elgato/icons.json b/homeassistant/components/elgato/icons.json index 1b5eaf3763a1c7..d2c286594c7b12 100644 --- a/homeassistant/components/elgato/icons.json +++ b/homeassistant/components/elgato/icons.json @@ -10,6 +10,8 @@ } }, "services": { - "identify": "mdi:crosshairs-question" + "identify": { + "service": "mdi:crosshairs-question" + } } } diff --git a/homeassistant/components/elkm1/icons.json b/homeassistant/components/elkm1/icons.json index 3bb9ea8c87d10b..54827e4b6ef36e 100644 --- a/homeassistant/components/elkm1/icons.json +++ b/homeassistant/components/elkm1/icons.json @@ -10,18 +10,44 @@ } }, "services": { - "alarm_bypass": "mdi:shield-off", - "alarm_clear_bypass": "mdi:shield", - "alarm_arm_home_instant": "mdi:shield-lock", - "alarm_arm_night_instant": "mdi:shield-moon", - "alarm_arm_vacation": "mdi:beach", - "alarm_display_message": "mdi:message-alert", - "set_time": "mdi:clock-edit", - "speak_phrase": "mdi:message-processing", - "speak_word": "mdi:message-minus", - "sensor_counter_refresh": "mdi:refresh", - "sensor_counter_set": "mdi:counter", - "sensor_zone_bypass": "mdi:shield-off", - "sensor_zone_trigger": "mdi:shield" + "alarm_bypass": { + "service": "mdi:shield-off" + }, + "alarm_clear_bypass": { + "service": "mdi:shield" + }, + "alarm_arm_home_instant": { + "service": "mdi:shield-lock" + }, + "alarm_arm_night_instant": { + "service": "mdi:shield-moon" + }, + "alarm_arm_vacation": { + "service": "mdi:beach" + }, + "alarm_display_message": { + "service": "mdi:message-alert" + }, + "set_time": { + "service": "mdi:clock-edit" + }, + "speak_phrase": { + "service": "mdi:message-processing" + }, + "speak_word": { + "service": "mdi:message-minus" + }, + "sensor_counter_refresh": { + "service": "mdi:refresh" + }, + "sensor_counter_set": { + "service": "mdi:counter" + }, + "sensor_zone_bypass": { + "service": "mdi:shield-off" + }, + "sensor_zone_trigger": { + "service": "mdi:shield" + } } } diff --git a/homeassistant/components/energyzero/icons.json b/homeassistant/components/energyzero/icons.json index bac061dd31886a..802f8ef69167cf 100644 --- a/homeassistant/components/energyzero/icons.json +++ b/homeassistant/components/energyzero/icons.json @@ -10,7 +10,11 @@ } }, "services": { - "get_gas_prices": "mdi:gas-station", - "get_energy_prices": "mdi:lightning-bolt" + "get_gas_prices": { + "service": "mdi:gas-station" + }, + "get_energy_prices": { + "service": "mdi:lightning-bolt" + } } } diff --git a/homeassistant/components/environment_canada/icons.json b/homeassistant/components/environment_canada/icons.json index 5e23a96bcfbdff..c3562ce1840728 100644 --- a/homeassistant/components/environment_canada/icons.json +++ b/homeassistant/components/environment_canada/icons.json @@ -19,6 +19,8 @@ } }, "services": { - "set_radar_type": "mdi:radar" + "set_radar_type": { + "service": "mdi:radar" + } } } diff --git a/homeassistant/components/envisalink/icons.json b/homeassistant/components/envisalink/icons.json index 20696067f76359..b25e988f478c2b 100644 --- a/homeassistant/components/envisalink/icons.json +++ b/homeassistant/components/envisalink/icons.json @@ -1,6 +1,10 @@ { "services": { - "alarm_keypress": "mdi:alarm-panel", - "invoke_custom_function": "mdi:console" + "alarm_keypress": { + "service": "mdi:alarm-panel" + }, + "invoke_custom_function": { + "service": "mdi:console" + } } } diff --git a/homeassistant/components/epson/icons.json b/homeassistant/components/epson/icons.json index a9237edcfd17ae..d41ddebcdce91f 100644 --- a/homeassistant/components/epson/icons.json +++ b/homeassistant/components/epson/icons.json @@ -1,5 +1,7 @@ { "services": { - "select_cmode": "mdi:palette" + "select_cmode": { + "service": "mdi:palette" + } } } diff --git a/homeassistant/components/evohome/icons.json b/homeassistant/components/evohome/icons.json index cd0005e2546a1d..54488440e60c39 100644 --- a/homeassistant/components/evohome/icons.json +++ b/homeassistant/components/evohome/icons.json @@ -1,9 +1,19 @@ { "services": { - "set_system_mode": "mdi:pencil", - "reset_system": "mdi:refresh", - "refresh_system": "mdi:refresh", - "set_zone_override": "mdi:motion-sensor", - "clear_zone_override": "mdi:motion-sensor-off" + "set_system_mode": { + "service": "mdi:pencil" + }, + "reset_system": { + "service": "mdi:refresh" + }, + "refresh_system": { + "service": "mdi:refresh" + }, + "set_zone_override": { + "service": "mdi:motion-sensor" + }, + "clear_zone_override": { + "service": "mdi:motion-sensor-off" + } } } diff --git a/homeassistant/components/ezviz/icons.json b/homeassistant/components/ezviz/icons.json index 89b4747ed69bd6..e4a2e49a22c71b 100644 --- a/homeassistant/components/ezviz/icons.json +++ b/homeassistant/components/ezviz/icons.json @@ -26,7 +26,11 @@ } }, "services": { - "set_alarm_detection_sensibility": "mdi:motion-sensor", - "wake_device": "mdi:sleep-off" + "set_alarm_detection_sensibility": { + "service": "mdi:motion-sensor" + }, + "wake_device": { + "service": "mdi:sleep-off" + } } } diff --git a/homeassistant/components/fan/icons.json b/homeassistant/components/fan/icons.json index 60edbce5f01986..caf80775f80245 100644 --- a/homeassistant/components/fan/icons.json +++ b/homeassistant/components/fan/icons.json @@ -20,14 +20,32 @@ } }, "services": { - "decrease_speed": "mdi:fan-minus", - "increase_speed": "mdi:fan-plus", - "oscillate": "mdi:arrow-oscillating", - "set_direction": "mdi:rotate-3d-variant", - "set_percentage": "mdi:fan", - "set_preset_mode": "mdi:fan-auto", - "toggle": "mdi:fan", - "turn_off": "mdi:fan-off", - "turn_on": "mdi:fan" + "decrease_speed": { + "service": "mdi:fan-minus" + }, + "increase_speed": { + "service": "mdi:fan-plus" + }, + "oscillate": { + "service": "mdi:arrow-oscillating" + }, + "set_direction": { + "service": "mdi:rotate-3d-variant" + }, + "set_percentage": { + "service": "mdi:fan" + }, + "set_preset_mode": { + "service": "mdi:fan-auto" + }, + "toggle": { + "service": "mdi:fan" + }, + "turn_off": { + "service": "mdi:fan-off" + }, + "turn_on": { + "service": "mdi:fan" + } } } diff --git a/homeassistant/components/ffmpeg/icons.json b/homeassistant/components/ffmpeg/icons.json index a23f024599c7c7..780eb071af19d3 100644 --- a/homeassistant/components/ffmpeg/icons.json +++ b/homeassistant/components/ffmpeg/icons.json @@ -1,7 +1,13 @@ { "services": { - "restart": "mdi:restart", - "start": "mdi:play", - "stop": "mdi:stop" + "restart": { + "service": "mdi:restart" + }, + "start": { + "service": "mdi:play" + }, + "stop": { + "service": "mdi:stop" + } } } diff --git a/homeassistant/components/filter/icons.json b/homeassistant/components/filter/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/filter/icons.json +++ b/homeassistant/components/filter/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/flo/icons.json b/homeassistant/components/flo/icons.json index 3164781c1b4d0f..4bd0380c56caf6 100644 --- a/homeassistant/components/flo/icons.json +++ b/homeassistant/components/flo/icons.json @@ -10,9 +10,17 @@ } }, "services": { - "set_sleep_mode": "mdi:sleep", - "set_away_mode": "mdi:home-off", - "set_home_mode": "mdi:home", - "run_health_test": "mdi:heart-flash" + "set_sleep_mode": { + "service": "mdi:sleep" + }, + "set_away_mode": { + "service": "mdi:home-off" + }, + "set_home_mode": { + "service": "mdi:home" + }, + "run_health_test": { + "service": "mdi:heart-flash" + } } } diff --git a/homeassistant/components/flume/icons.json b/homeassistant/components/flume/icons.json index 631c0645ed3f7e..90830943689231 100644 --- a/homeassistant/components/flume/icons.json +++ b/homeassistant/components/flume/icons.json @@ -10,6 +10,8 @@ } }, "services": { - "list_notifications": "mdi:bell" + "list_notifications": { + "service": "mdi:bell" + } } } diff --git a/homeassistant/components/flux_led/icons.json b/homeassistant/components/flux_led/icons.json index 873fcd7c441033..07c27869ff7128 100644 --- a/homeassistant/components/flux_led/icons.json +++ b/homeassistant/components/flux_led/icons.json @@ -54,8 +54,14 @@ } }, "services": { - "set_custom_effect": "mdi:creation", - "set_zones": "mdi:texture-box", - "set_music_mode": "mdi:music" + "set_custom_effect": { + "service": "mdi:creation" + }, + "set_zones": { + "service": "mdi:texture-box" + }, + "set_music_mode": { + "service": "mdi:music" + } } } diff --git a/homeassistant/components/foscam/icons.json b/homeassistant/components/foscam/icons.json index 0c7dba9a4dfb09..437575024d1708 100644 --- a/homeassistant/components/foscam/icons.json +++ b/homeassistant/components/foscam/icons.json @@ -1,6 +1,10 @@ { "services": { - "ptz": "mdi:pan", - "ptz_preset": "mdi:target-variant" + "ptz": { + "service": "mdi:pan" + }, + "ptz_preset": { + "service": "mdi:target-variant" + } } } diff --git a/homeassistant/components/foursquare/icons.json b/homeassistant/components/foursquare/icons.json index cf60ed9f247dda..8e2b4e91d5f7a3 100644 --- a/homeassistant/components/foursquare/icons.json +++ b/homeassistant/components/foursquare/icons.json @@ -1,5 +1,7 @@ { "services": { - "checkin": "mdi:map-marker" + "checkin": { + "service": "mdi:map-marker" + } } } diff --git a/homeassistant/components/freebox/icons.json b/homeassistant/components/freebox/icons.json index 81361d2c990482..f4184f0673ec06 100644 --- a/homeassistant/components/freebox/icons.json +++ b/homeassistant/components/freebox/icons.json @@ -1,5 +1,7 @@ { "services": { - "reboot": "mdi:restart" + "reboot": { + "service": "mdi:restart" + } } } diff --git a/homeassistant/components/fritz/icons.json b/homeassistant/components/fritz/icons.json index d2154dc7232f12..481568a4c2ce33 100644 --- a/homeassistant/components/fritz/icons.json +++ b/homeassistant/components/fritz/icons.json @@ -51,9 +51,17 @@ } }, "services": { - "reconnect": "mdi:connection", - "reboot": "mdi:refresh", - "cleanup": "mdi:broom", - "set_guest_wifi_password": "mdi:form-textbox-password" + "reconnect": { + "service": "mdi:connection" + }, + "reboot": { + "service": "mdi:refresh" + }, + "cleanup": { + "service": "mdi:broom" + }, + "set_guest_wifi_password": { + "service": "mdi:form-textbox-password" + } } } diff --git a/homeassistant/components/frontend/icons.json b/homeassistant/components/frontend/icons.json index 9fbe4d5b9b0901..b4bcdef6194891 100644 --- a/homeassistant/components/frontend/icons.json +++ b/homeassistant/components/frontend/icons.json @@ -1,6 +1,10 @@ { "services": { - "set_theme": "mdi:palette-swatch", - "reload_themes": "mdi:reload" + "set_theme": { + "service": "mdi:palette-swatch" + }, + "reload_themes": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/fully_kiosk/icons.json b/homeassistant/components/fully_kiosk/icons.json index 760698f7ac840f..0166679abe2848 100644 --- a/homeassistant/components/fully_kiosk/icons.json +++ b/homeassistant/components/fully_kiosk/icons.json @@ -1,7 +1,13 @@ { "services": { - "load_url": "mdi:link", - "set_config": "mdi:cog", - "start_application": "mdi:rocket-launch" + "load_url": { + "service": "mdi:link" + }, + "set_config": { + "service": "mdi:cog" + }, + "start_application": { + "service": "mdi:rocket-launch" + } } } diff --git a/homeassistant/components/generic/icons.json b/homeassistant/components/generic/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/generic/icons.json +++ b/homeassistant/components/generic/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } From cffa8b4febfb39124153d5cac38ed8399a4bd53c Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 13:47:41 +0200 Subject: [PATCH 58/67] Update icons.json to new service schema part 2 (#124769) --- .../components/generic_thermostat/icons.json | 4 +- homeassistant/components/geniushub/icons.json | 12 ++- homeassistant/components/google/icons.json | 8 +- .../components/google_assistant/icons.json | 4 +- .../google_assistant_sdk/icons.json | 4 +- .../icons.json | 4 +- .../components/google_mail/icons.json | 4 +- .../components/google_sheets/icons.json | 4 +- homeassistant/components/group/icons.json | 12 ++- homeassistant/components/guardian/icons.json | 12 ++- homeassistant/components/habitica/icons.json | 4 +- homeassistant/components/harmony/icons.json | 8 +- homeassistant/components/hassio/icons.json | 44 +++++++--- homeassistant/components/hdmi_cec/icons.json | 24 +++-- homeassistant/components/heos/icons.json | 8 +- .../components/history_stats/icons.json | 4 +- homeassistant/components/hive/icons.json | 12 ++- .../components/home_connect/icons.json | 28 ++++-- .../components/homeassistant/icons.json | 52 ++++++++--- homeassistant/components/homekit/icons.json | 12 ++- homeassistant/components/homematic/icons.json | 24 +++-- .../components/homematicip_cloud/icons.json | 36 ++++++-- homeassistant/components/homeworks/icons.json | 4 +- homeassistant/components/html5/icons.json | 4 +- .../components/huawei_lte/icons.json | 8 +- homeassistant/components/hue/icons.json | 8 +- .../components/humidifier/icons.json | 20 +++-- .../components/husqvarna_automower/icons.json | 8 +- homeassistant/components/hydrawise/icons.json | 12 ++- homeassistant/components/icloud/icons.json | 16 +++- homeassistant/components/ifttt/icons.json | 8 +- homeassistant/components/ihc/icons.json | 16 +++- .../components/image_processing/icons.json | 4 +- homeassistant/components/imap/icons.json | 16 +++- .../components/input_boolean/icons.json | 16 +++- .../components/input_button/icons.json | 8 +- .../components/input_datetime/icons.json | 8 +- .../components/input_number/icons.json | 16 +++- .../components/input_select/icons.json | 28 ++++-- .../components/input_text/icons.json | 8 +- homeassistant/components/insteon/icons.json | 44 +++++++--- .../components/intent_script/icons.json | 4 +- homeassistant/components/iperf3/icons.json | 4 +- homeassistant/components/isy994/icons.json | 32 +++++-- homeassistant/components/izone/icons.json | 8 +- homeassistant/components/keba/icons.json | 32 +++++-- homeassistant/components/kef/icons.json | 32 +++++-- homeassistant/components/keyboard/icons.json | 24 +++-- .../components/keymitt_ble/icons.json | 4 +- homeassistant/components/knx/icons.json | 20 +++-- homeassistant/components/kodi/icons.json | 8 +- homeassistant/components/lametric/icons.json | 8 +- .../components/lawn_mower/icons.json | 12 ++- homeassistant/components/lcn/icons.json | 52 ++++++++--- homeassistant/components/lifx/icons.json | 36 ++++++-- homeassistant/components/light/icons.json | 12 ++- .../components/litterrobot/icons.json | 4 +- .../components/local_file/icons.json | 4 +- homeassistant/components/lock/icons.json | 12 ++- homeassistant/components/logbook/icons.json | 4 +- homeassistant/components/logger/icons.json | 8 +- homeassistant/components/lovelace/icons.json | 4 +- homeassistant/components/lyric/icons.json | 4 +- homeassistant/components/matrix/icons.json | 4 +- homeassistant/components/mealie/icons.json | 20 +++-- .../components/media_extractor/icons.json | 8 +- .../components/media_player/icons.json | 88 ++++++++++++++----- homeassistant/components/melcloud/icons.json | 8 +- .../components/microsoft_face/icons.json | 24 +++-- homeassistant/components/mill/icons.json | 4 +- 70 files changed, 795 insertions(+), 265 deletions(-) diff --git a/homeassistant/components/generic_thermostat/icons.json b/homeassistant/components/generic_thermostat/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/generic_thermostat/icons.json +++ b/homeassistant/components/generic_thermostat/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/geniushub/icons.json b/homeassistant/components/geniushub/icons.json index 41697b419a858e..c8a59dedbbdb8d 100644 --- a/homeassistant/components/geniushub/icons.json +++ b/homeassistant/components/geniushub/icons.json @@ -1,7 +1,13 @@ { "services": { - "set_zone_mode": "mdi:auto-mode", - "set_zone_override": "mdi:thermometer-lines", - "set_switch_override": "mdi:toggle-switch-variant" + "set_zone_mode": { + "service": "mdi:auto-mode" + }, + "set_zone_override": { + "service": "mdi:thermometer-lines" + }, + "set_switch_override": { + "service": "mdi:toggle-switch-variant" + } } } diff --git a/homeassistant/components/google/icons.json b/homeassistant/components/google/icons.json index 6dbad61b43da04..e4f25442546c66 100644 --- a/homeassistant/components/google/icons.json +++ b/homeassistant/components/google/icons.json @@ -1,6 +1,10 @@ { "services": { - "add_event": "mdi:calendar-plus", - "create_event": "mdi:calendar-plus" + "add_event": { + "service": "mdi:calendar-plus" + }, + "create_event": { + "service": "mdi:calendar-plus" + } } } diff --git a/homeassistant/components/google_assistant/icons.json b/homeassistant/components/google_assistant/icons.json index 3bcab03d2c240b..a522103328a99b 100644 --- a/homeassistant/components/google_assistant/icons.json +++ b/homeassistant/components/google_assistant/icons.json @@ -1,5 +1,7 @@ { "services": { - "request_sync": "mdi:sync" + "request_sync": { + "service": "mdi:sync" + } } } diff --git a/homeassistant/components/google_assistant_sdk/icons.json b/homeassistant/components/google_assistant_sdk/icons.json index bf1420b2e3febf..75747c43f5b3a1 100644 --- a/homeassistant/components/google_assistant_sdk/icons.json +++ b/homeassistant/components/google_assistant_sdk/icons.json @@ -1,5 +1,7 @@ { "services": { - "send_text_command": "mdi:comment-text-outline" + "send_text_command": { + "service": "mdi:comment-text-outline" + } } } diff --git a/homeassistant/components/google_generative_ai_conversation/icons.json b/homeassistant/components/google_generative_ai_conversation/icons.json index 6544532783a053..6ac3cc3b21c57b 100644 --- a/homeassistant/components/google_generative_ai_conversation/icons.json +++ b/homeassistant/components/google_generative_ai_conversation/icons.json @@ -1,5 +1,7 @@ { "services": { - "generate_content": "mdi:receipt-text" + "generate_content": { + "service": "mdi:receipt-text" + } } } diff --git a/homeassistant/components/google_mail/icons.json b/homeassistant/components/google_mail/icons.json index 599ccffe3c71c7..d0a6eb33715f83 100644 --- a/homeassistant/components/google_mail/icons.json +++ b/homeassistant/components/google_mail/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_vacation": "mdi:beach" + "set_vacation": { + "service": "mdi:beach" + } } } diff --git a/homeassistant/components/google_sheets/icons.json b/homeassistant/components/google_sheets/icons.json index c8010a690bec04..e2b6ed57579f35 100644 --- a/homeassistant/components/google_sheets/icons.json +++ b/homeassistant/components/google_sheets/icons.json @@ -1,5 +1,7 @@ { "services": { - "append_sheet": "mdi:google-spreadsheet" + "append_sheet": { + "service": "mdi:google-spreadsheet" + } } } diff --git a/homeassistant/components/group/icons.json b/homeassistant/components/group/icons.json index 8cca94e08e1a94..577d1effac04c5 100644 --- a/homeassistant/components/group/icons.json +++ b/homeassistant/components/group/icons.json @@ -1,7 +1,13 @@ { "services": { - "reload": "mdi:reload", - "set": "mdi:home-group-plus", - "remove": "mdi:home-group-remove" + "reload": { + "service": "mdi:reload" + }, + "set": { + "service": "mdi:home-group-plus" + }, + "remove": { + "service": "mdi:home-group-remove" + } } } diff --git a/homeassistant/components/guardian/icons.json b/homeassistant/components/guardian/icons.json index 4740366e993000..fe44eb0460be13 100644 --- a/homeassistant/components/guardian/icons.json +++ b/homeassistant/components/guardian/icons.json @@ -18,8 +18,14 @@ } }, "services": { - "pair_sensor": "mdi:link-variant", - "unpair_sensor": "mdi:link-variant-remove", - "upgrade_firmware": "mdi:update" + "pair_sensor": { + "service": "mdi:link-variant" + }, + "unpair_sensor": { + "service": "mdi:link-variant-remove" + }, + "upgrade_firmware": { + "service": "mdi:update" + } } } diff --git a/homeassistant/components/habitica/icons.json b/homeassistant/components/habitica/icons.json index 710b8c9d25b928..662cf1d84a55ff 100644 --- a/homeassistant/components/habitica/icons.json +++ b/homeassistant/components/habitica/icons.json @@ -88,6 +88,8 @@ } }, "services": { - "api_call": "mdi:console" + "api_call": { + "service": "mdi:console" + } } } diff --git a/homeassistant/components/harmony/icons.json b/homeassistant/components/harmony/icons.json index f96fd985323ded..b6fe0d8c42e770 100644 --- a/homeassistant/components/harmony/icons.json +++ b/homeassistant/components/harmony/icons.json @@ -10,7 +10,11 @@ } }, "services": { - "sync": "mdi:sync", - "change_channel": "mdi:remote-tv" + "sync": { + "service": "mdi:sync" + }, + "change_channel": { + "service": "mdi:remote-tv" + } } } diff --git a/homeassistant/components/hassio/icons.json b/homeassistant/components/hassio/icons.json index c55820b58f2aab..64f032d9f806ea 100644 --- a/homeassistant/components/hassio/icons.json +++ b/homeassistant/components/hassio/icons.json @@ -10,16 +10,38 @@ } }, "services": { - "addon_start": "mdi:play", - "addon_restart": "mdi:restart", - "addon_stdin": "mdi:console", - "addon_stop": "mdi:stop", - "addon_update": "mdi:update", - "host_reboot": "mdi:restart", - "host_shutdown": "mdi:power", - "backup_full": "mdi:content-save", - "backup_partial": "mdi:content-save", - "restore_full": "mdi:backup-restore", - "restore_partial": "mdi:backup-restore" + "addon_start": { + "service": "mdi:play" + }, + "addon_restart": { + "service": "mdi:restart" + }, + "addon_stdin": { + "service": "mdi:console" + }, + "addon_stop": { + "service": "mdi:stop" + }, + "addon_update": { + "service": "mdi:update" + }, + "host_reboot": { + "service": "mdi:restart" + }, + "host_shutdown": { + "service": "mdi:power" + }, + "backup_full": { + "service": "mdi:content-save" + }, + "backup_partial": { + "service": "mdi:content-save" + }, + "restore_full": { + "service": "mdi:backup-restore" + }, + "restore_partial": { + "service": "mdi:backup-restore" + } } } diff --git a/homeassistant/components/hdmi_cec/icons.json b/homeassistant/components/hdmi_cec/icons.json index 0bfcb98eea2c9f..93647a6bb12e2e 100644 --- a/homeassistant/components/hdmi_cec/icons.json +++ b/homeassistant/components/hdmi_cec/icons.json @@ -1,10 +1,22 @@ { "services": { - "power_on": "mdi:power", - "select_device": "mdi:television", - "send_command": "mdi:console", - "standby": "mdi:power-standby", - "update": "mdi:update", - "volume": "mdi:volume-high" + "power_on": { + "service": "mdi:power" + }, + "select_device": { + "service": "mdi:television" + }, + "send_command": { + "service": "mdi:console" + }, + "standby": { + "service": "mdi:power-standby" + }, + "update": { + "service": "mdi:update" + }, + "volume": { + "service": "mdi:volume-high" + } } } diff --git a/homeassistant/components/heos/icons.json b/homeassistant/components/heos/icons.json index 69c434c8287b93..23c2c8faeafe3c 100644 --- a/homeassistant/components/heos/icons.json +++ b/homeassistant/components/heos/icons.json @@ -1,6 +1,10 @@ { "services": { - "sign_in": "mdi:login", - "sign_out": "mdi:logout" + "sign_in": { + "service": "mdi:login" + }, + "sign_out": { + "service": "mdi:logout" + } } } diff --git a/homeassistant/components/history_stats/icons.json b/homeassistant/components/history_stats/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/history_stats/icons.json +++ b/homeassistant/components/history_stats/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/hive/icons.json b/homeassistant/components/hive/icons.json index 2704317779cbd2..e4c06556906fd0 100644 --- a/homeassistant/components/hive/icons.json +++ b/homeassistant/components/hive/icons.json @@ -18,8 +18,14 @@ } }, "services": { - "boost_heating_on": "mdi:radiator", - "boost_heating_off": "mdi:radiator-off", - "boost_hot_water": "mdi:water-boiler" + "boost_heating_on": { + "service": "mdi:radiator" + }, + "boost_heating_off": { + "service": "mdi:radiator-off" + }, + "boost_hot_water": { + "service": "mdi:water-boiler" + } } } diff --git a/homeassistant/components/home_connect/icons.json b/homeassistant/components/home_connect/icons.json index 48965cc554ae19..33617f5472ebd9 100644 --- a/homeassistant/components/home_connect/icons.json +++ b/homeassistant/components/home_connect/icons.json @@ -1,11 +1,25 @@ { "services": { - "start_program": "mdi:play", - "select_program": "mdi:form-select", - "pause_program": "mdi:pause", - "resume_program": "mdi:play-pause", - "set_option_active": "mdi:gesture-tap", - "set_option_selected": "mdi:gesture-tap", - "change_setting": "mdi:cog" + "start_program": { + "service": "mdi:play" + }, + "select_program": { + "service": "mdi:form-select" + }, + "pause_program": { + "service": "mdi:pause" + }, + "resume_program": { + "service": "mdi:play-pause" + }, + "set_option_active": { + "service": "mdi:gesture-tap" + }, + "set_option_selected": { + "service": "mdi:gesture-tap" + }, + "change_setting": { + "service": "mdi:cog" + } } } diff --git a/homeassistant/components/homeassistant/icons.json b/homeassistant/components/homeassistant/icons.json index ec4d572991846f..f08fa8d969ba03 100644 --- a/homeassistant/components/homeassistant/icons.json +++ b/homeassistant/components/homeassistant/icons.json @@ -1,17 +1,43 @@ { "services": { - "check_config": "mdi:receipt-text-check", - "reload_core_config": "mdi:receipt-text-send", - "restart": "mdi:restart", - "set_location": "mdi:map-marker", - "stop": "mdi:stop", - "toggle": "mdi:toggle-switch", - "turn_on": "mdi:power-on", - "turn_off": "mdi:power-off", - "update_entity": "mdi:update", - "reload_custom_templates": "mdi:palette-swatch", - "reload_config_entry": "mdi:reload", - "save_persistent_states": "mdi:content-save", - "reload_all": "mdi:reload" + "check_config": { + "service": "mdi:receipt-text-check" + }, + "reload_core_config": { + "service": "mdi:receipt-text-send" + }, + "restart": { + "service": "mdi:restart" + }, + "set_location": { + "service": "mdi:map-marker" + }, + "stop": { + "service": "mdi:stop" + }, + "toggle": { + "service": "mdi:toggle-switch" + }, + "turn_on": { + "service": "mdi:power-on" + }, + "turn_off": { + "service": "mdi:power-off" + }, + "update_entity": { + "service": "mdi:update" + }, + "reload_custom_templates": { + "service": "mdi:palette-swatch" + }, + "reload_config_entry": { + "service": "mdi:reload" + }, + "save_persistent_states": { + "service": "mdi:content-save" + }, + "reload_all": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/homekit/icons.json b/homeassistant/components/homekit/icons.json index fb0461eb5d8415..7d8ddf131efeb7 100644 --- a/homeassistant/components/homekit/icons.json +++ b/homeassistant/components/homekit/icons.json @@ -1,7 +1,13 @@ { "services": { - "reload": "mdi:reload", - "reset_accessory": "mdi:cog-refresh", - "unpair": "mdi:link-variant-off" + "reload": { + "service": "mdi:reload" + }, + "reset_accessory": { + "service": "mdi:cog-refresh" + }, + "unpair": { + "service": "mdi:link-variant-off" + } } } diff --git a/homeassistant/components/homematic/icons.json b/homeassistant/components/homematic/icons.json index 998c9a385bac15..9e58bbe3a9095b 100644 --- a/homeassistant/components/homematic/icons.json +++ b/homeassistant/components/homematic/icons.json @@ -1,10 +1,22 @@ { "services": { - "virtualkey": "mdi:keyboard", - "set_variable_value": "mdi:console", - "set_device_value": "mdi:television", - "reconnect": "mdi:wifi-refresh", - "set_install_mode": "mdi:cog", - "put_paramset": "mdi:cog" + "virtualkey": { + "service": "mdi:keyboard" + }, + "set_variable_value": { + "service": "mdi:console" + }, + "set_device_value": { + "service": "mdi:television" + }, + "reconnect": { + "service": "mdi:wifi-refresh" + }, + "set_install_mode": { + "service": "mdi:cog" + }, + "put_paramset": { + "service": "mdi:cog" + } } } diff --git a/homeassistant/components/homematicip_cloud/icons.json b/homeassistant/components/homematicip_cloud/icons.json index 73c60ea8cddc8b..53a39d8213c50e 100644 --- a/homeassistant/components/homematicip_cloud/icons.json +++ b/homeassistant/components/homematicip_cloud/icons.json @@ -1,13 +1,31 @@ { "services": { - "activate_eco_mode_with_duration": "mdi:leaf", - "activate_eco_mode_with_period": "mdi:leaf", - "activate_vacation": "mdi:compass", - "deactivate_eco_mode": "mdi:leaf-off", - "deactivate_vacation": "mdi:compass-off", - "set_active_climate_profile": "mdi:home-thermometer", - "dump_hap_config": "mdi:database-export", - "reset_energy_counter": "mdi:reload", - "set_home_cooling_mode": "mdi:snowflake" + "activate_eco_mode_with_duration": { + "service": "mdi:leaf" + }, + "activate_eco_mode_with_period": { + "service": "mdi:leaf" + }, + "activate_vacation": { + "service": "mdi:compass" + }, + "deactivate_eco_mode": { + "service": "mdi:leaf-off" + }, + "deactivate_vacation": { + "service": "mdi:compass-off" + }, + "set_active_climate_profile": { + "service": "mdi:home-thermometer" + }, + "dump_hap_config": { + "service": "mdi:database-export" + }, + "reset_energy_counter": { + "service": "mdi:reload" + }, + "set_home_cooling_mode": { + "service": "mdi:snowflake" + } } } diff --git a/homeassistant/components/homeworks/icons.json b/homeassistant/components/homeworks/icons.json index f53b447d96e936..fc39b2ef455905 100644 --- a/homeassistant/components/homeworks/icons.json +++ b/homeassistant/components/homeworks/icons.json @@ -1,5 +1,7 @@ { "services": { - "send_command": "mdi:console" + "send_command": { + "service": "mdi:console" + } } } diff --git a/homeassistant/components/html5/icons.json b/homeassistant/components/html5/icons.json index c3d6e27efda376..d0a6013dd12524 100644 --- a/homeassistant/components/html5/icons.json +++ b/homeassistant/components/html5/icons.json @@ -1,5 +1,7 @@ { "services": { - "dismiss": "mdi:bell-off" + "dismiss": { + "service": "mdi:bell-off" + } } } diff --git a/homeassistant/components/huawei_lte/icons.json b/homeassistant/components/huawei_lte/icons.json index d105702bf51821..a338cc65ed4e56 100644 --- a/homeassistant/components/huawei_lte/icons.json +++ b/homeassistant/components/huawei_lte/icons.json @@ -53,7 +53,11 @@ } }, "services": { - "resume_integration": "mdi:play-pause", - "suspend_integration": "mdi:pause" + "resume_integration": { + "service": "mdi:play-pause" + }, + "suspend_integration": { + "service": "mdi:pause" + } } } diff --git a/homeassistant/components/hue/icons.json b/homeassistant/components/hue/icons.json index 9371ae5843e32a..31464308b0a3a2 100644 --- a/homeassistant/components/hue/icons.json +++ b/homeassistant/components/hue/icons.json @@ -1,6 +1,10 @@ { "services": { - "hue_activate_scene": "mdi:palette", - "activate_scene": "mdi:palette" + "hue_activate_scene": { + "service": "mdi:palette" + }, + "activate_scene": { + "service": "mdi:palette" + } } } diff --git a/homeassistant/components/humidifier/icons.json b/homeassistant/components/humidifier/icons.json index 2c67f759195236..15951df432db81 100644 --- a/homeassistant/components/humidifier/icons.json +++ b/homeassistant/components/humidifier/icons.json @@ -33,10 +33,20 @@ } }, "services": { - "set_humidity": "mdi:water-percent", - "set_mode": "mdi:air-humidifier", - "toggle": "mdi:air-humidifier", - "turn_off": "mdi:air-humidifier-off", - "turn_on": "mdi:air-humidifier" + "set_humidity": { + "service": "mdi:water-percent" + }, + "set_mode": { + "service": "mdi:air-humidifier" + }, + "toggle": { + "service": "mdi:air-humidifier" + }, + "turn_off": { + "service": "mdi:air-humidifier-off" + }, + "turn_on": { + "service": "mdi:air-humidifier" + } } } diff --git a/homeassistant/components/husqvarna_automower/icons.json b/homeassistant/components/husqvarna_automower/icons.json index 9dc1cbeb667645..bcaf1826260b57 100644 --- a/homeassistant/components/husqvarna_automower/icons.json +++ b/homeassistant/components/husqvarna_automower/icons.json @@ -34,7 +34,11 @@ } }, "services": { - "override_schedule": "mdi:debug-step-over", - "override_schedule_work_area": "mdi:land-fields" + "override_schedule": { + "service": "mdi:debug-step-over" + }, + "override_schedule_work_area": { + "service": "mdi:land-fields" + } } } diff --git a/homeassistant/components/hydrawise/icons.json b/homeassistant/components/hydrawise/icons.json index 1d1d349dbf9776..5baf76454b79c0 100644 --- a/homeassistant/components/hydrawise/icons.json +++ b/homeassistant/components/hydrawise/icons.json @@ -31,8 +31,14 @@ } }, "services": { - "start_watering": "mdi:sprinkler-variant", - "suspend": "mdi:pause-circle-outline", - "resume": "mdi:play" + "start_watering": { + "service": "mdi:sprinkler-variant" + }, + "suspend": { + "service": "mdi:pause-circle-outline" + }, + "resume": { + "service": "mdi:play" + } } } diff --git a/homeassistant/components/icloud/icons.json b/homeassistant/components/icloud/icons.json index 4ed856aabc1465..16280a063e3dab 100644 --- a/homeassistant/components/icloud/icons.json +++ b/homeassistant/components/icloud/icons.json @@ -1,8 +1,16 @@ { "services": { - "update": "mdi:update", - "play_sound": "mdi:speaker-wireless", - "display_message": "mdi:message-alert", - "lost_device": "mdi:devices" + "update": { + "service": "mdi:update" + }, + "play_sound": { + "service": "mdi:speaker-wireless" + }, + "display_message": { + "service": "mdi:message-alert" + }, + "lost_device": { + "service": "mdi:devices" + } } } diff --git a/homeassistant/components/ifttt/icons.json b/homeassistant/components/ifttt/icons.json index b943478a70bfab..a90d76f664aec9 100644 --- a/homeassistant/components/ifttt/icons.json +++ b/homeassistant/components/ifttt/icons.json @@ -1,6 +1,10 @@ { "services": { - "push_alarm_state": "mdi:security", - "trigger": "mdi:play" + "push_alarm_state": { + "service": "mdi:security" + }, + "trigger": { + "service": "mdi:play" + } } } diff --git a/homeassistant/components/ihc/icons.json b/homeassistant/components/ihc/icons.json index 73aab5f80d899c..3842d1a48a6d35 100644 --- a/homeassistant/components/ihc/icons.json +++ b/homeassistant/components/ihc/icons.json @@ -1,8 +1,16 @@ { "services": { - "set_runtime_value_bool": "mdi:toggle-switch", - "set_runtime_value_int": "mdi:numeric", - "set_runtime_value_float": "mdi:numeric", - "pulse": "mdi:pulse" + "set_runtime_value_bool": { + "service": "mdi:toggle-switch" + }, + "set_runtime_value_int": { + "service": "mdi:numeric" + }, + "set_runtime_value_float": { + "service": "mdi:numeric" + }, + "pulse": { + "service": "mdi:pulse" + } } } diff --git a/homeassistant/components/image_processing/icons.json b/homeassistant/components/image_processing/icons.json index b19d29c186dc43..ae95718e381977 100644 --- a/homeassistant/components/image_processing/icons.json +++ b/homeassistant/components/image_processing/icons.json @@ -1,5 +1,7 @@ { "services": { - "scan": "mdi:qrcode-scan" + "scan": { + "service": "mdi:qrcode-scan" + } } } diff --git a/homeassistant/components/imap/icons.json b/homeassistant/components/imap/icons.json index 6672f9a4a7fce3..17a11d0fe22d28 100644 --- a/homeassistant/components/imap/icons.json +++ b/homeassistant/components/imap/icons.json @@ -10,9 +10,17 @@ } }, "services": { - "seen": "mdi:email-open-outline", - "move": "mdi:email-arrow-right-outline", - "delete": "mdi:trash-can-outline", - "fetch": "mdi:email-sync-outline" + "seen": { + "service": "mdi:email-open-outline" + }, + "move": { + "service": "mdi:email-arrow-right-outline" + }, + "delete": { + "service": "mdi:trash-can-outline" + }, + "fetch": { + "service": "mdi:email-sync-outline" + } } } diff --git a/homeassistant/components/input_boolean/icons.json b/homeassistant/components/input_boolean/icons.json index dc595a60fba4d7..088c9094b3f556 100644 --- a/homeassistant/components/input_boolean/icons.json +++ b/homeassistant/components/input_boolean/icons.json @@ -8,9 +8,17 @@ } }, "services": { - "toggle": "mdi:toggle-switch", - "turn_off": "mdi:toggle-switch-off", - "turn_on": "mdi:toggle-switch", - "reload": "mdi:reload" + "toggle": { + "service": "mdi:toggle-switch" + }, + "turn_off": { + "service": "mdi:toggle-switch-off" + }, + "turn_on": { + "service": "mdi:toggle-switch" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/input_button/icons.json b/homeassistant/components/input_button/icons.json index 226b8ede1101f8..20d41b4934a236 100644 --- a/homeassistant/components/input_button/icons.json +++ b/homeassistant/components/input_button/icons.json @@ -1,6 +1,10 @@ { "services": { - "press": "mdi:gesture-tap-button", - "reload": "mdi:reload" + "press": { + "service": "mdi:gesture-tap-button" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/input_datetime/icons.json b/homeassistant/components/input_datetime/icons.json index de899023cf272f..f3676f022208da 100644 --- a/homeassistant/components/input_datetime/icons.json +++ b/homeassistant/components/input_datetime/icons.json @@ -1,6 +1,10 @@ { "services": { - "set_datetime": "mdi:calendar-clock", - "reload": "mdi:reload" + "set_datetime": { + "service": "mdi:calendar-clock" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/input_number/icons.json b/homeassistant/components/input_number/icons.json index d1423838491251..9f90582308bb90 100644 --- a/homeassistant/components/input_number/icons.json +++ b/homeassistant/components/input_number/icons.json @@ -1,8 +1,16 @@ { "services": { - "decrement": "mdi:minus", - "increment": "mdi:plus", - "set_value": "mdi:numeric", - "reload": "mdi:reload" + "decrement": { + "service": "mdi:minus" + }, + "increment": { + "service": "mdi:plus" + }, + "set_value": { + "service": "mdi:numeric" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/input_select/icons.json b/homeassistant/components/input_select/icons.json index 03b477ddb36e73..6ef5cfaf96a8c2 100644 --- a/homeassistant/components/input_select/icons.json +++ b/homeassistant/components/input_select/icons.json @@ -1,11 +1,25 @@ { "services": { - "select_next": "mdi:skip-next", - "select_option": "mdi:check", - "select_previous": "mdi:skip-previous", - "select_first": "mdi:skip-backward", - "select_last": "mdi:skip-forward", - "set_options": "mdi:cog", - "reload": "mdi:reload" + "select_next": { + "service": "mdi:skip-next" + }, + "select_option": { + "service": "mdi:check" + }, + "select_previous": { + "service": "mdi:skip-previous" + }, + "select_first": { + "service": "mdi:skip-backward" + }, + "select_last": { + "service": "mdi:skip-forward" + }, + "set_options": { + "service": "mdi:cog" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/input_text/icons.json b/homeassistant/components/input_text/icons.json index 0190e4ffba254b..8fca66668bc4bb 100644 --- a/homeassistant/components/input_text/icons.json +++ b/homeassistant/components/input_text/icons.json @@ -1,6 +1,10 @@ { "services": { - "set_value": "mdi:form-textbox", - "reload": "mdi:reload" + "set_value": { + "service": "mdi:form-textbox" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/insteon/icons.json b/homeassistant/components/insteon/icons.json index 4d015e13b0dc43..530006ca7d466e 100644 --- a/homeassistant/components/insteon/icons.json +++ b/homeassistant/components/insteon/icons.json @@ -1,15 +1,37 @@ { "services": { - "add_all_link": "mdi:link-variant", - "delete_all_link": "mdi:link-variant-remove", - "load_all_link_database": "mdi:database", - "print_all_link_database": "mdi:database-export", - "print_im_all_link_database": "mdi:database-export", - "x10_all_units_off": "mdi:power-off", - "x10_all_lights_on": "mdi:lightbulb-on", - "x10_all_lights_off": "mdi:lightbulb-off", - "scene_on": "mdi:palette", - "scene_off": "mdi:palette-outline", - "add_default_links": "mdi:link-variant-plus" + "add_all_link": { + "service": "mdi:link-variant" + }, + "delete_all_link": { + "service": "mdi:link-variant-remove" + }, + "load_all_link_database": { + "service": "mdi:database" + }, + "print_all_link_database": { + "service": "mdi:database-export" + }, + "print_im_all_link_database": { + "service": "mdi:database-export" + }, + "x10_all_units_off": { + "service": "mdi:power-off" + }, + "x10_all_lights_on": { + "service": "mdi:lightbulb-on" + }, + "x10_all_lights_off": { + "service": "mdi:lightbulb-off" + }, + "scene_on": { + "service": "mdi:palette" + }, + "scene_off": { + "service": "mdi:palette-outline" + }, + "add_default_links": { + "service": "mdi:link-variant-plus" + } } } diff --git a/homeassistant/components/intent_script/icons.json b/homeassistant/components/intent_script/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/intent_script/icons.json +++ b/homeassistant/components/intent_script/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/iperf3/icons.json b/homeassistant/components/iperf3/icons.json index 3ef7e301ed65d6..f6ebe1aee2f555 100644 --- a/homeassistant/components/iperf3/icons.json +++ b/homeassistant/components/iperf3/icons.json @@ -1,5 +1,7 @@ { "services": { - "speedtest": "mdi:speedometer" + "speedtest": { + "service": "mdi:speedometer" + } } } diff --git a/homeassistant/components/isy994/icons.json b/homeassistant/components/isy994/icons.json index 27b2ea6954ed4a..9c6e7fa78df23f 100644 --- a/homeassistant/components/isy994/icons.json +++ b/homeassistant/components/isy994/icons.json @@ -1,12 +1,28 @@ { "services": { - "send_raw_node_command": "mdi:console-line", - "send_node_command": "mdi:console", - "get_zwave_parameter": "mdi:download", - "set_zwave_parameter": "mdi:upload", - "set_zwave_lock_user_code": "mdi:upload-lock", - "delete_zwave_lock_user_code": "mdi:lock-remove", - "rename_node": "mdi:pencil", - "send_program_command": "mdi:console" + "send_raw_node_command": { + "service": "mdi:console-line" + }, + "send_node_command": { + "service": "mdi:console" + }, + "get_zwave_parameter": { + "service": "mdi:download" + }, + "set_zwave_parameter": { + "service": "mdi:upload" + }, + "set_zwave_lock_user_code": { + "service": "mdi:upload-lock" + }, + "delete_zwave_lock_user_code": { + "service": "mdi:lock-remove" + }, + "rename_node": { + "service": "mdi:pencil" + }, + "send_program_command": { + "service": "mdi:console" + } } } diff --git a/homeassistant/components/izone/icons.json b/homeassistant/components/izone/icons.json index e02cd57c141270..bb38db27839ba9 100644 --- a/homeassistant/components/izone/icons.json +++ b/homeassistant/components/izone/icons.json @@ -1,6 +1,10 @@ { "services": { - "airflow_min": "mdi:fan-minus", - "airflow_max": "mdi:fan-plus" + "airflow_min": { + "service": "mdi:fan-minus" + }, + "airflow_max": { + "service": "mdi:fan-plus" + } } } diff --git a/homeassistant/components/keba/icons.json b/homeassistant/components/keba/icons.json index 7f64bf7fb346a3..6de43a84cf6b40 100644 --- a/homeassistant/components/keba/icons.json +++ b/homeassistant/components/keba/icons.json @@ -1,12 +1,28 @@ { "services": { - "request_data": "mdi:database-arrow-down", - "authorize": "mdi:lock", - "deauthorize": "mdi:lock-open", - "set_energy": "mdi:flash", - "set_current": "mdi:flash", - "enable": "mdi:flash", - "disable": "mdi:fash-off", - "set_failsafe": "mdi:message-alert" + "request_data": { + "service": "mdi:database-arrow-down" + }, + "authorize": { + "service": "mdi:lock" + }, + "deauthorize": { + "service": "mdi:lock-open" + }, + "set_energy": { + "service": "mdi:flash" + }, + "set_current": { + "service": "mdi:flash" + }, + "enable": { + "service": "mdi:flash" + }, + "disable": { + "service": "mdi:fash-off" + }, + "set_failsafe": { + "service": "mdi:message-alert" + } } } diff --git a/homeassistant/components/kef/icons.json b/homeassistant/components/kef/icons.json index eeb6dd099cec41..e259e91eb1b0e4 100644 --- a/homeassistant/components/kef/icons.json +++ b/homeassistant/components/kef/icons.json @@ -1,12 +1,28 @@ { "services": { - "update_dsp": "mdi:update", - "set_mode": "mdi:cog", - "set_desk_db": "mdi:volume-high", - "set_wall_db": "mdi:volume-high", - "set_treble_db": "mdi:volume-high", - "set_high_hz": "mdi:sine-wave", - "set_low_hz": "mdi:cosine-wave", - "set_sub_db": "mdi:volume-high" + "update_dsp": { + "service": "mdi:update" + }, + "set_mode": { + "service": "mdi:cog" + }, + "set_desk_db": { + "service": "mdi:volume-high" + }, + "set_wall_db": { + "service": "mdi:volume-high" + }, + "set_treble_db": { + "service": "mdi:volume-high" + }, + "set_high_hz": { + "service": "mdi:sine-wave" + }, + "set_low_hz": { + "service": "mdi:cosine-wave" + }, + "set_sub_db": { + "service": "mdi:volume-high" + } } } diff --git a/homeassistant/components/keyboard/icons.json b/homeassistant/components/keyboard/icons.json index 8186b2684ddd09..03b6210bf41ad8 100644 --- a/homeassistant/components/keyboard/icons.json +++ b/homeassistant/components/keyboard/icons.json @@ -1,10 +1,22 @@ { "services": { - "volume_up": "mdi:volume-high", - "volume_down": "mdi:volume-low", - "volume_mute": "mdi:volume-off", - "media_play_pause": "mdi:play-pause", - "media_next_track": "mdi:skip-next", - "media_prev_track": "mdi:skip-previous" + "volume_up": { + "service": "mdi:volume-high" + }, + "volume_down": { + "service": "mdi:volume-low" + }, + "volume_mute": { + "service": "mdi:volume-off" + }, + "media_play_pause": { + "service": "mdi:play-pause" + }, + "media_next_track": { + "service": "mdi:skip-next" + }, + "media_prev_track": { + "service": "mdi:skip-previous" + } } } diff --git a/homeassistant/components/keymitt_ble/icons.json b/homeassistant/components/keymitt_ble/icons.json index 77450fbf02647f..d265d96b395f91 100644 --- a/homeassistant/components/keymitt_ble/icons.json +++ b/homeassistant/components/keymitt_ble/icons.json @@ -1,5 +1,7 @@ { "services": { - "calibrate": "mdi:wrench" + "calibrate": { + "service": "mdi:wrench" + } } } diff --git a/homeassistant/components/knx/icons.json b/homeassistant/components/knx/icons.json index 2aee34219f66f4..756b6ab9f9e4e0 100644 --- a/homeassistant/components/knx/icons.json +++ b/homeassistant/components/knx/icons.json @@ -36,10 +36,20 @@ } }, "services": { - "send": "mdi:email-arrow-right", - "read": "mdi:email-search", - "event_register": "mdi:home-import-outline", - "exposure_register": "mdi:home-export-outline", - "reload": "mdi:reload" + "send": { + "service": "mdi:email-arrow-right" + }, + "read": { + "service": "mdi:email-search" + }, + "event_register": { + "service": "mdi:home-import-outline" + }, + "exposure_register": { + "service": "mdi:home-export-outline" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/kodi/icons.json b/homeassistant/components/kodi/icons.json index 07bd246e92d6fe..d9c32630961b88 100644 --- a/homeassistant/components/kodi/icons.json +++ b/homeassistant/components/kodi/icons.json @@ -1,6 +1,10 @@ { "services": { - "add_to_playlist": "mdi:playlist-plus", - "call_method": "mdi:console" + "add_to_playlist": { + "service": "mdi:playlist-plus" + }, + "call_method": { + "service": "mdi:console" + } } } diff --git a/homeassistant/components/lametric/icons.json b/homeassistant/components/lametric/icons.json index 7e1841272cfab7..229770c96dc85d 100644 --- a/homeassistant/components/lametric/icons.json +++ b/homeassistant/components/lametric/icons.json @@ -39,7 +39,11 @@ } }, "services": { - "chart": "mdi:chart-areaspline-variant", - "message": "mdi:message" + "chart": { + "service": "mdi:chart-areaspline-variant" + }, + "message": { + "service": "mdi:message" + } } } diff --git a/homeassistant/components/lawn_mower/icons.json b/homeassistant/components/lawn_mower/icons.json index b25bf927fcdc9e..2fa1f79efa1182 100644 --- a/homeassistant/components/lawn_mower/icons.json +++ b/homeassistant/components/lawn_mower/icons.json @@ -5,8 +5,14 @@ } }, "services": { - "dock": "mdi:home-import-outline", - "pause": "mdi:pause", - "start_mowing": "mdi:play" + "dock": { + "service": "mdi:home-import-outline" + }, + "pause": { + "service": "mdi:pause" + }, + "start_mowing": { + "service": "mdi:play" + } } } diff --git a/homeassistant/components/lcn/icons.json b/homeassistant/components/lcn/icons.json index c8b451a79ea3b7..944c3938a92112 100644 --- a/homeassistant/components/lcn/icons.json +++ b/homeassistant/components/lcn/icons.json @@ -1,17 +1,43 @@ { "services": { - "output_abs": "mdi:brightness-auto", - "output_rel": "mdi:brightness-7", - "output_toggle": "mdi:toggle-switch", - "relays": "mdi:light-switch-off", - "led": "mdi:led-on", - "var_abs": "mdi:wrench", - "var_reset": "mdi:reload", - "var_rel": "mdi:wrench", - "lock_regulator": "mdi:lock", - "send_keys": "mdi:alarm-panel", - "lock_keys": "mdi:lock", - "dyn_text": "mdi:form-textbox", - "pck": "mdi:package-variant-closed" + "output_abs": { + "service": "mdi:brightness-auto" + }, + "output_rel": { + "service": "mdi:brightness-7" + }, + "output_toggle": { + "service": "mdi:toggle-switch" + }, + "relays": { + "service": "mdi:light-switch-off" + }, + "led": { + "service": "mdi:led-on" + }, + "var_abs": { + "service": "mdi:wrench" + }, + "var_reset": { + "service": "mdi:reload" + }, + "var_rel": { + "service": "mdi:wrench" + }, + "lock_regulator": { + "service": "mdi:lock" + }, + "send_keys": { + "service": "mdi:alarm-panel" + }, + "lock_keys": { + "service": "mdi:lock" + }, + "dyn_text": { + "service": "mdi:form-textbox" + }, + "pck": { + "service": "mdi:package-variant-closed" + } } } diff --git a/homeassistant/components/lifx/icons.json b/homeassistant/components/lifx/icons.json index e32fdb5e06bf3a..58a7c89e266264 100644 --- a/homeassistant/components/lifx/icons.json +++ b/homeassistant/components/lifx/icons.json @@ -1,13 +1,31 @@ { "services": { - "set_hev_cycle_state": "mdi:led-on", - "set_state": "mdi:led-on", - "effect_pulse": "mdi:pulse", - "effect_colorloop": "mdi:looks", - "effect_move": "mdi:cube-send", - "effect_flame": "mdi:fire", - "effect_morph": "mdi:shape-outline", - "effect_sky": "mdi:clouds", - "effect_stop": "mdi:stop" + "set_hev_cycle_state": { + "service": "mdi:led-on" + }, + "set_state": { + "service": "mdi:led-on" + }, + "effect_pulse": { + "service": "mdi:pulse" + }, + "effect_colorloop": { + "service": "mdi:looks" + }, + "effect_move": { + "service": "mdi:cube-send" + }, + "effect_flame": { + "service": "mdi:fire" + }, + "effect_morph": { + "service": "mdi:shape-outline" + }, + "effect_sky": { + "service": "mdi:clouds" + }, + "effect_stop": { + "service": "mdi:stop" + } } } diff --git a/homeassistant/components/light/icons.json b/homeassistant/components/light/icons.json index 5113834e575a55..df98def090e480 100644 --- a/homeassistant/components/light/icons.json +++ b/homeassistant/components/light/icons.json @@ -5,8 +5,14 @@ } }, "services": { - "toggle": "mdi:lightbulb", - "turn_off": "mdi:lightbulb-off", - "turn_on": "mdi:lightbulb-on" + "toggle": { + "service": "mdi:lightbulb" + }, + "turn_off": { + "service": "mdi:lightbulb-off" + }, + "turn_on": { + "service": "mdi:lightbulb-on" + } } } diff --git a/homeassistant/components/litterrobot/icons.json b/homeassistant/components/litterrobot/icons.json index 333f309e9e8a31..482031f8424fdc 100644 --- a/homeassistant/components/litterrobot/icons.json +++ b/homeassistant/components/litterrobot/icons.json @@ -40,6 +40,8 @@ } }, "services": { - "set_sleep_mode": "mdi:sleep" + "set_sleep_mode": { + "service": "mdi:sleep" + } } } diff --git a/homeassistant/components/local_file/icons.json b/homeassistant/components/local_file/icons.json index c9c92fa86c8d70..7b0067c6a44e3f 100644 --- a/homeassistant/components/local_file/icons.json +++ b/homeassistant/components/local_file/icons.json @@ -1,5 +1,7 @@ { "services": { - "update_file_path": "mdi:cog" + "update_file_path": { + "service": "mdi:cog" + } } } diff --git a/homeassistant/components/lock/icons.json b/homeassistant/components/lock/icons.json index 009bd84a372903..0b1befde9ff409 100644 --- a/homeassistant/components/lock/icons.json +++ b/homeassistant/components/lock/icons.json @@ -13,8 +13,14 @@ } }, "services": { - "lock": "mdi:lock", - "open": "mdi:door-open", - "unlock": "mdi:lock-open-variant" + "lock": { + "service": "mdi:lock" + }, + "open": { + "service": "mdi:door-open" + }, + "unlock": { + "service": "mdi:lock-open-variant" + } } } diff --git a/homeassistant/components/logbook/icons.json b/homeassistant/components/logbook/icons.json index cd2cde8600c65c..a8af6427b8c7a2 100644 --- a/homeassistant/components/logbook/icons.json +++ b/homeassistant/components/logbook/icons.json @@ -1,5 +1,7 @@ { "services": { - "log": "mdi:file-document" + "log": { + "service": "mdi:file-document" + } } } diff --git a/homeassistant/components/logger/icons.json b/homeassistant/components/logger/icons.json index 305dd3ece915dd..1542e1e5ad36e6 100644 --- a/homeassistant/components/logger/icons.json +++ b/homeassistant/components/logger/icons.json @@ -1,6 +1,10 @@ { "services": { - "set_default_level": "mdi:cog-outline", - "set_level": "mdi:cog-outline" + "set_default_level": { + "service": "mdi:cog-outline" + }, + "set_level": { + "service": "mdi:cog-outline" + } } } diff --git a/homeassistant/components/lovelace/icons.json b/homeassistant/components/lovelace/icons.json index fe0a0e114aeecd..8261dc2d0c9da9 100644 --- a/homeassistant/components/lovelace/icons.json +++ b/homeassistant/components/lovelace/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload_resources": "mdi:reload" + "reload_resources": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/lyric/icons.json b/homeassistant/components/lyric/icons.json index 555215f8685edb..edb61c3f8e2bd3 100644 --- a/homeassistant/components/lyric/icons.json +++ b/homeassistant/components/lyric/icons.json @@ -7,6 +7,8 @@ } }, "services": { - "set_hold_time": "mdi:timer-pause" + "set_hold_time": { + "service": "mdi:timer-pause" + } } } diff --git a/homeassistant/components/matrix/icons.json b/homeassistant/components/matrix/icons.json index 4fc56ebe0ff0b7..a8b83e67303fb7 100644 --- a/homeassistant/components/matrix/icons.json +++ b/homeassistant/components/matrix/icons.json @@ -1,5 +1,7 @@ { "services": { - "send_message": "mdi:matrix" + "send_message": { + "service": "mdi:matrix" + } } } diff --git a/homeassistant/components/mealie/icons.json b/homeassistant/components/mealie/icons.json index 16176391701c25..d7e29cc8bbec06 100644 --- a/homeassistant/components/mealie/icons.json +++ b/homeassistant/components/mealie/icons.json @@ -24,10 +24,20 @@ } }, "services": { - "get_mealplan": "mdi:food", - "get_recipe": "mdi:map", - "import_recipe": "mdi:map-search", - "set_random_mealplan": "mdi:dice-multiple", - "set_mealplan": "mdi:food" + "get_mealplan": { + "service": "mdi:food" + }, + "get_recipe": { + "service": "mdi:map" + }, + "import_recipe": { + "service": "mdi:map-search" + }, + "set_random_mealplan": { + "service": "mdi:dice-multiple" + }, + "set_mealplan": { + "service": "mdi:food" + } } } diff --git a/homeassistant/components/media_extractor/icons.json b/homeassistant/components/media_extractor/icons.json index 7abc4410b1956e..611db7c944cfd0 100644 --- a/homeassistant/components/media_extractor/icons.json +++ b/homeassistant/components/media_extractor/icons.json @@ -1,6 +1,10 @@ { "services": { - "play_media": "mdi:play", - "extract_media_url": "mdi:link" + "play_media": { + "service": "mdi:play" + }, + "extract_media_url": { + "service": "mdi:link" + } } } diff --git a/homeassistant/components/media_player/icons.json b/homeassistant/components/media_player/icons.json index 847ce5989d6442..c11211c38ec384 100644 --- a/homeassistant/components/media_player/icons.json +++ b/homeassistant/components/media_player/icons.json @@ -32,27 +32,71 @@ } }, "services": { - "clear_playlist": "mdi:playlist-remove", - "join": "mdi:group", - "media_next_track": "mdi:skip-next", - "media_pause": "mdi:pause", - "media_play": "mdi:play", - "media_play_pause": "mdi:play-pause", - "media_previous_track": "mdi:skip-previous", - "media_seek": "mdi:fast-forward", - "media_stop": "mdi:stop", - "play_media": "mdi:play", - "repeat_set": "mdi:repeat", - "select_sound_mode": "mdi:surround-sound", - "select_source": "mdi:import", - "shuffle_set": "mdi:shuffle", - "toggle": "mdi:play-pause", - "turn_off": "mdi:power", - "turn_on": "mdi:power", - "unjoin": "mdi:ungroup", - "volume_down": "mdi:volume-minus", - "volume_mute": "mdi:volume-mute", - "volume_set": "mdi:volume-medium", - "volume_up": "mdi:volume-plus" + "clear_playlist": { + "service": "mdi:playlist-remove" + }, + "join": { + "service": "mdi:group" + }, + "media_next_track": { + "service": "mdi:skip-next" + }, + "media_pause": { + "service": "mdi:pause" + }, + "media_play": { + "service": "mdi:play" + }, + "media_play_pause": { + "service": "mdi:play-pause" + }, + "media_previous_track": { + "service": "mdi:skip-previous" + }, + "media_seek": { + "service": "mdi:fast-forward" + }, + "media_stop": { + "service": "mdi:stop" + }, + "play_media": { + "service": "mdi:play" + }, + "repeat_set": { + "service": "mdi:repeat" + }, + "select_sound_mode": { + "service": "mdi:surround-sound" + }, + "select_source": { + "service": "mdi:import" + }, + "shuffle_set": { + "service": "mdi:shuffle" + }, + "toggle": { + "service": "mdi:play-pause" + }, + "turn_off": { + "service": "mdi:power" + }, + "turn_on": { + "service": "mdi:power" + }, + "unjoin": { + "service": "mdi:ungroup" + }, + "volume_down": { + "service": "mdi:volume-minus" + }, + "volume_mute": { + "service": "mdi:volume-mute" + }, + "volume_set": { + "service": "mdi:volume-medium" + }, + "volume_up": { + "service": "mdi:volume-plus" + } } } diff --git a/homeassistant/components/melcloud/icons.json b/homeassistant/components/melcloud/icons.json index de3eb3c0ba2c97..b91696b5b357ea 100644 --- a/homeassistant/components/melcloud/icons.json +++ b/homeassistant/components/melcloud/icons.json @@ -7,7 +7,11 @@ } }, "services": { - "set_vane_horizontal": "mdi:arrow-left-right", - "set_vane_vertical": "mdi:arrow-up-down" + "set_vane_horizontal": { + "service": "mdi:arrow-left-right" + }, + "set_vane_vertical": { + "service": "mdi:arrow-up-down" + } } } diff --git a/homeassistant/components/microsoft_face/icons.json b/homeassistant/components/microsoft_face/icons.json index 826e390197a3a7..6e61676224d2bc 100644 --- a/homeassistant/components/microsoft_face/icons.json +++ b/homeassistant/components/microsoft_face/icons.json @@ -1,10 +1,22 @@ { "services": { - "create_group": "mdi:account-multiple-plus", - "create_person": "mdi:account-plus", - "delete_group": "mdi:account-multiple-remove", - "delete_person": "mdi:account-remove", - "face_person": "mdi:face-man", - "train_group": "mdi:account-multiple-check" + "create_group": { + "service": "mdi:account-multiple-plus" + }, + "create_person": { + "service": "mdi:account-plus" + }, + "delete_group": { + "service": "mdi:account-multiple-remove" + }, + "delete_person": { + "service": "mdi:account-remove" + }, + "face_person": { + "service": "mdi:face-man" + }, + "train_group": { + "service": "mdi:account-multiple-check" + } } } diff --git a/homeassistant/components/mill/icons.json b/homeassistant/components/mill/icons.json index 13d6bb650c112a..f2595f28057386 100644 --- a/homeassistant/components/mill/icons.json +++ b/homeassistant/components/mill/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_room_temperature": "mdi:thermometer" + "set_room_temperature": { + "service": "mdi:thermometer" + } } } From 1a2d013c979d9e4b5e788b638408371bb0cbf3ed Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 13:48:01 +0200 Subject: [PATCH 59/67] Update icons.json to new service schema part 3 (#124770) --- homeassistant/components/min_max/icons.json | 4 +- homeassistant/components/minio/icons.json | 12 +++-- homeassistant/components/modbus/icons.json | 20 ++++++-- .../components/modern_forms/icons.json | 16 +++++-- homeassistant/components/monoprice/icons.json | 8 +++- .../components/motion_blinds/icons.json | 4 +- homeassistant/components/motioneye/icons.json | 12 +++-- homeassistant/components/mqtt/icons.json | 12 +++-- homeassistant/components/neato/icons.json | 4 +- .../components/ness_alarm/icons.json | 8 +++- homeassistant/components/netatmo/icons.json | 40 ++++++++++++---- .../components/netgear_lte/icons.json | 16 +++++-- homeassistant/components/nexia/icons.json | 12 +++-- .../components/nissan_leaf/icons.json | 8 +++- homeassistant/components/notify/icons.json | 12 +++-- homeassistant/components/nuki/icons.json | 8 +++- homeassistant/components/number/icons.json | 4 +- homeassistant/components/nws/icons.json | 4 +- homeassistant/components/nx584/icons.json | 8 +++- homeassistant/components/nzbget/icons.json | 12 +++-- homeassistant/components/octoprint/icons.json | 4 +- homeassistant/components/ombi/icons.json | 12 +++-- homeassistant/components/omnilogic/icons.json | 4 +- homeassistant/components/onvif/icons.json | 4 +- .../components/openai_conversation/icons.json | 4 +- homeassistant/components/openhome/icons.json | 4 +- .../components/opentherm_gw/icons.json | 48 ++++++++++++++----- .../persistent_notification/icons.json | 12 +++-- homeassistant/components/person/icons.json | 4 +- homeassistant/components/pi_hole/icons.json | 4 +- homeassistant/components/picnic/icons.json | 4 +- homeassistant/components/pilight/icons.json | 4 +- homeassistant/components/plex/icons.json | 8 +++- homeassistant/components/profiler/icons.json | 48 ++++++++++++++----- homeassistant/components/prosegur/icons.json | 4 +- homeassistant/components/ps4/icons.json | 4 +- .../components/python_script/icons.json | 4 +- .../components/qbittorrent/icons.json | 8 +++- homeassistant/components/qvr_pro/icons.json | 8 +++- homeassistant/components/rachio/icons.json | 24 +++++++--- homeassistant/components/rainbird/icons.json | 8 +++- .../components/rainmachine/icons.json | 44 ++++++++++++----- homeassistant/components/recorder/icons.json | 16 +++++-- .../components/remember_the_milk/icons.json | 8 +++- homeassistant/components/remote/icons.json | 24 +++++++--- homeassistant/components/renault/icons.json | 12 +++-- homeassistant/components/renson/icons.json | 12 +++-- homeassistant/components/reolink/icons.json | 8 +++- homeassistant/components/rest/icons.json | 4 +- .../components/rest_command/icons.json | 4 +- homeassistant/components/rflink/icons.json | 4 +- homeassistant/components/rfxtrx/icons.json | 4 +- homeassistant/components/ring/icons.json | 4 +- homeassistant/components/roborock/icons.json | 4 +- homeassistant/components/roku/icons.json | 4 +- homeassistant/components/roon/icons.json | 4 +- homeassistant/components/route53/icons.json | 4 +- homeassistant/components/sabnzbd/icons.json | 12 +++-- homeassistant/components/scene/icons.json | 20 ++++++-- homeassistant/components/schedule/icons.json | 4 +- .../components/screenlogic/icons.json | 12 +++-- homeassistant/components/script/icons.json | 16 +++++-- homeassistant/components/select/icons.json | 20 ++++++-- homeassistant/components/sensibo/icons.json | 20 ++++++-- .../components/seventeentrack/icons.json | 4 +- homeassistant/components/sharkiq/icons.json | 4 +- .../components/shopping_list/icons.json | 32 +++++++++---- .../components/simplisafe/icons.json | 12 +++-- homeassistant/components/siren/icons.json | 12 +++-- homeassistant/components/smarttub/icons.json | 16 +++++-- 70 files changed, 594 insertions(+), 198 deletions(-) diff --git a/homeassistant/components/min_max/icons.json b/homeassistant/components/min_max/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/min_max/icons.json +++ b/homeassistant/components/min_max/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/minio/icons.json b/homeassistant/components/minio/icons.json index 16deb1a168d50f..dce148a23de663 100644 --- a/homeassistant/components/minio/icons.json +++ b/homeassistant/components/minio/icons.json @@ -1,7 +1,13 @@ { "services": { - "get": "mdi:cloud-download", - "put": "mdi:cloud-upload", - "remove": "mdi:delete" + "get": { + "service": "mdi:cloud-download" + }, + "put": { + "service": "mdi:cloud-upload" + }, + "remove": { + "service": "mdi:delete" + } } } diff --git a/homeassistant/components/modbus/icons.json b/homeassistant/components/modbus/icons.json index eeaeff6403b5dd..05ee76fd44ed96 100644 --- a/homeassistant/components/modbus/icons.json +++ b/homeassistant/components/modbus/icons.json @@ -1,9 +1,19 @@ { "services": { - "reload": "mdi:reload", - "write_coil": "mdi:pencil", - "write_register": "mdi:database-edit", - "stop": "mdi:stop", - "restart": "mdi:restart" + "reload": { + "service": "mdi:reload" + }, + "write_coil": { + "service": "mdi:pencil" + }, + "write_register": { + "service": "mdi:database-edit" + }, + "stop": { + "service": "mdi:stop" + }, + "restart": { + "service": "mdi:restart" + } } } diff --git a/homeassistant/components/modern_forms/icons.json b/homeassistant/components/modern_forms/icons.json index e5df55dc15e5fe..544e48e17f1f9f 100644 --- a/homeassistant/components/modern_forms/icons.json +++ b/homeassistant/components/modern_forms/icons.json @@ -26,9 +26,17 @@ } }, "services": { - "set_light_sleep_timer": "mdi:timer", - "clear_light_sleep_timer": "mdi:timer-cancel", - "set_fan_sleep_timer": "mdi:timer", - "clear_fan_sleep_timer": "mdi:timer-cancel" + "set_light_sleep_timer": { + "service": "mdi:timer" + }, + "clear_light_sleep_timer": { + "service": "mdi:timer-cancel" + }, + "set_fan_sleep_timer": { + "service": "mdi:timer" + }, + "clear_fan_sleep_timer": { + "service": "mdi:timer-cancel" + } } } diff --git a/homeassistant/components/monoprice/icons.json b/homeassistant/components/monoprice/icons.json index 22610cc2a470f2..d560c7bcfa8265 100644 --- a/homeassistant/components/monoprice/icons.json +++ b/homeassistant/components/monoprice/icons.json @@ -1,6 +1,10 @@ { "services": { - "snapshot": "mdi:content-copy", - "restore": "mdi:content-paste" + "snapshot": { + "service": "mdi:content-copy" + }, + "restore": { + "service": "mdi:content-paste" + } } } diff --git a/homeassistant/components/motion_blinds/icons.json b/homeassistant/components/motion_blinds/icons.json index 9e1cd613e5b53d..e50e50130f7ab6 100644 --- a/homeassistant/components/motion_blinds/icons.json +++ b/homeassistant/components/motion_blinds/icons.json @@ -10,6 +10,8 @@ } }, "services": { - "set_absolute_position": "mdi:set-square" + "set_absolute_position": { + "service": "mdi:set-square" + } } } diff --git a/homeassistant/components/motioneye/icons.json b/homeassistant/components/motioneye/icons.json index b0a4ea8dcb149d..7cc93d528e88aa 100644 --- a/homeassistant/components/motioneye/icons.json +++ b/homeassistant/components/motioneye/icons.json @@ -1,7 +1,13 @@ { "services": { - "set_text_overlay": "mdi:text-box-outline", - "action": "mdi:gesture-tap-button", - "snapshot": "mdi:camera" + "set_text_overlay": { + "service": "mdi:text-box-outline" + }, + "action": { + "service": "mdi:gesture-tap-button" + }, + "snapshot": { + "service": "mdi:camera" + } } } diff --git a/homeassistant/components/mqtt/icons.json b/homeassistant/components/mqtt/icons.json index 1979359c5a1261..73cbf22b629b62 100644 --- a/homeassistant/components/mqtt/icons.json +++ b/homeassistant/components/mqtt/icons.json @@ -1,7 +1,13 @@ { "services": { - "publish": "mdi:publish", - "dump": "mdi:database-export", - "reload": "mdi:reload" + "publish": { + "service": "mdi:publish" + }, + "dump": { + "service": "mdi:database-export" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/neato/icons.json b/homeassistant/components/neato/icons.json index ca50d5a9bc7064..eb18a7e3196dc6 100644 --- a/homeassistant/components/neato/icons.json +++ b/homeassistant/components/neato/icons.json @@ -1,5 +1,7 @@ { "services": { - "custom_cleaning": "mdi:broom" + "custom_cleaning": { + "service": "mdi:broom" + } } } diff --git a/homeassistant/components/ness_alarm/icons.json b/homeassistant/components/ness_alarm/icons.json index ea17fd2b299618..29d8ae1c8f5aa0 100644 --- a/homeassistant/components/ness_alarm/icons.json +++ b/homeassistant/components/ness_alarm/icons.json @@ -1,6 +1,10 @@ { "services": { - "aux": "mdi:audio-input-stereo-minijack", - "panic": "mdi:fire" + "aux": { + "service": "mdi:audio-input-stereo-minijack" + }, + "panic": { + "service": "mdi:fire" + } } } diff --git a/homeassistant/components/netatmo/icons.json b/homeassistant/components/netatmo/icons.json index 31b1740ab21fb3..70a51542126252 100644 --- a/homeassistant/components/netatmo/icons.json +++ b/homeassistant/components/netatmo/icons.json @@ -34,15 +34,35 @@ } }, "services": { - "set_camera_light": "mdi:led-on", - "set_schedule": "mdi:calendar-clock", - "set_preset_mode_with_end_datetime": "mdi:calendar-clock", - "set_temperature_with_end_datetime": "mdi:thermometer", - "set_temperature_with_time_period": "mdi:thermometer", - "clear_temperature_setting": "mdi:thermometer", - "set_persons_home": "mdi:home", - "set_person_away": "mdi:walk", - "register_webhook": "mdi:link-variant", - "unregister_webhook": "mdi:link-variant-off" + "set_camera_light": { + "service": "mdi:led-on" + }, + "set_schedule": { + "service": "mdi:calendar-clock" + }, + "set_preset_mode_with_end_datetime": { + "service": "mdi:calendar-clock" + }, + "set_temperature_with_end_datetime": { + "service": "mdi:thermometer" + }, + "set_temperature_with_time_period": { + "service": "mdi:thermometer" + }, + "clear_temperature_setting": { + "service": "mdi:thermometer" + }, + "set_persons_home": { + "service": "mdi:home" + }, + "set_person_away": { + "service": "mdi:walk" + }, + "register_webhook": { + "service": "mdi:link-variant" + }, + "unregister_webhook": { + "service": "mdi:link-variant-off" + } } } diff --git a/homeassistant/components/netgear_lte/icons.json b/homeassistant/components/netgear_lte/icons.json index 543d9bf46903a7..703d330512bf93 100644 --- a/homeassistant/components/netgear_lte/icons.json +++ b/homeassistant/components/netgear_lte/icons.json @@ -31,9 +31,17 @@ } }, "services": { - "delete_sms": "mdi:delete", - "set_option": "mdi:cog", - "connect_lte": "mdi:wifi", - "disconnect_lte": "mdi:wifi-off" + "delete_sms": { + "service": "mdi:delete" + }, + "set_option": { + "service": "mdi:cog" + }, + "connect_lte": { + "service": "mdi:wifi" + }, + "disconnect_lte": { + "service": "mdi:wifi-off" + } } } diff --git a/homeassistant/components/nexia/icons.json b/homeassistant/components/nexia/icons.json index 620d1a42c03218..a2157f5c035179 100644 --- a/homeassistant/components/nexia/icons.json +++ b/homeassistant/components/nexia/icons.json @@ -20,8 +20,14 @@ } }, "services": { - "set_aircleaner_mode": "mdi:air-filter", - "set_humidify_setpoint": "mdi:water-percent", - "set_hvac_run_mode": "mdi:hvac" + "set_aircleaner_mode": { + "service": "mdi:air-filter" + }, + "set_humidify_setpoint": { + "service": "mdi:water-percent" + }, + "set_hvac_run_mode": { + "service": "mdi:hvac" + } } } diff --git a/homeassistant/components/nissan_leaf/icons.json b/homeassistant/components/nissan_leaf/icons.json index 5da03ed5f1a4ec..832fce90c086fb 100644 --- a/homeassistant/components/nissan_leaf/icons.json +++ b/homeassistant/components/nissan_leaf/icons.json @@ -1,6 +1,10 @@ { "services": { - "start_charge": "mdi:flash", - "update": "mdi:update" + "start_charge": { + "service": "mdi:flash" + }, + "update": { + "service": "mdi:update" + } } } diff --git a/homeassistant/components/notify/icons.json b/homeassistant/components/notify/icons.json index ace8ee0c96b47c..e5ab34031f752a 100644 --- a/homeassistant/components/notify/icons.json +++ b/homeassistant/components/notify/icons.json @@ -5,8 +5,14 @@ } }, "services": { - "notify": "mdi:bell-ring", - "persistent_notification": "mdi:bell-badge", - "send_message": "mdi:message-arrow-right" + "notify": { + "service": "mdi:bell-ring" + }, + "persistent_notification": { + "service": "mdi:bell-badge" + }, + "send_message": { + "service": "mdi:message-arrow-right" + } } } diff --git a/homeassistant/components/nuki/icons.json b/homeassistant/components/nuki/icons.json index f74603cb9dc14a..ea1ff9c4fedee4 100644 --- a/homeassistant/components/nuki/icons.json +++ b/homeassistant/components/nuki/icons.json @@ -7,7 +7,11 @@ } }, "services": { - "lock_n_go": "mdi:lock-clock", - "set_continuous_mode": "mdi:bell-cog" + "lock_n_go": { + "service": "mdi:lock-clock" + }, + "set_continuous_mode": { + "service": "mdi:bell-cog" + } } } diff --git a/homeassistant/components/number/icons.json b/homeassistant/components/number/icons.json index d74aa1bf408966..a122aaecb09465 100644 --- a/homeassistant/components/number/icons.json +++ b/homeassistant/components/number/icons.json @@ -149,6 +149,8 @@ } }, "services": { - "set_value": "mdi:numeric" + "set_value": { + "service": "mdi:numeric" + } } } diff --git a/homeassistant/components/nws/icons.json b/homeassistant/components/nws/icons.json index 8f91388a3ef611..2aef3a2e614047 100644 --- a/homeassistant/components/nws/icons.json +++ b/homeassistant/components/nws/icons.json @@ -1,5 +1,7 @@ { "services": { - "get_forecasts_extra": "mdi:weather-cloudy-clock" + "get_forecasts_extra": { + "service": "mdi:weather-cloudy-clock" + } } } diff --git a/homeassistant/components/nx584/icons.json b/homeassistant/components/nx584/icons.json index 76e5ae82e0984a..3bd8e485bfd127 100644 --- a/homeassistant/components/nx584/icons.json +++ b/homeassistant/components/nx584/icons.json @@ -1,6 +1,10 @@ { "services": { - "bypass_zone": "mdi:wrench", - "unbypass_zone": "mdi:wrench" + "bypass_zone": { + "service": "mdi:wrench" + }, + "unbypass_zone": { + "service": "mdi:wrench" + } } } diff --git a/homeassistant/components/nzbget/icons.json b/homeassistant/components/nzbget/icons.json index a693e9fec86d89..ca4f4d584ae1fb 100644 --- a/homeassistant/components/nzbget/icons.json +++ b/homeassistant/components/nzbget/icons.json @@ -1,7 +1,13 @@ { "services": { - "pause": "mdi:pause", - "resume": "mdi:play", - "set_speed": "mdi:speedometer" + "pause": { + "service": "mdi:pause" + }, + "resume": { + "service": "mdi:play" + }, + "set_speed": { + "service": "mdi:speedometer" + } } } diff --git a/homeassistant/components/octoprint/icons.json b/homeassistant/components/octoprint/icons.json index 972ecabb765b09..720718fcedefe5 100644 --- a/homeassistant/components/octoprint/icons.json +++ b/homeassistant/components/octoprint/icons.json @@ -1,5 +1,7 @@ { "services": { - "printer_connect": "mdi:lan-connect" + "printer_connect": { + "service": "mdi:lan-connect" + } } } diff --git a/homeassistant/components/ombi/icons.json b/homeassistant/components/ombi/icons.json index 4b3e32a1e1301d..15b8af56188a7f 100644 --- a/homeassistant/components/ombi/icons.json +++ b/homeassistant/components/ombi/icons.json @@ -1,7 +1,13 @@ { "services": { - "submit_movie_request": "mdi:movie-roll", - "submit_tv_request": "mdi:television-classic", - "submit_music_request": "mdi:music" + "submit_movie_request": { + "service": "mdi:movie-roll" + }, + "submit_tv_request": { + "service": "mdi:television-classic" + }, + "submit_music_request": { + "service": "mdi:music" + } } } diff --git a/homeassistant/components/omnilogic/icons.json b/homeassistant/components/omnilogic/icons.json index ee5b51021779bb..8f0f13fe6522d8 100644 --- a/homeassistant/components/omnilogic/icons.json +++ b/homeassistant/components/omnilogic/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_pump_speed": "mdi:water-pump" + "set_pump_speed": { + "service": "mdi:water-pump" + } } } diff --git a/homeassistant/components/onvif/icons.json b/homeassistant/components/onvif/icons.json index 4db9a9f9e49b2c..d42985d34e8209 100644 --- a/homeassistant/components/onvif/icons.json +++ b/homeassistant/components/onvif/icons.json @@ -13,6 +13,8 @@ } }, "services": { - "ptz": "mdi:pan" + "ptz": { + "service": "mdi:pan" + } } } diff --git a/homeassistant/components/openai_conversation/icons.json b/homeassistant/components/openai_conversation/icons.json index 7f736a5ff3b2f1..3abecd640d18ee 100644 --- a/homeassistant/components/openai_conversation/icons.json +++ b/homeassistant/components/openai_conversation/icons.json @@ -1,5 +1,7 @@ { "services": { - "generate_image": "mdi:image-sync" + "generate_image": { + "service": "mdi:image-sync" + } } } diff --git a/homeassistant/components/openhome/icons.json b/homeassistant/components/openhome/icons.json index 081e97c3489ccf..d75659f17daa3c 100644 --- a/homeassistant/components/openhome/icons.json +++ b/homeassistant/components/openhome/icons.json @@ -1,5 +1,7 @@ { "services": { - "invoke_pin": "mdi:alarm-panel" + "invoke_pin": { + "service": "mdi:alarm-panel" + } } } diff --git a/homeassistant/components/opentherm_gw/icons.json b/homeassistant/components/opentherm_gw/icons.json index 13dbe0a70a1792..37942aa0e63d0a 100644 --- a/homeassistant/components/opentherm_gw/icons.json +++ b/homeassistant/components/opentherm_gw/icons.json @@ -1,16 +1,40 @@ { "services": { - "reset_gateway": "mdi:reload", - "set_central_heating_ovrd": "mdi:heat-wave", - "set_clock": "mdi:clock", - "set_control_setpoint": "mdi:thermometer-lines", - "set_hot_water_ovrd": "mdi:thermometer-lines", - "set_hot_water_setpoint": "mdi:thermometer-lines", - "set_gpio_mode": "mdi:cable-data", - "set_led_mode": "mdi:led-on", - "set_max_modulation": "mdi:thermometer-lines", - "set_outside_temperature": "mdi:thermometer-lines", - "set_setback_temperature": "mdi:thermometer-lines", - "send_transparent_command": "mdi:console" + "reset_gateway": { + "service": "mdi:reload" + }, + "set_central_heating_ovrd": { + "service": "mdi:heat-wave" + }, + "set_clock": { + "service": "mdi:clock" + }, + "set_control_setpoint": { + "service": "mdi:thermometer-lines" + }, + "set_hot_water_ovrd": { + "service": "mdi:thermometer-lines" + }, + "set_hot_water_setpoint": { + "service": "mdi:thermometer-lines" + }, + "set_gpio_mode": { + "service": "mdi:cable-data" + }, + "set_led_mode": { + "service": "mdi:led-on" + }, + "set_max_modulation": { + "service": "mdi:thermometer-lines" + }, + "set_outside_temperature": { + "service": "mdi:thermometer-lines" + }, + "set_setback_temperature": { + "service": "mdi:thermometer-lines" + }, + "send_transparent_command": { + "service": "mdi:console" + } } } diff --git a/homeassistant/components/persistent_notification/icons.json b/homeassistant/components/persistent_notification/icons.json index 9c782bd7b21b0f..30847357a47e78 100644 --- a/homeassistant/components/persistent_notification/icons.json +++ b/homeassistant/components/persistent_notification/icons.json @@ -1,7 +1,13 @@ { "services": { - "create": "mdi:message-badge", - "dismiss": "mdi:bell-off", - "dismiss_all": "mdi:notification-clear-all" + "create": { + "service": "mdi:message-badge" + }, + "dismiss": { + "service": "mdi:bell-off" + }, + "dismiss_all": { + "service": "mdi:notification-clear-all" + } } } diff --git a/homeassistant/components/person/icons.json b/homeassistant/components/person/icons.json index fbfd5be75d2e59..f645d9c20905fc 100644 --- a/homeassistant/components/person/icons.json +++ b/homeassistant/components/person/icons.json @@ -8,6 +8,8 @@ } }, "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/pi_hole/icons.json b/homeassistant/components/pi_hole/icons.json index 58f20da5a2d9cd..3a45f8ab4544be 100644 --- a/homeassistant/components/pi_hole/icons.json +++ b/homeassistant/components/pi_hole/icons.json @@ -36,6 +36,8 @@ } }, "services": { - "disable": "mdi:server-off" + "disable": { + "service": "mdi:server-off" + } } } diff --git a/homeassistant/components/picnic/icons.json b/homeassistant/components/picnic/icons.json index d8f99153f330a8..78803b6d263b50 100644 --- a/homeassistant/components/picnic/icons.json +++ b/homeassistant/components/picnic/icons.json @@ -57,6 +57,8 @@ } }, "services": { - "add_product": "mdi:cart-plus" + "add_product": { + "service": "mdi:cart-plus" + } } } diff --git a/homeassistant/components/pilight/icons.json b/homeassistant/components/pilight/icons.json index c1b8e741e4536c..cbc48cf2105355 100644 --- a/homeassistant/components/pilight/icons.json +++ b/homeassistant/components/pilight/icons.json @@ -1,5 +1,7 @@ { "services": { - "send": "mdi:send" + "send": { + "service": "mdi:send" + } } } diff --git a/homeassistant/components/plex/icons.json b/homeassistant/components/plex/icons.json index 03bc835d2f60a2..2d3a7342ad2882 100644 --- a/homeassistant/components/plex/icons.json +++ b/homeassistant/components/plex/icons.json @@ -7,7 +7,11 @@ } }, "services": { - "refresh_library": "mdi:refresh", - "scan_for_clients": "mdi:database-refresh" + "refresh_library": { + "service": "mdi:refresh" + }, + "scan_for_clients": { + "service": "mdi:database-refresh" + } } } diff --git a/homeassistant/components/profiler/icons.json b/homeassistant/components/profiler/icons.json index 4dda003c186db3..c1f996b6eb15ce 100644 --- a/homeassistant/components/profiler/icons.json +++ b/homeassistant/components/profiler/icons.json @@ -1,16 +1,40 @@ { "services": { - "start": "mdi:play", - "memory": "mdi:memory", - "start_log_objects": "mdi:invoice-text-plus", - "stop_log_objects": "mdi:invoice-text-remove", - "dump_log_objects": "mdi:invoice-export-outline", - "start_log_object_sources": "mdi:play", - "stop_log_object_sources": "mdi:stop", - "lru_stats": "mdi:chart-areaspline", - "log_current_tasks": "mdi:format-list-bulleted", - "log_thread_frames": "mdi:format-list-bulleted", - "log_event_loop_scheduled": "mdi:calendar-clock", - "set_asyncio_debug": "mdi:bug-check" + "start": { + "service": "mdi:play" + }, + "memory": { + "service": "mdi:memory" + }, + "start_log_objects": { + "service": "mdi:invoice-text-plus" + }, + "stop_log_objects": { + "service": "mdi:invoice-text-remove" + }, + "dump_log_objects": { + "service": "mdi:invoice-export-outline" + }, + "start_log_object_sources": { + "service": "mdi:play" + }, + "stop_log_object_sources": { + "service": "mdi:stop" + }, + "lru_stats": { + "service": "mdi:chart-areaspline" + }, + "log_current_tasks": { + "service": "mdi:format-list-bulleted" + }, + "log_thread_frames": { + "service": "mdi:format-list-bulleted" + }, + "log_event_loop_scheduled": { + "service": "mdi:calendar-clock" + }, + "set_asyncio_debug": { + "service": "mdi:bug-check" + } } } diff --git a/homeassistant/components/prosegur/icons.json b/homeassistant/components/prosegur/icons.json index 33cddefdaea341..8f175ab905678f 100644 --- a/homeassistant/components/prosegur/icons.json +++ b/homeassistant/components/prosegur/icons.json @@ -1,5 +1,7 @@ { "services": { - "request_image": "mdi:image-sync" + "request_image": { + "service": "mdi:image-sync" + } } } diff --git a/homeassistant/components/ps4/icons.json b/homeassistant/components/ps4/icons.json index 8da5909213b0fd..21f8405f8161fb 100644 --- a/homeassistant/components/ps4/icons.json +++ b/homeassistant/components/ps4/icons.json @@ -7,6 +7,8 @@ } }, "services": { - "send_command": "mdi:console" + "send_command": { + "service": "mdi:console" + } } } diff --git a/homeassistant/components/python_script/icons.json b/homeassistant/components/python_script/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/python_script/icons.json +++ b/homeassistant/components/python_script/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/qbittorrent/icons.json b/homeassistant/components/qbittorrent/icons.json index 68fc1020daec74..cede127ebe8b20 100644 --- a/homeassistant/components/qbittorrent/icons.json +++ b/homeassistant/components/qbittorrent/icons.json @@ -10,7 +10,11 @@ } }, "services": { - "get_torrents": "mdi:file-arrow-up-down-outline", - "get_all_torrents": "mdi:file-arrow-up-down-outline" + "get_torrents": { + "service": "mdi:file-arrow-up-down-outline" + }, + "get_all_torrents": { + "service": "mdi:file-arrow-up-down-outline" + } } } diff --git a/homeassistant/components/qvr_pro/icons.json b/homeassistant/components/qvr_pro/icons.json index 556a8d40752bb2..3b57387d2517d2 100644 --- a/homeassistant/components/qvr_pro/icons.json +++ b/homeassistant/components/qvr_pro/icons.json @@ -1,6 +1,10 @@ { "services": { - "start_record": "mdi:record-rec", - "stop_record": "mdi:stop" + "start_record": { + "service": "mdi:record-rec" + }, + "stop_record": { + "service": "mdi:stop" + } } } diff --git a/homeassistant/components/rachio/icons.json b/homeassistant/components/rachio/icons.json index dfab8788fc8b00..df30929ab4c2a4 100644 --- a/homeassistant/components/rachio/icons.json +++ b/homeassistant/components/rachio/icons.json @@ -10,11 +10,23 @@ } }, "services": { - "set_zone_moisture_percent": "mdi:water-percent", - "start_multiple_zone_schedule": "mdi:play", - "pause_watering": "mdi:pause", - "resume_watering": "mdi:play", - "stop_watering": "mdi:stop", - "start_watering": "mdi:water" + "set_zone_moisture_percent": { + "service": "mdi:water-percent" + }, + "start_multiple_zone_schedule": { + "service": "mdi:play" + }, + "pause_watering": { + "service": "mdi:pause" + }, + "resume_watering": { + "service": "mdi:play" + }, + "stop_watering": { + "service": "mdi:stop" + }, + "start_watering": { + "service": "mdi:water" + } } } diff --git a/homeassistant/components/rainbird/icons.json b/homeassistant/components/rainbird/icons.json index 79d2256f184994..61c09f74e88cae 100644 --- a/homeassistant/components/rainbird/icons.json +++ b/homeassistant/components/rainbird/icons.json @@ -22,7 +22,11 @@ } }, "services": { - "start_irrigation": "mdi:water", - "set_rain_delay": "mdi:water-sync" + "start_irrigation": { + "service": "mdi:water" + }, + "set_rain_delay": { + "service": "mdi:water-sync" + } } } diff --git a/homeassistant/components/rainmachine/icons.json b/homeassistant/components/rainmachine/icons.json index 32988081a18edb..ca85d81346efc1 100644 --- a/homeassistant/components/rainmachine/icons.json +++ b/homeassistant/components/rainmachine/icons.json @@ -70,16 +70,38 @@ } }, "services": { - "pause_watering": "mdi:pause", - "restrict_watering": "mdi:cancel", - "start_program": "mdi:play", - "start_zone": "mdi:play", - "stop_all": "mdi:stop", - "stop_program": "mdi:stop", - "stop_zone": "mdi:stop", - "unpause_watering": "mdi:play-pause", - "push_flow_meter_data": "mdi:database-arrow-up", - "push_weather_data": "mdi:database-arrow-up", - "unrestrict_watering": "mdi:check" + "pause_watering": { + "service": "mdi:pause" + }, + "restrict_watering": { + "service": "mdi:cancel" + }, + "start_program": { + "service": "mdi:play" + }, + "start_zone": { + "service": "mdi:play" + }, + "stop_all": { + "service": "mdi:stop" + }, + "stop_program": { + "service": "mdi:stop" + }, + "stop_zone": { + "service": "mdi:stop" + }, + "unpause_watering": { + "service": "mdi:play-pause" + }, + "push_flow_meter_data": { + "service": "mdi:database-arrow-up" + }, + "push_weather_data": { + "service": "mdi:database-arrow-up" + }, + "unrestrict_watering": { + "service": "mdi:check" + } } } diff --git a/homeassistant/components/recorder/icons.json b/homeassistant/components/recorder/icons.json index 1090401abd598e..9e41637184a2b2 100644 --- a/homeassistant/components/recorder/icons.json +++ b/homeassistant/components/recorder/icons.json @@ -1,8 +1,16 @@ { "services": { - "purge": "mdi:database-sync", - "purge_entities": "mdi:database-sync", - "disable": "mdi:database-off", - "enable": "mdi:database" + "purge": { + "service": "mdi:database-sync" + }, + "purge_entities": { + "service": "mdi:database-sync" + }, + "disable": { + "service": "mdi:database-off" + }, + "enable": { + "service": "mdi:database" + } } } diff --git a/homeassistant/components/remember_the_milk/icons.json b/homeassistant/components/remember_the_milk/icons.json index 3ca17113fb8b62..04502aea5ef578 100644 --- a/homeassistant/components/remember_the_milk/icons.json +++ b/homeassistant/components/remember_the_milk/icons.json @@ -1,6 +1,10 @@ { "services": { - "create_task": "mdi:check", - "complete_task": "mdi:check-all" + "create_task": { + "service": "mdi:check" + }, + "complete_task": { + "service": "mdi:check-all" + } } } diff --git a/homeassistant/components/remote/icons.json b/homeassistant/components/remote/icons.json index 07526a4bc7942a..43a7f6ee7b659f 100644 --- a/homeassistant/components/remote/icons.json +++ b/homeassistant/components/remote/icons.json @@ -8,11 +8,23 @@ } }, "services": { - "delete_command": "mdi:delete", - "learn_command": "mdi:school", - "send_command": "mdi:remote", - "toggle": "mdi:remote", - "turn_off": "mdi:remote-off", - "turn_on": "mdi:remote" + "delete_command": { + "service": "mdi:delete" + }, + "learn_command": { + "service": "mdi:school" + }, + "send_command": { + "service": "mdi:remote" + }, + "toggle": { + "service": "mdi:remote" + }, + "turn_off": { + "service": "mdi:remote-off" + }, + "turn_on": { + "service": "mdi:remote" + } } } diff --git a/homeassistant/components/renault/icons.json b/homeassistant/components/renault/icons.json index 75356fda411290..883725eb601915 100644 --- a/homeassistant/components/renault/icons.json +++ b/homeassistant/components/renault/icons.json @@ -64,8 +64,14 @@ } }, "services": { - "ac_start": "mdi:hvac", - "ac_cancel": "mdi:hvac-off", - "charge_set_schedules": "mdi:calendar-clock" + "ac_start": { + "service": "mdi:hvac" + }, + "ac_cancel": { + "service": "mdi:hvac-off" + }, + "charge_set_schedules": { + "service": "mdi:calendar-clock" + } } } diff --git a/homeassistant/components/renson/icons.json b/homeassistant/components/renson/icons.json index b7b1fdfdd8cbf3..b558759a0dd612 100644 --- a/homeassistant/components/renson/icons.json +++ b/homeassistant/components/renson/icons.json @@ -17,8 +17,14 @@ } }, "services": { - "set_timer_level": "mdi:timer", - "set_breeze": "mdi:weather-windy", - "set_pollution_settings": "mdi:air-filter" + "set_timer_level": { + "service": "mdi:timer" + }, + "set_breeze": { + "service": "mdi:weather-windy" + }, + "set_pollution_settings": { + "service": "mdi:air-filter" + } } } diff --git a/homeassistant/components/reolink/icons.json b/homeassistant/components/reolink/icons.json index f7729789c4e16d..f1c6f88a0f007e 100644 --- a/homeassistant/components/reolink/icons.json +++ b/homeassistant/components/reolink/icons.json @@ -300,7 +300,11 @@ } }, "services": { - "ptz_move": "mdi:pan", - "play_chime": "mdi:music" + "ptz_move": { + "service": "mdi:pan" + }, + "play_chime": { + "service": "mdi:music" + } } } diff --git a/homeassistant/components/rest/icons.json b/homeassistant/components/rest/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/rest/icons.json +++ b/homeassistant/components/rest/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/rest_command/icons.json b/homeassistant/components/rest_command/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/rest_command/icons.json +++ b/homeassistant/components/rest_command/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/rflink/icons.json b/homeassistant/components/rflink/icons.json index 988b048eee7e00..de2942f44ac8b3 100644 --- a/homeassistant/components/rflink/icons.json +++ b/homeassistant/components/rflink/icons.json @@ -1,5 +1,7 @@ { "services": { - "send_command": "mdi:send" + "send_command": { + "service": "mdi:send" + } } } diff --git a/homeassistant/components/rfxtrx/icons.json b/homeassistant/components/rfxtrx/icons.json index c1b8e741e4536c..cbc48cf2105355 100644 --- a/homeassistant/components/rfxtrx/icons.json +++ b/homeassistant/components/rfxtrx/icons.json @@ -1,5 +1,7 @@ { "services": { - "send": "mdi:send" + "send": { + "service": "mdi:send" + } } } diff --git a/homeassistant/components/ring/icons.json b/homeassistant/components/ring/icons.json index 9dd31fd0fd1443..5820fbf77c82d7 100644 --- a/homeassistant/components/ring/icons.json +++ b/homeassistant/components/ring/icons.json @@ -39,6 +39,8 @@ } }, "services": { - "update": "mdi:refresh" + "update": { + "service": "mdi:refresh" + } } } diff --git a/homeassistant/components/roborock/icons.json b/homeassistant/components/roborock/icons.json index 6a615ab82a1a47..c7df6d35460b58 100644 --- a/homeassistant/components/roborock/icons.json +++ b/homeassistant/components/roborock/icons.json @@ -119,6 +119,8 @@ } }, "services": { - "get_maps": "mdi:floor-plan" + "get_maps": { + "service": "mdi:floor-plan" + } } } diff --git a/homeassistant/components/roku/icons.json b/homeassistant/components/roku/icons.json index 02e5d1e56989df..355b5a715e5013 100644 --- a/homeassistant/components/roku/icons.json +++ b/homeassistant/components/roku/icons.json @@ -32,6 +32,8 @@ } }, "services": { - "search": "mdi:magnify" + "search": { + "service": "mdi:magnify" + } } } diff --git a/homeassistant/components/roon/icons.json b/homeassistant/components/roon/icons.json index 571ca3f45a21bb..1e1dd42b765d1b 100644 --- a/homeassistant/components/roon/icons.json +++ b/homeassistant/components/roon/icons.json @@ -1,5 +1,7 @@ { "services": { - "transfer": "mdi:monitor-multiple" + "transfer": { + "service": "mdi:monitor-multiple" + } } } diff --git a/homeassistant/components/route53/icons.json b/homeassistant/components/route53/icons.json index 30a854991f0093..5afe13ce9499c1 100644 --- a/homeassistant/components/route53/icons.json +++ b/homeassistant/components/route53/icons.json @@ -1,5 +1,7 @@ { "services": { - "update_records": "mdi:database-refresh" + "update_records": { + "service": "mdi:database-refresh" + } } } diff --git a/homeassistant/components/sabnzbd/icons.json b/homeassistant/components/sabnzbd/icons.json index a693e9fec86d89..ca4f4d584ae1fb 100644 --- a/homeassistant/components/sabnzbd/icons.json +++ b/homeassistant/components/sabnzbd/icons.json @@ -1,7 +1,13 @@ { "services": { - "pause": "mdi:pause", - "resume": "mdi:play", - "set_speed": "mdi:speedometer" + "pause": { + "service": "mdi:pause" + }, + "resume": { + "service": "mdi:play" + }, + "set_speed": { + "service": "mdi:speedometer" + } } } diff --git a/homeassistant/components/scene/icons.json b/homeassistant/components/scene/icons.json index 563c0f31ddcd79..b08d06fb43472a 100644 --- a/homeassistant/components/scene/icons.json +++ b/homeassistant/components/scene/icons.json @@ -5,10 +5,20 @@ } }, "services": { - "turn_on": "mdi:power", - "reload": "mdi:reload", - "apply": "mdi:check", - "create": "mdi:plus", - "delete": "mdi:delete" + "turn_on": { + "service": "mdi:power" + }, + "reload": { + "service": "mdi:reload" + }, + "apply": { + "service": "mdi:check" + }, + "create": { + "service": "mdi:plus" + }, + "delete": { + "service": "mdi:delete" + } } } diff --git a/homeassistant/components/schedule/icons.json b/homeassistant/components/schedule/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/schedule/icons.json +++ b/homeassistant/components/schedule/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/screenlogic/icons.json b/homeassistant/components/screenlogic/icons.json index d8d021c20e62e1..ef8dc46f61d61a 100644 --- a/homeassistant/components/screenlogic/icons.json +++ b/homeassistant/components/screenlogic/icons.json @@ -1,7 +1,13 @@ { "services": { - "set_color_mode": "mdi:palette", - "start_super_chlorination": "mdi:pool", - "stop_super_chlorination": "mdi:pool" + "set_color_mode": { + "service": "mdi:palette" + }, + "start_super_chlorination": { + "service": "mdi:pool" + }, + "stop_super_chlorination": { + "service": "mdi:pool" + } } } diff --git a/homeassistant/components/script/icons.json b/homeassistant/components/script/icons.json index d253d0fd829902..7e160941c0581d 100644 --- a/homeassistant/components/script/icons.json +++ b/homeassistant/components/script/icons.json @@ -8,9 +8,17 @@ } }, "services": { - "reload": "mdi:reload", - "turn_on": "mdi:script-text-play", - "turn_off": "mdi:script-text", - "toggle": "mdi:script-text" + "reload": { + "service": "mdi:reload" + }, + "turn_on": { + "service": "mdi:script-text-play" + }, + "turn_off": { + "service": "mdi:script-text" + }, + "toggle": { + "service": "mdi:script-text" + } } } diff --git a/homeassistant/components/select/icons.json b/homeassistant/components/select/icons.json index 1b440d2a1defbe..fbd1d4568f1072 100644 --- a/homeassistant/components/select/icons.json +++ b/homeassistant/components/select/icons.json @@ -5,10 +5,20 @@ } }, "services": { - "select_first": "mdi:format-list-bulleted", - "select_last": "mdi:format-list-bulleted", - "select_next": "mdi:format-list-bulleted", - "select_option": "mdi:format-list-bulleted", - "select_previous": "mdi:format-list-bulleted" + "select_first": { + "service": "mdi:format-list-bulleted" + }, + "select_last": { + "service": "mdi:format-list-bulleted" + }, + "select_next": { + "service": "mdi:format-list-bulleted" + }, + "select_option": { + "service": "mdi:format-list-bulleted" + }, + "select_previous": { + "service": "mdi:format-list-bulleted" + } } } diff --git a/homeassistant/components/sensibo/icons.json b/homeassistant/components/sensibo/icons.json index e26840e48eb4cb..ccab3c198d2c0c 100644 --- a/homeassistant/components/sensibo/icons.json +++ b/homeassistant/components/sensibo/icons.json @@ -45,10 +45,20 @@ } }, "services": { - "assume_state": "mdi:shape-outline", - "enable_timer": "mdi:timer-play", - "enable_pure_boost": "mdi:air-filter", - "full_state": "mdi:shape", - "enable_climate_react": "mdi:wizard-hat" + "assume_state": { + "service": "mdi:shape-outline" + }, + "enable_timer": { + "service": "mdi:timer-play" + }, + "enable_pure_boost": { + "service": "mdi:air-filter" + }, + "full_state": { + "service": "mdi:shape" + }, + "enable_climate_react": { + "service": "mdi:wizard-hat" + } } } diff --git a/homeassistant/components/seventeentrack/icons.json b/homeassistant/components/seventeentrack/icons.json index 78ca65edc4d7a6..94ca8cd535a240 100644 --- a/homeassistant/components/seventeentrack/icons.json +++ b/homeassistant/components/seventeentrack/icons.json @@ -28,6 +28,8 @@ } }, "services": { - "get_packages": "mdi:package" + "get_packages": { + "service": "mdi:package" + } } } diff --git a/homeassistant/components/sharkiq/icons.json b/homeassistant/components/sharkiq/icons.json index 13fd58ce66d4d7..e58a317f5034f7 100644 --- a/homeassistant/components/sharkiq/icons.json +++ b/homeassistant/components/sharkiq/icons.json @@ -1,5 +1,7 @@ { "services": { - "clean_room": "mdi:robot-vacuum" + "clean_room": { + "service": "mdi:robot-vacuum" + } } } diff --git a/homeassistant/components/shopping_list/icons.json b/homeassistant/components/shopping_list/icons.json index 7de3eb1b948b2a..9b3d8a08a79beb 100644 --- a/homeassistant/components/shopping_list/icons.json +++ b/homeassistant/components/shopping_list/icons.json @@ -7,13 +7,29 @@ } }, "services": { - "add_item": "mdi:cart-plus", - "remove_item": "mdi:cart-remove", - "complete_item": "mdi:cart-check", - "incomplete_item": "mdi:cart-off", - "complete_all": "mdi:cart-check", - "incomplete_all": "mdi:cart-off", - "clear_completed_items": "mdi:cart-remove", - "sort": "mdi:sort" + "add_item": { + "service": "mdi:cart-plus" + }, + "remove_item": { + "service": "mdi:cart-remove" + }, + "complete_item": { + "service": "mdi:cart-check" + }, + "incomplete_item": { + "service": "mdi:cart-off" + }, + "complete_all": { + "service": "mdi:cart-check" + }, + "incomplete_all": { + "service": "mdi:cart-off" + }, + "clear_completed_items": { + "service": "mdi:cart-remove" + }, + "sort": { + "service": "mdi:sort" + } } } diff --git a/homeassistant/components/simplisafe/icons.json b/homeassistant/components/simplisafe/icons.json index 60ddb7f09824c0..8552993210f9f9 100644 --- a/homeassistant/components/simplisafe/icons.json +++ b/homeassistant/components/simplisafe/icons.json @@ -1,7 +1,13 @@ { "services": { - "remove_pin": "mdi:alarm-panel-outline", - "set_pin": "mdi:alarm-panel", - "set_system_properties": "mdi:cog" + "remove_pin": { + "service": "mdi:alarm-panel-outline" + }, + "set_pin": { + "service": "mdi:alarm-panel" + }, + "set_system_properties": { + "service": "mdi:cog" + } } } diff --git a/homeassistant/components/siren/icons.json b/homeassistant/components/siren/icons.json index 0083a2540c702f..75caf6417da2f0 100644 --- a/homeassistant/components/siren/icons.json +++ b/homeassistant/components/siren/icons.json @@ -5,8 +5,14 @@ } }, "services": { - "toggle": "mdi:bullhorn", - "turn_off": "mdi:bullhorn", - "turn_on": "mdi:bullhorn" + "toggle": { + "service": "mdi:bullhorn" + }, + "turn_off": { + "service": "mdi:bullhorn" + }, + "turn_on": { + "service": "mdi:bullhorn" + } } } diff --git a/homeassistant/components/smarttub/icons.json b/homeassistant/components/smarttub/icons.json index 7ae96d03383a7a..2b89445754ca63 100644 --- a/homeassistant/components/smarttub/icons.json +++ b/homeassistant/components/smarttub/icons.json @@ -1,8 +1,16 @@ { "services": { - "set_primary_filtration": "mdi:filter", - "set_secondary_filtration": "mdi:filter-multiple", - "snooze_reminder": "mdi:timer-pause", - "reset_reminder": "mdi:timer-sync" + "set_primary_filtration": { + "service": "mdi:filter" + }, + "set_secondary_filtration": { + "service": "mdi:filter-multiple" + }, + "snooze_reminder": { + "service": "mdi:timer-pause" + }, + "reset_reminder": { + "service": "mdi:timer-sync" + } } } From 38ef216894a125f6eca79f4fcef85cb41bed9c4a Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 13:48:13 +0200 Subject: [PATCH 60/67] Update icons.json to new service schema part 4 (#124771) --- homeassistant/components/smtp/icons.json | 4 +- homeassistant/components/snapcast/icons.json | 20 +++- homeassistant/components/snips/icons.json | 16 +++- homeassistant/components/snooz/icons.json | 8 +- homeassistant/components/songpal/icons.json | 4 +- homeassistant/components/sonos/icons.json | 28 ++++-- .../components/soundtouch/icons.json | 16 +++- .../components/squeezebox/icons.json | 16 +++- homeassistant/components/starline/icons.json | 12 ++- .../components/statistics/icons.json | 4 +- .../components/streamlabswater/icons.json | 4 +- homeassistant/components/subaru/icons.json | 4 +- .../components/surepetcare/icons.json | 8 +- .../swiss_public_transport/icons.json | 4 +- homeassistant/components/switch/icons.json | 12 ++- .../components/switcher_kis/icons.json | 8 +- .../components/synology_dsm/icons.json | 8 +- .../components/system_bridge/icons.json | 28 ++++-- .../components/system_log/icons.json | 8 +- homeassistant/components/tado/icons.json | 16 +++- homeassistant/components/telegram/icons.json | 4 +- .../components/telegram_bot/icons.json | 56 ++++++++--- homeassistant/components/template/icons.json | 4 +- .../components/teslemetry/icons.json | 25 +++-- homeassistant/components/text/icons.json | 4 +- homeassistant/components/tibber/icons.json | 4 +- homeassistant/components/time/icons.json | 4 +- homeassistant/components/timer/icons.json | 24 +++-- homeassistant/components/todo/icons.json | 20 +++- homeassistant/components/todoist/icons.json | 4 +- homeassistant/components/toon/icons.json | 4 +- .../components/totalconnect/icons.json | 8 +- homeassistant/components/tplink/icons.json | 8 +- .../components/transmission/icons.json | 16 +++- homeassistant/components/trend/icons.json | 4 +- homeassistant/components/tts/icons.json | 12 ++- homeassistant/components/unifi/icons.json | 8 +- .../components/unifiprotect/icons.json | 16 +++- homeassistant/components/universal/icons.json | 4 +- homeassistant/components/upb/icons.json | 32 +++++-- homeassistant/components/update/icons.json | 12 ++- .../components/utility_meter/icons.json | 8 +- homeassistant/components/vacuum/icons.json | 48 +++++++--- homeassistant/components/vallox/icons.json | 12 ++- homeassistant/components/valve/icons.json | 20 +++- homeassistant/components/velbus/icons.json | 16 +++- homeassistant/components/velux/icons.json | 4 +- homeassistant/components/verisure/icons.json | 12 ++- homeassistant/components/vesync/icons.json | 4 +- homeassistant/components/vicare/icons.json | 4 +- homeassistant/components/vizio/icons.json | 4 +- .../components/wake_on_lan/icons.json | 4 +- .../components/water_heater/icons.json | 20 +++- .../components/waze_travel_time/icons.json | 4 +- homeassistant/components/weather/icons.json | 8 +- homeassistant/components/webostv/icons.json | 12 ++- homeassistant/components/wemo/icons.json | 8 +- homeassistant/components/wilight/icons.json | 12 ++- homeassistant/components/workday/icons.json | 4 +- .../components/xiaomi_aqara/icons.json | 16 +++- .../components/xiaomi_miio/icons.json | 96 ++++++++++++++----- homeassistant/components/yamaha/icons.json | 12 ++- homeassistant/components/yardian/icons.json | 4 +- homeassistant/components/yeelight/icons.json | 32 +++++-- homeassistant/components/yolink/icons.json | 4 +- homeassistant/components/zha/icons.json | 48 +++++++--- homeassistant/components/zone/icons.json | 4 +- .../components/zoneminder/icons.json | 4 +- homeassistant/components/zwave_js/icons.json | 48 +++++++--- 69 files changed, 729 insertions(+), 244 deletions(-) diff --git a/homeassistant/components/smtp/icons.json b/homeassistant/components/smtp/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/smtp/icons.json +++ b/homeassistant/components/smtp/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/snapcast/icons.json b/homeassistant/components/snapcast/icons.json index bdc20665282404..d6511d768e2ddd 100644 --- a/homeassistant/components/snapcast/icons.json +++ b/homeassistant/components/snapcast/icons.json @@ -1,9 +1,19 @@ { "services": { - "join": "mdi:music-note-plus", - "unjoin": "mdi:music-note-minus", - "snapshot": "mdi:camera", - "restore": "mdi:camera-retake", - "set_latency": "mdi:camera-timer" + "join": { + "service": "mdi:music-note-plus" + }, + "unjoin": { + "service": "mdi:music-note-minus" + }, + "snapshot": { + "service": "mdi:camera" + }, + "restore": { + "service": "mdi:camera-retake" + }, + "set_latency": { + "service": "mdi:camera-timer" + } } } diff --git a/homeassistant/components/snips/icons.json b/homeassistant/components/snips/icons.json index 0d465465fe4d3e..9c86a7ad5b36a0 100644 --- a/homeassistant/components/snips/icons.json +++ b/homeassistant/components/snips/icons.json @@ -1,8 +1,16 @@ { "services": { - "feedback_off": "mdi:message-alert", - "feedback_on": "mdi:message-alert", - "say": "mdi:chat", - "say_action": "mdi:account-voice" + "feedback_off": { + "service": "mdi:message-alert" + }, + "feedback_on": { + "service": "mdi:message-alert" + }, + "say": { + "service": "mdi:chat" + }, + "say_action": { + "service": "mdi:account-voice" + } } } diff --git a/homeassistant/components/snooz/icons.json b/homeassistant/components/snooz/icons.json index d9cccfff4eab90..be7d2714a2093a 100644 --- a/homeassistant/components/snooz/icons.json +++ b/homeassistant/components/snooz/icons.json @@ -1,6 +1,10 @@ { "services": { - "transition_on": "mdi:blur", - "transition_off": "mdi:blur-off" + "transition_on": { + "service": "mdi:blur" + }, + "transition_off": { + "service": "mdi:blur-off" + } } } diff --git a/homeassistant/components/songpal/icons.json b/homeassistant/components/songpal/icons.json index 1c831fbbd008b6..6e7cf359c238b0 100644 --- a/homeassistant/components/songpal/icons.json +++ b/homeassistant/components/songpal/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_sound_setting": "mdi:volume-high" + "set_sound_setting": { + "service": "mdi:volume-high" + } } } diff --git a/homeassistant/components/sonos/icons.json b/homeassistant/components/sonos/icons.json index e2545358ba6e09..e7403b454533f5 100644 --- a/homeassistant/components/sonos/icons.json +++ b/homeassistant/components/sonos/icons.json @@ -44,12 +44,26 @@ } }, "services": { - "snapshot": "mdi:camera", - "restore": "mdi:camera-retake", - "set_sleep_timer": "mdi:alarm", - "clear_sleep_timer": "mdi:alarm-off", - "play_queue": "mdi:play", - "remove_from_queue": "mdi:playlist-remove", - "update_alarm": "mdi:alarm" + "snapshot": { + "service": "mdi:camera" + }, + "restore": { + "service": "mdi:camera-retake" + }, + "set_sleep_timer": { + "service": "mdi:alarm" + }, + "clear_sleep_timer": { + "service": "mdi:alarm-off" + }, + "play_queue": { + "service": "mdi:play" + }, + "remove_from_queue": { + "service": "mdi:playlist-remove" + }, + "update_alarm": { + "service": "mdi:alarm" + } } } diff --git a/homeassistant/components/soundtouch/icons.json b/homeassistant/components/soundtouch/icons.json index 0dd41f4f881a9d..721a5c77032d6f 100644 --- a/homeassistant/components/soundtouch/icons.json +++ b/homeassistant/components/soundtouch/icons.json @@ -1,8 +1,16 @@ { "services": { - "play_everywhere": "mdi:play", - "create_zone": "mdi:plus", - "add_zone_slave": "mdi:plus", - "remove_zone_slave": "mdi:minus" + "play_everywhere": { + "service": "mdi:play" + }, + "create_zone": { + "service": "mdi:plus" + }, + "add_zone_slave": { + "service": "mdi:plus" + }, + "remove_zone_slave": { + "service": "mdi:minus" + } } } diff --git a/homeassistant/components/squeezebox/icons.json b/homeassistant/components/squeezebox/icons.json index d58f0d5634d866..b11311e1292cff 100644 --- a/homeassistant/components/squeezebox/icons.json +++ b/homeassistant/components/squeezebox/icons.json @@ -1,8 +1,16 @@ { "services": { - "call_method": "mdi:console", - "call_query": "mdi:database", - "sync": "mdi:sync", - "unsync": "mdi:sync-off" + "call_method": { + "service": "mdi:console" + }, + "call_query": { + "service": "mdi:database" + }, + "sync": { + "service": "mdi:sync" + }, + "unsync": { + "service": "mdi:sync-off" + } } } diff --git a/homeassistant/components/starline/icons.json b/homeassistant/components/starline/icons.json index b98c4178af10e6..8a4f85a89bf7c7 100644 --- a/homeassistant/components/starline/icons.json +++ b/homeassistant/components/starline/icons.json @@ -72,8 +72,14 @@ } }, "services": { - "update_state": "mdi:reload", - "set_scan_interval": "mdi:timer", - "set_scan_obd_interval": "mdi:timer" + "update_state": { + "service": "mdi:reload" + }, + "set_scan_interval": { + "service": "mdi:timer" + }, + "set_scan_obd_interval": { + "service": "mdi:timer" + } } } diff --git a/homeassistant/components/statistics/icons.json b/homeassistant/components/statistics/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/statistics/icons.json +++ b/homeassistant/components/statistics/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/streamlabswater/icons.json b/homeassistant/components/streamlabswater/icons.json index aebe224b35ea10..0cc64fd24cb27d 100644 --- a/homeassistant/components/streamlabswater/icons.json +++ b/homeassistant/components/streamlabswater/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_away_mode": "mdi:home" + "set_away_mode": { + "service": "mdi:home" + } } } diff --git a/homeassistant/components/subaru/icons.json b/homeassistant/components/subaru/icons.json index f6c3597c3c32d7..ca8648296c7c75 100644 --- a/homeassistant/components/subaru/icons.json +++ b/homeassistant/components/subaru/icons.json @@ -24,6 +24,8 @@ } }, "services": { - "unlock_specific_door": "mdi:lock-open-variant" + "unlock_specific_door": { + "service": "mdi:lock-open-variant" + } } } diff --git a/homeassistant/components/surepetcare/icons.json b/homeassistant/components/surepetcare/icons.json index 1db15b599dfd5f..0daad594c48b7f 100644 --- a/homeassistant/components/surepetcare/icons.json +++ b/homeassistant/components/surepetcare/icons.json @@ -1,6 +1,10 @@ { "services": { - "set_lock_state": "mdi:lock", - "set_pet_location": "mdi:dog" + "set_lock_state": { + "service": "mdi:lock" + }, + "set_pet_location": { + "service": "mdi:dog" + } } } diff --git a/homeassistant/components/swiss_public_transport/icons.json b/homeassistant/components/swiss_public_transport/icons.json index 7c2e543683476a..0f868c18c1fac4 100644 --- a/homeassistant/components/swiss_public_transport/icons.json +++ b/homeassistant/components/swiss_public_transport/icons.json @@ -25,6 +25,8 @@ } }, "services": { - "fetch_connections": "mdi:bus-clock" + "fetch_connections": { + "service": "mdi:bus-clock" + } } } diff --git a/homeassistant/components/switch/icons.json b/homeassistant/components/switch/icons.json index fbc1af5a126ba4..10299a2ffc8e94 100644 --- a/homeassistant/components/switch/icons.json +++ b/homeassistant/components/switch/icons.json @@ -20,8 +20,14 @@ } }, "services": { - "toggle": "mdi:toggle-switch-variant", - "turn_off": "mdi:toggle-switch-variant-off", - "turn_on": "mdi:toggle-switch-variant" + "toggle": { + "service": "mdi:toggle-switch-variant" + }, + "turn_off": { + "service": "mdi:toggle-switch-variant-off" + }, + "turn_on": { + "service": "mdi:toggle-switch-variant" + } } } diff --git a/homeassistant/components/switcher_kis/icons.json b/homeassistant/components/switcher_kis/icons.json index 4d3576f1a99841..6ca8e0e83516f6 100644 --- a/homeassistant/components/switcher_kis/icons.json +++ b/homeassistant/components/switcher_kis/icons.json @@ -24,7 +24,11 @@ } }, "services": { - "set_auto_off": "mdi:progress-clock", - "turn_on_with_timer": "mdi:timer" + "set_auto_off": { + "service": "mdi:progress-clock" + }, + "turn_on_with_timer": { + "service": "mdi:timer" + } } } diff --git a/homeassistant/components/synology_dsm/icons.json b/homeassistant/components/synology_dsm/icons.json index 8e6d2b17f02b14..3c4d028dc7ad36 100644 --- a/homeassistant/components/synology_dsm/icons.json +++ b/homeassistant/components/synology_dsm/icons.json @@ -78,7 +78,11 @@ } }, "services": { - "reboot": "mdi:restart", - "shutdown": "mdi:power" + "reboot": { + "service": "mdi:restart" + }, + "shutdown": { + "service": "mdi:power" + } } } diff --git a/homeassistant/components/system_bridge/icons.json b/homeassistant/components/system_bridge/icons.json index cc648889f0b9cb..a03f77049a315d 100644 --- a/homeassistant/components/system_bridge/icons.json +++ b/homeassistant/components/system_bridge/icons.json @@ -1,11 +1,25 @@ { "services": { - "get_process_by_id": "mdi:console", - "get_processes_by_name": "mdi:console", - "open_path": "mdi:folder-open", - "open_url": "mdi:web", - "send_keypress": "mdi:keyboard", - "send_text": "mdi:keyboard", - "power_command": "mdi:power" + "get_process_by_id": { + "service": "mdi:console" + }, + "get_processes_by_name": { + "service": "mdi:console" + }, + "open_path": { + "service": "mdi:folder-open" + }, + "open_url": { + "service": "mdi:web" + }, + "send_keypress": { + "service": "mdi:keyboard" + }, + "send_text": { + "service": "mdi:keyboard" + }, + "power_command": { + "service": "mdi:power" + } } } diff --git a/homeassistant/components/system_log/icons.json b/homeassistant/components/system_log/icons.json index 436a6c348085a9..fe269c5154dd1e 100644 --- a/homeassistant/components/system_log/icons.json +++ b/homeassistant/components/system_log/icons.json @@ -1,6 +1,10 @@ { "services": { - "clear": "mdi:delete", - "write": "mdi:pencil" + "clear": { + "service": "mdi:delete" + }, + "write": { + "service": "mdi:pencil" + } } } diff --git a/homeassistant/components/tado/icons.json b/homeassistant/components/tado/icons.json index 83ef6d4b332266..c799bef0260acb 100644 --- a/homeassistant/components/tado/icons.json +++ b/homeassistant/components/tado/icons.json @@ -1,8 +1,16 @@ { "services": { - "set_climate_timer": "mdi:timer", - "set_water_heater_timer": "mdi:timer", - "set_climate_temperature_offset": "mdi:thermometer", - "add_meter_reading": "mdi:counter" + "set_climate_timer": { + "service": "mdi:timer" + }, + "set_water_heater_timer": { + "service": "mdi:timer" + }, + "set_climate_temperature_offset": { + "service": "mdi:thermometer" + }, + "add_meter_reading": { + "service": "mdi:counter" + } } } diff --git a/homeassistant/components/telegram/icons.json b/homeassistant/components/telegram/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/telegram/icons.json +++ b/homeassistant/components/telegram/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/telegram_bot/icons.json b/homeassistant/components/telegram_bot/icons.json index f410d3874356d9..0acf20d561ae1e 100644 --- a/homeassistant/components/telegram_bot/icons.json +++ b/homeassistant/components/telegram_bot/icons.json @@ -1,18 +1,46 @@ { "services": { - "send_message": "mdi:send", - "send_photo": "mdi:camera", - "send_sticker": "mdi:sticker", - "send_animation": "mdi:animation", - "send_video": "mdi:video", - "send_voice": "mdi:microphone", - "send_document": "mdi:file-document", - "send_location": "mdi:map-marker", - "send_poll": "mdi:poll", - "edit_message": "mdi:pencil", - "edit_caption": "mdi:pencil", - "edit_replymarkup": "mdi:pencil", - "answer_callback_query": "mdi:check", - "delete_message": "mdi:delete" + "send_message": { + "service": "mdi:send" + }, + "send_photo": { + "service": "mdi:camera" + }, + "send_sticker": { + "service": "mdi:sticker" + }, + "send_animation": { + "service": "mdi:animation" + }, + "send_video": { + "service": "mdi:video" + }, + "send_voice": { + "service": "mdi:microphone" + }, + "send_document": { + "service": "mdi:file-document" + }, + "send_location": { + "service": "mdi:map-marker" + }, + "send_poll": { + "service": "mdi:poll" + }, + "edit_message": { + "service": "mdi:pencil" + }, + "edit_caption": { + "service": "mdi:pencil" + }, + "edit_replymarkup": { + "service": "mdi:pencil" + }, + "answer_callback_query": { + "service": "mdi:check" + }, + "delete_message": { + "service": "mdi:delete" + } } } diff --git a/homeassistant/components/template/icons.json b/homeassistant/components/template/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/template/icons.json +++ b/homeassistant/components/template/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/teslemetry/icons.json b/homeassistant/components/teslemetry/icons.json index aea98e95e0ba9b..1912d2265f64c3 100644 --- a/homeassistant/components/teslemetry/icons.json +++ b/homeassistant/components/teslemetry/icons.json @@ -129,7 +129,6 @@ "off": "mdi:car-seat" } }, - "components_customer_preferred_export_rule": { "default": "mdi:transmission-tower", "state": { @@ -259,11 +258,23 @@ } }, "services": { - "navigation_gps_request": "mdi:crosshairs-gps", - "set_scheduled_charging": "mdi:timeline-clock-outline", - "set_scheduled_departure": "mdi:home-clock", - "speed_limit": "mdi:car-speed-limiter", - "valet_mode": "mdi:speedometer-slow", - "time_of_use": "mdi:clock-time-eight-outline" + "navigation_gps_request": { + "service": "mdi:crosshairs-gps" + }, + "set_scheduled_charging": { + "service": "mdi:timeline-clock-outline" + }, + "set_scheduled_departure": { + "service": "mdi:home-clock" + }, + "speed_limit": { + "service": "mdi:car-speed-limiter" + }, + "valet_mode": { + "service": "mdi:speedometer-slow" + }, + "time_of_use": { + "service": "mdi:clock-time-eight-outline" + } } } diff --git a/homeassistant/components/text/icons.json b/homeassistant/components/text/icons.json index 355c439ec3338e..9448c9a73252ab 100644 --- a/homeassistant/components/text/icons.json +++ b/homeassistant/components/text/icons.json @@ -5,6 +5,8 @@ } }, "services": { - "set_value": "mdi:form-textbox" + "set_value": { + "service": "mdi:form-textbox" + } } } diff --git a/homeassistant/components/tibber/icons.json b/homeassistant/components/tibber/icons.json index c6cdd9b0e25475..ddc8c73514564a 100644 --- a/homeassistant/components/tibber/icons.json +++ b/homeassistant/components/tibber/icons.json @@ -1,5 +1,7 @@ { "services": { - "get_prices": "mdi:cash" + "get_prices": { + "service": "mdi:cash" + } } } diff --git a/homeassistant/components/time/icons.json b/homeassistant/components/time/icons.json index c08e457e04dd9e..f172c28ae0dfb6 100644 --- a/homeassistant/components/time/icons.json +++ b/homeassistant/components/time/icons.json @@ -5,6 +5,8 @@ } }, "services": { - "set_value": "mdi:clock-edit" + "set_value": { + "service": "mdi:clock-edit" + } } } diff --git a/homeassistant/components/timer/icons.json b/homeassistant/components/timer/icons.json index 1e352f7280b2ca..a5319688646b9f 100644 --- a/homeassistant/components/timer/icons.json +++ b/homeassistant/components/timer/icons.json @@ -1,10 +1,22 @@ { "services": { - "start": "mdi:play", - "pause": "mdi:pause", - "cancel": "mdi:cancel", - "finish": "mdi:check", - "change": "mdi:pencil", - "reload": "mdi:reload" + "start": { + "service": "mdi:play" + }, + "pause": { + "service": "mdi:pause" + }, + "cancel": { + "service": "mdi:cancel" + }, + "finish": { + "service": "mdi:check" + }, + "change": { + "service": "mdi:pencil" + }, + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/todo/icons.json b/homeassistant/components/todo/icons.json index 05c9af7463095f..4040a0c6b8f909 100644 --- a/homeassistant/components/todo/icons.json +++ b/homeassistant/components/todo/icons.json @@ -5,10 +5,20 @@ } }, "services": { - "add_item": "mdi:clipboard-plus", - "get_items": "mdi:clipboard-arrow-down", - "remove_completed_items": "mdi:clipboard-remove", - "remove_item": "mdi:clipboard-minus", - "update_item": "mdi:clipboard-edit" + "add_item": { + "service": "mdi:clipboard-plus" + }, + "get_items": { + "service": "mdi:clipboard-arrow-down" + }, + "remove_completed_items": { + "service": "mdi:clipboard-remove" + }, + "remove_item": { + "service": "mdi:clipboard-minus" + }, + "update_item": { + "service": "mdi:clipboard-edit" + } } } diff --git a/homeassistant/components/todoist/icons.json b/homeassistant/components/todoist/icons.json index d3b881d480c565..73778f1ca23e7e 100644 --- a/homeassistant/components/todoist/icons.json +++ b/homeassistant/components/todoist/icons.json @@ -1,5 +1,7 @@ { "services": { - "new_task": "mdi:checkbox-marked-circle-plus-outline" + "new_task": { + "service": "mdi:checkbox-marked-circle-plus-outline" + } } } diff --git a/homeassistant/components/toon/icons.json b/homeassistant/components/toon/icons.json index 650bf0b6d19f57..217f1240893477 100644 --- a/homeassistant/components/toon/icons.json +++ b/homeassistant/components/toon/icons.json @@ -1,5 +1,7 @@ { "services": { - "update": "mdi:update" + "update": { + "service": "mdi:update" + } } } diff --git a/homeassistant/components/totalconnect/icons.json b/homeassistant/components/totalconnect/icons.json index cb62a79c7bba8f..a21df03e15d18b 100644 --- a/homeassistant/components/totalconnect/icons.json +++ b/homeassistant/components/totalconnect/icons.json @@ -10,7 +10,11 @@ } }, "services": { - "arm_away_instant": "mdi:shield-lock", - "arm_home_instant": "mdi:shield-home" + "arm_away_instant": { + "service": "mdi:shield-lock" + }, + "arm_home_instant": { + "service": "mdi:shield-home" + } } } diff --git a/homeassistant/components/tplink/icons.json b/homeassistant/components/tplink/icons.json index 3da3b4806d341f..96ea8f41bb7f0d 100644 --- a/homeassistant/components/tplink/icons.json +++ b/homeassistant/components/tplink/icons.json @@ -109,7 +109,11 @@ } }, "services": { - "sequence_effect": "mdi:playlist-play", - "random_effect": "mdi:shuffle-variant" + "sequence_effect": { + "service": "mdi:playlist-play" + }, + "random_effect": { + "service": "mdi:shuffle-variant" + } } } diff --git a/homeassistant/components/transmission/icons.json b/homeassistant/components/transmission/icons.json index 56ae46f933df71..4458f5109514b6 100644 --- a/homeassistant/components/transmission/icons.json +++ b/homeassistant/components/transmission/icons.json @@ -1,8 +1,16 @@ { "services": { - "add_torrent": "mdi:download", - "remove_torrent": "mdi:download-off", - "start_torrent": "mdi:play", - "stop_torrent": "mdi:stop" + "add_torrent": { + "service": "mdi:download" + }, + "remove_torrent": { + "service": "mdi:download-off" + }, + "start_torrent": { + "service": "mdi:play" + }, + "stop_torrent": { + "service": "mdi:stop" + } } } diff --git a/homeassistant/components/trend/icons.json b/homeassistant/components/trend/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/trend/icons.json +++ b/homeassistant/components/trend/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/tts/icons.json b/homeassistant/components/tts/icons.json index cda5f877b25900..8cfae7cc8e9d06 100644 --- a/homeassistant/components/tts/icons.json +++ b/homeassistant/components/tts/icons.json @@ -5,8 +5,14 @@ } }, "services": { - "clear_cache": "mdi:delete", - "say": "mdi:speaker-message", - "speak": "mdi:speaker-message" + "clear_cache": { + "service": "mdi:delete" + }, + "say": { + "service": "mdi:speaker-message" + }, + "speak": { + "service": "mdi:speaker-message" + } } } diff --git a/homeassistant/components/unifi/icons.json b/homeassistant/components/unifi/icons.json index 2d5017a318707d..b089d8eff9cb02 100644 --- a/homeassistant/components/unifi/icons.json +++ b/homeassistant/components/unifi/icons.json @@ -1,6 +1,10 @@ { "services": { - "reconnect_client": "mdi:sync", - "remove_clients": "mdi:delete" + "reconnect_client": { + "service": "mdi:sync" + }, + "remove_clients": { + "service": "mdi:delete" + } } } diff --git a/homeassistant/components/unifiprotect/icons.json b/homeassistant/components/unifiprotect/icons.json index bb713d4ee7903e..5e80e3095b31f8 100644 --- a/homeassistant/components/unifiprotect/icons.json +++ b/homeassistant/components/unifiprotect/icons.json @@ -1,8 +1,16 @@ { "services": { - "add_doorbell_text": "mdi:message-plus", - "remove_doorbell_text": "mdi:message-minus", - "set_chime_paired_doorbells": "mdi:bell-cog", - "remove_privacy_zone": "mdi:eye-minus" + "add_doorbell_text": { + "service": "mdi:message-plus" + }, + "remove_doorbell_text": { + "service": "mdi:message-minus" + }, + "set_chime_paired_doorbells": { + "service": "mdi:bell-cog" + }, + "remove_privacy_zone": { + "service": "mdi:eye-minus" + } } } diff --git a/homeassistant/components/universal/icons.json b/homeassistant/components/universal/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/universal/icons.json +++ b/homeassistant/components/universal/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/upb/icons.json b/homeassistant/components/upb/icons.json index 187f0f60970b11..0274233da520cb 100644 --- a/homeassistant/components/upb/icons.json +++ b/homeassistant/components/upb/icons.json @@ -1,12 +1,28 @@ { "services": { - "light_fade_start": "mdi:transition", - "light_fade_stop": "mdi:transition-masked", - "light_blink": "mdi:eye", - "link_deactivate": "mdi:link-off", - "link_goto": "mdi:link-variant", - "link_fade_start": "mdi:transition", - "link_fade_stop": "mdi:transition-masked", - "link_blink": "mdi:eye" + "light_fade_start": { + "service": "mdi:transition" + }, + "light_fade_stop": { + "service": "mdi:transition-masked" + }, + "light_blink": { + "service": "mdi:eye" + }, + "link_deactivate": { + "service": "mdi:link-off" + }, + "link_goto": { + "service": "mdi:link-variant" + }, + "link_fade_start": { + "service": "mdi:transition" + }, + "link_fade_stop": { + "service": "mdi:transition-masked" + }, + "link_blink": { + "service": "mdi:eye" + } } } diff --git a/homeassistant/components/update/icons.json b/homeassistant/components/update/icons.json index 96920c962537bc..89af07de67f360 100644 --- a/homeassistant/components/update/icons.json +++ b/homeassistant/components/update/icons.json @@ -8,8 +8,14 @@ } }, "services": { - "clear_skipped": "mdi:package", - "install": "mdi:package-down", - "skip": "mdi:package-check" + "clear_skipped": { + "service": "mdi:package" + }, + "install": { + "service": "mdi:package-down" + }, + "skip": { + "service": "mdi:package-check" + } } } diff --git a/homeassistant/components/utility_meter/icons.json b/homeassistant/components/utility_meter/icons.json index 3c447b4a8108c5..2539b73d168ce7 100644 --- a/homeassistant/components/utility_meter/icons.json +++ b/homeassistant/components/utility_meter/icons.json @@ -12,7 +12,11 @@ } }, "services": { - "reset": "mdi:numeric-0-box-outline", - "calibrate": "mdi:auto-fix" + "reset": { + "service": "mdi:numeric-0-box-outline" + }, + "calibrate": { + "service": "mdi:auto-fix" + } } } diff --git a/homeassistant/components/vacuum/icons.json b/homeassistant/components/vacuum/icons.json index 25f0cfd03ef2f7..4169729efec2a1 100644 --- a/homeassistant/components/vacuum/icons.json +++ b/homeassistant/components/vacuum/icons.json @@ -5,17 +5,41 @@ } }, "services": { - "clean_spot": "mdi:target-variant", - "locate": "mdi:map-marker", - "pause": "mdi:pause", - "return_to_base": "mdi:home-import-outline", - "send_command": "mdi:send", - "set_fan_speed": "mdi:fan", - "start": "mdi:play", - "start_pause": "mdi:play-pause", - "stop": "mdi:stop", - "toggle": "mdi:play-pause", - "turn_off": "mdi:stop", - "turn_on": "mdi:play" + "clean_spot": { + "service": "mdi:target-variant" + }, + "locate": { + "service": "mdi:map-marker" + }, + "pause": { + "service": "mdi:pause" + }, + "return_to_base": { + "service": "mdi:home-import-outline" + }, + "send_command": { + "service": "mdi:send" + }, + "set_fan_speed": { + "service": "mdi:fan" + }, + "start": { + "service": "mdi:play" + }, + "start_pause": { + "service": "mdi:play-pause" + }, + "stop": { + "service": "mdi:stop" + }, + "toggle": { + "service": "mdi:play-pause" + }, + "turn_off": { + "service": "mdi:stop" + }, + "turn_on": { + "service": "mdi:play" + } } } diff --git a/homeassistant/components/vallox/icons.json b/homeassistant/components/vallox/icons.json index 67b41d216d2ce6..f6beb55f1daa9a 100644 --- a/homeassistant/components/vallox/icons.json +++ b/homeassistant/components/vallox/icons.json @@ -37,8 +37,14 @@ } }, "services": { - "set_profile_fan_speed_home": "mdi:home", - "set_profile_fan_speed_away": "mdi:walk", - "set_profile_fan_speed_boost": "mdi:speedometer" + "set_profile_fan_speed_home": { + "service": "mdi:home" + }, + "set_profile_fan_speed_away": { + "service": "mdi:walk" + }, + "set_profile_fan_speed_boost": { + "service": "mdi:speedometer" + } } } diff --git a/homeassistant/components/valve/icons.json b/homeassistant/components/valve/icons.json index 2c887ebf273c2b..c9c6b632dcbc6b 100644 --- a/homeassistant/components/valve/icons.json +++ b/homeassistant/components/valve/icons.json @@ -17,10 +17,20 @@ } }, "services": { - "close_valve": "mdi:valve-closed", - "open_valve": "mdi:valve-open", - "set_valve_position": "mdi:valve", - "stop_valve": "mdi:stop", - "toggle": "mdi:valve-open" + "close_valve": { + "service": "mdi:valve-closed" + }, + "open_valve": { + "service": "mdi:valve-open" + }, + "set_valve_position": { + "service": "mdi:valve" + }, + "stop_valve": { + "service": "mdi:stop" + }, + "toggle": { + "service": "mdi:valve-open" + } } } diff --git a/homeassistant/components/velbus/icons.json b/homeassistant/components/velbus/icons.json index a806782d189a1a..a46f5e5fbf113f 100644 --- a/homeassistant/components/velbus/icons.json +++ b/homeassistant/components/velbus/icons.json @@ -1,8 +1,16 @@ { "services": { - "sync_clock": "mdi:clock", - "scan": "mdi:magnify", - "clear_cache": "mdi:delete", - "set_memo_text": "mdi:note-text" + "sync_clock": { + "service": "mdi:clock" + }, + "scan": { + "service": "mdi:magnify" + }, + "clear_cache": { + "service": "mdi:delete" + }, + "set_memo_text": { + "service": "mdi:note-text" + } } } diff --git a/homeassistant/components/velux/icons.json b/homeassistant/components/velux/icons.json index a16e7b5009399b..78cb5b148385d3 100644 --- a/homeassistant/components/velux/icons.json +++ b/homeassistant/components/velux/icons.json @@ -1,5 +1,7 @@ { "services": { - "reboot_gateway": "mdi:restart" + "reboot_gateway": { + "service": "mdi:restart" + } } } diff --git a/homeassistant/components/verisure/icons.json b/homeassistant/components/verisure/icons.json index 35f6960b1e80d0..809cf004a3fd6f 100644 --- a/homeassistant/components/verisure/icons.json +++ b/homeassistant/components/verisure/icons.json @@ -1,7 +1,13 @@ { "services": { - "capture_smartcam": "mdi:camera", - "enable_autolock": "mdi:lock", - "disable_autolock": "mdi:lock-off" + "capture_smartcam": { + "service": "mdi:camera" + }, + "enable_autolock": { + "service": "mdi:lock" + }, + "disable_autolock": { + "service": "mdi:lock-off" + } } } diff --git a/homeassistant/components/vesync/icons.json b/homeassistant/components/vesync/icons.json index a4bf4afd410bca..cfdefb2ed09d49 100644 --- a/homeassistant/components/vesync/icons.json +++ b/homeassistant/components/vesync/icons.json @@ -1,5 +1,7 @@ { "services": { - "update_devices": "mdi:update" + "update_devices": { + "service": "mdi:update" + } } } diff --git a/homeassistant/components/vicare/icons.json b/homeassistant/components/vicare/icons.json index 2f40d8a882214e..9d0f27a863c5ac 100644 --- a/homeassistant/components/vicare/icons.json +++ b/homeassistant/components/vicare/icons.json @@ -88,6 +88,8 @@ } }, "services": { - "set_vicare_mode": "mdi:cog" + "set_vicare_mode": { + "service": "mdi:cog" + } } } diff --git a/homeassistant/components/vizio/icons.json b/homeassistant/components/vizio/icons.json index ccdaf816bb09ee..be6f727de6f91f 100644 --- a/homeassistant/components/vizio/icons.json +++ b/homeassistant/components/vizio/icons.json @@ -1,5 +1,7 @@ { "services": { - "update_setting": "mdi:cog" + "update_setting": { + "service": "mdi:cog" + } } } diff --git a/homeassistant/components/wake_on_lan/icons.json b/homeassistant/components/wake_on_lan/icons.json index 6426c478157f62..f083b0342f475b 100644 --- a/homeassistant/components/wake_on_lan/icons.json +++ b/homeassistant/components/wake_on_lan/icons.json @@ -1,5 +1,7 @@ { "services": { - "send_magic_packet": "mdi:cube-send" + "send_magic_packet": { + "service": "mdi:cube-send" + } } } diff --git a/homeassistant/components/water_heater/icons.json b/homeassistant/components/water_heater/icons.json index af6996374c52a8..bc80128c6a30e7 100644 --- a/homeassistant/components/water_heater/icons.json +++ b/homeassistant/components/water_heater/icons.json @@ -22,10 +22,20 @@ } }, "services": { - "set_away_mode": "mdi:account-arrow-right", - "set_operation_mode": "mdi:water-boiler", - "set_temperature": "mdi:thermometer", - "turn_off": "mdi:water-boiler-off", - "turn_on": "mdi:water-boiler" + "set_away_mode": { + "service": "mdi:account-arrow-right" + }, + "set_operation_mode": { + "service": "mdi:water-boiler" + }, + "set_temperature": { + "service": "mdi:thermometer" + }, + "turn_off": { + "service": "mdi:water-boiler-off" + }, + "turn_on": { + "service": "mdi:water-boiler" + } } } diff --git a/homeassistant/components/waze_travel_time/icons.json b/homeassistant/components/waze_travel_time/icons.json index fa95e8fdd8af26..98e6f26774c074 100644 --- a/homeassistant/components/waze_travel_time/icons.json +++ b/homeassistant/components/waze_travel_time/icons.json @@ -7,6 +7,8 @@ } }, "services": { - "get_travel_times": "mdi:timelapse" + "get_travel_times": { + "service": "mdi:timelapse" + } } } diff --git a/homeassistant/components/weather/icons.json b/homeassistant/components/weather/icons.json index cc53861e700a10..04b3c1d3df84cb 100644 --- a/homeassistant/components/weather/icons.json +++ b/homeassistant/components/weather/icons.json @@ -21,7 +21,11 @@ } }, "services": { - "get_forecast": "mdi:weather-cloudy-clock", - "get_forecasts": "mdi:weather-cloudy-clock" + "get_forecast": { + "service": "mdi:weather-cloudy-clock" + }, + "get_forecasts": { + "service": "mdi:weather-cloudy-clock" + } } } diff --git a/homeassistant/components/webostv/icons.json b/homeassistant/components/webostv/icons.json index deb9729a99fff9..edc058d099fd37 100644 --- a/homeassistant/components/webostv/icons.json +++ b/homeassistant/components/webostv/icons.json @@ -1,7 +1,13 @@ { "services": { - "button": "mdi:button-pointer", - "command": "mdi:console", - "select_sound_output": "mdi:volume-source" + "button": { + "service": "mdi:button-pointer" + }, + "command": { + "service": "mdi:console" + }, + "select_sound_output": { + "service": "mdi:volume-source" + } } } diff --git a/homeassistant/components/wemo/icons.json b/homeassistant/components/wemo/icons.json index c5ddf5912d6dc3..af5024afcff9ee 100644 --- a/homeassistant/components/wemo/icons.json +++ b/homeassistant/components/wemo/icons.json @@ -1,6 +1,10 @@ { "services": { - "set_humidity": "mdi:water-percent", - "reset_filter_life": "mdi:refresh" + "set_humidity": { + "service": "mdi:water-percent" + }, + "reset_filter_life": { + "service": "mdi:refresh" + } } } diff --git a/homeassistant/components/wilight/icons.json b/homeassistant/components/wilight/icons.json index 3c5d0112de1ab3..48bcae2a3016ec 100644 --- a/homeassistant/components/wilight/icons.json +++ b/homeassistant/components/wilight/icons.json @@ -10,8 +10,14 @@ } }, "services": { - "set_watering_time": "mdi:timer", - "set_pause_time": "mdi:timer-pause", - "set_trigger": "mdi:gesture-tap-button" + "set_watering_time": { + "service": "mdi:timer" + }, + "set_pause_time": { + "service": "mdi:timer-pause" + }, + "set_trigger": { + "service": "mdi:gesture-tap-button" + } } } diff --git a/homeassistant/components/workday/icons.json b/homeassistant/components/workday/icons.json index 10d3c93a288611..ec5c64dce971bb 100644 --- a/homeassistant/components/workday/icons.json +++ b/homeassistant/components/workday/icons.json @@ -1,5 +1,7 @@ { "services": { - "check_date": "mdi:calendar-check" + "check_date": { + "service": "mdi:calendar-check" + } } } diff --git a/homeassistant/components/xiaomi_aqara/icons.json b/homeassistant/components/xiaomi_aqara/icons.json index 4975414833dce6..62149b0dd402af 100644 --- a/homeassistant/components/xiaomi_aqara/icons.json +++ b/homeassistant/components/xiaomi_aqara/icons.json @@ -1,8 +1,16 @@ { "services": { - "add_device": "mdi:cellphone-link", - "play_ringtone": "mdi:music", - "remove_device": "mdi:cellphone-link", - "stop_ringtone": "mdi:music-off" + "add_device": { + "service": "mdi:cellphone-link" + }, + "play_ringtone": { + "service": "mdi:music" + }, + "remove_device": { + "service": "mdi:cellphone-link" + }, + "stop_ringtone": { + "service": "mdi:music-off" + } } } diff --git a/homeassistant/components/xiaomi_miio/icons.json b/homeassistant/components/xiaomi_miio/icons.json index 2e5084a1f6c8bd..cc0800f1d9d30d 100644 --- a/homeassistant/components/xiaomi_miio/icons.json +++ b/homeassistant/components/xiaomi_miio/icons.json @@ -14,29 +14,77 @@ } }, "services": { - "fan_reset_filter": "mdi:refresh", - "fan_set_extra_features": "mdi:cog", - "light_set_scene": "mdi:palette", - "light_set_delayed_turn_off": "mdi:timer", - "light_reminder_on": "mdi:alarm", - "light_reminder_off": "mdi:alarm-off", - "light_night_light_mode_on": "mdi:weather-night", - "light_night_light_mode_off": "mdi:weather-sunny", - "light_eyecare_mode_on": "mdi:eye", - "light_eyecare_mode_off": "mdi:eye-off", - "remote_learn_command": "mdi:remote", - "remote_set_led_on": "mdi:led-on", - "remote_set_led_off": "mdi:led-off", - "switch_set_wifi_led_on": "mdi:wifi", - "switch_set_wifi_led_off": "mdi:wifi-off", - "switch_set_power_price": "mdi:currency-usd", - "switch_set_power_mode": "mdi:power", - "vacuum_remote_control_start": "mdi:play", - "vacuum_remote_control_stop": "mdi:stop", - "vacuum_remote_control_move": "mdi:remote", - "vacuum_remote_control_move_step": "mdi:remote", - "vacuum_clean_zone": "mdi:map-marker", - "vacuum_goto": "mdi:map-marker", - "vacuum_clean_segment": "mdi:map-marker" + "fan_reset_filter": { + "service": "mdi:refresh" + }, + "fan_set_extra_features": { + "service": "mdi:cog" + }, + "light_set_scene": { + "service": "mdi:palette" + }, + "light_set_delayed_turn_off": { + "service": "mdi:timer" + }, + "light_reminder_on": { + "service": "mdi:alarm" + }, + "light_reminder_off": { + "service": "mdi:alarm-off" + }, + "light_night_light_mode_on": { + "service": "mdi:weather-night" + }, + "light_night_light_mode_off": { + "service": "mdi:weather-sunny" + }, + "light_eyecare_mode_on": { + "service": "mdi:eye" + }, + "light_eyecare_mode_off": { + "service": "mdi:eye-off" + }, + "remote_learn_command": { + "service": "mdi:remote" + }, + "remote_set_led_on": { + "service": "mdi:led-on" + }, + "remote_set_led_off": { + "service": "mdi:led-off" + }, + "switch_set_wifi_led_on": { + "service": "mdi:wifi" + }, + "switch_set_wifi_led_off": { + "service": "mdi:wifi-off" + }, + "switch_set_power_price": { + "service": "mdi:currency-usd" + }, + "switch_set_power_mode": { + "service": "mdi:power" + }, + "vacuum_remote_control_start": { + "service": "mdi:play" + }, + "vacuum_remote_control_stop": { + "service": "mdi:stop" + }, + "vacuum_remote_control_move": { + "service": "mdi:remote" + }, + "vacuum_remote_control_move_step": { + "service": "mdi:remote" + }, + "vacuum_clean_zone": { + "service": "mdi:map-marker" + }, + "vacuum_goto": { + "service": "mdi:map-marker" + }, + "vacuum_clean_segment": { + "service": "mdi:map-marker" + } } } diff --git a/homeassistant/components/yamaha/icons.json b/homeassistant/components/yamaha/icons.json index f7075508b0dd93..40eceda3b3e00e 100644 --- a/homeassistant/components/yamaha/icons.json +++ b/homeassistant/components/yamaha/icons.json @@ -1,7 +1,13 @@ { "services": { - "enable_output": "mdi:audio-input-stereo-minijack", - "menu_cursor": "mdi:cursor-default", - "select_scene": "mdi:palette" + "enable_output": { + "service": "mdi:audio-input-stereo-minijack" + }, + "menu_cursor": { + "service": "mdi:cursor-default" + }, + "select_scene": { + "service": "mdi:palette" + } } } diff --git a/homeassistant/components/yardian/icons.json b/homeassistant/components/yardian/icons.json index 79bcc32adf2f06..4ca3d83bd158c6 100644 --- a/homeassistant/components/yardian/icons.json +++ b/homeassistant/components/yardian/icons.json @@ -7,6 +7,8 @@ } }, "services": { - "start_irrigation": "mdi:water" + "start_irrigation": { + "service": "mdi:water" + } } } diff --git a/homeassistant/components/yeelight/icons.json b/homeassistant/components/yeelight/icons.json index bf0d0c497f0ee8..898637e752c3ea 100644 --- a/homeassistant/components/yeelight/icons.json +++ b/homeassistant/components/yeelight/icons.json @@ -7,13 +7,29 @@ } }, "services": { - "set_mode": "mdi:cog", - "set_color_scene": "mdi:palette", - "set_hsv_scene": "mdi:palette", - "set_color_temp_scene": "mdi:palette", - "set_color_flow_scene": "mdi:palette", - "set_auto_delay_off_scene": "mdi:timer", - "start_flow": "mdi:play", - "set_music_mode": "mdi:music" + "set_mode": { + "service": "mdi:cog" + }, + "set_color_scene": { + "service": "mdi:palette" + }, + "set_hsv_scene": { + "service": "mdi:palette" + }, + "set_color_temp_scene": { + "service": "mdi:palette" + }, + "set_color_flow_scene": { + "service": "mdi:palette" + }, + "set_auto_delay_off_scene": { + "service": "mdi:timer" + }, + "start_flow": { + "service": "mdi:play" + }, + "set_music_mode": { + "service": "mdi:music" + } } } diff --git a/homeassistant/components/yolink/icons.json b/homeassistant/components/yolink/icons.json index 1158c9bd8f2fac..c58d219a2e0e58 100644 --- a/homeassistant/components/yolink/icons.json +++ b/homeassistant/components/yolink/icons.json @@ -29,6 +29,8 @@ } }, "services": { - "play_on_speaker_hub": "mdi:speaker" + "play_on_speaker_hub": { + "service": "mdi:speaker" + } } } diff --git a/homeassistant/components/zha/icons.json b/homeassistant/components/zha/icons.json index 9b060e8105a295..65ad029a66decb 100644 --- a/homeassistant/components/zha/icons.json +++ b/homeassistant/components/zha/icons.json @@ -162,17 +162,41 @@ } }, "services": { - "permit": "mdi:cellphone-link", - "remove": "mdi:cellphone-remove", - "reconfigure_device": "mdi:cellphone-cog", - "set_zigbee_cluster_attribute": "mdi:cog", - "issue_zigbee_cluster_command": "mdi:console", - "issue_zigbee_group_command": "mdi:console", - "warning_device_squawk": "mdi:alert", - "warning_device_warn": "mdi:alert", - "clear_lock_user_code": "mdi:lock-remove", - "enable_lock_user_code": "mdi:lock", - "disable_lock_user_code": "mdi:lock-off", - "set_lock_user_code": "mdi:lock" + "permit": { + "service": "mdi:cellphone-link" + }, + "remove": { + "service": "mdi:cellphone-remove" + }, + "reconfigure_device": { + "service": "mdi:cellphone-cog" + }, + "set_zigbee_cluster_attribute": { + "service": "mdi:cog" + }, + "issue_zigbee_cluster_command": { + "service": "mdi:console" + }, + "issue_zigbee_group_command": { + "service": "mdi:console" + }, + "warning_device_squawk": { + "service": "mdi:alert" + }, + "warning_device_warn": { + "service": "mdi:alert" + }, + "clear_lock_user_code": { + "service": "mdi:lock-remove" + }, + "enable_lock_user_code": { + "service": "mdi:lock" + }, + "disable_lock_user_code": { + "service": "mdi:lock-off" + }, + "set_lock_user_code": { + "service": "mdi:lock" + } } } diff --git a/homeassistant/components/zone/icons.json b/homeassistant/components/zone/icons.json index a03163179cb5bd..a9829425570a0c 100644 --- a/homeassistant/components/zone/icons.json +++ b/homeassistant/components/zone/icons.json @@ -1,5 +1,7 @@ { "services": { - "reload": "mdi:reload" + "reload": { + "service": "mdi:reload" + } } } diff --git a/homeassistant/components/zoneminder/icons.json b/homeassistant/components/zoneminder/icons.json index 8ca180d7399586..3f9f6410a22ad4 100644 --- a/homeassistant/components/zoneminder/icons.json +++ b/homeassistant/components/zoneminder/icons.json @@ -1,5 +1,7 @@ { "services": { - "set_run_state": "mdi:cog" + "set_run_state": { + "service": "mdi:cog" + } } } diff --git a/homeassistant/components/zwave_js/icons.json b/homeassistant/components/zwave_js/icons.json index 2956cf2c6e002a..b52255e09d15aa 100644 --- a/homeassistant/components/zwave_js/icons.json +++ b/homeassistant/components/zwave_js/icons.json @@ -57,17 +57,41 @@ } }, "services": { - "bulk_set_partial_config_parameters": "mdi:cogs", - "clear_lock_usercode": "mdi:eraser", - "invoke_cc_api": "mdi:api", - "multicast_set_value": "mdi:list-box", - "ping": "mdi:crosshairs-gps", - "refresh_notifications": "mdi:bell", - "refresh_value": "mdi:refresh", - "reset_meter": "mdi:meter-electric", - "set_config_parameter": "mdi:cog", - "set_lock_configuration": "mdi:shield-lock", - "set_lock_usercode": "mdi:lock-smart", - "set_value": "mdi:form-textbox" + "bulk_set_partial_config_parameters": { + "service": "mdi:cogs" + }, + "clear_lock_usercode": { + "service": "mdi:eraser" + }, + "invoke_cc_api": { + "service": "mdi:api" + }, + "multicast_set_value": { + "service": "mdi:list-box" + }, + "ping": { + "service": "mdi:crosshairs-gps" + }, + "refresh_notifications": { + "service": "mdi:bell" + }, + "refresh_value": { + "service": "mdi:refresh" + }, + "reset_meter": { + "service": "mdi:meter-electric" + }, + "set_config_parameter": { + "service": "mdi:cog" + }, + "set_lock_configuration": { + "service": "mdi:shield-lock" + }, + "set_lock_usercode": { + "service": "mdi:lock-smart" + }, + "set_value": { + "service": "mdi:form-textbox" + } } } From cff4e4669426e077fc263d93d0f269adabe69e76 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 13:48:49 +0200 Subject: [PATCH 61/67] Deduplicate TTS mocks (#124773) --- tests/components/assist_pipeline/conftest.py | 47 +++----------------- tests/components/tts/common.py | 12 ++--- tests/components/tts/conftest.py | 8 ++-- tests/components/tts/test_init.py | 28 ++++++------ tests/components/tts/test_legacy.py | 8 ++-- tests/components/tts/test_media_source.py | 4 +- 6 files changed, 37 insertions(+), 70 deletions(-) diff --git a/tests/components/assist_pipeline/conftest.py b/tests/components/assist_pipeline/conftest.py index c03874c16af71b..0f6872edbfedf3 100644 --- a/tests/components/assist_pipeline/conftest.py +++ b/tests/components/assist_pipeline/conftest.py @@ -23,7 +23,7 @@ ) from homeassistant.config_entries import ConfigEntry, ConfigFlow from homeassistant.const import Platform -from homeassistant.core import HomeAssistant, callback +from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.setup import async_setup_component @@ -37,6 +37,7 @@ mock_platform, ) from tests.components.stt.common import MockSTTProvider, MockSTTProviderEntity +from tests.components.tts.common import MockTTSProvider _TRANSCRIPT = "test transcript" @@ -48,46 +49,6 @@ def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> None: """Mock the TTS cache dir with empty dir.""" -class MockTTSProvider(tts.Provider): - """Mock TTS provider.""" - - name = "Test" - _supported_languages = ["en-US"] - _supported_voices = { - "en-US": [ - tts.Voice("james_earl_jones", "James Earl Jones"), - tts.Voice("fran_drescher", "Fran Drescher"), - ] - } - _supported_options = ["voice", "age", tts.ATTR_AUDIO_OUTPUT] - - @property - def default_language(self) -> str: - """Return the default language.""" - return "en" - - @property - def supported_languages(self) -> list[str]: - """Return list of supported languages.""" - return self._supported_languages - - @callback - def async_get_supported_voices(self, language: str) -> list[tts.Voice] | None: - """Return a list of supported voices for a language.""" - return self._supported_voices.get(language) - - @property - def supported_options(self) -> list[str]: - """Return list of supported options like voice, emotions.""" - return self._supported_options - - def get_tts_audio( - self, message: str, language: str, options: dict[str, Any] - ) -> tts.TtsAudioType: - """Load TTS data.""" - return ("mp3", b"") - - class MockTTSPlatform(MockPlatform): """A mock TTS platform.""" @@ -102,7 +63,9 @@ def __init__(self, *, async_get_engine, **kwargs: Any) -> None: @pytest.fixture async def mock_tts_provider() -> MockTTSProvider: """Mock TTS provider.""" - return MockTTSProvider() + provider = MockTTSProvider("en") + provider._supported_languages = ["en-US"] + return provider @pytest.fixture diff --git a/tests/components/tts/common.py b/tests/components/tts/common.py index 4acba401fad982..b1eae12d694b72 100644 --- a/tests/components/tts/common.py +++ b/tests/components/tts/common.py @@ -130,6 +130,8 @@ class BaseProvider: def __init__(self, lang: str) -> None: """Initialize test provider.""" self._lang = lang + self._supported_languages = SUPPORT_LANGUAGES + self._supported_options = ["voice", "age"] @property def default_language(self) -> str: @@ -139,7 +141,7 @@ def default_language(self) -> str: @property def supported_languages(self) -> list[str]: """Return list of supported languages.""" - return SUPPORT_LANGUAGES + return self._supported_languages @callback def async_get_supported_voices(self, language: str) -> list[Voice] | None: @@ -154,7 +156,7 @@ def async_get_supported_voices(self, language: str) -> list[Voice] | None: @property def supported_options(self) -> list[str]: """Return list of supported options like voice, emotions.""" - return ["voice", "age"] + return self._supported_options def get_tts_audio( self, message: str, language: str, options: dict[str, Any] @@ -163,7 +165,7 @@ def get_tts_audio( return ("mp3", b"") -class MockProvider(BaseProvider, Provider): +class MockTTSProvider(BaseProvider, Provider): """Test speech API provider.""" def __init__(self, lang: str) -> None: @@ -185,7 +187,7 @@ class MockTTS(MockPlatform): {vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORT_LANGUAGES)} ) - def __init__(self, provider: MockProvider, **kwargs: Any) -> None: + def __init__(self, provider: MockTTSProvider, **kwargs: Any) -> None: """Initialize.""" super().__init__(**kwargs) self._provider = provider @@ -202,7 +204,7 @@ async def async_get_engine( async def mock_setup( hass: HomeAssistant, - mock_provider: MockProvider, + mock_provider: MockTTSProvider, ) -> None: """Set up a test provider.""" mock_integration(hass, MockModule(domain=TEST_DOMAIN)) diff --git a/tests/components/tts/conftest.py b/tests/components/tts/conftest.py index 91ddd7742af8a4..16c24f006d733f 100644 --- a/tests/components/tts/conftest.py +++ b/tests/components/tts/conftest.py @@ -17,9 +17,9 @@ from .common import ( DEFAULT_LANG, TEST_DOMAIN, - MockProvider, MockTTS, MockTTSEntity, + MockTTSProvider, mock_config_entry_setup, mock_setup, ) @@ -67,9 +67,9 @@ async def mock_tts(hass: HomeAssistant, mock_provider) -> None: @pytest.fixture -def mock_provider() -> MockProvider: +def mock_provider() -> MockTTSProvider: """Test TTS provider.""" - return MockProvider(DEFAULT_LANG) + return MockTTSProvider(DEFAULT_LANG) @pytest.fixture @@ -106,7 +106,7 @@ def config_flow_fixture( async def setup_fixture( hass: HomeAssistant, request: pytest.FixtureRequest, - mock_provider: MockProvider, + mock_provider: MockTTSProvider, mock_tts_entity: MockTTSEntity, ) -> None: """Set up the test environment.""" diff --git a/tests/components/tts/test_init.py b/tests/components/tts/test_init.py index 1417fcda2a77d5..cf04fbb175ba87 100644 --- a/tests/components/tts/test_init.py +++ b/tests/components/tts/test_init.py @@ -30,9 +30,9 @@ DEFAULT_LANG, SUPPORT_LANGUAGES, TEST_DOMAIN, - MockProvider, MockTTS, MockTTSEntity, + MockTTSProvider, get_media_source_url, mock_config_entry_setup, mock_setup, @@ -220,7 +220,7 @@ async def test_service( @pytest.mark.parametrize( ("mock_provider", "mock_tts_entity"), - [(MockProvider("de_DE"), MockTTSEntity("de_DE"))], + [(MockTTSProvider("de_DE"), MockTTSEntity("de_DE"))], ) @pytest.mark.parametrize( ("setup", "tts_service", "service_data", "expected_url_suffix"), @@ -281,7 +281,7 @@ async def test_service_default_language( @pytest.mark.parametrize( ("mock_provider", "mock_tts_entity"), - [(MockProvider("en_US"), MockTTSEntity("en_US"))], + [(MockTTSProvider("en_US"), MockTTSEntity("en_US"))], ) @pytest.mark.parametrize( ("setup", "tts_service", "service_data", "expected_url_suffix"), @@ -511,7 +511,7 @@ async def test_service_options( ).is_file() -class MockProviderWithDefaults(MockProvider): +class MockProviderWithDefaults(MockTTSProvider): """Mock provider with default options.""" @property @@ -854,7 +854,7 @@ async def test_service_receive_voice( @pytest.mark.parametrize( ("mock_provider", "mock_tts_entity"), - [(MockProvider("de_DE"), MockTTSEntity("de_DE"))], + [(MockTTSProvider("de_DE"), MockTTSEntity("de_DE"))], ) @pytest.mark.parametrize( ("setup", "tts_service", "service_data", "expected_url_suffix"), @@ -1015,7 +1015,7 @@ async def test_service_without_cache( ).is_file() -class MockProviderBoom(MockProvider): +class MockProviderBoom(MockTTSProvider): """Mock provider that blows up.""" def get_tts_audio( @@ -1041,7 +1041,7 @@ def get_tts_audio( async def test_setup_legacy_cache_dir( hass: HomeAssistant, mock_tts_cache_dir: Path, - mock_provider: MockProvider, + mock_provider: MockTTSProvider, ) -> None: """Set up a TTS platform with cache and call service without cache.""" calls = async_mock_service(hass, DOMAIN_MP, SERVICE_PLAY_MEDIA) @@ -1106,7 +1106,7 @@ async def test_setup_cache_dir( await hass.async_block_till_done() -class MockProviderEmpty(MockProvider): +class MockProviderEmpty(MockTTSProvider): """Mock provider with empty get_tts_audio.""" def get_tts_audio( @@ -1178,7 +1178,7 @@ async def test_service_get_tts_error( async def test_load_cache_legacy_retrieve_without_mem_cache( hass: HomeAssistant, - mock_provider: MockProvider, + mock_provider: MockTTSProvider, mock_tts_cache_dir: Path, hass_client: ClientSessionGenerator, ) -> None: @@ -1426,7 +1426,7 @@ async def test_legacy_fetching_in_async( """Test async fetching of data for a legacy provider.""" tts_audio: asyncio.Future[bytes] = asyncio.Future() - class ProviderWithAsyncFetching(MockProvider): + class ProviderWithAsyncFetching(MockTTSProvider): """Provider that supports audio output option.""" @property @@ -1662,8 +1662,8 @@ async def test_ws_list_engines_deprecated( also provides tts entities. """ - mock_provider = MockProvider(DEFAULT_LANG) - mock_provider_2 = MockProvider(DEFAULT_LANG) + mock_provider = MockTTSProvider(DEFAULT_LANG) + mock_provider_2 = MockTTSProvider(DEFAULT_LANG) mock_integration(hass, MockModule(domain="test")) mock_platform(hass, "test.tts", MockTTS(mock_provider)) mock_integration(hass, MockModule(domain="test_2")) @@ -1910,7 +1910,7 @@ def supported_languages(self) -> list[str]: async def test_default_engine_prefer_entity( hass: HomeAssistant, mock_tts_entity: MockTTSEntity, - mock_provider: MockProvider, + mock_provider: MockTTSProvider, ) -> None: """Test async_default_engine. @@ -1941,7 +1941,7 @@ async def test_default_engine_prefer_entity( ) async def test_default_engine_prefer_cloud_entity( hass: HomeAssistant, - mock_provider: MockProvider, + mock_provider: MockTTSProvider, config_flow_test_domains: str, ) -> None: """Test async_default_engine. diff --git a/tests/components/tts/test_legacy.py b/tests/components/tts/test_legacy.py index 0d7f99e8cd112e..22e8ac35f16171 100644 --- a/tests/components/tts/test_legacy.py +++ b/tests/components/tts/test_legacy.py @@ -17,7 +17,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.setup import async_setup_component -from .common import SUPPORT_LANGUAGES, MockProvider, MockTTS +from .common import SUPPORT_LANGUAGES, MockTTS, MockTTSProvider from tests.common import ( MockModule, @@ -75,7 +75,9 @@ async def test_invalid_platform( async def test_platform_setup_without_provider( - hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mock_provider: MockProvider + hass: HomeAssistant, + caplog: pytest.LogCaptureFixture, + mock_provider: MockTTSProvider, ) -> None: """Test platform setup without provider returned.""" @@ -109,7 +111,7 @@ async def async_get_engine( async def test_platform_setup_with_error( hass: HomeAssistant, caplog: pytest.LogCaptureFixture, - mock_provider: MockProvider, + mock_provider: MockTTSProvider, ) -> None: """Test platform setup with an error during setup.""" diff --git a/tests/components/tts/test_media_source.py b/tests/components/tts/test_media_source.py index 4c10d8f0b08b88..ba856fd9622293 100644 --- a/tests/components/tts/test_media_source.py +++ b/tests/components/tts/test_media_source.py @@ -12,8 +12,8 @@ from .common import ( DEFAULT_LANG, - MockProvider, MockTTSEntity, + MockTTSProvider, mock_config_entry_setup, mock_setup, retrieve_media, @@ -28,7 +28,7 @@ class MSEntity(MockTTSEntity): get_tts_audio = MagicMock(return_value=("mp3", b"")) -class MSProvider(MockProvider): +class MSProvider(MockTTSProvider): """Test speech API provider.""" get_tts_audio = MagicMock(return_value=("mp3", b"")) From c4e5d6755194fd8678b63d9ae8022b5475906e7f Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 14:14:45 +0200 Subject: [PATCH 62/67] Enforce new service icon schema for core integrations (#124772) Co-authored-by: Paulus Schoutsen --- script/hassfest/icons.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/script/hassfest/icons.py b/script/hassfest/icons.py index 92d42efb842614..f6bcd865c23cd7 100644 --- a/script/hassfest/icons.py +++ b/script/hassfest/icons.py @@ -61,7 +61,20 @@ def ensure_not_same_as_default(value: dict) -> dict: ) -SERVICE_ICONS_SCHEMA = cv.schema_with_slug_keys( +CORE_SERVICE_ICONS_SCHEMA = cv.schema_with_slug_keys( + vol.Schema( + { + vol.Optional("service"): icon_value_validator, + vol.Optional("sections"): cv.schema_with_slug_keys( + icon_value_validator, slug_validator=translation_key_validator + ), + } + ), + slug_validator=translation_key_validator, +) + + +CUSTOM_INTEGRATION_SERVICE_ICONS_SCHEMA = cv.schema_with_slug_keys( vol.All( convert_shorthand_service_icon, vol.Schema( @@ -77,7 +90,9 @@ def ensure_not_same_as_default(value: dict) -> dict: ) -def icon_schema(integration_type: str, no_entity_platform: bool) -> vol.Schema: +def icon_schema( + core_integration: bool, integration_type: str, no_entity_platform: bool +) -> vol.Schema: """Create an icon schema.""" state_validator = cv.schema_with_slug_keys( @@ -108,7 +123,9 @@ def icon_schema_slug(marker: type[vol.Marker]) -> dict[vol.Marker, Any]: {str: {"fix_flow": DATA_ENTRY_ICONS_SCHEMA}} ), vol.Optional("options"): DATA_ENTRY_ICONS_SCHEMA, - vol.Optional("services"): SERVICE_ICONS_SCHEMA, + vol.Optional("services"): CORE_SERVICE_ICONS_SCHEMA + if core_integration + else CUSTOM_INTEGRATION_SERVICE_ICONS_SCHEMA, } ) @@ -163,7 +180,9 @@ def validate_icon_file(config: Config, integration: Integration) -> None: no_entity_platform = integration.domain in ("notify", "image_processing") - schema = icon_schema(integration.integration_type, no_entity_platform) + schema = icon_schema( + integration.core, integration.integration_type, no_entity_platform + ) try: schema(icons) From f8ac952cd7f5e2b36d259bed9f2652adfb9f86f8 Mon Sep 17 00:00:00 2001 From: Matrix Date: Wed, 28 Aug 2024 20:18:55 +0800 Subject: [PATCH 63/67] Add YoLink lock V2 support (#124202) * Add Lock V2 Support * Change as suggestions --- homeassistant/components/yolink/lock.py | 39 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/yolink/lock.py b/homeassistant/components/yolink/lock.py index 177a8808de143e..d675fd8cf06a1f 100644 --- a/homeassistant/components/yolink/lock.py +++ b/homeassistant/components/yolink/lock.py @@ -1,11 +1,11 @@ -"""YoLink Lock.""" +"""YoLink Lock V1/V2.""" from __future__ import annotations from typing import Any from yolink.client_request import ClientRequest -from yolink.const import ATTR_DEVICE_LOCK +from yolink.const import ATTR_DEVICE_LOCK, ATTR_DEVICE_LOCK_V2 from homeassistant.components.lock import LockEntity from homeassistant.config_entries import ConfigEntry @@ -27,7 +27,8 @@ async def async_setup_entry( entities = [ YoLinkLockEntity(config_entry, device_coordinator) for device_coordinator in device_coordinators.values() - if device_coordinator.device.device_type == ATTR_DEVICE_LOCK + if device_coordinator.device.device_type + in [ATTR_DEVICE_LOCK, ATTR_DEVICE_LOCK_V2] ] async_add_entities(entities) @@ -50,21 +51,41 @@ def __init__( def update_entity_state(self, state: dict[str, Any]) -> None: """Update HA Entity State.""" state_value = state.get("state") - self._attr_is_locked = ( - state_value == "locked" if state_value is not None else None - ) + if self.coordinator.device.device_type == ATTR_DEVICE_LOCK_V2: + self._attr_is_locked = ( + state_value["lock"] == "locked" if state_value is not None else None + ) + else: + self._attr_is_locked = ( + state_value == "locked" if state_value is not None else None + ) self.async_write_ha_state() async def call_lock_state_change(self, state: str) -> None: """Call setState api to change lock state.""" - await self.call_device(ClientRequest("setState", {"state": state})) + if self.coordinator.device.device_type == ATTR_DEVICE_LOCK_V2: + await self.call_device( + ClientRequest("setState", {"state": {"lock": state}}) + ) + else: + await self.call_device(ClientRequest("setState", {"state": state})) self._attr_is_locked = state == "lock" self.async_write_ha_state() async def async_lock(self, **kwargs: Any) -> None: """Lock device.""" - await self.call_lock_state_change("lock") + state_param = ( + "locked" + if self.coordinator.device.device_type == ATTR_DEVICE_LOCK_V2 + else "lock" + ) + await self.call_lock_state_change(state_param) async def async_unlock(self, **kwargs: Any) -> None: """Unlock device.""" - await self.call_lock_state_change("unlock") + state_param = ( + "unlocked" + if self.coordinator.device.device_type == ATTR_DEVICE_LOCK_V2 + else "unlock" + ) + await self.call_lock_state_change(state_param) From 0afae45bc5c652d47866f11ebc0da68b084587b1 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 28 Aug 2024 14:27:01 +0200 Subject: [PATCH 64/67] Trigger full CI run on Blueprint integration changes (#124778) --- .core_files.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.core_files.yaml b/.core_files.yaml index 3f92ed87a84f04..4a11d5da27c5e4 100644 --- a/.core_files.yaml +++ b/.core_files.yaml @@ -61,6 +61,7 @@ components: &components - homeassistant/components/auth/** - homeassistant/components/automation/** - homeassistant/components/backup/** + - homeassistant/components/blueprint/** - homeassistant/components/bluetooth/** - homeassistant/components/cloud/** - homeassistant/components/config/** From 11370979e5c07e028a537b6502f480fe211f93bc Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:54:30 +0200 Subject: [PATCH 65/67] Fix translation for AVM Fritz!Box Tools (#124784) add missing ssl option to strings --- homeassistant/components/fritz/strings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/fritz/strings.json b/homeassistant/components/fritz/strings.json index 3b6c60ed48fc1b..6be393cc63601d 100644 --- a/homeassistant/components/fritz/strings.json +++ b/homeassistant/components/fritz/strings.json @@ -7,7 +7,8 @@ "description": "Discovered FRITZ!Box: {name}\n\nSet up FRITZ!Box Tools to control your {name}", "data": { "username": "[%key:common::config_flow::data::username%]", - "password": "[%key:common::config_flow::data::password%]" + "password": "[%key:common::config_flow::data::password%]", + "ssl": "[%key:common::config_flow::data::ssl%]" } }, "reauth_confirm": { From e39b3796f34523d29ee82575d7d3b2f602618dad Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Wed, 28 Aug 2024 22:58:16 +1000 Subject: [PATCH 66/67] Fix OAuth reauth in Tesla Fleet (#124744) * Fix auth failure * Test * Fix test * Only reauth on 401 * Cover 401 and others * Update homeassistant/components/tesla_fleet/strings.json Co-authored-by: Jan Bouwhuis --------- Co-authored-by: Jan Bouwhuis --- .../components/tesla_fleet/__init__.py | 8 ++- .../components/tesla_fleet/config_flow.py | 5 +- .../components/tesla_fleet/strings.json | 2 +- tests/components/tesla_fleet/conftest.py | 2 +- tests/components/tesla_fleet/test_init.py | 49 ++++++++++++++++++- 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/tesla_fleet/__init__.py b/homeassistant/components/tesla_fleet/__init__.py index 47a2a9173a5d09..183e7e753b5a51 100644 --- a/homeassistant/components/tesla_fleet/__init__.py +++ b/homeassistant/components/tesla_fleet/__init__.py @@ -3,6 +3,7 @@ import asyncio from typing import Final +from aiohttp.client_exceptions import ClientResponseError import jwt from tesla_fleet_api import EnergySpecific, TeslaFleetApi, VehicleSpecific from tesla_fleet_api.const import Scope @@ -66,7 +67,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) - async def _refresh_token() -> str: async with refresh_lock: - await oauth_session.async_ensure_token_valid() + try: + await oauth_session.async_ensure_token_valid() + except ClientResponseError as e: + if e.status == 401: + raise ConfigEntryAuthFailed from e + raise ConfigEntryNotReady from e token: str = oauth_session.token[CONF_ACCESS_TOKEN] return token diff --git a/homeassistant/components/tesla_fleet/config_flow.py b/homeassistant/components/tesla_fleet/config_flow.py index 0ffdca1aec601a..64b88792387de2 100644 --- a/homeassistant/components/tesla_fleet/config_flow.py +++ b/homeassistant/components/tesla_fleet/config_flow.py @@ -83,5 +83,8 @@ async def async_step_reauth_confirm( ) -> ConfigFlowResult: """Confirm reauth dialog.""" if user_input is None: - return self.async_show_form(step_id="reauth_confirm") + return self.async_show_form( + step_id="reauth_confirm", + description_placeholders={"name": "Tesla Fleet"}, + ) return await self.async_step_user() diff --git a/homeassistant/components/tesla_fleet/strings.json b/homeassistant/components/tesla_fleet/strings.json index 6e74714ddd5dae..d4848836689396 100644 --- a/homeassistant/components/tesla_fleet/strings.json +++ b/homeassistant/components/tesla_fleet/strings.json @@ -19,7 +19,7 @@ }, "reauth_confirm": { "title": "[%key:common::config_flow::title::reauth%]", - "description": "The Withings integration needs to re-authenticate your account" + "description": "The {name} integration needs to re-authenticate your account" } }, "create_entry": { diff --git a/tests/components/tesla_fleet/conftest.py b/tests/components/tesla_fleet/conftest.py index 49f0be9cca7f66..615c62fe16e549 100644 --- a/tests/components/tesla_fleet/conftest.py +++ b/tests/components/tesla_fleet/conftest.py @@ -124,7 +124,7 @@ def mock_site_info() -> Generator[AsyncMock]: yield mock_live_status -@pytest.fixture(autouse=True) +@pytest.fixture def mock_find_server() -> Generator[AsyncMock]: """Mock Tesla Fleet find server method.""" with patch( diff --git a/tests/components/tesla_fleet/test_init.py b/tests/components/tesla_fleet/test_init.py index b5eb21d1cdd523..9dcac4ec388c72 100644 --- a/tests/components/tesla_fleet/test_init.py +++ b/tests/components/tesla_fleet/test_init.py @@ -1,7 +1,9 @@ """Test the Tesla Fleet init.""" -from unittest.mock import AsyncMock +from unittest.mock import AsyncMock, patch +from aiohttp import RequestInfo +from aiohttp.client_exceptions import ClientResponseError from freezegun.api import FrozenDateTimeFactory import pytest from syrupy.assertion import SnapshotAssertion @@ -16,6 +18,7 @@ VehicleOffline, ) +from homeassistant.components.tesla_fleet.const import AUTHORIZE_URL from homeassistant.components.tesla_fleet.coordinator import ( ENERGY_INTERVAL, ENERGY_INTERVAL_SECONDS, @@ -72,6 +75,50 @@ async def test_init_error( assert normal_config_entry.state is state +async def test_oauth_refresh_expired( + hass: HomeAssistant, + normal_config_entry: MockConfigEntry, + mock_products: AsyncMock, +) -> None: + """Test init with expired Oauth token.""" + + # Patch the token refresh to raise an error + with patch( + "homeassistant.components.tesla_fleet.OAuth2Session.async_ensure_token_valid", + side_effect=ClientResponseError( + RequestInfo(AUTHORIZE_URL, "POST", {}, AUTHORIZE_URL), None, status=401 + ), + ) as mock_async_ensure_token_valid: + # Trigger an unmocked function call + mock_products.side_effect = InvalidRegion + await setup_platform(hass, normal_config_entry) + + mock_async_ensure_token_valid.assert_called_once() + assert normal_config_entry.state is ConfigEntryState.SETUP_ERROR + + +async def test_oauth_refresh_error( + hass: HomeAssistant, + normal_config_entry: MockConfigEntry, + mock_products: AsyncMock, +) -> None: + """Test init with Oauth refresh failure.""" + + # Patch the token refresh to raise an error + with patch( + "homeassistant.components.tesla_fleet.OAuth2Session.async_ensure_token_valid", + side_effect=ClientResponseError( + RequestInfo(AUTHORIZE_URL, "POST", {}, AUTHORIZE_URL), None, status=400 + ), + ) as mock_async_ensure_token_valid: + # Trigger an unmocked function call + mock_products.side_effect = InvalidRegion + await setup_platform(hass, normal_config_entry) + + mock_async_ensure_token_valid.assert_called_once() + assert normal_config_entry.state is ConfigEntryState.SETUP_RETRY + + # Test devices async def test_devices( hass: HomeAssistant, From 84c989b6a2cd922a793f26c1aa2d6d7eafdb65d4 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Wed, 28 Aug 2024 13:26:33 +0000 Subject: [PATCH 67/67] Typo --- .github/workflows/builder.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index d47e45e14e227f..d206f8fe8c803a 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -494,8 +494,8 @@ jobs: needs: ["init", "build_base"] if: github.repository_owner == 'home-assistant' env: - HASSFEST_IMAGE_NAME: ghcr.io/homeassistant/hassfest - HASSFEST_IMAGE_TAG: ghcr.io/homeassistant/hassfest:${{ needs.init.outputs.version }} + HASSFEST_IMAGE_NAME: ghcr.io/home-assistant/hassfest + HASSFEST_IMAGE_TAG: ghcr.io/home-assistant/hassfest:${{ needs.init.outputs.version }} steps: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7