From baef267f335b95ec30cf8791f74e199a104e8148 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 22 Dec 2022 13:35:47 +0100 Subject: [PATCH] String formatting and max line length - Part 3 (#84394) --- .../components/input_number/__init__.py | 3 +- .../components/input_select/__init__.py | 5 +- .../components/insteon/insteon_entity.py | 10 +++- homeassistant/components/ipma/weather.py | 5 +- homeassistant/components/ipp/config_flow.py | 6 ++- homeassistant/components/ipp/sensor.py | 4 +- .../islamic_prayer_times/__init__.py | 6 ++- homeassistant/components/isy994/__init__.py | 6 ++- .../components/isy994/binary_sensor.py | 6 ++- homeassistant/components/isy994/entity.py | 6 ++- homeassistant/components/isy994/helpers.py | 5 +- homeassistant/components/isy994/services.py | 6 ++- homeassistant/components/juicenet/entity.py | 4 +- homeassistant/components/keba/__init__.py | 6 ++- homeassistant/components/knx/__init__.py | 10 +++- homeassistant/components/knx/config_flow.py | 10 +++- homeassistant/components/knx/schema.py | 48 ++++++++++++++----- homeassistant/components/konnected/panel.py | 6 ++- homeassistant/components/kraken/__init__.py | 6 ++- .../components/lacrosse_view/sensor.py | 3 +- homeassistant/components/lcn/__init__.py | 11 +++-- homeassistant/components/lcn/config_flow.py | 6 ++- .../components/led_ble/config_flow.py | 4 +- .../components/life360/device_tracker.py | 12 +++-- homeassistant/components/lifx/__init__.py | 5 +- homeassistant/components/lifx/light.py | 5 +- homeassistant/components/lifx/util.py | 3 +- .../components/light/reproduce_state.py | 5 +- .../components/logi_circle/__init__.py | 15 +++--- homeassistant/components/london_air/sensor.py | 5 +- homeassistant/components/lovelace/__init__.py | 6 ++- homeassistant/components/luftdaten/sensor.py | 4 +- .../components/lutron_caseta/logbook.py | 4 +- homeassistant/components/lyric/climate.py | 3 +- .../components/magicseaweed/sensor.py | 10 +++- .../components/mailgun/config_flow.py | 4 +- homeassistant/components/maxcube/__init__.py | 5 +- .../components/media_player/__init__.py | 6 ++- homeassistant/components/melcloud/climate.py | 6 ++- homeassistant/components/met/weather.py | 3 +- .../components/meteo_france/__init__.py | 15 ++++-- .../components/minecraft_server/__init__.py | 5 +- .../components/mobile_app/webhook.py | 6 ++- .../components/modbus/base_platform.py | 5 +- homeassistant/components/modbus/validators.py | 18 +++++-- .../components/modern_forms/__init__.py | 5 +- .../components/moehlenhoff_alpha2/sensor.py | 5 +- .../components/motion_blinds/__init__.py | 6 ++- .../components/motion_blinds/gateway.py | 5 +- homeassistant/components/motioneye/const.py | 4 +- homeassistant/components/mqtt/__init__.py | 30 ++++++++---- .../components/mqtt/binary_sensor.py | 20 ++++++-- homeassistant/components/mqtt/client.py | 11 +++-- .../components/mqtt/config_integration.py | 3 +- homeassistant/components/mqtt/cover.py | 23 ++++++--- homeassistant/components/mqtt/discovery.py | 9 ++-- homeassistant/components/mqtt/fan.py | 10 +++- homeassistant/components/mqtt/mixins.py | 14 ++++-- homeassistant/components/mqtt/models.py | 5 +- homeassistant/components/mqtt/sensor.py | 5 +- homeassistant/components/mqtt/siren.py | 10 +++- homeassistant/components/mqtt/update.py | 15 ++++-- homeassistant/components/mqtt/util.py | 3 +- .../components/mqtt_json/device_tracker.py | 6 ++- homeassistant/components/nest/__init__.py | 9 +++- .../nest/application_credentials.py | 4 +- homeassistant/components/nest/config_flow.py | 3 +- .../components/nest/legacy/__init__.py | 17 ++++--- homeassistant/components/netgear/__init__.py | 6 ++- homeassistant/components/netgear/router.py | 5 +- homeassistant/components/network/__init__.py | 6 ++- homeassistant/components/network/util.py | 5 +- homeassistant/components/nextdns/switch.py | 3 +- homeassistant/components/nilu/air_quality.py | 16 ++++--- .../components/nmap_tracker/__init__.py | 10 +++- homeassistant/components/nobo_hub/climate.py | 3 +- homeassistant/components/notify/legacy.py | 13 +++-- homeassistant/components/numato/__init__.py | 8 +++- .../components/numato/binary_sensor.py | 5 +- homeassistant/components/number/__init__.py | 25 ++++++---- .../components/onkyo/media_player.py | 3 +- homeassistant/components/onvif/config_flow.py | 5 +- homeassistant/components/onvif/device.py | 24 +++++++--- homeassistant/components/onvif/event.py | 17 +++++-- .../components/opentherm_gw/binary_sensor.py | 10 ++-- .../components/opentherm_gw/sensor.py | 10 ++-- homeassistant/components/opple/light.py | 3 +- .../components/osramlightify/light.py | 4 +- 88 files changed, 517 insertions(+), 218 deletions(-) diff --git a/homeassistant/components/input_number/__init__.py b/homeassistant/components/input_number/__init__.py index 99e54dc9baa..d81ec581bc8 100644 --- a/homeassistant/components/input_number/__init__.py +++ b/homeassistant/components/input_number/__init__.py @@ -307,7 +307,8 @@ class InputNumber(collection.CollectionEntity, RestoreEntity): if num_value < self._minimum or num_value > self._maximum: raise vol.Invalid( - f"Invalid value for {self.entity_id}: {value} (range {self._minimum} - {self._maximum})" + f"Invalid value for {self.entity_id}: {value} (range {self._minimum} -" + f" {self._maximum})" ) self._current_value = num_value diff --git a/homeassistant/components/input_select/__init__.py b/homeassistant/components/input_select/__init__.py index f30b2ca1e36..bd9c43e8538 100644 --- a/homeassistant/components/input_select/__init__.py +++ b/homeassistant/components/input_select/__init__.py @@ -73,7 +73,10 @@ def _remove_duplicates(options: list[str], name: str | None) -> list[str]: # Reject YAML configured input_select with duplicates from 2022.6 if len(unique_options) != len(options): _LOGGER.warning( - "Input select '%s' with options %s had duplicated options, the duplicates have been removed", + ( + "Input select '%s' with options %s had duplicated options, the" + " duplicates have been removed" + ), name or "", options, ) diff --git a/homeassistant/components/insteon/insteon_entity.py b/homeassistant/components/insteon/insteon_entity.py index d1ba7c5f829..dd7acc65458 100644 --- a/homeassistant/components/insteon/insteon_entity.py +++ b/homeassistant/components/insteon/insteon_entity.py @@ -83,9 +83,15 @@ class InsteonEntity(Entity): return DeviceInfo( identifiers={(DOMAIN, str(self._insteon_device.address))}, manufacturer="SmartLabs, Inc", - model=f"{self._insteon_device.model} ({self._insteon_device.cat!r}, 0x{self._insteon_device.subcat:02x})", + model=( + f"{self._insteon_device.model} ({self._insteon_device.cat!r}," + f" 0x{self._insteon_device.subcat:02x})" + ), name=f"{self._insteon_device.description} {self._insteon_device.address}", - sw_version=f"{self._insteon_device.firmware:02x} Engine Version: {self._insteon_device.engine_version}", + sw_version=( + f"{self._insteon_device.firmware:02x} Engine Version:" + f" {self._insteon_device.engine_version}" + ), via_device=(DOMAIN, str(devices.modem.address)), ) diff --git a/homeassistant/components/ipma/weather.py b/homeassistant/components/ipma/weather.py index 467523c5830..4387e2d8e1e 100644 --- a/homeassistant/components/ipma/weather.py +++ b/homeassistant/components/ipma/weather.py @@ -158,7 +158,10 @@ class IPMAWeather(WeatherEntity): @property def unique_id(self) -> str: """Return a unique id.""" - return f"{self._location.station_latitude}, {self._location.station_longitude}, {self._mode}" + return ( + f"{self._location.station_latitude}, {self._location.station_longitude}," + f" {self._mode}" + ) @property def name(self): diff --git a/homeassistant/components/ipp/config_flow.py b/homeassistant/components/ipp/config_flow.py index fa5e23063b4..a00190eebce 100644 --- a/homeassistant/components/ipp/config_flow.py +++ b/homeassistant/components/ipp/config_flow.py @@ -90,7 +90,8 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): if not unique_id and info[CONF_SERIAL]: _LOGGER.debug( - "Printer UUID is missing from IPP response. Falling back to IPP serial number" + "Printer UUID is missing from IPP response. Falling back to IPP serial" + " number" ) unique_id = info[CONF_SERIAL] elif not unique_id: @@ -154,7 +155,8 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): unique_id = self.discovery_info[CONF_UUID] = info[CONF_UUID] elif not unique_id and info[CONF_SERIAL]: _LOGGER.debug( - "Printer UUID is missing from discovery info and IPP response. Falling back to IPP serial number" + "Printer UUID is missing from discovery info and IPP response. Falling" + " back to IPP serial number" ) unique_id = info[CONF_SERIAL] elif not unique_id: diff --git a/homeassistant/components/ipp/sensor.py b/homeassistant/components/ipp/sensor.py index 718b35dbc6a..293a6378b78 100644 --- a/homeassistant/components/ipp/sensor.py +++ b/homeassistant/components/ipp/sensor.py @@ -101,7 +101,9 @@ class IPPMarkerSensor(IPPSensor): unique_id=unique_id, icon="mdi:water", key=f"marker_{marker_index}", - name=f"{coordinator.data.info.name} {coordinator.data.markers[marker_index].name}", + name=( + f"{coordinator.data.info.name} {coordinator.data.markers[marker_index].name}" + ), unit_of_measurement=PERCENTAGE, ) diff --git a/homeassistant/components/islamic_prayer_times/__init__.py b/homeassistant/components/islamic_prayer_times/__init__.py index 406eaf23670..55c27c4cc59 100644 --- a/homeassistant/components/islamic_prayer_times/__init__.py +++ b/homeassistant/components/islamic_prayer_times/__init__.py @@ -105,11 +105,13 @@ class IslamicPrayerClient: if now > dt_util.as_utc(midnight_dt): next_update_at = midnight_dt + timedelta(days=1, minutes=1) _LOGGER.debug( - "Midnight is after day the changes so schedule update for after Midnight the next day" + "Midnight is after day the changes so schedule update for after" + " Midnight the next day" ) else: _LOGGER.debug( - "Midnight is before the day changes so schedule update for the next start of day" + "Midnight is before the day changes so schedule update for the next" + " start of day" ) next_update_at = dt_util.start_of_local_day(now + timedelta(days=1)) diff --git a/homeassistant/components/isy994/__init__.py b/homeassistant/components/isy994/__init__.py index 1b689e563dc..4fabb120102 100644 --- a/homeassistant/components/isy994/__init__.py +++ b/homeassistant/components/isy994/__init__.py @@ -180,7 +180,8 @@ async def async_setup_entry( await isy.initialize() except asyncio.TimeoutError as err: raise ConfigEntryNotReady( - f"Timed out initializing the ISY; device may be busy, trying again later: {err}" + "Timed out initializing the ISY; device may be busy, trying again later:" + f" {err}" ) from err except ISYInvalidAuthError as err: raise ConfigEntryAuthFailed(f"Invalid credentials for the ISY: {err}") from err @@ -190,7 +191,8 @@ async def async_setup_entry( ) from err except ISYResponseParseError as err: raise ConfigEntryNotReady( - f"Invalid XML response from ISY; Ensure the ISY is running the latest firmware: {err}" + "Invalid XML response from ISY; Ensure the ISY is running the latest" + f" firmware: {err}" ) from err except TypeError as err: raise ConfigEntryNotReady( diff --git a/homeassistant/components/isy994/binary_sensor.py b/homeassistant/components/isy994/binary_sensor.py index 81efdb5922a..399d9953170 100644 --- a/homeassistant/components/isy994/binary_sensor.py +++ b/homeassistant/components/isy994/binary_sensor.py @@ -116,8 +116,10 @@ async def async_setup_entry( parent_entity = entities_by_address.get(node.parent_node.address) if not parent_entity: _LOGGER.error( - "Node %s has a parent node %s, but no device " - "was created for the parent. Skipping", + ( + "Node %s has a parent node %s, but no device " + "was created for the parent. Skipping" + ), node.address, node.parent_node, ) diff --git a/homeassistant/components/isy994/entity.py b/homeassistant/components/isy994/entity.py index 61f42a60a6e..a90701f3323 100644 --- a/homeassistant/components/isy994/entity.py +++ b/homeassistant/components/isy994/entity.py @@ -209,7 +209,8 @@ class ISYNodeEntity(ISYEntity): """Respond to an entity service command to request a Z-Wave device parameter from the ISY.""" if not hasattr(self._node, "protocol") or self._node.protocol != PROTO_ZWAVE: raise HomeAssistantError( - f"Invalid service call: cannot request Z-Wave Parameter for non-Z-Wave device {self.entity_id}" + "Invalid service call: cannot request Z-Wave Parameter for non-Z-Wave" + f" device {self.entity_id}" ) await self._node.get_zwave_parameter(parameter) @@ -219,7 +220,8 @@ class ISYNodeEntity(ISYEntity): """Respond to an entity service command to set a Z-Wave device parameter via the ISY.""" if not hasattr(self._node, "protocol") or self._node.protocol != PROTO_ZWAVE: raise HomeAssistantError( - f"Invalid service call: cannot set Z-Wave Parameter for non-Z-Wave device {self.entity_id}" + "Invalid service call: cannot set Z-Wave Parameter for non-Z-Wave" + f" device {self.entity_id}" ) await self._node.set_zwave_parameter(parameter, value, size) await self._node.get_zwave_parameter(parameter) diff --git a/homeassistant/components/isy994/helpers.py b/homeassistant/components/isy994/helpers.py index 736cd12b9ea..c4f0c2ea595 100644 --- a/homeassistant/components/isy994/helpers.py +++ b/homeassistant/components/isy994/helpers.py @@ -352,7 +352,10 @@ def _categorize_programs(hass_isy_data: dict, programs: Programs) -> None: actions = entity_folder.get_by_name(KEY_ACTIONS) if not actions or actions.protocol != PROTO_PROGRAM: _LOGGER.warning( - "Program %s entity '%s' not loaded, invalid/missing actions program", + ( + "Program %s entity '%s' not loaded, invalid/missing actions" + " program" + ), platform, entity_folder.name, ) diff --git a/homeassistant/components/isy994/services.py b/homeassistant/components/isy994/services.py index 30b5f121df3..18076e2da98 100644 --- a/homeassistant/components/isy994/services.py +++ b/homeassistant/components/isy994/services.py @@ -299,8 +299,10 @@ def async_setup_services(hass: HomeAssistant) -> None: # noqa: C901 entity_registry.async_remove(entity_id) _LOGGER.debug( - "Cleaning up ISY994 Entities and devices: Config Entries: %s, Current Entries: %s, " - "Extra Entries Removed: %s", + ( + "Cleaning up ISY994 Entities and devices: Config Entries: %s, Current" + " Entries: %s, Extra Entries Removed: %s" + ), len(config_ids), len(current_unique_ids), len(extra_entities), diff --git a/homeassistant/components/juicenet/entity.py b/homeassistant/components/juicenet/entity.py index c0151a0cd00..0f3811bef6f 100644 --- a/homeassistant/components/juicenet/entity.py +++ b/homeassistant/components/juicenet/entity.py @@ -31,7 +31,9 @@ class JuiceNetDevice(CoordinatorEntity): def device_info(self) -> DeviceInfo: """Return device information about this JuiceNet Device.""" return DeviceInfo( - configuration_url=f"https://home.juice.net/Portal/Details?unitID={self.device.id}", + configuration_url=( + f"https://home.juice.net/Portal/Details?unitID={self.device.id}" + ), identifiers={(DOMAIN, self.device.id)}, manufacturer="JuiceNet", name=self.device.name, diff --git a/homeassistant/components/keba/__init__.py b/homeassistant/components/keba/__init__.py index b957acd2a31..1c99a6500c5 100644 --- a/homeassistant/components/keba/__init__.py +++ b/homeassistant/components/keba/__init__.py @@ -235,7 +235,9 @@ class KebaHandler(KebaKeContact): self._set_fast_polling() except (KeyError, ValueError) as ex: _LOGGER.warning( - "Values are not correct for: failsafe_timeout, failsafe_fallback and/or " - "failsafe_persist: %s", + ( + "Values are not correct for: failsafe_timeout, failsafe_fallback" + " and/or failsafe_persist: %s" + ), ex, ) diff --git a/homeassistant/components/knx/__init__.py b/homeassistant/components/knx/__init__.py index 5d2ab031323..0159f6f1cac 100644 --- a/homeassistant/components/knx/__init__.py +++ b/homeassistant/components/knx/__init__.py @@ -495,7 +495,10 @@ class KNXModule: value = transcoder.from_knx(data) except ConversionError as err: _LOGGER.warning( - "Error in `knx_event` at decoding type '%s' from telegram %s\n%s", + ( + "Error in `knx_event` at decoding type '%s' from" + " telegram %s\n%s" + ), transcoder.__name__, telegram, err, @@ -584,7 +587,10 @@ class KNXModule: if group_address in self.service_exposures: replaced_exposure = self.service_exposures.pop(group_address) _LOGGER.warning( - "Service exposure_register replacing already registered exposure for '%s' - %s", + ( + "Service exposure_register replacing already registered exposure" + " for '%s' - %s" + ), group_address, replaced_exposure.device.name, ) diff --git a/homeassistant/components/knx/config_flow.py b/homeassistant/components/knx/config_flow.py index 6e0c357b5fa..c1e8c12dd01 100644 --- a/homeassistant/components/knx/config_flow.py +++ b/homeassistant/components/knx/config_flow.py @@ -399,7 +399,10 @@ class KNXCommonFlow(ABC, FlowHandler): ], ) return self.finish_flow( - title=f"Secure Routing as {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}" + title=( + "Secure Routing as" + f" {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}" + ) ) fields = { @@ -464,7 +467,10 @@ class KNXCommonFlow(ABC, FlowHandler): self.new_entry_data[CONF_KNX_CONNECTION_TYPE] == CONF_KNX_ROUTING_SECURE ): - title = f"Secure Routing as {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}" + title = ( + "Secure Routing as" + f" {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}" + ) else: title = f"Secure Tunneling @ {self.new_entry_data[CONF_HOST]}" return self.finish_flow(title=title) diff --git a/homeassistant/components/knx/schema.py b/homeassistant/components/knx/schema.py index 87a7b6fdab5..e756fc5e466 100644 --- a/homeassistant/components/knx/schema.py +++ b/homeassistant/components/knx/schema.py @@ -74,7 +74,8 @@ def dpt_subclass_validator(dpt_base_class: type[DPTBase]) -> Callable[[Any], str ): return value raise vol.Invalid( - f"type '{value}' is not a valid DPT identifier for {dpt_base_class.__name__}." + f"type '{value}' is not a valid DPT identifier for" + f" {dpt_base_class.__name__}." ) return dpt_value_validator @@ -94,8 +95,9 @@ def ga_validator(value: Any) -> str | int: except CouldNotParseAddress: pass raise vol.Invalid( - f"value '{value}' is not a valid KNX group address '
//', '
/' " - "or '' (eg.'1/2/3', '9/234', '123'), nor xknx internal address 'i-'." + f"value '{value}' is not a valid KNX group address '
//'," + " '
/' or '' (eg.'1/2/3', '9/234', '123'), nor xknx internal" + " address 'i-'." ) @@ -104,7 +106,10 @@ ga_list_validator = vol.All(cv.ensure_list, [ga_validator]) ia_validator = vol.Any( vol.All(str, str.strip, cv.matches_regex(IndividualAddress.ADDRESS_RE.pattern)), vol.All(vol.Coerce(int), vol.Range(min=1, max=65535)), - msg="value does not match pattern for KNX individual address '..' (eg.'1.1.100')", + msg=( + "value does not match pattern for KNX individual address" + " '..' (eg.'1.1.100')" + ), ) @@ -120,7 +125,8 @@ def ip_v4_validator(value: Any, multicast: bool | None = None) -> str: raise vol.Invalid(f"value '{value}' is not a valid IPv4 address: {ex}") from ex if multicast is not None and address.is_multicast != multicast: raise vol.Invalid( - f"value '{value}' is not a valid IPv4 {'multicast' if multicast else 'unicast'} address" + f"value '{value}' is not a valid IPv4" + f" {'multicast' if multicast else 'unicast'} address" ) return str(address) @@ -433,14 +439,18 @@ class ClimateSchema(KNXPlatformSchema): vol.Inclusive( CONF_SETPOINT_SHIFT_ADDRESS, "setpoint_shift", - msg="'setpoint_shift_address' and 'setpoint_shift_state_address' " - "are required for setpoint_shift configuration", + msg=( + "'setpoint_shift_address' and 'setpoint_shift_state_address' " + "are required for setpoint_shift configuration" + ), ): ga_list_validator, vol.Inclusive( CONF_SETPOINT_SHIFT_STATE_ADDRESS, "setpoint_shift", - msg="'setpoint_shift_address' and 'setpoint_shift_state_address' " - "are required for setpoint_shift configuration", + msg=( + "'setpoint_shift_address' and 'setpoint_shift_state_address' " + "are required for setpoint_shift configuration" + ), ): ga_list_validator, vol.Optional(CONF_SETPOINT_SHIFT_MODE): vol.Maybe( vol.All(vol.Upper, cv.enum(SetpointShiftMode)) @@ -509,7 +519,10 @@ class CoverSchema(KNXPlatformSchema): { vol.Required( vol.Any(CONF_MOVE_LONG_ADDRESS, CONF_POSITION_ADDRESS), - msg=f"At least one of '{CONF_MOVE_LONG_ADDRESS}' or '{CONF_POSITION_ADDRESS}' is required.", + msg=( + f"At least one of '{CONF_MOVE_LONG_ADDRESS}' or" + f" '{CONF_POSITION_ADDRESS}' is required." + ), ): object, }, extra=vol.ALLOW_EXTRA, @@ -669,17 +682,26 @@ class LightSchema(KNXPlatformSchema): vol.Inclusive( CONF_RED, "individual_colors", - msg="'red', 'green' and 'blue' are required for individual colors configuration", + msg=( + "'red', 'green' and 'blue' are required for individual" + " colors configuration" + ), ): INDIVIDUAL_COLOR_SCHEMA, vol.Inclusive( CONF_GREEN, "individual_colors", - msg="'red', 'green' and 'blue' are required for individual colors configuration", + msg=( + "'red', 'green' and 'blue' are required for individual" + " colors configuration" + ), ): INDIVIDUAL_COLOR_SCHEMA, vol.Inclusive( CONF_BLUE, "individual_colors", - msg="'red', 'green' and 'blue' are required for individual colors configuration", + msg=( + "'red', 'green' and 'blue' are required for individual" + " colors configuration" + ), ): INDIVIDUAL_COLOR_SCHEMA, vol.Optional(CONF_WHITE): INDIVIDUAL_COLOR_SCHEMA, }, diff --git a/homeassistant/components/konnected/panel.py b/homeassistant/components/konnected/panel.py index 2c7b57449b7..61c77f5a7de 100644 --- a/homeassistant/components/konnected/panel.py +++ b/homeassistant/components/konnected/panel.py @@ -145,8 +145,10 @@ class AlarmPanel: self.connect_attempts = 0 self.connected = True _LOGGER.info( - "Set up Konnected device %s. Open http://%s:%s in a " - "web browser to view device status", + ( + "Set up Konnected device %s. Open http://%s:%s in a " + "web browser to view device status" + ), self.device_id, self.host, self.port, diff --git a/homeassistant/components/kraken/__init__.py b/homeassistant/components/kraken/__init__.py index db2baf56f97..1cfade2a6b7 100644 --- a/homeassistant/components/kraken/__init__.py +++ b/homeassistant/components/kraken/__init__.py @@ -78,7 +78,8 @@ class KrakenData: except pykrakenapi.pykrakenapi.KrakenAPIError as error: if "Unknown asset pair" in str(error): _LOGGER.info( - "Kraken.com reported an unknown asset pair. Refreshing list of tradable asset pairs" + "Kraken.com reported an unknown asset pair. Refreshing list of" + " tradable asset pairs" ) await self._async_refresh_tradable_asset_pairs() else: @@ -87,7 +88,8 @@ class KrakenData: ) from error except pykrakenapi.pykrakenapi.CallRateLimitError: _LOGGER.warning( - "Exceeded the Kraken.com call rate limit. Increase the update interval to prevent this error" + "Exceeded the Kraken.com call rate limit. Increase the update interval" + " to prevent this error" ) return None diff --git a/homeassistant/components/lacrosse_view/sensor.py b/homeassistant/components/lacrosse_view/sensor.py index 52388ca6216..7ef154015cb 100644 --- a/homeassistant/components/lacrosse_view/sensor.py +++ b/homeassistant/components/lacrosse_view/sensor.py @@ -111,7 +111,8 @@ async def async_setup_entry( if description is None: message = ( f"Unsupported sensor field: {field}\nPlease create an issue on " - "GitHub. https://github.com/home-assistant/core/issues/new?assignees=&la" + "GitHub." + " https://github.com/home-assistant/core/issues/new?assignees=&la" "bels=&template=bug_report.yml&integration_name=LaCrosse%20View&integrat" "ion_link=https://www.home-assistant.io/integrations/lacrosse_view/&addi" f"tional_information=Field:%20{field}%0ASensor%20Model:%20{sensor.model}&" diff --git a/homeassistant/components/lcn/__init__.py b/homeassistant/components/lcn/__init__.py index d4a20c4d849..2e1185fd692 100644 --- a/homeassistant/components/lcn/__init__.py +++ b/homeassistant/components/lcn/__init__.py @@ -99,8 +99,10 @@ async def async_setup_entry( return False except pypck.connection.PchkLicenseError: _LOGGER.warning( - 'Maximum number of connections on PCHK "%s" was ' - "reached. An additional license key is required", + ( + 'Maximum number of connections on PCHK "%s" was ' + "reached. An additional license key is required" + ), config_entry.title, ) return False @@ -269,7 +271,10 @@ class LcnEntity(Entity): def device_info(self) -> DeviceInfo | None: """Return device specific attributes.""" address = f"{'g' if self.address[2] else 'm'}{self.address[0]:03d}{self.address[1]:03d}" - model = f"LCN resource ({get_device_model(self.config[CONF_DOMAIN], self.config[CONF_DOMAIN_DATA])})" + model = ( + "LCN resource" + f" ({get_device_model(self.config[CONF_DOMAIN], self.config[CONF_DOMAIN_DATA])})" + ) return { "identifiers": {(DOMAIN, self.unique_id)}, diff --git a/homeassistant/components/lcn/config_flow.py b/homeassistant/components/lcn/config_flow.py index a8c5a311971..09f588b6953 100644 --- a/homeassistant/components/lcn/config_flow.py +++ b/homeassistant/components/lcn/config_flow.py @@ -81,8 +81,10 @@ class LcnFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return self.async_abort(reason="authentication_error") except pypck.connection.PchkLicenseError: _LOGGER.warning( - 'Maximum number of connections on PCHK "%s" was ' - "reached. An additional license key is required", + ( + 'Maximum number of connections on PCHK "%s" was ' + "reached. An additional license key is required" + ), host_name, ) return self.async_abort(reason="license_error") diff --git a/homeassistant/components/led_ble/config_flow.py b/homeassistant/components/led_ble/config_flow.py index d757b5021af..55b7ed45793 100644 --- a/homeassistant/components/led_ble/config_flow.py +++ b/homeassistant/components/led_ble/config_flow.py @@ -104,7 +104,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): { vol.Required(CONF_ADDRESS): vol.In( { - service_info.address: f"{service_info.name} ({service_info.address})" + service_info.address: ( + f"{service_info.name} ({service_info.address})" + ) for service_info in self._discovered_devices.values() } ), diff --git a/homeassistant/components/life360/device_tracker.py b/homeassistant/components/life360/device_tracker.py index 74ab63f88a1..f16e7215a22 100644 --- a/homeassistant/components/life360/device_tracker.py +++ b/homeassistant/components/life360/device_tracker.py @@ -152,16 +152,20 @@ class Life360DeviceTracker( if bad_last_seen or bad_accuracy: if bad_last_seen: LOGGER.warning( - "%s: Ignoring location update because " - "last_seen (%s) < previous last_seen (%s)", + ( + "%s: Ignoring location update because " + "last_seen (%s) < previous last_seen (%s)" + ), self.entity_id, last_seen, prev_seen, ) if bad_accuracy: LOGGER.warning( - "%s: Ignoring location update because " - "expected GPS accuracy (%0.1f) is not met: %i", + ( + "%s: Ignoring location update because " + "expected GPS accuracy (%0.1f) is not met: %i" + ), self.entity_id, max_gps_acc, self.location_accuracy, diff --git a/homeassistant/components/lifx/__init__.py b/homeassistant/components/lifx/__init__.py index abe35c0a0d8..b2265d81da9 100644 --- a/homeassistant/components/lifx/__init__.py +++ b/homeassistant/components/lifx/__init__.py @@ -143,7 +143,10 @@ class LIFXDiscoveryManager: if migration_complete and migrating_was_in_progress: self.migrating = False _LOGGER.debug( - "LIFX migration complete, switching to normal discovery interval: %s", + ( + "LIFX migration complete, switching to normal discovery" + " interval: %s" + ), DISCOVERY_INTERVAL, ) self.async_setup_discovery_interval() diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py index 7b23e1d34c4..eb62cb8016e 100644 --- a/homeassistant/components/lifx/light.py +++ b/homeassistant/components/lifx/light.py @@ -221,7 +221,10 @@ class LIFXLight(LIFXEntity, LightEntity): Platform.SELECT, INFRARED_BRIGHTNESS ) _LOGGER.warning( - "The 'infrared' attribute of 'lifx.set_state' is deprecated: call 'select.select_option' targeting '%s' instead", + ( + "The 'infrared' attribute of 'lifx.set_state' is deprecated:" + " call 'select.select_option' targeting '%s' instead" + ), infrared_entity_id, ) bulb.set_infrared(convert_8_to_16(kwargs[ATTR_INFRARED])) diff --git a/homeassistant/components/lifx/util.py b/homeassistant/components/lifx/util.py index fde36d714d5..67190aaa599 100644 --- a/homeassistant/components/lifx/util.py +++ b/homeassistant/components/lifx/util.py @@ -110,7 +110,8 @@ def find_hsbk(hass: HomeAssistant, **kwargs: Any) -> list[float | int | None] | if ATTR_KELVIN in kwargs: _LOGGER.warning( - "The 'kelvin' parameter is deprecated. Please use 'color_temp_kelvin' for all service calls" + "The 'kelvin' parameter is deprecated. Please use 'color_temp_kelvin' for" + " all service calls" ) kelvin = kwargs.pop(ATTR_KELVIN) saturation = 0 diff --git a/homeassistant/components/light/reproduce_state.py b/homeassistant/components/light/reproduce_state.py index 46adcc1fa2e..15141b6d428 100644 --- a/homeassistant/components/light/reproduce_state.py +++ b/homeassistant/components/light/reproduce_state.py @@ -89,8 +89,9 @@ DEPRECATED_GROUP = [ ] DEPRECATION_WARNING = ( - "The use of other attributes than device state attributes is deprecated and will be removed in a future release. " - "Invalid attributes are %s. Read the logs for further details: https://www.home-assistant.io/integrations/scene/" + "The use of other attributes than device state attributes is deprecated and will be" + " removed in a future release. Invalid attributes are %s. Read the logs for further" + " details: https://www.home-assistant.io/integrations/scene/" ) diff --git a/homeassistant/components/logi_circle/__init__.py b/homeassistant/components/logi_circle/__init__.py index cabf6342fac..7e5d0df0259 100644 --- a/homeassistant/components/logi_circle/__init__.py +++ b/homeassistant/components/logi_circle/__init__.py @@ -144,8 +144,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: persistent_notification.create( hass, ( - f"Error: The cached access tokens are missing from {DEFAULT_CACHEDB}.
" - f"Please unload then re-add the Logi Circle integration to resolve." + "Error: The cached access tokens are missing from" + f" {DEFAULT_CACHEDB}.
Please unload then re-add the Logi Circle" + " integration to resolve." ), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID, @@ -160,10 +161,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: except AuthorizationFailed: persistent_notification.create( hass, - "Error: Failed to obtain an access token from the cached " - "refresh token.
" - "Token may have expired or been revoked.
" - "Please unload then re-add the Logi Circle integration to resolve", + ( + "Error: Failed to obtain an access token from the cached " + "refresh token.
" + "Token may have expired or been revoked.
" + "Please unload then re-add the Logi Circle integration to resolve" + ), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID, ) diff --git a/homeassistant/components/london_air/sensor.py b/homeassistant/components/london_air/sensor.py index 33fe1d4d7fb..45f585da39d 100644 --- a/homeassistant/components/london_air/sensor.py +++ b/homeassistant/components/london_air/sensor.py @@ -51,10 +51,7 @@ AUTHORITIES = [ "Westminster", ] -URL = ( - "http://api.erg.kcl.ac.uk/AirQuality/Hourly/" - "MonitoringIndex/GroupName=London/Json" -) +URL = "http://api.erg.kcl.ac.uk/AirQuality/Hourly/MonitoringIndex/GroupName=London/Json" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { diff --git a/homeassistant/components/lovelace/__init__.py b/homeassistant/components/lovelace/__init__.py index c2e709aeb40..485579087a1 100644 --- a/homeassistant/components/lovelace/__init__.py +++ b/homeassistant/components/lovelace/__init__.py @@ -113,7 +113,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: if yaml_resources is not None: _LOGGER.warning( - "Lovelace is running in storage mode. Define resources via user interface" + "Lovelace is running in storage mode. Define resources via user" + " interface" ) resource_collection = resources.ResourceStorageCollection(hass, default_config) @@ -220,7 +221,8 @@ async def create_yaml_resource_col(hass, yaml_resources): else: if CONF_RESOURCES in ll_conf: _LOGGER.warning( - "Resources need to be specified in your configuration.yaml. Please see the docs" + "Resources need to be specified in your configuration.yaml. Please" + " see the docs" ) yaml_resources = ll_conf[CONF_RESOURCES] diff --git a/homeassistant/components/luftdaten/sensor.py b/homeassistant/components/luftdaten/sensor.py index 0bd595493db..67672759706 100644 --- a/homeassistant/components/luftdaten/sensor.py +++ b/homeassistant/components/luftdaten/sensor.py @@ -116,7 +116,9 @@ class SensorCommunitySensor(CoordinatorEntity, SensorEntity): ATTR_SENSOR_ID: sensor_id, } self._attr_device_info = DeviceInfo( - configuration_url=f"https://devices.sensor.community/sensors/{sensor_id}/settings", + configuration_url=( + f"https://devices.sensor.community/sensors/{sensor_id}/settings" + ), identifiers={(DOMAIN, str(sensor_id))}, name=f"Sensor {sensor_id}", manufacturer="Sensor.Community", diff --git a/homeassistant/components/lutron_caseta/logbook.py b/homeassistant/components/lutron_caseta/logbook.py index ccefaff2a78..18c46405ed0 100644 --- a/homeassistant/components/lutron_caseta/logbook.py +++ b/homeassistant/components/lutron_caseta/logbook.py @@ -51,7 +51,9 @@ def async_describe_events( if rev_button_map is None: return { LOGBOOK_ENTRY_NAME: f"{data[ATTR_AREA_NAME]} {data[ATTR_DEVICE_NAME]}", - LOGBOOK_ENTRY_MESSAGE: f"{data[ATTR_ACTION]} Error retrieving button description", + LOGBOOK_ENTRY_MESSAGE: ( + f"{data[ATTR_ACTION]} Error retrieving button description" + ), } button_description = rev_button_map.get(leap_button_number) diff --git a/homeassistant/components/lyric/climate.py b/homeassistant/components/lyric/climate.py index 8339c4dad45..a8930a14848 100644 --- a/homeassistant/components/lyric/climate.py +++ b/homeassistant/components/lyric/climate.py @@ -277,7 +277,8 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity): if device.changeableValues.autoChangeoverActive: if target_temp_low is None or target_temp_high is None: raise HomeAssistantError( - "Could not find target_temp_low and/or target_temp_high in arguments" + "Could not find target_temp_low and/or target_temp_high in" + " arguments" ) _LOGGER.debug("Set temperature: %s - %s", target_temp_low, target_temp_high) try: diff --git a/homeassistant/components/magicseaweed/sensor.py b/homeassistant/components/magicseaweed/sensor.py index 79b77a362c4..0fb2df6aaca 100644 --- a/homeassistant/components/magicseaweed/sensor.py +++ b/homeassistant/components/magicseaweed/sensor.py @@ -168,12 +168,18 @@ class MagicSeaweedSensor(SensorEntity): elif sensor_type == "max_breaking_swell": self._attr_native_value = forecast.swell_maxBreakingHeight elif sensor_type == "swell_forecast": - summary = f"{forecast.swell_minBreakingHeight} - {forecast.swell_maxBreakingHeight}" + summary = ( + f"{forecast.swell_minBreakingHeight} -" + f" {forecast.swell_maxBreakingHeight}" + ) self._attr_native_value = summary if self.hour is None: for hour, data in self.data.hourly.items(): occurs = hour - hr_summary = f"{data.swell_minBreakingHeight} - {data.swell_maxBreakingHeight} {data.swell_unit}" + hr_summary = ( + f"{data.swell_minBreakingHeight} -" + f" {data.swell_maxBreakingHeight} {data.swell_unit}" + ) self._attr_extra_state_attributes[occurs] = hr_summary if sensor_type != "swell_forecast": diff --git a/homeassistant/components/mailgun/config_flow.py b/homeassistant/components/mailgun/config_flow.py index 6fe87e7cbf4..bfeaed5ae5b 100644 --- a/homeassistant/components/mailgun/config_flow.py +++ b/homeassistant/components/mailgun/config_flow.py @@ -7,7 +7,9 @@ config_entry_flow.register_webhook_flow( DOMAIN, "Mailgun Webhook", { - "mailgun_url": "https://documentation.mailgun.com/en/latest/user_manual.html#webhooks", + "mailgun_url": ( + "https://documentation.mailgun.com/en/latest/user_manual.html#webhooks" + ), "docs_url": "https://www.home-assistant.io/integrations/mailgun/", }, ) diff --git a/homeassistant/components/maxcube/__init__.py b/homeassistant/components/maxcube/__init__.py index 04a5ee97935..f8899ea082f 100644 --- a/homeassistant/components/maxcube/__init__.py +++ b/homeassistant/components/maxcube/__init__.py @@ -69,7 +69,10 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: _LOGGER.error("Unable to connect to Max!Cube gateway: %s", str(ex)) persistent_notification.create( hass, - f"Error: {ex}
You will need to restart Home Assistant after fixing.", + ( + f"Error: {ex}
You will need to restart Home Assistant after" + " fixing." + ), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID, ) diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index ffe0b4e2813..fa2c5465443 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -393,12 +393,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: elif value[ATTR_MEDIA_ENQUEUE] is True: value[ATTR_MEDIA_ENQUEUE] = MediaPlayerEnqueue.ADD _LOGGER.warning( - "Playing media with enqueue set to True is deprecated. Use 'add' instead" + "Playing media with enqueue set to True is deprecated. Use 'add'" + " instead" ) elif value[ATTR_MEDIA_ENQUEUE] is False: value[ATTR_MEDIA_ENQUEUE] = MediaPlayerEnqueue.PLAY _LOGGER.warning( - "Playing media with enqueue set to False is deprecated. Use 'play' instead" + "Playing media with enqueue set to False is deprecated. Use 'play'" + " instead" ) return value diff --git a/homeassistant/components/melcloud/climate.py b/homeassistant/components/melcloud/climate.py index 323108cd5c5..2cac1abcf88 100644 --- a/homeassistant/components/melcloud/climate.py +++ b/homeassistant/components/melcloud/climate.py @@ -240,7 +240,8 @@ class AtaDeviceClimate(MelCloudClimate): """Set horizontal vane position.""" if position not in self._device.vane_horizontal_positions: raise ValueError( - f"Invalid horizontal vane position {position}. Valid positions: [{self._device.vane_horizontal_positions}]." + f"Invalid horizontal vane position {position}. Valid positions:" + f" [{self._device.vane_horizontal_positions}]." ) await self._device.set({ata.PROPERTY_VANE_HORIZONTAL: position}) @@ -248,7 +249,8 @@ class AtaDeviceClimate(MelCloudClimate): """Set vertical vane position.""" if position not in self._device.vane_vertical_positions: raise ValueError( - f"Invalid vertical vane position {position}. Valid positions: [{self._device.vane_vertical_positions}]." + f"Invalid vertical vane position {position}. Valid positions:" + f" [{self._device.vane_vertical_positions}]." ) await self._device.set({ata.PROPERTY_VANE_VERTICAL: position}) diff --git a/homeassistant/components/met/weather.py b/homeassistant/components/met/weather.py index 222d4a040e3..ba8ccadfca5 100644 --- a/homeassistant/components/met/weather.py +++ b/homeassistant/components/met/weather.py @@ -36,8 +36,7 @@ from . import MetDataUpdateCoordinator from .const import ATTR_MAP, CONDITIONS_MAP, CONF_TRACK_HOME, DOMAIN, FORECAST_MAP ATTRIBUTION = ( - "Weather forecast from met.no, delivered by the Norwegian " - "Meteorological Institute." + "Weather forecast from met.no, delivered by the Norwegian Meteorological Institute." ) DEFAULT_NAME = "Met.no" diff --git a/homeassistant/components/meteo_france/__init__.py b/homeassistant/components/meteo_france/__init__.py index 1d36746413e..6c9af12a322 100644 --- a/homeassistant/components/meteo_france/__init__.py +++ b/homeassistant/components/meteo_france/__init__.py @@ -139,13 +139,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data[DOMAIN][department] = True else: _LOGGER.warning( - "Weather alert for department %s won't be added with city %s, as it has already been added within another city", + ( + "Weather alert for department %s won't be added with city %s, as it" + " has already been added within another city" + ), department, entry.title, ) else: _LOGGER.warning( - "Weather alert not available: The city %s is not in metropolitan France or Andorre", + ( + "Weather alert not available: The city %s is not in metropolitan France" + " or Andorre" + ), entry.title, ) @@ -172,7 +178,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ].data.position.get("dept") hass.data[DOMAIN][department] = False _LOGGER.debug( - "Weather alert for depatment %s unloaded and released. It can be added now by another city", + ( + "Weather alert for depatment %s unloaded and released. It can be added" + " now by another city" + ), department, ) diff --git a/homeassistant/components/minecraft_server/__init__.py b/homeassistant/components/minecraft_server/__init__.py index b2f7698d969..dad8ebe7f11 100644 --- a/homeassistant/components/minecraft_server/__init__.py +++ b/homeassistant/components/minecraft_server/__init__.py @@ -143,7 +143,10 @@ class MinecraftServer: self.online = True except OSError as error: _LOGGER.debug( - "Error occurred while trying to check the connection to '%s:%s' - OSError: %s", + ( + "Error occurred while trying to check the connection to '%s:%s' -" + " OSError: %s" + ), self.host, self.port, error, diff --git a/homeassistant/components/mobile_app/webhook.py b/homeassistant/components/mobile_app/webhook.py index 2dd578a3fea..107058352c1 100644 --- a/homeassistant/components/mobile_app/webhook.py +++ b/homeassistant/components/mobile_app/webhook.py @@ -268,8 +268,10 @@ async def webhook_call_service( ) except (vol.Invalid, ServiceNotFound, Exception) as ex: _LOGGER.error( - "Error when calling service during mobile_app " - "webhook (device name: %s): %s", + ( + "Error when calling service during mobile_app " + "webhook (device name: %s): %s" + ), config_entry.data[ATTR_DEVICE_NAME], ex, ) diff --git a/homeassistant/components/modbus/base_platform.py b/homeassistant/components/modbus/base_platform.py index 0727fa81e44..9463847a4ee 100644 --- a/homeassistant/components/modbus/base_platform.py +++ b/homeassistant/components/modbus/base_platform.py @@ -322,7 +322,10 @@ class BaseSwitch(BasePlatform, ToggleEntity, RestoreEntity): self._attr_is_on = False elif value is not None: _LOGGER.error( - "Unexpected response from modbus device slave %s register %s, got 0x%2x", + ( + "Unexpected response from modbus device slave %s register %s," + " got 0x%2x" + ), self._slave, self._verify_address, value, diff --git a/homeassistant/components/modbus/validators.py b/homeassistant/components/modbus/validators.py index 315e138e130..84e2e6d06b5 100644 --- a/homeassistant/components/modbus/validators.py +++ b/homeassistant/components/modbus/validators.py @@ -111,7 +111,7 @@ def struct_validator(config: dict[str, Any]) -> dict[str, Any]: if count < regs_needed or (count % regs_needed) != 0: raise vol.Invalid( f"Error in sensor {name} swap({swap_type}) " - f"not possible due to the registers " + "not possible due to the registers " f"count: {count}, needed: {regs_needed}" ) @@ -153,8 +153,10 @@ def scan_interval_validator(config: dict) -> dict: continue if scan_interval < 5: _LOGGER.warning( - "%s %s scan_interval(%d) is lower than 5 seconds, " - "which may cause Home Assistant stability issues", + ( + "%s %s scan_interval(%d) is lower than 5 seconds, " + "which may cause Home Assistant stability issues" + ), component, entry.get(CONF_NAME), scan_interval, @@ -198,11 +200,17 @@ def duplicate_entity_validator(config: dict) -> dict: addr += "_" + str(entry[CONF_COMMAND_OFF]) addr += "_" + str(entry.get(CONF_SLAVE, 0)) if addr in addresses: - err = f"Modbus {component}/{name} address {addr} is duplicate, second entry not loaded!" + err = ( + f"Modbus {component}/{name} address {addr} is duplicate, second" + " entry not loaded!" + ) _LOGGER.warning(err) errors.append(index) elif name in names: - err = f"Modbus {component}/{name}  is duplicate, second entry not loaded!" + err = ( + f"Modbus {component}/{name}  is duplicate, second entry not" + " loaded!" + ) _LOGGER.warning(err) errors.append(index) else: diff --git a/homeassistant/components/modern_forms/__init__.py b/homeassistant/components/modern_forms/__init__.py index 9b425f61ad0..d00fe793bf8 100644 --- a/homeassistant/components/modern_forms/__init__.py +++ b/homeassistant/components/modern_forms/__init__.py @@ -145,5 +145,8 @@ class ModernFormsDeviceEntity(CoordinatorEntity[ModernFormsDataUpdateCoordinator name=self.coordinator.data.info.device_name, manufacturer="Modern Forms", model=self.coordinator.data.info.fan_type, - sw_version=f"{self.coordinator.data.info.firmware_version} / {self.coordinator.data.info.main_mcu_firmware_version}", + sw_version=( + f"{self.coordinator.data.info.firmware_version} /" + f" {self.coordinator.data.info.main_mcu_firmware_version}" + ), ) diff --git a/homeassistant/components/moehlenhoff_alpha2/sensor.py b/homeassistant/components/moehlenhoff_alpha2/sensor.py index d26786e1923..e41c6b041f6 100644 --- a/homeassistant/components/moehlenhoff_alpha2/sensor.py +++ b/homeassistant/components/moehlenhoff_alpha2/sensor.py @@ -46,7 +46,10 @@ class Alpha2HeatControlValveOpeningSensor( self._attr_unique_id = f"{heat_control_id}:valve_opening" heat_control = self.coordinator.data["heat_controls"][heat_control_id] heat_area = self.coordinator.data["heat_areas"][heat_control["_HEATAREA_ID"]] - self._attr_name = f"{heat_area['HEATAREA_NAME']} heat control {heat_control['NR']} valve opening" + self._attr_name = ( + f"{heat_area['HEATAREA_NAME']} heat control {heat_control['NR']} valve" + " opening" + ) @property def native_value(self) -> int: diff --git a/homeassistant/components/motion_blinds/__init__.py b/homeassistant/components/motion_blinds/__init__.py index a023fc05d14..378a2f1f03d 100644 --- a/homeassistant/components/motion_blinds/__init__.py +++ b/homeassistant/components/motion_blinds/__init__.py @@ -135,8 +135,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: data = {**entry.data, CONF_INTERFACE: working_interface} hass.config_entries.async_update_entry(entry, data=data) _LOGGER.debug( - "Motion Blinds interface updated from %s to %s, " - "this should only occur after a network change", + ( + "Motion Blinds interface updated from %s to %s, " + "this should only occur after a network change" + ), multicast_interface, working_interface, ) diff --git a/homeassistant/components/motion_blinds/gateway.py b/homeassistant/components/motion_blinds/gateway.py index 96a85246666..ac18840ddeb 100644 --- a/homeassistant/components/motion_blinds/gateway.py +++ b/homeassistant/components/motion_blinds/gateway.py @@ -133,7 +133,10 @@ class ConnectMotionGateway: return interface _LOGGER.error( - "Could not find working interface for Motion Blinds host %s, using interface '%s'", + ( + "Could not find working interface for Motion Blinds host %s, using" + " interface '%s'" + ), host, self._interface, ) diff --git a/homeassistant/components/motioneye/const.py b/homeassistant/components/motioneye/const.py index 37e751236da..ebe4e24d6cf 100644 --- a/homeassistant/components/motioneye/const.py +++ b/homeassistant/components/motioneye/const.py @@ -89,8 +89,8 @@ SERVICE_SET_TEXT_OVERLAY: Final = "set_text_overlay" SERVICE_ACTION: Final = "action" SERVICE_SNAPSHOT: Final = "snapshot" -SIGNAL_CAMERA_ADD: Final = f"{DOMAIN}_camera_add_signal." "{}" -SIGNAL_CAMERA_REMOVE: Final = f"{DOMAIN}_camera_remove_signal." "{}" +SIGNAL_CAMERA_ADD: Final = f"{DOMAIN}_camera_add_signal.{{}}" +SIGNAL_CAMERA_REMOVE: Final = f"{DOMAIN}_camera_remove_signal.{{}}" TYPE_MOTIONEYE_ACTION_SENSOR = f"{DOMAIN}_action_sensor" TYPE_MOTIONEYE_MJPEG_CAMERA: Final = "motioneye_mjpeg_camera" diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index bb4b3e09015..3f6f2122757 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -240,8 +240,10 @@ def _filter_entry_config(hass: HomeAssistant, entry: ConfigEntry) -> None: } if entry.data.keys() != filtered_data.keys(): _LOGGER.warning( - "The following unsupported configuration options were removed from the " - "MQTT config entry: %s", + ( + "The following unsupported configuration options were removed from the " + "MQTT config entry: %s" + ), entry.data.keys() - filtered_data.keys(), ) hass.config_entries.async_update_entry(entry, data=filtered_data) @@ -329,8 +331,10 @@ async def async_fetch_config( override[CONF_CLIENT_KEY] = "-----PRIVATE KEY-----" if override: _LOGGER.warning( - "Deprecated configuration settings found in configuration.yaml. " - "These settings from your configuration entry will override: %s", + ( + "Deprecated configuration settings found in configuration.yaml. " + "These settings from your configuration entry will override: %s" + ), override, ) # Register a repair issue @@ -389,16 +393,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: msg_topic = valid_publish_topic(rendered_topic) except (jinja2.TemplateError, TemplateError) as exc: _LOGGER.error( - "Unable to publish: rendering topic template of %s " - "failed because %s", + ( + "Unable to publish: rendering topic template of %s " + "failed because %s" + ), msg_topic_template, exc, ) return except vol.Invalid as err: _LOGGER.error( - "Unable to publish: topic template '%s' produced an " - "invalid topic '%s' after rendering (%s)", + ( + "Unable to publish: topic template '%s' produced an " + "invalid topic '%s' after rendering (%s)" + ), msg_topic_template, rendered_topic, err, @@ -412,8 +420,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ).async_render() except (jinja2.TemplateError, TemplateError) as exc: _LOGGER.error( - "Unable to publish to %s: rendering payload template of " - "%s failed because %s", + ( + "Unable to publish to %s: rendering payload template of " + "%s failed because %s" + ), msg_topic, payload_template, exc, diff --git a/homeassistant/components/mqtt/binary_sensor.py b/homeassistant/components/mqtt/binary_sensor.py index 85ff6e959b3..f604bbbdd64 100644 --- a/homeassistant/components/mqtt/binary_sensor.py +++ b/homeassistant/components/mqtt/binary_sensor.py @@ -145,7 +145,10 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity): self.hass, self._value_is_expired, expiration_at ) _LOGGER.debug( - "State recovered after reload for %s, remaining time before expiring %s", + ( + "State recovered after reload for %s, remaining time before" + " expiring %s" + ), self.entity_id, expiration_at - time_now, ) @@ -215,7 +218,10 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity): payload = self._value_template(msg.payload) if not payload.strip(): # No output from template, ignore _LOGGER.debug( - "Empty template output for entity: %s with state topic: %s. Payload: '%s', with value template '%s'", + ( + "Empty template output for entity: %s with state topic: %s." + " Payload: '%s', with value template '%s'" + ), self._config[CONF_NAME], self._config[CONF_STATE_TOPIC], msg.payload, @@ -232,9 +238,15 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity): else: # Payload is not for this entity template_info = "" if self._config.get(CONF_VALUE_TEMPLATE) is not None: - template_info = f", template output: '{str(payload)}', with value template '{str(self._config.get(CONF_VALUE_TEMPLATE))}'" + template_info = ( + f", template output: '{str(payload)}', with value template" + f" '{str(self._config.get(CONF_VALUE_TEMPLATE))}'" + ) _LOGGER.info( - "No matching payload found for entity: %s with state topic: %s. Payload: '%s'%s", + ( + "No matching payload found for entity: %s with state topic: %s." + " Payload: '%s'%s" + ), self._config[CONF_NAME], self._config[CONF_STATE_TOPIC], msg.payload, diff --git a/homeassistant/components/mqtt/client.py b/homeassistant/components/mqtt/client.py index b4351c70f60..7dc6048f2f7 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -121,7 +121,10 @@ async def async_publish( if not isinstance(payload, bytes): if not encoding: _LOGGER.error( - "Can't pass-through payload for publishing %s on %s with no encoding set, need 'bytes' got %s", + ( + "Can't pass-through payload for publishing %s on %s with no" + " encoding set, need 'bytes' got %s" + ), payload, topic, type(payload), @@ -221,8 +224,10 @@ async def async_subscribe( if non_default == 3: module = inspect.getmodule(msg_callback) _LOGGER.warning( - "Signature of MQTT msg_callback '%s.%s' is deprecated, " - "this will stop working with HA core 2023.2", + ( + "Signature of MQTT msg_callback '%s.%s' is deprecated, " + "this will stop working with HA core 2023.2" + ), module.__name__ if module else "", msg_callback.__name__, ) diff --git a/homeassistant/components/mqtt/config_integration.py b/homeassistant/components/mqtt/config_integration.py index 9db18af0718..4140c5963ca 100644 --- a/homeassistant/components/mqtt/config_integration.py +++ b/homeassistant/components/mqtt/config_integration.py @@ -145,8 +145,7 @@ PLATFORM_CONFIG_SCHEMA_BASE = vol.Schema( CLIENT_KEY_AUTH_MSG = ( - "client_key and client_cert must both be present in " - "the MQTT broker configuration" + "client_key and client_cert must both be present in the MQTT broker configuration" ) CONFIG_SCHEMA_ENTRY = vol.Schema( diff --git a/homeassistant/components/mqtt/cover.py b/homeassistant/components/mqtt/cover.py index 7f9b5dc3e85..9d5f58eaa6d 100644 --- a/homeassistant/components/mqtt/cover.py +++ b/homeassistant/components/mqtt/cover.py @@ -120,7 +120,8 @@ def validate_options(config: ConfigType) -> ConfigType: """ if CONF_SET_POSITION_TOPIC in config and CONF_GET_POSITION_TOPIC not in config: raise vol.Invalid( - f"'{CONF_SET_POSITION_TOPIC}' must be set together with '{CONF_GET_POSITION_TOPIC}'." + f"'{CONF_SET_POSITION_TOPIC}' must be set together with" + f" '{CONF_GET_POSITION_TOPIC}'." ) # if templates are set make sure the topic for the template is also set @@ -132,22 +133,26 @@ def validate_options(config: ConfigType) -> ConfigType: if CONF_GET_POSITION_TEMPLATE in config and CONF_GET_POSITION_TOPIC not in config: raise vol.Invalid( - f"'{CONF_GET_POSITION_TEMPLATE}' must be set together with '{CONF_GET_POSITION_TOPIC}'." + f"'{CONF_GET_POSITION_TEMPLATE}' must be set together with" + f" '{CONF_GET_POSITION_TOPIC}'." ) if CONF_SET_POSITION_TEMPLATE in config and CONF_SET_POSITION_TOPIC not in config: raise vol.Invalid( - f"'{CONF_SET_POSITION_TEMPLATE}' must be set together with '{CONF_SET_POSITION_TOPIC}'." + f"'{CONF_SET_POSITION_TEMPLATE}' must be set together with" + f" '{CONF_SET_POSITION_TOPIC}'." ) if CONF_TILT_COMMAND_TEMPLATE in config and CONF_TILT_COMMAND_TOPIC not in config: raise vol.Invalid( - f"'{CONF_TILT_COMMAND_TEMPLATE}' must be set together with '{CONF_TILT_COMMAND_TOPIC}'." + f"'{CONF_TILT_COMMAND_TEMPLATE}' must be set together with" + f" '{CONF_TILT_COMMAND_TOPIC}'." ) if CONF_TILT_STATUS_TEMPLATE in config and CONF_TILT_STATUS_TOPIC not in config: raise vol.Invalid( - f"'{CONF_TILT_STATUS_TEMPLATE}' must be set together with '{CONF_TILT_STATUS_TOPIC}'." + f"'{CONF_TILT_STATUS_TEMPLATE}' must be set together with" + f" '{CONF_TILT_STATUS_TOPIC}'." ) return config @@ -388,7 +393,10 @@ class MqttCover(MqttEntity, CoverEntity): self._state = STATE_CLOSED else: _LOGGER.warning( - "Payload is not supported (e.g. open, closed, opening, closing, stopped): %s", + ( + "Payload is not supported (e.g. open, closed, opening, closing," + " stopped): %s" + ), payload, ) return @@ -414,7 +422,8 @@ class MqttCover(MqttEntity, CoverEntity): if payload_dict and isinstance(payload_dict, dict): if "position" not in payload_dict: _LOGGER.warning( - "Template (position_template) returned JSON without position attribute" + "Template (position_template) returned JSON without position" + " attribute" ) return if "tilt_position" in payload_dict: diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 2d460a69592..b6104a570d4 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -108,9 +108,12 @@ async def async_start( # noqa: C901 if not (match := TOPIC_MATCHER.match(topic_trimmed)): if topic_trimmed.endswith("config"): _LOGGER.warning( - "Received message on illegal discovery topic '%s'. The topic contains " - "not allowed characters. For more information see " - "https://www.home-assistant.io/docs/mqtt/discovery/#discovery-topic", + ( + "Received message on illegal discovery topic '%s'. The topic" + " contains " + "not allowed characters. For more information see " + "https://www.home-assistant.io/docs/mqtt/discovery/#discovery-topic" + ), topic, ) return diff --git a/homeassistant/components/mqtt/fan.py b/homeassistant/components/mqtt/fan.py index da061da14e4..82fd0d4063a 100644 --- a/homeassistant/components/mqtt/fan.py +++ b/homeassistant/components/mqtt/fan.py @@ -386,7 +386,10 @@ class MqttFan(MqttEntity, FanEntity): ) except ValueError: _LOGGER.warning( - "'%s' received on topic %s. '%s' is not a valid speed within the speed range", + ( + "'%s' received on topic %s. '%s' is not a valid speed within" + " the speed range" + ), msg.payload, msg.topic, rendered_percentage_payload, @@ -394,7 +397,10 @@ class MqttFan(MqttEntity, FanEntity): return if percentage < 0 or percentage > 100: _LOGGER.warning( - "'%s' received on topic %s. '%s' is not a valid speed within the speed range", + ( + "'%s' received on topic %s. '%s' is not a valid speed within" + " the speed range" + ), msg.payload, msg.topic, rendered_percentage_payload, diff --git a/homeassistant/components/mqtt/mixins.py b/homeassistant/components/mqtt/mixins.py index c2c26de9a36..1e6e9989577 100644 --- a/homeassistant/components/mqtt/mixins.py +++ b/homeassistant/components/mqtt/mixins.py @@ -244,9 +244,11 @@ def warn_for_legacy_schema(domain: str) -> Callable[[ConfigType], ConfigType]: return config _LOGGER.error( - "Manually configured MQTT %s(s) found under platform key '%s', " - "please move to the mqtt integration key, see " - "https://www.home-assistant.io/integrations/%s.mqtt/#new_format", + ( + "Manually configured MQTT %s(s) found under platform key '%s', " + "please move to the mqtt integration key, see " + "https://www.home-assistant.io/integrations/%s.mqtt/#new_format" + ), domain, domain, domain, @@ -316,8 +318,10 @@ async def async_setup_entry_helper( """Discover and add an MQTT entity, automation or tag.""" if not mqtt_config_entry_enabled(hass): _LOGGER.warning( - "MQTT integration is disabled, skipping setup of discovered item " - "MQTT %s, payload %s", + ( + "MQTT integration is disabled, skipping setup of discovered item " + "MQTT %s, payload %s" + ), domain, discovery_payload, ) diff --git a/homeassistant/components/mqtt/models.py b/homeassistant/components/mqtt/models.py index aaef5e3e3e8..408e455365e 100644 --- a/homeassistant/components/mqtt/models.py +++ b/homeassistant/components/mqtt/models.py @@ -237,7 +237,10 @@ class MqttValueTemplate: return rendered_payload _LOGGER.debug( - "Rendering incoming payload '%s' with variables %s with default value '%s' and %s", + ( + "Rendering incoming payload '%s' with variables %s with default value" + " '%s' and %s" + ), payload, values, default, diff --git a/homeassistant/components/mqtt/sensor.py b/homeassistant/components/mqtt/sensor.py index 092ab88b28d..f05082849fc 100644 --- a/homeassistant/components/mqtt/sensor.py +++ b/homeassistant/components/mqtt/sensor.py @@ -198,7 +198,10 @@ class MqttSensor(MqttEntity, RestoreSensor): self.hass, self._value_is_expired, expiration_at ) _LOGGER.debug( - "State recovered after reload for %s, remaining time before expiring %s", + ( + "State recovered after reload for %s, remaining time before" + " expiring %s" + ), self.entity_id, expiration_at - time_now, ) diff --git a/homeassistant/components/mqtt/siren.py b/homeassistant/components/mqtt/siren.py index 06916c7c04b..6043773d5d6 100644 --- a/homeassistant/components/mqtt/siren.py +++ b/homeassistant/components/mqtt/siren.py @@ -249,13 +249,19 @@ class MqttSiren(MqttEntity, SirenEntity): try: json_payload = json_loads(payload) _LOGGER.debug( - "JSON payload detected after processing payload '%s' on topic %s", + ( + "JSON payload detected after processing payload '%s' on" + " topic %s" + ), json_payload, msg.topic, ) except JSON_DECODE_EXCEPTIONS: _LOGGER.warning( - "No valid (JSON) payload detected after processing payload '%s' on topic %s", + ( + "No valid (JSON) payload detected after processing payload" + " '%s' on topic %s" + ), json_payload, msg.topic, ) diff --git a/homeassistant/components/mqtt/update.py b/homeassistant/components/mqtt/update.py index 874f6024a37..12d7723da3b 100644 --- a/homeassistant/components/mqtt/update.py +++ b/homeassistant/components/mqtt/update.py @@ -177,20 +177,29 @@ class MqttUpdate(MqttEntity, UpdateEntity, RestoreEntity): json_payload = json_loads(payload) if isinstance(json_payload, dict): _LOGGER.debug( - "JSON payload detected after processing payload '%s' on topic %s", + ( + "JSON payload detected after processing payload '%s' on" + " topic %s" + ), json_payload, msg.topic, ) else: _LOGGER.debug( - "Non-dictionary JSON payload detected after processing payload '%s' on topic %s", + ( + "Non-dictionary JSON payload detected after processing" + " payload '%s' on topic %s" + ), payload, msg.topic, ) json_payload = {"installed_version": payload} except JSON_DECODE_EXCEPTIONS: _LOGGER.debug( - "No valid (JSON) payload detected after processing payload '%s' on topic %s", + ( + "No valid (JSON) payload detected after processing payload '%s'" + " on topic %s" + ), payload, msg.topic, ) diff --git a/homeassistant/components/mqtt/util.py b/homeassistant/components/mqtt/util.py index 25fb71831bc..bf26729470d 100644 --- a/homeassistant/components/mqtt/util.py +++ b/homeassistant/components/mqtt/util.py @@ -84,8 +84,7 @@ def valid_subscribe_topic(topic: Any) -> str: if index != len(validated_topic) - 1: # If there are multiple wildcards, this will also trigger raise vol.Invalid( - "Multi-level wildcard must be the last " - "character in the topic filter." + "Multi-level wildcard must be the last character in the topic filter." ) if len(validated_topic) > 1 and validated_topic[index - 1] != "/": raise vol.Invalid( diff --git a/homeassistant/components/mqtt_json/device_tracker.py b/homeassistant/components/mqtt_json/device_tracker.py index f0330e39e86..2c67751551c 100644 --- a/homeassistant/components/mqtt_json/device_tracker.py +++ b/homeassistant/components/mqtt_json/device_tracker.py @@ -59,8 +59,10 @@ async def async_setup_scanner( data = GPS_JSON_PAYLOAD_SCHEMA(json.loads(msg.payload)) except vol.MultipleInvalid: _LOGGER.error( - "Skipping update for following data " - "because of missing or malformatted data: %s", + ( + "Skipping update for following data " + "because of missing or malformatted data: %s" + ), msg.payload, ) return diff --git a/homeassistant/components/nest/__init__.py b/homeassistant/components/nest/__init__.py index 99760d4be39..c2e295dbfdf 100644 --- a/homeassistant/components/nest/__init__.py +++ b/homeassistant/components/nest/__init__.py @@ -270,7 +270,9 @@ async def async_import_config(hass: HomeAssistant, entry: ConfigEntry) -> None: severity=IssueSeverity.ERROR, translation_key="removed_app_auth", translation_placeholders={ - "more_info_url": "https://www.home-assistant.io/more-info/nest-auth-deprecation", + "more_info_url": ( + "https://www.home-assistant.io/more-info/nest-auth-deprecation" + ), "documentation_url": "https://www.home-assistant.io/integrations/nest/", }, ) @@ -333,7 +335,10 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: await subscriber.delete_subscription() except (AuthException, SubscriberException) as err: _LOGGER.warning( - "Unable to delete subscription '%s'; Will be automatically cleaned up by cloud console: %s", + ( + "Unable to delete subscription '%s'; Will be automatically cleaned up" + " by cloud console: %s" + ), subscriber.subscriber_id, err, ) diff --git a/homeassistant/components/nest/application_credentials.py b/homeassistant/components/nest/application_credentials.py index 7d88bc37322..d9398523a57 100644 --- a/homeassistant/components/nest/application_credentials.py +++ b/homeassistant/components/nest/application_credentials.py @@ -17,7 +17,9 @@ async def async_get_authorization_server(hass: HomeAssistant) -> AuthorizationSe async def async_get_description_placeholders(hass: HomeAssistant) -> dict[str, str]: """Return description placeholders for the credentials dialog.""" return { - "oauth_consent_url": "https://console.cloud.google.com/apis/credentials/consent", + "oauth_consent_url": ( + "https://console.cloud.google.com/apis/credentials/consent" + ), "more_info_url": "https://www.home-assistant.io/integrations/nest/", "oauth_creds_url": "https://console.cloud.google.com/apis/credentials", "redirect_url": "https://my.home-assistant.io/redirect/oauth", diff --git a/homeassistant/components/nest/config_flow.py b/homeassistant/components/nest/config_flow.py index 1288592be74..a837290249e 100644 --- a/homeassistant/components/nest/config_flow.py +++ b/homeassistant/components/nest/config_flow.py @@ -333,7 +333,8 @@ class NestFlowHandler( project_id = user_input[CONF_PROJECT_ID] if project_id == self._data[CONF_CLOUD_PROJECT_ID]: _LOGGER.error( - "Device Access Project ID and Cloud Project ID must not be the same, see documentation" + "Device Access Project ID and Cloud Project ID must not be the" + " same, see documentation" ) errors[CONF_PROJECT_ID] = "wrong_project_id" else: diff --git a/homeassistant/components/nest/legacy/__init__.py b/homeassistant/components/nest/legacy/__init__.py index b244dea182e..ee660b8062f 100644 --- a/homeassistant/components/nest/legacy/__init__.py +++ b/homeassistant/components/nest/legacy/__init__.py @@ -192,8 +192,10 @@ async def async_setup_legacy_entry(hass: HomeAssistant, entry: ConfigEntry) -> b eta_window = service.data.get(ATTR_ETA_WINDOW, timedelta(minutes=1)) eta_end = eta_begin + eta_window _LOGGER.info( - "Setting ETA for trip: %s, " - "ETA window starts at: %s and ends at: %s", + ( + "Setting ETA for trip: %s, " + "ETA window starts at: %s and ends at: %s" + ), trip_id, eta_begin, eta_end, @@ -221,8 +223,7 @@ async def async_setup_legacy_entry(hass: HomeAssistant, entry: ConfigEntry) -> b structure.cancel_eta(trip_id) else: _LOGGER.info( - "No thermostats found in structure: %s, " - "unable to cancel ETA", + "No thermostats found in structure: %s, unable to cancel ETA", structure.name, ) @@ -333,9 +334,11 @@ class NestLegacyDevice: device.name_long except KeyError: _LOGGER.warning( - "Cannot retrieve device name for [%s]" - ", please check your Nest developer " - "account permission settings", + ( + "Cannot retrieve device name for [%s]" + ", please check your Nest developer " + "account permission settings" + ), device.serial, ) continue diff --git a/homeassistant/components/netgear/__init__.py b/homeassistant/components/netgear/__init__.py index ade5a8df6bd..c78ba024813 100644 --- a/homeassistant/components/netgear/__init__.py +++ b/homeassistant/components/netgear/__init__.py @@ -48,8 +48,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: data = {**entry.data, CONF_PORT: router.port, CONF_SSL: router.ssl} hass.config_entries.async_update_entry(entry, data=data) _LOGGER.info( - "Netgear port-SSL combination updated from (%i, %r) to (%i, %r), " - "this should only occur after a firmware update", + ( + "Netgear port-SSL combination updated from (%i, %r) to (%i, %r), " + "this should only occur after a firmware update" + ), port, ssl, router.port, diff --git a/homeassistant/components/netgear/router.py b/homeassistant/components/netgear/router.py index c6384a44351..3e285f998a1 100644 --- a/homeassistant/components/netgear/router.py +++ b/homeassistant/components/netgear/router.py @@ -132,7 +132,10 @@ class NetgearRouter: if self.method_version == 2 and self.track_devices: if not self.api.get_attached_devices_2(): _LOGGER.error( - "Netgear Model '%s' in MODELS_V2 list, but failed to get attached devices using V2", + ( + "Netgear Model '%s' in MODELS_V2 list, but failed to get" + " attached devices using V2" + ), self.model, ) self.method_version = 1 diff --git a/homeassistant/components/network/__init__.py b/homeassistant/components/network/__init__.py index 1ad975e1d85..a57334d2531 100644 --- a/homeassistant/components/network/__init__.py +++ b/homeassistant/components/network/__init__.py @@ -51,11 +51,13 @@ async def async_get_source_ip( if not all_ipv4s: _LOGGER.warning( - "Because the system does not have any enabled IPv4 addresses, source address detection may be inaccurate" + "Because the system does not have any enabled IPv4 addresses, source" + " address detection may be inaccurate" ) if source_ip is None: raise HomeAssistantError( - "Could not determine source ip because the system does not have any enabled IPv4 addresses and creating a socket failed" + "Could not determine source ip because the system does not have any" + " enabled IPv4 addresses and creating a socket failed" ) return source_ip diff --git a/homeassistant/components/network/util.py b/homeassistant/components/network/util.py index 4b920e5d927..6f204b05397 100644 --- a/homeassistant/components/network/util.py +++ b/homeassistant/components/network/util.py @@ -142,7 +142,10 @@ def async_get_source_ip(target_ip: str) -> str | None: return cast(str, test_sock.getsockname()[0]) except Exception: # pylint: disable=broad-except _LOGGER.debug( - "The system could not auto detect the source ip for %s on your operating system", + ( + "The system could not auto detect the source ip for %s on your" + " operating system" + ), target_ip, ) return None diff --git a/homeassistant/components/nextdns/switch.py b/homeassistant/components/nextdns/switch.py index a0e8f15e44d..3856ac0a2a2 100644 --- a/homeassistant/components/nextdns/switch.py +++ b/homeassistant/components/nextdns/switch.py @@ -587,7 +587,8 @@ class NextDnsSwitch(CoordinatorEntity[NextDnsSettingsUpdateCoordinator], SwitchE ClientError, ) as err: raise HomeAssistantError( - f"NextDNS API returned an error calling set_setting for {self.entity_id}: {err}" + "NextDNS API returned an error calling set_setting for" + f" {self.entity_id}: {err}" ) from err if result: diff --git a/homeassistant/components/nilu/air_quality.py b/homeassistant/components/nilu/air_quality.py index 400c9f0ab8e..5c3f9c59460 100644 --- a/homeassistant/components/nilu/air_quality.py +++ b/homeassistant/components/nilu/air_quality.py @@ -97,16 +97,20 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( vol.Exclusive( CONF_AREA, "station_collection", - "Can only configure one specific station or " - "stations in a specific area pr sensor. " - "Please only configure station or area.", + ( + "Can only configure one specific station or " + "stations in a specific area pr sensor. " + "Please only configure station or area." + ), ): vol.All(cv.string, vol.In(CONF_ALLOWED_AREAS)), vol.Exclusive( CONF_STATION, "station_collection", - "Can only configure one specific station or " - "stations in a specific area pr sensor. " - "Please only configure station or area.", + ( + "Can only configure one specific station or " + "stations in a specific area pr sensor. " + "Please only configure station or area." + ), ): vol.All(cv.ensure_list, [cv.string]), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_SHOW_ON_MAP, default=False): cv.boolean, diff --git a/homeassistant/components/nmap_tracker/__init__.py b/homeassistant/components/nmap_tracker/__init__.py index e3b83f8abc2..827fb93a012 100644 --- a/homeassistant/components/nmap_tracker/__init__.py +++ b/homeassistant/components/nmap_tracker/__init__.py @@ -343,7 +343,10 @@ class NmapDeviceScanner: return if device.first_offline + self.consider_home > now: _LOGGER.debug( - "Device %s (%s) has NOT been offline (first offline at: %s) long enough to be considered not home: %s", + ( + "Device %s (%s) has NOT been offline (first offline at: %s) long" + " enough to be considered not home: %s" + ), ipv4, formatted_mac, device.first_offline, @@ -351,7 +354,10 @@ class NmapDeviceScanner: ) return _LOGGER.debug( - "Device %s (%s) has been offline (first offline at: %s) long enough to be considered not home: %s", + ( + "Device %s (%s) has been offline (first offline at: %s) long enough to" + " be considered not home: %s" + ), ipv4, formatted_mac, device.first_offline, diff --git a/homeassistant/components/nobo_hub/climate.py b/homeassistant/components/nobo_hub/climate.py index 6f6b2561d4d..6e4cf13c986 100644 --- a/homeassistant/components/nobo_hub/climate.py +++ b/homeassistant/components/nobo_hub/climate.py @@ -115,7 +115,8 @@ class NoboZone(ClimateEntity): """Set new target HVAC mode, if it's supported.""" if hvac_mode not in self.hvac_modes: raise ValueError( - f"Zone {self._id} '{self._attr_name}' called with unsupported HVAC mode '{hvac_mode}'" + f"Zone {self._id} '{self._attr_name}' called with unsupported HVAC mode" + f" '{hvac_mode}'" ) if hvac_mode == HVACMode.AUTO: await self.async_set_preset_mode(PRESET_NONE) diff --git a/homeassistant/components/notify/legacy.py b/homeassistant/components/notify/legacy.py index 35c1bbe65bf..a5d58451c5e 100644 --- a/homeassistant/components/notify/legacy.py +++ b/homeassistant/components/notify/legacy.py @@ -151,8 +151,8 @@ def check_templates_warn(hass: HomeAssistant, tpl: template.Template) -> None: hass.data["notify_template_warned"] = True LOGGER.warning( - "Passing templates to notify service is deprecated and will be removed in 2021.12. " - "Automations and scripts handle templates automatically" + "Passing templates to notify service is deprecated and will be removed in" + " 2021.12. Automations and scripts handle templates automatically" ) @@ -301,7 +301,10 @@ class BaseNotificationService: # Register the service description service_desc = { CONF_NAME: f"Send a notification via {target_name}", - CONF_DESCRIPTION: f"Sends a notification message using the {target_name} integration.", + CONF_DESCRIPTION: ( + "Sends a notification message using the" + f" {target_name} integration." + ), CONF_FIELDS: self.services_dict[SERVICE_NOTIFY][CONF_FIELDS], } async_set_service_schema(self.hass, DOMAIN, target_name, service_desc) @@ -326,7 +329,9 @@ class BaseNotificationService: # Register the service description service_desc = { CONF_NAME: f"Send a notification with {self._service_name}", - CONF_DESCRIPTION: f"Sends a notification message using the {self._service_name} service.", + CONF_DESCRIPTION: ( + f"Sends a notification message using the {self._service_name} service." + ), CONF_FIELDS: self.services_dict[SERVICE_NOTIFY][CONF_FIELDS], } async_set_service_schema(self.hass, DOMAIN, self._service_name, service_desc) diff --git a/homeassistant/components/numato/__init__.py b/homeassistant/components/numato/__init__.py index e2a5400e050..7a66ac55d70 100644 --- a/homeassistant/components/numato/__init__.py +++ b/homeassistant/components/numato/__init__.py @@ -209,8 +209,12 @@ class NumatoAPI: f"Port {port} is not set up for numato device {device_id}." ) msg = { - gpio.OUT: f"Trying to write to device {device_id} port {port} set up as input.", - gpio.IN: f"Trying to read from device {device_id} port {port} set up as output.", + gpio.OUT: ( + f"Trying to write to device {device_id} port {port} set up as input." + ), + gpio.IN: ( + f"Trying to read from device {device_id} port {port} set up as output." + ), } if self.ports_registered[(device_id, port)] != direction: raise gpio.NumatoGpioError(msg[direction]) diff --git a/homeassistant/components/numato/binary_sensor.py b/homeassistant/components/numato/binary_sensor.py index c326a45d462..cefec42ba3a 100644 --- a/homeassistant/components/numato/binary_sensor.py +++ b/homeassistant/components/numato/binary_sensor.py @@ -58,7 +58,10 @@ def setup_platform( except NumatoGpioError as err: _LOGGER.error( - "Failed to initialize binary sensor '%s' on Numato device %s port %s: %s", + ( + "Failed to initialize binary sensor '%s' on Numato device %s" + " port %s: %s" + ), port_name, device_id, port, diff --git a/homeassistant/components/number/__init__.py b/homeassistant/components/number/__init__.py index fb90d373113..2f5ebc662a3 100644 --- a/homeassistant/components/number/__init__.py +++ b/homeassistant/components/number/__init__.py @@ -376,7 +376,8 @@ async def async_set_value(entity: NumberEntity, service_call: ServiceCall) -> No value = service_call.data["value"] if value < entity.min_value or value > entity.max_value: raise ValueError( - f"Value {value} for {entity.name} is outside valid range {entity.min_value} - {entity.max_value}" + f"Value {value} for {entity.name} is outside valid range" + f" {entity.min_value} - {entity.max_value}" ) try: native_value = entity.convert_to_native_value(value) @@ -436,9 +437,11 @@ class NumberEntityDescription(EntityDescription): "https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue" ) _LOGGER.warning( - "%s is setting deprecated attributes on an instance of " - "NumberEntityDescription, this is not valid and will be unsupported " - "from Home Assistant 2022.10. Please %s", + ( + "%s is setting deprecated attributes on an instance of" + " NumberEntityDescription, this is not valid and will be" + " unsupported from Home Assistant 2022.10. Please %s" + ), module.__name__ if module else self.__class__.__name__, report_issue, ) @@ -507,9 +510,11 @@ class NumberEntity(Entity): "https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue" ) _LOGGER.warning( - "%s::%s is overriding deprecated methods on an instance of " - "NumberEntity, this is not valid and will be unsupported " - "from Home Assistant 2022.10. Please %s", + ( + "%s::%s is overriding deprecated methods on an instance of " + "NumberEntity, this is not valid and will be unsupported " + "from Home Assistant 2022.10. Please %s" + ), cls.__module__, cls.__name__, report_issue, @@ -772,8 +777,10 @@ class NumberEntity(Entity): self._deprecated_number_entity_reported = True report_issue = self._suggest_report_issue() _LOGGER.warning( - "Entity %s (%s) is using deprecated NumberEntity features which will " - "be unsupported from Home Assistant Core 2022.10, please %s", + ( + "Entity %s (%s) is using deprecated NumberEntity features which" + " will be unsupported from Home Assistant Core 2022.10, please %s" + ), self.entity_id, type(self), report_issue, diff --git a/homeassistant/components/onkyo/media_player.py b/homeassistant/components/onkyo/media_player.py index d9de2730659..9b41a635fe1 100644 --- a/homeassistant/components/onkyo/media_player.py +++ b/homeassistant/components/onkyo/media_player.py @@ -365,7 +365,8 @@ class OnkyoDevice(MediaPlayerEntity): """ # HA_VOL * (MAX VOL / 100) * MAX_RECEIVER_VOL self.command( - f"volume {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}" + "volume" + f" {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}" ) def volume_up(self) -> None: diff --git a/homeassistant/components/onvif/config_flow.py b/homeassistant/components/onvif/config_flow.py index 48e5163ced5..a0dd77df53a 100644 --- a/homeassistant/components/onvif/config_flow.py +++ b/homeassistant/components/onvif/config_flow.py @@ -213,7 +213,10 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): raise fault LOGGER.debug( - "Couldn't get network interfaces from ONVIF deivice '%s'. Error: %s", + ( + "Couldn't get network interfaces from ONVIF deivice '%s'." + " Error: %s" + ), self.onvif_config[CONF_NAME], fault, ) diff --git a/homeassistant/components/onvif/device.py b/homeassistant/components/onvif/device.py index 8c000852c48..3398c905d58 100644 --- a/homeassistant/components/onvif/device.py +++ b/homeassistant/components/onvif/device.py @@ -135,8 +135,10 @@ class ONVIFDevice: await self.device.close() except Fault as err: LOGGER.error( - "Couldn't connect to camera '%s', please verify " - "that the credentials are correct. Error: %s", + ( + "Couldn't connect to camera '%s', please verify " + "that the credentials are correct. Error: %s" + ), self.name, err, ) @@ -230,9 +232,11 @@ class ONVIFDevice: if self._dt_diff_seconds > 5: LOGGER.warning( - "The date/time on %s (UTC) is '%s', " - "which is different from the system '%s', " - "this could lead to authentication issues", + ( + "The date/time on %s (UTC) is '%s', " + "which is different from the system '%s', " + "this could lead to authentication issues" + ), self.name, cam_date_utc, system_date, @@ -384,7 +388,10 @@ class ONVIFDevice: speed_val = speed preset_val = preset LOGGER.debug( - "Calling %s PTZ | Pan = %4.2f | Tilt = %4.2f | Zoom = %4.2f | Speed = %4.2f | Preset = %s", + ( + "Calling %s PTZ | Pan = %4.2f | Tilt = %4.2f | Zoom = %4.2f | Speed =" + " %4.2f | Preset = %s" + ), move_mode, pan_val, tilt_val, @@ -461,7 +468,10 @@ class ONVIFDevice: return if preset_val not in profile.ptz.presets: LOGGER.warning( - "PTZ preset '%s' does not exist on device '%s'. Available Presets: %s", + ( + "PTZ preset '%s' does not exist on device '%s'. Available" + " Presets: %s" + ), preset_val, self.name, ", ".join(profile.ptz.presets), diff --git a/homeassistant/components/onvif/event.py b/homeassistant/components/onvif/event.py index 8b09ee99079..4766bf0b002 100644 --- a/homeassistant/components/onvif/event.py +++ b/homeassistant/components/onvif/event.py @@ -126,8 +126,10 @@ class EventManager: await self._subscription.Unsubscribe() except (XMLParseError, *SUBSCRIPTION_ERRORS) as err: LOGGER.debug( - "Failed to unsubscribe ONVIF PullPoint subscription for '%s';" - " This is normal if the device restarted: %s", + ( + "Failed to unsubscribe ONVIF PullPoint subscription for '%s';" + " This is normal if the device restarted: %s" + ), self.unique_id, err, ) @@ -141,8 +143,10 @@ class EventManager: # when we get an XMLParseError LOGGER.log( DEBUG if isinstance(err, XMLParseError) else WARNING, - "Failed to restart ONVIF PullPoint subscription for '%s'; " - "Retrying later: %s", + ( + "Failed to restart ONVIF PullPoint subscription for '%s'; " + "Retrying later: %s" + ), self.unique_id, err, ) @@ -194,7 +198,10 @@ class EventManager: # when we get an XMLParseError LOGGER.log( DEBUG if isinstance(err, XMLParseError) else WARNING, - "Failed to fetch ONVIF PullPoint subscription messages for '%s': %s", + ( + "Failed to fetch ONVIF PullPoint subscription messages for" + " '%s': %s" + ), self.unique_id, err, ) diff --git a/homeassistant/components/opentherm_gw/binary_sensor.py b/homeassistant/components/opentherm_gw/binary_sensor.py index 194e047e50e..1a4247992a7 100644 --- a/homeassistant/components/opentherm_gw/binary_sensor.py +++ b/homeassistant/components/opentherm_gw/binary_sensor.py @@ -70,10 +70,12 @@ async def async_setup_entry( if deprecated_sensors: _LOGGER.warning( - "The following binary_sensor entities are deprecated and may " - "no longer behave as expected. They will be removed in a " - "future version. You can force removal of these entities by " - "disabling them and restarting Home Assistant.\n%s", + ( + "The following binary_sensor entities are deprecated and may " + "no longer behave as expected. They will be removed in a " + "future version. You can force removal of these entities by " + "disabling them and restarting Home Assistant.\n%s" + ), pformat([s.entity_id for s in deprecated_sensors]), ) diff --git a/homeassistant/components/opentherm_gw/sensor.py b/homeassistant/components/opentherm_gw/sensor.py index 67b4eb138dd..d1f99461b22 100644 --- a/homeassistant/components/opentherm_gw/sensor.py +++ b/homeassistant/components/opentherm_gw/sensor.py @@ -73,10 +73,12 @@ async def async_setup_entry( if deprecated_sensors: _LOGGER.warning( - "The following sensor entities are deprecated and may no " - "longer behave as expected. They will be removed in a future " - "version. You can force removal of these entities by disabling " - "them and restarting Home Assistant.\n%s", + ( + "The following sensor entities are deprecated and may no " + "longer behave as expected. They will be removed in a future " + "version. You can force removal of these entities by disabling " + "them and restarting Home Assistant.\n%s" + ), pformat([s.entity_id for s in deprecated_sensors]), ) diff --git a/homeassistant/components/opple/light.py b/homeassistant/components/opple/light.py index 80d0f8630dc..0d42b35b83b 100644 --- a/homeassistant/components/opple/light.py +++ b/homeassistant/components/opple/light.py @@ -151,8 +151,7 @@ class OppleLight(LightEntity): _LOGGER.debug("Update light %s success: power off", self._device.ip) else: _LOGGER.debug( - "Update light %s success: power on brightness %s " - "color temperature %s", + "Update light %s success: power on brightness %s color temperature %s", self._device.ip, self._brightness, self._color_temp, diff --git a/homeassistant/components/osramlightify/light.py b/homeassistant/components/osramlightify/light.py index fa4aca357c1..1c0a134831b 100644 --- a/homeassistant/components/osramlightify/light.py +++ b/homeassistant/components/osramlightify/light.py @@ -412,7 +412,9 @@ class OsramLightifyLight(Luminary): """Update static attributes of the luminary.""" super().update_static_attributes() attrs = { - "device_type": f"{self._luminary.type_id()} ({self._luminary.devicename()})", + "device_type": ( + f"{self._luminary.type_id()} ({self._luminary.devicename()})" + ), "firmware_version": self._luminary.version(), } if self._luminary.devicetype().name == "SENSOR":