From cb13418babd21a1e9584978b0c523f1b1e4e1cb0 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 22 Dec 2022 11:38:59 +0100 Subject: [PATCH] String formatting and max line length - Part 2 (#84393) --- homeassistant/components/fitbit/sensor.py | 5 +- homeassistant/components/flux/switch.py | 12 +++-- homeassistant/components/flux_led/__init__.py | 3 +- homeassistant/components/foscam/camera.py | 25 ++++++++-- homeassistant/components/freebox/switch.py | 3 +- homeassistant/components/fritz/common.py | 24 +++++++--- homeassistant/components/fritz/services.py | 3 +- homeassistant/components/fritzbox/light.py | 3 +- .../fritzbox_callmonitor/__init__.py | 5 +- homeassistant/components/frontend/__init__.py | 4 +- .../frontier_silicon/browse_media.py | 4 +- .../generic_hygrostat/humidifier.py | 6 ++- .../components/generic_thermostat/climate.py | 14 ++++-- homeassistant/components/github/__init__.py | 5 +- .../google/application_credentials.py | 4 +- homeassistant/components/google/calendar.py | 5 +- .../components/google_assistant/__init__.py | 3 +- .../components/google_assistant/button.py | 3 +- .../components/google_assistant/helpers.py | 10 +++- .../components/google_assistant/trait.py | 4 +- .../application_credentials.py | 8 +++- .../components/google_maps/device_tracker.py | 12 +++-- .../google_sheets/application_credentials.py | 4 +- .../components/google_wifi/sensor.py | 6 ++- .../components/greeneye_monitor/__init__.py | 6 ++- .../components/greeneye_monitor/sensor.py | 3 +- .../components/growatt_server/sensor.py | 21 +++++++-- homeassistant/components/gtfs/sensor.py | 14 +++--- homeassistant/components/habitica/sensor.py | 12 +++-- homeassistant/components/harmony/data.py | 9 ++-- homeassistant/components/hassio/handler.py | 7 ++- homeassistant/components/heos/__init__.py | 10 ++-- .../here_travel_time/coordinator.py | 10 +++- homeassistant/components/hive/climate.py | 3 +- .../homeassistant/triggers/numeric_state.py | 5 +- .../components/homeassistant/triggers/time.py | 4 +- homeassistant/components/homekit/__init__.py | 25 +++++++--- .../components/homekit/accessories.py | 9 ++-- .../components/homekit/config_flow.py | 4 +- homeassistant/components/homekit/logbook.py | 5 +- .../components/homekit/type_cameras.py | 3 +- .../components/homekit/type_covers.py | 5 +- .../components/homekit/type_humidifiers.py | 11 +++-- .../components/homekit/type_thermostats.py | 22 ++++++--- homeassistant/components/homekit/util.py | 2 +- .../components/homekit_controller/__init__.py | 8 ++-- .../components/homekit_controller/climate.py | 14 ++++-- .../homekit_controller/config_flow.py | 22 ++++++--- .../homekit_controller/connection.py | 46 +++++++++++++++---- homeassistant/components/homematic/sensor.py | 5 +- .../homematicip_cloud/alarm_control_panel.py | 5 +- .../components/homematicip_cloud/hap.py | 6 ++- .../components/homewizard/config_flow.py | 5 +- .../components/honeywell/__init__.py | 3 +- homeassistant/components/http/__init__.py | 10 ++-- homeassistant/components/http/ban.py | 5 +- homeassistant/components/http/forwarded.py | 11 +++-- homeassistant/components/hue/__init__.py | 8 ++-- homeassistant/components/hue/migration.py | 10 +++- homeassistant/components/hue/services.py | 6 ++- homeassistant/components/hue/v2/entity.py | 12 +++-- .../components/humidifier/device_trigger.py | 4 +- .../hunterdouglas_powerview/entity.py | 4 +- .../components/hvv_departures/config_flow.py | 5 +- homeassistant/components/hyperion/__init__.py | 8 ++-- homeassistant/components/hyperion/const.py | 6 +-- homeassistant/components/hyperion/light.py | 12 +++-- homeassistant/components/influxdb/__init__.py | 9 ++-- homeassistant/components/influxdb/sensor.py | 16 +++++-- 69 files changed, 431 insertions(+), 174 deletions(-) diff --git a/homeassistant/components/fitbit/sensor.py b/homeassistant/components/fitbit/sensor.py index fc0f7fca082..0f3f4c22ff7 100644 --- a/homeassistant/components/fitbit/sensor.py +++ b/homeassistant/components/fitbit/sensor.py @@ -86,7 +86,10 @@ def request_app_setup( if os.path.isfile(config_path): config_file = load_json(config_path) if config_file == DEFAULT_CONFIG: - error_msg = f"You didn't correctly modify {FITBIT_CONFIG_FILE}, please try again." + error_msg = ( + f"You didn't correctly modify {FITBIT_CONFIG_FILE}, please try" + " again." + ) configurator.notify_errors(hass, _CONFIGURING["fitbit"], error_msg) else: diff --git a/homeassistant/components/flux/switch.py b/homeassistant/components/flux/switch.py index baa2d658d23..6da3f88eedf 100644 --- a/homeassistant/components/flux/switch.py +++ b/homeassistant/components/flux/switch.py @@ -316,8 +316,10 @@ class FluxSwitch(SwitchEntity, RestoreEntity): self.hass, self._lights, x_val, y_val, brightness, self._transition ) _LOGGER.debug( - "Lights updated to x:%s y:%s brightness:%s, %s%% " - "of %s cycle complete at %s", + ( + "Lights updated to x:%s y:%s brightness:%s, %s%% " + "of %s cycle complete at %s" + ), x_val, y_val, brightness, @@ -341,8 +343,10 @@ class FluxSwitch(SwitchEntity, RestoreEntity): self.hass, self._lights, mired, brightness, self._transition ) _LOGGER.debug( - "Lights updated to mired:%s brightness:%s, %s%% " - "of %s cycle complete at %s", + ( + "Lights updated to mired:%s brightness:%s, %s%% " + "of %s cycle complete at %s" + ), mired, brightness, round(percentage_complete * 100), diff --git a/homeassistant/components/flux_led/__init__.py b/homeassistant/components/flux_led/__init__.py index 717b4a685df..04d60fec25e 100644 --- a/homeassistant/components/flux_led/__init__.py +++ b/homeassistant/components/flux_led/__init__.py @@ -177,7 +177,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if not mac_matches_by_one(mac, entry.unique_id): # The device is offline and another flux_led device is now using the ip address raise ConfigEntryNotReady( - f"Unexpected device found at {host}; Expected {entry.unique_id}, found {mac}" + f"Unexpected device found at {host}; Expected {entry.unique_id}, found" + f" {mac}" ) if not discovery_cached: diff --git a/homeassistant/components/foscam/camera.py b/homeassistant/components/foscam/camera.py index c0b6661a392..fe11b056880 100644 --- a/homeassistant/components/foscam/camera.py +++ b/homeassistant/components/foscam/camera.py @@ -117,7 +117,10 @@ class HassFoscamCamera(Camera): if ret == -3: LOGGER.info( - "Can't get motion detection status, camera %s configured with non-admin user", + ( + "Can't get motion detection status, camera %s configured with" + " non-admin user" + ), self.name, ) @@ -156,7 +159,10 @@ class HassFoscamCamera(Camera): if ret != 0: if ret == -3: LOGGER.info( - "Can't set motion detection status, camera %s configured with non-admin user", + ( + "Can't set motion detection status, camera %s configured" + " with non-admin user" + ), self.name, ) return @@ -164,7 +170,10 @@ class HassFoscamCamera(Camera): self._attr_motion_detection_enabled = True except TypeError: LOGGER.debug( - "Failed enabling motion detection on '%s'. Is it supported by the device?", + ( + "Failed enabling motion detection on '%s'. Is it supported by the" + " device?" + ), self.name, ) @@ -176,7 +185,10 @@ class HassFoscamCamera(Camera): if ret != 0: if ret == -3: LOGGER.info( - "Can't set motion detection status, camera %s configured with non-admin user", + ( + "Can't set motion detection status, camera %s configured" + " with non-admin user" + ), self.name, ) return @@ -184,7 +196,10 @@ class HassFoscamCamera(Camera): self._attr_motion_detection_enabled = False except TypeError: LOGGER.debug( - "Failed disabling motion detection on '%s'. Is it supported by the device?", + ( + "Failed disabling motion detection on '%s'. Is it supported by the" + " device?" + ), self.name, ) diff --git a/homeassistant/components/freebox/switch.py b/homeassistant/components/freebox/switch.py index 9bef539bfd8..41edc3f02c9 100644 --- a/homeassistant/components/freebox/switch.py +++ b/homeassistant/components/freebox/switch.py @@ -57,7 +57,8 @@ class FreeboxSwitch(SwitchEntity): await self._router.wifi.set_global_config({"enabled": enabled}) except InsufficientPermissionsError: _LOGGER.warning( - "Home Assistant does not have permissions to modify the Freebox settings. Please refer to documentation" + "Home Assistant does not have permissions to modify the Freebox" + " settings. Please refer to documentation" ) async def async_turn_on(self, **kwargs: Any) -> None: diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index 14e0f154374..28d5cff032d 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -328,7 +328,10 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator): ).get("NewDisallow") except FRITZ_EXCEPTIONS as ex: _LOGGER.debug( - "could not get WAN access rule for client device with IP '%s', error: %s", + ( + "could not get WAN access rule for client device with IP '%s'," + " error: %s" + ), ip_address, ex, ) @@ -574,21 +577,24 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator): try: if service_call.service == SERVICE_REBOOT: _LOGGER.warning( - 'Service "fritz.reboot" is deprecated, please use the corresponding button entity instead' + 'Service "fritz.reboot" is deprecated, please use the corresponding' + " button entity instead" ) await self.async_trigger_reboot() return if service_call.service == SERVICE_RECONNECT: _LOGGER.warning( - 'Service "fritz.reconnect" is deprecated, please use the corresponding button entity instead' + 'Service "fritz.reconnect" is deprecated, please use the' + " corresponding button entity instead" ) await self.async_trigger_reconnect() return if service_call.service == SERVICE_CLEANUP: _LOGGER.warning( - 'Service "fritz.cleanup" is deprecated, please use the corresponding button entity instead' + 'Service "fritz.cleanup" is deprecated, please use the' + " corresponding button entity instead" ) await self.async_trigger_cleanup(config_entry) return @@ -634,7 +640,10 @@ class AvmWrapper(FritzBoxTools): return result except FritzSecurityError: _LOGGER.error( - "Authorization Error: Please check the provided credentials and verify that you can log into the web interface", + ( + "Authorization Error: Please check the provided credentials and" + " verify that you can log into the web interface" + ), exc_info=True, ) except FRITZ_EXCEPTIONS: @@ -646,7 +655,10 @@ class AvmWrapper(FritzBoxTools): ) except FritzConnectionException: _LOGGER.error( - "Connection Error: Please check the device is properly configured for remote login", + ( + "Connection Error: Please check the device is properly configured" + " for remote login" + ), exc_info=True, ) return {} diff --git a/homeassistant/components/fritz/services.py b/homeassistant/components/fritz/services.py index c4e7de8df5e..e0b41d0e87e 100644 --- a/homeassistant/components/fritz/services.py +++ b/homeassistant/components/fritz/services.py @@ -54,7 +54,8 @@ async def async_setup_services(hass: HomeAssistant) -> None: ) ): raise HomeAssistantError( - f"Failed to call service '{service_call.service}'. Config entry for target not found" + f"Failed to call service '{service_call.service}'. Config entry for" + " target not found" ) for entry_id in fritzbox_entry_ids: diff --git a/homeassistant/components/fritzbox/light.py b/homeassistant/components/fritzbox/light.py index 03eb9eb9d78..24431f78aca 100644 --- a/homeassistant/components/fritzbox/light.py +++ b/homeassistant/components/fritzbox/light.py @@ -149,7 +149,8 @@ class FritzboxLight(FritzBoxDeviceEntity, LightEntity): if err.response.status_code != 400: raise LOGGER.debug( - "fritzbox does not support method 'setunmappedcolor', fallback to 'setcolor'" + "fritzbox does not support method 'setunmappedcolor', fallback to" + " 'setcolor'" ) # find supported hs values closest to what user selected hue = min( diff --git a/homeassistant/components/fritzbox_callmonitor/__init__.py b/homeassistant/components/fritzbox_callmonitor/__init__.py index a47c3c24755..534f3b0c8fc 100644 --- a/homeassistant/components/fritzbox_callmonitor/__init__.py +++ b/homeassistant/components/fritzbox_callmonitor/__init__.py @@ -36,7 +36,10 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b await hass.async_add_executor_job(fritzbox_phonebook.init_phonebook) except FritzSecurityError as ex: _LOGGER.error( - "User has insufficient permissions to access AVM FRITZ!Box settings and its phonebooks: %s", + ( + "User has insufficient permissions to access AVM FRITZ!Box settings and" + " its phonebooks: %s" + ), ex, ) return False diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index f5fe37c1819..eff8bc77a9a 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -146,7 +146,9 @@ class Manifest: MANIFEST_JSON = Manifest( { "background_color": "#FFFFFF", - "description": "Home automation platform that puts local control and privacy first.", + "description": ( + "Home automation platform that puts local control and privacy first." + ), "dir": "ltr", "display": "standalone", "icons": [ diff --git a/homeassistant/components/frontier_silicon/browse_media.py b/homeassistant/components/frontier_silicon/browse_media.py index 53deb399b87..7815b029735 100644 --- a/homeassistant/components/frontier_silicon/browse_media.py +++ b/homeassistant/components/frontier_silicon/browse_media.py @@ -87,7 +87,9 @@ async def browse_top_level(current_mode, afsapi: AFSAPI): title=name, media_class=MediaClass.DIRECTORY, media_content_type=MediaType.CHANNELS, - media_content_id=f"{current_mode or 'unknown'}/{top_level_media_content_id}", + media_content_id=( + f"{current_mode or 'unknown'}/{top_level_media_content_id}" + ), can_play=False, can_expand=True, ) diff --git a/homeassistant/components/generic_hygrostat/humidifier.py b/homeassistant/components/generic_hygrostat/humidifier.py index e6caf2ca097..b8db68fbee9 100644 --- a/homeassistant/components/generic_hygrostat/humidifier.py +++ b/homeassistant/components/generic_hygrostat/humidifier.py @@ -358,8 +358,10 @@ class GenericHygrostat(HumidifierEntity, RestoreEntity): self._active = True force = True _LOGGER.info( - "Obtained current and target humidity. " - "Generic hygrostat active. %s, %s", + ( + "Obtained current and target humidity. " + "Generic hygrostat active. %s, %s" + ), self._cur_humidity, self._target_humidity, ) diff --git a/homeassistant/components/generic_thermostat/climate.py b/homeassistant/components/generic_thermostat/climate.py index dadfc995e03..22a3f98a9f0 100644 --- a/homeassistant/components/generic_thermostat/climate.py +++ b/homeassistant/components/generic_thermostat/climate.py @@ -409,7 +409,10 @@ class GenericThermostat(ClimateEntity, RestoreEntity): """Prevent the device from keep running if HVACMode.OFF.""" if self._hvac_mode == HVACMode.OFF and self._is_device_active: _LOGGER.warning( - "The climate mode is OFF, but the switch device is ON. Turning off device %s", + ( + "The climate mode is OFF, but the switch device is ON. Turning off" + " device %s" + ), self.heater_entity_id, ) await self._async_heater_turn_off() @@ -445,8 +448,10 @@ class GenericThermostat(ClimateEntity, RestoreEntity): ): self._active = True _LOGGER.info( - "Obtained current and target temperature. " - "Generic thermostat active. %s, %s", + ( + "Obtained current and target temperature. " + "Generic thermostat active. %s, %s" + ), self._cur_temp, self._target_temp, ) @@ -526,7 +531,8 @@ class GenericThermostat(ClimateEntity, RestoreEntity): """Set new preset mode.""" if preset_mode not in (self.preset_modes or []): raise ValueError( - f"Got unsupported preset_mode {preset_mode}. Must be one of {self.preset_modes}" + f"Got unsupported preset_mode {preset_mode}. Must be one of" + f" {self.preset_modes}" ) if preset_mode == self._attr_preset_mode: # I don't think we need to call async_write_ha_state if we didn't change the state diff --git a/homeassistant/components/github/__init__.py b/homeassistant/components/github/__init__.py index bc2bab49bdb..1ce5d7df0ce 100644 --- a/homeassistant/components/github/__init__.py +++ b/homeassistant/components/github/__init__.py @@ -66,7 +66,10 @@ def async_cleanup_device_registry( for item in device.identifiers: if DOMAIN == item[0] and item[1] not in entry.options[CONF_REPOSITORIES]: LOGGER.debug( - "Unlinking device %s for untracked repository %s from config entry %s", + ( + "Unlinking device %s for untracked repository %s from config" + " entry %s" + ), device.id, item[1], entry.entry_id, diff --git a/homeassistant/components/google/application_credentials.py b/homeassistant/components/google/application_credentials.py index 3d557630b05..60ad9b3275e 100644 --- a/homeassistant/components/google/application_credentials.py +++ b/homeassistant/components/google/application_credentials.py @@ -26,7 +26,9 @@ async def async_get_auth_implementation( 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/google/", "oauth_creds_url": "https://console.cloud.google.com/apis/credentials", } diff --git a/homeassistant/components/google/calendar.py b/homeassistant/components/google/calendar.py index e6f31cc54cb..ffd12fcfcf9 100644 --- a/homeassistant/components/google/calendar.py +++ b/homeassistant/components/google/calendar.py @@ -173,8 +173,9 @@ async def async_setup_entry( entity_enabled = data.get(CONF_TRACK, True) if not entity_enabled: _LOGGER.warning( - "The 'track' option in google_calendars.yaml has been deprecated. The setting " - "has been imported to the UI, and should now be removed from google_calendars.yaml" + "The 'track' option in google_calendars.yaml has been deprecated." + " The setting has been imported to the UI, and should now be" + " removed from google_calendars.yaml" ) entity_name = data[CONF_DEVICE_ID] # The unique id is based on the config entry and calendar id since multiple accounts diff --git a/homeassistant/components/google_assistant/__init__.py b/homeassistant/components/google_assistant/__init__.py index 644179858a3..82868828531 100644 --- a/homeassistant/components/google_assistant/__init__.py +++ b/homeassistant/components/google_assistant/__init__.py @@ -153,7 +153,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if agent_user_id is None: _LOGGER.warning( - "No agent_user_id supplied for request_sync. Call as a user or pass in user id as agent_user_id" + "No agent_user_id supplied for request_sync. Call as a user or pass in" + " user id as agent_user_id" ) return diff --git a/homeassistant/components/google_assistant/button.py b/homeassistant/components/google_assistant/button.py index 322a021053a..c77edf4520b 100644 --- a/homeassistant/components/google_assistant/button.py +++ b/homeassistant/components/google_assistant/button.py @@ -49,5 +49,6 @@ class SyncButton(ButtonEntity): result = await self._google_config.async_sync_entities(agent_user_id) if result != 200: raise HomeAssistantError( - f"Unable to sync devices with result code: {result}, check log for more info." + f"Unable to sync devices with result code: {result}, check log for more" + " info." ) diff --git a/homeassistant/components/google_assistant/helpers.py b/homeassistant/components/google_assistant/helpers.py index 9d06af2555a..3f9c90d40e1 100644 --- a/homeassistant/components/google_assistant/helpers.py +++ b/homeassistant/components/google_assistant/helpers.py @@ -349,7 +349,10 @@ class AbstractConfig(ABC): not version or AwesomeVersion(version) < LOCAL_SDK_MIN_VERSION ): _LOGGER.warning( - "Local SDK version is too old (%s), check documentation on how to update to the latest version", + ( + "Local SDK version is too old (%s), check documentation on how to" + " update to the latest version" + ), version, ) self._local_sdk_version_warn = True @@ -368,7 +371,10 @@ class AbstractConfig(ABC): # No agent user linked to this webhook, means that the user has somehow unregistered # removing webhook and stopping processing of this request. _LOGGER.error( - "Cannot process request for webhook %s as no linked agent user is found:\n%s\n", + ( + "Cannot process request for webhook %s as no linked agent user is" + " found:\n%s\n" + ), webhook_id, pprint.pformat(payload), ) diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index 8fb5aed76a4..920a63b70f8 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -1043,7 +1043,7 @@ class TemperatureSettingTrait(_Trait): raise SmartHomeError( ERR_VALUE_OUT_OF_RANGE, ( - f"Upper bound for temperature range should be between " + "Upper bound for temperature range should be between " f"{min_temp} and {max_temp}" ), ) @@ -1060,7 +1060,7 @@ class TemperatureSettingTrait(_Trait): raise SmartHomeError( ERR_VALUE_OUT_OF_RANGE, ( - f"Lower bound for temperature range should be between " + "Lower bound for temperature range should be between " f"{min_temp} and {max_temp}" ), ) diff --git a/homeassistant/components/google_assistant_sdk/application_credentials.py b/homeassistant/components/google_assistant_sdk/application_credentials.py index 5c62c9a4e00..74cefb14b65 100644 --- a/homeassistant/components/google_assistant_sdk/application_credentials.py +++ b/homeassistant/components/google_assistant_sdk/application_credentials.py @@ -16,7 +16,11 @@ 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", - "more_info_url": "https://www.home-assistant.io/integrations/google_assistant_sdk/", + "oauth_consent_url": ( + "https://console.cloud.google.com/apis/credentials/consent" + ), + "more_info_url": ( + "https://www.home-assistant.io/integrations/google_assistant_sdk/" + ), "oauth_creds_url": "https://console.cloud.google.com/apis/credentials", } diff --git a/homeassistant/components/google_maps/device_tracker.py b/homeassistant/components/google_maps/device_tracker.py index 8f15278e214..e1927aa81c5 100644 --- a/homeassistant/components/google_maps/device_tracker.py +++ b/homeassistant/components/google_maps/device_tracker.py @@ -80,7 +80,8 @@ class GoogleMapsScanner: except InvalidCookies: _LOGGER.error( - "The cookie file provided does not provide a valid session. Please create another one and try again" + "The cookie file provided does not provide a valid session. Please" + " create another one and try again" ) self.success_init = False @@ -97,8 +98,10 @@ class GoogleMapsScanner: and person.accuracy > self.max_gps_accuracy ): _LOGGER.info( - "Ignoring %s update because expected GPS " - "accuracy %s is not met: %s", + ( + "Ignoring %s update because expected GPS " + "accuracy %s is not met: %s" + ), person.nickname, self.max_gps_accuracy, person.accuracy, @@ -108,8 +111,7 @@ class GoogleMapsScanner: last_seen = dt_util.as_utc(person.datetime) if last_seen < self._prev_seen.get(dev_id, last_seen): _LOGGER.warning( - "Ignoring %s update because timestamp " - "is older than last timestamp", + "Ignoring %s update because timestamp is older than last timestamp", person.nickname, ) _LOGGER.debug("%s < %s", last_seen, self._prev_seen[dev_id]) diff --git a/homeassistant/components/google_sheets/application_credentials.py b/homeassistant/components/google_sheets/application_credentials.py index 52942825595..415ab5947bf 100644 --- a/homeassistant/components/google_sheets/application_credentials.py +++ b/homeassistant/components/google_sheets/application_credentials.py @@ -16,7 +16,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/google_sheets/", "oauth_creds_url": "https://console.cloud.google.com/apis/credentials", } diff --git a/homeassistant/components/google_wifi/sensor.py b/homeassistant/components/google_wifi/sensor.py index 3aeeb802362..d7be81a8ea5 100644 --- a/homeassistant/components/google_wifi/sensor.py +++ b/homeassistant/components/google_wifi/sensor.py @@ -228,8 +228,10 @@ class GoogleWifiAPI: self.data[attr_key] = sensor_value except KeyError: _LOGGER.error( - "Router does not support %s field. " - "Please remove %s from monitored_conditions", + ( + "Router does not support %s field. " + "Please remove %s from monitored_conditions" + ), description.sensor_key, attr_key, ) diff --git a/homeassistant/components/greeneye_monitor/__init__.py b/homeassistant/components/greeneye_monitor/__init__.py index 7d4b6dac68f..e4090787e65 100644 --- a/homeassistant/components/greeneye_monitor/__init__.py +++ b/homeassistant/components/greeneye_monitor/__init__.py @@ -89,8 +89,10 @@ MONITOR_SCHEMA = vol.Schema( vol.Length( min=8, max=8, - msg="GEM serial number must be specified as an 8-character " - "string (including leading zeroes).", + msg=( + "GEM serial number must be specified as an 8-character " + "string (including leading zeroes)." + ), ), vol.Coerce(int), ), diff --git a/homeassistant/components/greeneye_monitor/sensor.py b/homeassistant/components/greeneye_monitor/sensor.py index f0be0f70032..55318ad6018 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -240,7 +240,8 @@ class PulseCounter(GEMSensor): # Config schema should have ensured it is one of the above values raise Exception( - f"Invalid value for time unit: {self._time_unit}. Expected one of {UnitOfTime.SECONDS}, {UnitOfTime.MINUTES}, or {UnitOfTime.HOURS}" + f"Invalid value for time unit: {self._time_unit}. Expected one of" + f" {UnitOfTime.SECONDS}, {UnitOfTime.MINUTES}, or {UnitOfTime.HOURS}" ) @property diff --git a/homeassistant/components/growatt_server/sensor.py b/homeassistant/components/growatt_server/sensor.py index b22664897fd..57dd7f10fb1 100644 --- a/homeassistant/components/growatt_server/sensor.py +++ b/homeassistant/components/growatt_server/sensor.py @@ -84,7 +84,9 @@ async def async_setup_entry( # also extend the library's default identifier to include 'home-assistant' api = growattServer.GrowattApi( add_random_user_id=True, - agent_identifier=f"{growattServer.GrowattApi.agent_identifier} - home-assistant", + agent_identifier=( + f"{growattServer.GrowattApi.agent_identifier} - home-assistant" + ), ) api.server_url = url @@ -290,7 +292,10 @@ class GrowattData: and api_value is not None ): _LOGGER.debug( - "%s - Drop threshold specified (%s), checking for drop... API Value: %s, Previous Value: %s", + ( + "%s - Drop threshold specified (%s), checking for drop... API" + " Value: %s, Previous Value: %s" + ), entity_description.name, entity_description.previous_value_drop_threshold, api_value, @@ -304,8 +309,11 @@ class GrowattData: # however if the value is low e.g. 0.2 and drops by 0.1 it classes as a reset. if -(entity_description.previous_value_drop_threshold) <= diff < 0: _LOGGER.debug( - "Diff is negative, but only by a small amount therefore not a nightly reset, " - "using previous value (%s) instead of api value (%s)", + ( + "Diff is negative, but only by a small amount therefore not a" + " nightly reset, using previous value (%s) instead of api value" + " (%s)" + ), previous_value, api_value, ) @@ -329,7 +337,10 @@ class GrowattData: # value of the entity from the recorder if entity_description.never_resets and api_value == 0 and previous_value: _LOGGER.debug( - "API value is 0, but this value should never reset, returning previous value (%s) instead", + ( + "API value is 0, but this value should never reset, returning" + " previous value (%s) instead" + ), previous_value, ) return_value = previous_value diff --git a/homeassistant/components/gtfs/sensor.py b/homeassistant/components/gtfs/sensor.py index 9b733d41502..2bce3cb21c1 100644 --- a/homeassistant/components/gtfs/sensor.py +++ b/homeassistant/components/gtfs/sensor.py @@ -427,16 +427,14 @@ def get_next_departure( if item["dest_arrival_time"] < item["origin_depart_time"]: dest_arrival += datetime.timedelta(days=1) dest_arrival_time = ( - f"{dest_arrival.strftime(dt_util.DATE_STR_FORMAT)} " - f"{item['dest_arrival_time']}" + f"{dest_arrival.strftime(dt_util.DATE_STR_FORMAT)} {item['dest_arrival_time']}" ) dest_depart = dest_arrival if item["dest_depart_time"] < item["dest_arrival_time"]: dest_depart += datetime.timedelta(days=1) dest_depart_time = ( - f"{dest_depart.strftime(dt_util.DATE_STR_FORMAT)} " - f"{item['dest_depart_time']}" + f"{dest_depart.strftime(dt_util.DATE_STR_FORMAT)} {item['dest_depart_time']}" ) depart_time = dt_util.parse_datetime(origin_depart_time) @@ -638,9 +636,11 @@ class GTFSDepartureSensor(SensorEntity): self._agency = self._pygtfs.agencies_by_id(self._route.agency_id)[0] except IndexError: _LOGGER.warning( - "Agency ID '%s' was not found in agency table, " - "you may want to update the routes database table " - "to fix this missing reference", + ( + "Agency ID '%s' was not found in agency table, " + "you may want to update the routes database table " + "to fix this missing reference" + ), self._route.agency_id, ) self._agency = False diff --git a/homeassistant/components/habitica/sensor.py b/homeassistant/components/habitica/sensor.py index 5a7109df0b9..e085167301f 100644 --- a/homeassistant/components/habitica/sensor.py +++ b/homeassistant/components/habitica/sensor.py @@ -114,8 +114,10 @@ class HabitipyData: except ClientResponseError as error: if error.status == HTTPStatus.TOO_MANY_REQUESTS: _LOGGER.warning( - "Sensor data update for %s has too many API requests;" - " Skipping the update", + ( + "Sensor data update for %s has too many API requests;" + " Skipping the update" + ), DOMAIN, ) else: @@ -131,8 +133,10 @@ class HabitipyData: except ClientResponseError as error: if error.status == HTTPStatus.TOO_MANY_REQUESTS: _LOGGER.warning( - "Sensor data update for %s has too many API requests;" - " Skipping the update", + ( + "Sensor data update for %s has too many API requests;" + " Skipping the update" + ), DOMAIN, ) else: diff --git a/homeassistant/components/harmony/data.py b/homeassistant/components/harmony/data.py index fbbbbd38e3a..33c0e3c5b5f 100644 --- a/homeassistant/components/harmony/data.py +++ b/homeassistant/components/harmony/data.py @@ -126,7 +126,8 @@ class HarmonyData(HarmonySubscriberMixin): except (ValueError, AttributeError) as err: await self._client.close() raise ConfigEntryNotReady( - f"{self._name}: Error {err} while connected HUB at: {self._address}:8088" + f"{self._name}: Error {err} while connected HUB at:" + f" {self._address}:8088" ) from err if not connected: await self._client.close() @@ -219,8 +220,10 @@ class HarmonyData(HarmonySubscriberMixin): return _LOGGER.debug( - "Sending commands to device %s holding for %s seconds " - "with a delay of %s seconds", + ( + "Sending commands to device %s holding for %s seconds " + "with a delay of %s seconds" + ), device, hold_secs, delay_secs, diff --git a/homeassistant/components/hassio/handler.py b/homeassistant/components/hassio/handler.py index 4f300ef16db..2806c08ee54 100644 --- a/homeassistant/components/hassio/handler.py +++ b/homeassistant/components/hassio/handler.py @@ -414,7 +414,8 @@ class HassIO: if http_config.get(CONF_SERVER_HOST) is not None: options["watchdog"] = False _LOGGER.warning( - "Found incompatible HTTP option 'server_host'. Watchdog feature disabled" + "Found incompatible HTTP option 'server_host'. Watchdog feature" + " disabled" ) return await self.send_command("/homeassistant/options", payload=options) @@ -455,7 +456,9 @@ class HassIO: f"http://{self._ip}{command}", json=payload, headers={ - aiohttp.hdrs.AUTHORIZATION: f"Bearer {os.environ.get('SUPERVISOR_TOKEN', '')}" + aiohttp.hdrs.AUTHORIZATION: ( + f"Bearer {os.environ.get('SUPERVISOR_TOKEN', '')}" + ) }, timeout=aiohttp.ClientTimeout(total=timeout), ) diff --git a/homeassistant/components/heos/__init__.py b/homeassistant/components/heos/__init__.py index a7f56e91368..2df7c37a51c 100644 --- a/homeassistant/components/heos/__init__.py +++ b/homeassistant/components/heos/__init__.py @@ -108,8 +108,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: favorites = await controller.get_favorites() else: _LOGGER.warning( - "%s is not logged in to a HEOS account and will be unable to retrieve " - "HEOS favorites: Use the 'heos.sign_in' service to sign-in to a HEOS account", + ( + "%s is not logged in to a HEOS account and will be unable to" + " retrieve HEOS favorites: Use the 'heos.sign_in' service to" + " sign-in to a HEOS account" + ), host, ) inputs = await controller.get_input_sources() @@ -289,7 +292,8 @@ class GroupManager: leader_id = entity_id_to_player_id_map.get(leader_entity_id) if not leader_id: raise HomeAssistantError( - f"The group leader {leader_entity_id} could not be resolved to a HEOS player." + f"The group leader {leader_entity_id} could not be resolved to a HEOS" + " player." ) member_ids = [ entity_id_to_player_id_map[member] diff --git a/homeassistant/components/here_travel_time/coordinator.py b/homeassistant/components/here_travel_time/coordinator.py index a058f858077..56430d79a22 100644 --- a/homeassistant/components/here_travel_time/coordinator.py +++ b/homeassistant/components/here_travel_time/coordinator.py @@ -72,7 +72,10 @@ class HERERoutingDataUpdateCoordinator(DataUpdateCoordinator): ) _LOGGER.debug( - "Requesting route for origin: %s, destination: %s, route_mode: %s, mode: %s, arrival: %s, departure: %s", + ( + "Requesting route for origin: %s, destination: %s, route_mode: %s," + " mode: %s, arrival: %s, departure: %s" + ), origin, destination, route_mode, @@ -167,7 +170,10 @@ class HERETransitDataUpdateCoordinator(DataUpdateCoordinator): ) _LOGGER.debug( - "Requesting transit route for origin: %s, destination: %s, arrival: %s, departure: %s", + ( + "Requesting transit route for origin: %s, destination: %s, arrival: %s," + " departure: %s" + ), origin, destination, arrival, diff --git a/homeassistant/components/hive/climate.py b/homeassistant/components/hive/climate.py index 4dc8d921cd3..95304371e79 100644 --- a/homeassistant/components/hive/climate.py +++ b/homeassistant/components/hive/climate.py @@ -140,7 +140,8 @@ class HiveClimateEntity(HiveEntity, ClimateEntity): async def async_heating_boost(self, time_period, temperature): """Handle boost heating service call.""" _LOGGER.warning( - "Hive Service heating_boost will be removed in 2021.7.0, please update to heating_boost_on" + "Hive Service heating_boost will be removed in 2021.7.0, please update to" + " heating_boost_on" ) await self.async_heating_boost_on(time_period, temperature) diff --git a/homeassistant/components/homeassistant/triggers/numeric_state.py b/homeassistant/components/homeassistant/triggers/numeric_state.py index b8f548adb16..53d3fb1217f 100644 --- a/homeassistant/components/homeassistant/triggers/numeric_state.py +++ b/homeassistant/components/homeassistant/triggers/numeric_state.py @@ -41,7 +41,10 @@ def validate_above_below(value): if above > below: raise vol.Invalid( - f"A value can never be above {above} and below {below} at the same time. You probably want two different triggers.", + ( + f"A value can never be above {above} and below {below} at the same" + " time. You probably want two different triggers." + ), ) return value diff --git a/homeassistant/components/homeassistant/triggers/time.py b/homeassistant/components/homeassistant/triggers/time.py index a51eff004e5..f5473d66a5b 100644 --- a/homeassistant/components/homeassistant/triggers/time.py +++ b/homeassistant/components/homeassistant/triggers/time.py @@ -26,7 +26,9 @@ import homeassistant.util.dt as dt_util _TIME_TRIGGER_SCHEMA = vol.Any( cv.time, vol.All(str, cv.entity_domain(["input_datetime", "sensor"])), - msg="Expected HH:MM, HH:MM:SS or Entity ID with domain 'input_datetime' or 'sensor'", + msg=( + "Expected HH:MM, HH:MM:SS or Entity ID with domain 'input_datetime' or 'sensor'" + ), ) TRIGGER_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend( diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 1129e8c3f66..c9faa2e28e0 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -653,10 +653,12 @@ class HomeKit: if self._exclude_accessory_mode: return None _LOGGER.warning( - "The bridge %s has entity %s. For best performance, " - "and to prevent unexpected unavailability, create and " - "pair a separate HomeKit instance in accessory mode for " - "this entity", + ( + "The bridge %s has entity %s. For best performance, " + "and to prevent unexpected unavailability, create and " + "pair a separate HomeKit instance in accessory mode for " + "this entity" + ), self._name, state.entity_id, ) @@ -685,7 +687,10 @@ class HomeKit: assert self.bridge is not None if len(self.bridge.accessories) + 1 >= MAX_DEVICES: _LOGGER.warning( - "Cannot add %s as this would exceed the %d device limit. Consider using the filter option", + ( + "Cannot add %s as this would exceed the %d device limit. Consider" + " using the filter option" + ), name, MAX_DEVICES, ) @@ -920,7 +925,10 @@ class HomeKit: for device_id in self._devices: if not dev_reg.async_get(device_id): _LOGGER.warning( - "HomeKit %s cannot add device %s because it is missing from the device registry", + ( + "HomeKit %s cannot add device %s because it is missing from the" + " device registry" + ), self._name, device_id, ) @@ -941,7 +949,10 @@ class HomeKit: await async_validate_trigger_config(self.hass, trigger) except vol.Invalid as ex: _LOGGER.debug( - "%s: cannot add unsupported trigger %s because it requires additional inputs which are not supported by HomeKit: %s", + ( + "%s: cannot add unsupported trigger %s because it requires" + " additional inputs which are not supported by HomeKit: %s" + ), self._name, trigger, ex, diff --git a/homeassistant/components/homekit/accessories.py b/homeassistant/components/homekit/accessories.py index b43ab932cf6..e91a710e4fe 100644 --- a/homeassistant/components/homekit/accessories.py +++ b/homeassistant/components/homekit/accessories.py @@ -114,8 +114,10 @@ def get_accessory( # noqa: C901 """Take state and return an accessory object if supported.""" if not aid: _LOGGER.warning( - 'The entity "%s" is not supported, since it ' - "generates an invalid aid, please change it", + ( + 'The entity "%s" is not supported, since it ' + "generates an invalid aid, please change it" + ), state.entity_id, ) return None @@ -666,6 +668,7 @@ class HomeIIDManager(IIDManager): # type: ignore[misc] ) if iid in self.objs: raise RuntimeError( - f"Cannot assign IID {iid} to {obj} as it is already in use by: {self.objs[iid]}" + f"Cannot assign IID {iid} to {obj} as it is already in use by:" + f" {self.objs[iid]}" ) return iid diff --git a/homeassistant/components/homekit/config_flow.py b/homeassistant/components/homekit/config_flow.py index 5f142fdb0fe..e1d107065a4 100644 --- a/homeassistant/components/homekit/config_flow.py +++ b/homeassistant/components/homekit/config_flow.py @@ -667,7 +667,9 @@ def _async_get_matching_entities( """Fetch all entities or entities in the given domains.""" ent_reg = entity_registry.async_get(hass) return { - state.entity_id: f"{state.attributes.get(ATTR_FRIENDLY_NAME, state.entity_id)} ({state.entity_id})" + state.entity_id: ( + f"{state.attributes.get(ATTR_FRIENDLY_NAME, state.entity_id)} ({state.entity_id})" + ) for state in sorted( hass.states.async_all(domains and set(domains)), key=lambda item: item.entity_id, diff --git a/homeassistant/components/homekit/logbook.py b/homeassistant/components/homekit/logbook.py index 17cdac51799..e71695883a8 100644 --- a/homeassistant/components/homekit/logbook.py +++ b/homeassistant/components/homekit/logbook.py @@ -28,7 +28,10 @@ def async_describe_events( value = data.get(ATTR_VALUE) value_msg = f" to {value}" if value else "" - message = f"send command {data[ATTR_SERVICE]}{value_msg} for {data[ATTR_DISPLAY_NAME]}" + message = ( + f"send command {data[ATTR_SERVICE]}{value_msg} for" + f" {data[ATTR_DISPLAY_NAME]}" + ) return { LOGBOOK_ENTRY_NAME: "HomeKit", diff --git a/homeassistant/components/homekit/type_cameras.py b/homeassistant/components/homekit/type_cameras.py index e612c8248be..2bb6272aaeb 100644 --- a/homeassistant/components/homekit/type_cameras.py +++ b/homeassistant/components/homekit/type_cameras.py @@ -325,7 +325,8 @@ class Camera(HomeAccessory, PyhapCamera): ) except Exception: # pylint: disable=broad-except _LOGGER.exception( - "Failed to get stream source - this could be a transient error or your camera might not be compatible with HomeKit yet" + "Failed to get stream source - this could be a transient error or your" + " camera might not be compatible with HomeKit yet" ) return stream_source diff --git a/homeassistant/components/homekit/type_covers.py b/homeassistant/components/homekit/type_covers.py index 6db9b081bf1..4b21bfb77df 100644 --- a/homeassistant/components/homekit/type_covers.py +++ b/homeassistant/components/homekit/type_covers.py @@ -283,7 +283,10 @@ class OpeningDevice(OpeningDeviceBase, HomeAccessory): # since CHAR_CURRENT_POSITION/CHAR_TARGET_POSITION are required # by homekit, but really don't exist. _LOGGER.debug( - "%s does not support setting position, current position will be locked to closed", + ( + "%s does not support setting position, current position will be" + " locked to closed" + ), self.entity_id, ) target_args["properties"] = {PROP_MIN_VALUE: 0, PROP_MAX_VALUE: 0} diff --git a/homeassistant/components/homekit/type_humidifiers.py b/homeassistant/components/homekit/type_humidifiers.py index 0babb285bed..b585f38e981 100644 --- a/homeassistant/components/homekit/type_humidifiers.py +++ b/homeassistant/components/homekit/type_humidifiers.py @@ -174,7 +174,10 @@ class HumidifierDehumidifier(HomeAccessory): """Handle linked humidity sensor state change to update HomeKit value.""" if new_state is None: _LOGGER.error( - "%s: Unable to update from linked humidity sensor %s: the entity state is None", + ( + "%s: Unable to update from linked humidity sensor %s: the entity" + " state is None" + ), self.entity_id, self.linked_humidity_sensor, ) @@ -221,8 +224,10 @@ class HumidifierDehumidifier(HomeAccessory): DOMAIN, SERVICE_SET_HUMIDITY, {ATTR_ENTITY_ID: self.entity_id, ATTR_HUMIDITY: humidity}, - f"{self._target_humidity_char_name} to " - f"{char_values[self._target_humidity_char_name]}{PERCENTAGE}", + ( + f"{self._target_humidity_char_name} to " + f"{char_values[self._target_humidity_char_name]}{PERCENTAGE}" + ), ) @callback diff --git a/homeassistant/components/homekit/type_thermostats.py b/homeassistant/components/homekit/type_thermostats.py index f4bed70c09c..24a137e4957 100644 --- a/homeassistant/components/homekit/type_thermostats.py +++ b/homeassistant/components/homekit/type_thermostats.py @@ -419,7 +419,10 @@ class Thermostat(HomeAccessory): for hc_fallback in hc_fallback_order: if hc_fallback in self.hc_homekit_to_hass: _LOGGER.debug( - "Siri requested target mode: %s and the device does not support, falling back to %s", + ( + "Siri requested target mode: %s and the device does not" + " support, falling back to %s" + ), target_hc, hc_fallback, ) @@ -428,7 +431,8 @@ class Thermostat(HomeAccessory): params[ATTR_HVAC_MODE] = self.hc_homekit_to_hass[target_hc] events.append( - f"{CHAR_TARGET_HEATING_COOLING} to {char_values[CHAR_TARGET_HEATING_COOLING]}" + f"{CHAR_TARGET_HEATING_COOLING} to" + f" {char_values[CHAR_TARGET_HEATING_COOLING]}" ) # Many integrations do not actually implement `hvac_mode` for the # `SERVICE_SET_TEMPERATURE_THERMOSTAT` service so we made a call to @@ -447,7 +451,8 @@ class Thermostat(HomeAccessory): service = SERVICE_SET_TEMPERATURE_THERMOSTAT temperature = self._temperature_to_states(hc_target_temp) events.append( - f"{CHAR_TARGET_TEMPERATURE} to {char_values[CHAR_TARGET_TEMPERATURE]}°C" + f"{CHAR_TARGET_TEMPERATURE} to" + f" {char_values[CHAR_TARGET_TEMPERATURE]}°C" ) params[ATTR_TEMPERATURE] = temperature elif features & ClimateEntityFeature.TARGET_TEMPERATURE_RANGE: @@ -478,7 +483,8 @@ class Thermostat(HomeAccessory): min_temp, max_temp = self.get_temperature_range() if CHAR_COOLING_THRESHOLD_TEMPERATURE in char_values: events.append( - f"{CHAR_COOLING_THRESHOLD_TEMPERATURE} to {char_values[CHAR_COOLING_THRESHOLD_TEMPERATURE]}°C" + f"{CHAR_COOLING_THRESHOLD_TEMPERATURE} to" + f" {char_values[CHAR_COOLING_THRESHOLD_TEMPERATURE]}°C" ) high = char_values[CHAR_COOLING_THRESHOLD_TEMPERATURE] # If the device doesn't support TARGET_TEMPATURE @@ -487,7 +493,8 @@ class Thermostat(HomeAccessory): low = high - HEAT_COOL_DEADBAND if CHAR_HEATING_THRESHOLD_TEMPERATURE in char_values: events.append( - f"{CHAR_HEATING_THRESHOLD_TEMPERATURE} to {char_values[CHAR_HEATING_THRESHOLD_TEMPERATURE]}°C" + f"{CHAR_HEATING_THRESHOLD_TEMPERATURE} to" + f" {char_values[CHAR_HEATING_THRESHOLD_TEMPERATURE]}°C" ) low = char_values[CHAR_HEATING_THRESHOLD_TEMPERATURE] # If the device doesn't support TARGET_TEMPATURE @@ -598,7 +605,10 @@ class Thermostat(HomeAccessory): self.char_target_heat_cool.set_value(homekit_hvac_mode) else: _LOGGER.error( - "Cannot map hvac target mode: %s to homekit as only %s modes are supported", + ( + "Cannot map hvac target mode: %s to homekit as only %s modes" + " are supported" + ), hvac_mode, self.hc_homekit_to_hass, ) diff --git a/homeassistant/components/homekit/util.py b/homeassistant/components/homekit/util.py index 2663f7b004d..53fd9fbfed7 100644 --- a/homeassistant/components/homekit/util.py +++ b/homeassistant/components/homekit/util.py @@ -349,7 +349,7 @@ def async_show_setup_message( message = ( f"To set up {bridge_name} in the Home App, " - f"scan the QR code or enter the following code:\n" + "scan the QR code or enter the following code:\n" f"### {pin}\n" f"![image](/api/homekit/pairingqr?{entry_id}-{pairing_secret})" ) diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index aa56bbbda78..ecd8113a2bb 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -97,9 +97,11 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: await controller.remove_pairing(hkid) except aiohomekit.AccessoryDisconnectedError: _LOGGER.warning( - "Accessory %s was removed from HomeAssistant but was not reachable " - "to properly unpair. It may need resetting before you can use it with " - "HomeKit again", + ( + "Accessory %s was removed from HomeAssistant but was not reachable " + "to properly unpair. It may need resetting before you can use it with " + "HomeKit again" + ), entry.title, ) diff --git a/homeassistant/components/homekit_controller/climate.py b/homeassistant/components/homekit_controller/climate.py index 524847d46fe..df43d8929e9 100644 --- a/homeassistant/components/homekit_controller/climate.py +++ b/homeassistant/components/homekit_controller/climate.py @@ -187,8 +187,11 @@ class HomeKitHeaterCoolerEntity(HomeKitBaseClimateEntity): else: hvac_mode = TARGET_HEATER_COOLER_STATE_HOMEKIT_TO_HASS.get(state) _LOGGER.warning( - "HomeKit device %s: Setting temperature in %s mode is not supported yet;" - " Consider raising a ticket if you have this device and want to help us implement this feature", + ( + "HomeKit device %s: Setting temperature in %s mode is not supported" + " yet; Consider raising a ticket if you have this device and want" + " to help us implement this feature" + ), self.entity_id, hvac_mode, ) @@ -202,8 +205,11 @@ class HomeKitHeaterCoolerEntity(HomeKitBaseClimateEntity): return if hvac_mode not in {HVACMode.HEAT, HVACMode.COOL}: _LOGGER.warning( - "HomeKit device %s: Setting temperature in %s mode is not supported yet;" - " Consider raising a ticket if you have this device and want to help us implement this feature", + ( + "HomeKit device %s: Setting temperature in %s mode is not supported" + " yet; Consider raising a ticket if you have this device and want" + " to help us implement this feature" + ), self.entity_id, hvac_mode, ) diff --git a/homeassistant/components/homekit_controller/config_flow.py b/homeassistant/components/homekit_controller/config_flow.py index 1cfedb05847..71884f25ef4 100644 --- a/homeassistant/components/homekit_controller/config_flow.py +++ b/homeassistant/components/homekit_controller/config_flow.py @@ -167,7 +167,9 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): { vol.Required("device"): vol.In( { - key: f"{key} ({formatted_category(discovery.description.category)})" + key: ( + f"{key} ({formatted_category(discovery.description.category)})" + ) for key, discovery in self.devices.items() } ) @@ -232,7 +234,10 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): # This can happen if the TXT record is received after the PTR record # we will wait for the next update in this case _LOGGER.debug( - "HomeKit device %s: id not exposed; TXT record may have not yet been received", + ( + "HomeKit device %s: id not exposed; TXT record may have not yet" + " been received" + ), properties, ) return self.async_abort(reason="invalid_properties") @@ -291,7 +296,10 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await pairing.list_accessories_and_characteristics() except AuthenticationError: _LOGGER.debug( - "%s (%s - %s) is unpaired. Removing invalid pairing for this device", + ( + "%s (%s - %s) is unpaired. Removing invalid pairing for this" + " device" + ), name, model, hkid, @@ -299,9 +307,11 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await self.hass.config_entries.async_remove(existing.entry_id) else: _LOGGER.debug( - "%s (%s - %s) claims to be unpaired but isn't. " - "It's implementation of HomeKit is defective " - "or a zeroconf relay is broadcasting stale data", + ( + "%s (%s - %s) claims to be unpaired but isn't. " + "It's implementation of HomeKit is defective " + "or a zeroconf relay is broadcasting stale data" + ), name, model, hkid, diff --git a/homeassistant/components/homekit_controller/connection.py b/homeassistant/components/homekit_controller/connection.py index d230fe64517..f0de7307d7c 100644 --- a/homeassistant/components/homekit_controller/connection.py +++ b/homeassistant/components/homekit_controller/connection.py @@ -194,8 +194,10 @@ class HKDevice: await self.pairing.async_populate_accessories_state(force_update=True) except STARTUP_EXCEPTIONS as ex: _LOGGER.debug( - "Failed to populate BLE accessory state for %s, accessory may be sleeping" - " and will be retried the next time it advertises: %s", + ( + "Failed to populate BLE accessory state for %s, accessory may be" + " sleeping and will be retried the next time it advertises: %s" + ), self.config_entry.title, ex, ) @@ -360,7 +362,10 @@ class HKDevice: if self.config_entry.entry_id not in device.config_entries: _LOGGER.info( - "Found candidate device for %s:aid:%s, but owned by a different config entry, skipping", + ( + "Found candidate device for %s:aid:%s, but owned by a different" + " config entry, skipping" + ), self.unique_id, accessory.aid, ) @@ -407,7 +412,10 @@ class HKDevice: platform, DOMAIN, new_unique_id ): _LOGGER.debug( - "Unique ID %s is already in use by %s (system may have been downgraded)", + ( + "Unique ID %s is already in use by %s (system may have been" + " downgraded)" + ), new_unique_id, new_entity_id, ) @@ -429,7 +437,10 @@ class HKDevice: does not require them to be stable. """ _LOGGER.debug( - "Removing legacy serial numbers from device registry entries for pairing %s", + ( + "Removing legacy serial numbers from device registry entries for" + " pairing %s" + ), self.unique_id, ) @@ -491,14 +502,20 @@ class HKDevice: for accessory in self.entity_map.accessories: if not valid_serial_number(accessory.serial_number): _LOGGER.debug( - "Serial number %r is not valid, it cannot be used as a unique identifier", + ( + "Serial number %r is not valid, it cannot be used as a unique" + " identifier" + ), accessory.serial_number, ) unreliable_serial_numbers = True elif accessory.serial_number in devices: _LOGGER.debug( - "Serial number %r is duplicated within this pairing, it cannot be used as a unique identifier", + ( + "Serial number %r is duplicated within this pairing, it cannot" + " be used as a unique identifier" + ), accessory.serial_number, ) unreliable_serial_numbers = True @@ -506,7 +523,10 @@ class HKDevice: elif accessory.serial_number == accessory.hardware_revision: # This is a known bug with some devices (e.g. RYSE SmartShades) _LOGGER.debug( - "Serial number %r is actually the hardware revision, it cannot be used as a unique identifier", + ( + "Serial number %r is actually the hardware revision, it cannot" + " be used as a unique identifier" + ), accessory.serial_number, ) unreliable_serial_numbers = True @@ -670,7 +690,10 @@ class HKDevice: if self._polling_lock.locked(): if not self._polling_lock_warned: _LOGGER.warning( - "HomeKit controller update skipped as previous poll still in flight: %s", + ( + "HomeKit controller update skipped as previous poll still in" + " flight: %s" + ), self.unique_id, ) self._polling_lock_warned = True @@ -678,7 +701,10 @@ class HKDevice: if self._polling_lock_warned: _LOGGER.info( - "HomeKit controller no longer detecting back pressure - not skipping poll: %s", + ( + "HomeKit controller no longer detecting back pressure - not" + " skipping poll: %s" + ), self.unique_id, ) self._polling_lock_warned = False diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index 927532b0d02..8b5d7b6bff1 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -308,7 +308,10 @@ def setup_platform( if (entity_desc := SENSOR_DESCRIPTIONS.get(state)) is None: name = conf.get(ATTR_NAME) _LOGGER.warning( - "Sensor (%s) entity description is missing. Sensor state (%s) needs to be maintained", + ( + "Sensor (%s) entity description is missing. Sensor state (%s) needs" + " to be maintained" + ), name, state, ) diff --git a/homeassistant/components/homematicip_cloud/alarm_control_panel.py b/homeassistant/components/homematicip_cloud/alarm_control_panel.py index 85d241051c1..1b29fcb1068 100644 --- a/homeassistant/components/homematicip_cloud/alarm_control_panel.py +++ b/homeassistant/components/homematicip_cloud/alarm_control_panel.py @@ -109,7 +109,10 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity): self.async_write_ha_state() else: _LOGGER.debug( - "Device Changed Event for %s (Alarm Control Panel) not fired. Entity is disabled", + ( + "Device Changed Event for %s (Alarm Control Panel) not fired." + " Entity is disabled" + ), self.name, ) diff --git a/homeassistant/components/homematicip_cloud/hap.py b/homeassistant/components/homematicip_cloud/hap.py index 3960dc1f9b9..7ba30372451 100644 --- a/homeassistant/components/homematicip_cloud/hap.py +++ b/homeassistant/components/homematicip_cloud/hap.py @@ -190,8 +190,10 @@ class HomematicipHAP: await hmip_events except HmipConnectionError: _LOGGER.error( - "Error connecting to HomematicIP with HAP %s. " - "Retrying in %d seconds", + ( + "Error connecting to HomematicIP with HAP %s. " + "Retrying in %d seconds" + ), self.config_entry.unique_id, retry_delay, ) diff --git a/homeassistant/components/homewizard/config_flow.py b/homeassistant/components/homewizard/config_flow.py index 02d0976157e..bdd84c0d07e 100644 --- a/homeassistant/components/homewizard/config_flow.py +++ b/homeassistant/components/homewizard/config_flow.py @@ -44,8 +44,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self.hass, title="HomeWizard Energy", message=( - "The custom integration of HomeWizard Energy has been migrated to core. " - "You can safely remove the custom integration from the custom_integrations folder." + "The custom integration of HomeWizard Energy has been migrated to core." + " You can safely remove the custom integration from the" + " custom_integrations folder." ), notification_id=f"homewizard_energy_to_{DOMAIN}", ) diff --git a/homeassistant/components/honeywell/__init__.py b/homeassistant/components/honeywell/__init__.py index 143b485a80f..99f682fd7a4 100644 --- a/homeassistant/components/honeywell/__init__.py +++ b/homeassistant/components/honeywell/__init__.py @@ -162,7 +162,8 @@ class HoneywellData: self.devices[updated_device.deviceid] = updated_device else: _LOGGER.info( - "New device with ID %s detected, reload the honeywell integration if you want to access it in Home Assistant" + "New device with ID %s detected, reload the honeywell integration" + " if you want to access it in Home Assistant" ) await self._hass.config_entries.async_reload(self._config.entry_id) diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http/__init__.py index 9e022ab0444..6624d941114 100644 --- a/homeassistant/components/http/__init__.py +++ b/homeassistant/components/http/__init__.py @@ -361,7 +361,8 @@ class HomeAssistantHTTP: except OSError as error: if not self.hass.config.safe_mode: raise HomeAssistantError( - f"Could not use SSL certificate from {self.ssl_certificate}: {error}" + f"Could not use SSL certificate from {self.ssl_certificate}:" + f" {error}" ) from error _LOGGER.error( "Could not read SSL certificate from %s: %s", @@ -378,14 +379,17 @@ class HomeAssistantHTTP: context = None else: _LOGGER.critical( - "Home Assistant is running in safe mode with an emergency self signed ssl certificate because the configured SSL certificate was not usable" + "Home Assistant is running in safe mode with an emergency self" + " signed ssl certificate because the configured SSL certificate was" + " not usable" ) return context if self.ssl_peer_certificate: if context is None: raise HomeAssistantError( - "Failed to create ssl context, no fallback available because a peer certificate is required." + "Failed to create ssl context, no fallback available because a peer" + " certificate is required." ) context.verify_mode = ssl.CERT_REQUIRED diff --git a/homeassistant/components/http/ban.py b/homeassistant/components/http/ban.py index 7be8634212a..9f300aa9db9 100644 --- a/homeassistant/components/http/ban.py +++ b/homeassistant/components/http/ban.py @@ -116,7 +116,10 @@ async def process_wrong_login(request: Request) -> None: gethostbyaddr, request.remote ) - base_msg = f"Login attempt or request with invalid authentication from {remote_host} ({remote_addr})." + base_msg = ( + "Login attempt or request with invalid authentication from" + f" {remote_host} ({remote_addr})." + ) # The user-agent is unsanitized input so we only include it in the log user_agent = request.headers.get("user-agent") diff --git a/homeassistant/components/http/forwarded.py b/homeassistant/components/http/forwarded.py index c0aaa31fab0..5d122436af2 100644 --- a/homeassistant/components/http/forwarded.py +++ b/homeassistant/components/http/forwarded.py @@ -112,8 +112,10 @@ def async_setup_forwarded( # We have X-Forwarded-For, but config does not agree if not use_x_forwarded_for: _LOGGER.error( - "A request from a reverse proxy was received from %s, but your " - "HTTP integration is not set-up for reverse proxies", + ( + "A request from a reverse proxy was received from %s, but your " + "HTTP integration is not set-up for reverse proxies" + ), connected_ip, ) raise HTTPBadRequest @@ -186,7 +188,10 @@ def async_setup_forwarded( # of elements as X-Forwarded-For if len(forwarded_proto) not in (1, len(forwarded_for)): _LOGGER.error( - "Incorrect number of elements in X-Forward-Proto. Expected 1 or %d, got %d: %s", + ( + "Incorrect number of elements in X-Forward-Proto. Expected 1 or" + " %d, got %d: %s" + ), len(forwarded_for), len(forwarded_proto), forwarded_proto_headers[0], diff --git a/homeassistant/components/hue/__init__.py b/homeassistant/components/hue/__init__.py index 9723d506404..21e9bfab6be 100644 --- a/homeassistant/components/hue/__init__.py +++ b/homeassistant/components/hue/__init__.py @@ -78,9 +78,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ): persistent_notification.async_create( hass, - "Your Hue hub has a known security vulnerability ([CVE-2020-6007] " - "(https://cve.circl.lu/cve/CVE-2020-6007)). " - "Go to the Hue app and check for software updates.", + ( + "Your Hue hub has a known security vulnerability ([CVE-2020-6007] " + "(https://cve.circl.lu/cve/CVE-2020-6007)). " + "Go to the Hue app and check for software updates." + ), "Signify Hue", "hue_hub_firmware", ) diff --git a/homeassistant/components/hue/migration.py b/homeassistant/components/hue/migration.py index 1d56d493785..221888b0854 100644 --- a/homeassistant/components/hue/migration.py +++ b/homeassistant/components/hue/migration.py @@ -115,7 +115,10 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N if hass_dev_id is None: # can be safely ignored, this device does not exist in current config LOGGER.debug( - "Ignoring device %s (%s) as it does not (yet) exist in the device registry", + ( + "Ignoring device %s (%s) as it does not (yet) exist in the" + " device registry" + ), hue_dev.metadata.name, hue_dev.id, ) @@ -149,7 +152,10 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N if new_unique_id is None: # this may happen if we're looking at orphaned or unsupported entity LOGGER.warning( - "Skip migration of %s because it no longer exists on the bridge", + ( + "Skip migration of %s because it no longer exists on the" + " bridge" + ), ent.entity_id, ) continue diff --git a/homeassistant/components/hue/services.py b/homeassistant/components/hue/services.py index 652ec52ebed..5b0b252e8d4 100644 --- a/homeassistant/components/hue/services.py +++ b/homeassistant/components/hue/services.py @@ -133,8 +133,10 @@ async def hue_activate_scene_v2( ) -> bool: """Service for V2 bridge to call scene by name.""" LOGGER.warning( - "Use of service_call '%s' is deprecated and will be removed " - "in a future release. Please use scene entities instead", + ( + "Use of service_call '%s' is deprecated and will be removed " + "in a future release. Please use scene entities instead" + ), SERVICE_HUE_ACTIVATE_SCENE, ) api: HueBridgeV2 = bridge.api diff --git a/homeassistant/components/hue/v2/entity.py b/homeassistant/components/hue/v2/entity.py index fec14075b42..7335bf71058 100644 --- a/homeassistant/components/hue/v2/entity.py +++ b/homeassistant/components/hue/v2/entity.py @@ -196,11 +196,13 @@ class HueBaseEntity(Entity): # the device state changed from on->off or off->on # while it was reported as not connected! self.logger.warning( - "Device %s changed state while reported as disconnected. " - "This might be an indicator that routing is not working for this device " - "or the device is having connectivity issues. " - "You can disable availability reporting for this device in the Hue options. " - "Device details: %s - %s (%s) fw: %s", + ( + "Device %s changed state while reported as disconnected. This" + " might be an indicator that routing is not working for this" + " device or the device is having connectivity issues. You can" + " disable availability reporting for this device in the Hue" + " options. Device details: %s - %s (%s) fw: %s" + ), self.name, self.device.product_data.manufacturer_name, self.device.product_data.product_name, diff --git a/homeassistant/components/humidifier/device_trigger.py b/homeassistant/components/humidifier/device_trigger.py index b9abb231dfd..ed1620c51a2 100644 --- a/homeassistant/components/humidifier/device_trigger.py +++ b/homeassistant/components/humidifier/device_trigger.py @@ -87,7 +87,9 @@ async def async_attach_trigger( numeric_state_config = { numeric_state_trigger.CONF_PLATFORM: "numeric_state", numeric_state_trigger.CONF_ENTITY_ID: config[CONF_ENTITY_ID], - numeric_state_trigger.CONF_VALUE_TEMPLATE: "{{ state.attributes.humidity }}", + numeric_state_trigger.CONF_VALUE_TEMPLATE: ( + "{{ state.attributes.humidity }}" + ), } if CONF_ABOVE in config: diff --git a/homeassistant/components/hunterdouglas_powerview/entity.py b/homeassistant/components/hunterdouglas_powerview/entity.py index a2bbf39fb96..655eb572c31 100644 --- a/homeassistant/components/hunterdouglas_powerview/entity.py +++ b/homeassistant/components/hunterdouglas_powerview/entity.py @@ -95,7 +95,9 @@ class ShadeEntity(HDEntity): manufacturer=MANUFACTURER, model=str(self._shade.raw_data[ATTR_TYPE]), via_device=(DOMAIN, self._device_info.serial_number), - configuration_url=f"http://{self._device_info.hub_address}/api/shades/{self._shade.id}", + configuration_url=( + f"http://{self._device_info.hub_address}/api/shades/{self._shade.id}" + ), ) for shade in self._shade.shade_types: diff --git a/homeassistant/components/hvv_departures/config_flow.py b/homeassistant/components/hvv_departures/config_flow.py index d96ab359dda..5f07593eeb5 100644 --- a/homeassistant/components/hvv_departures/config_flow.py +++ b/homeassistant/components/hvv_departures/config_flow.py @@ -198,7 +198,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow): { vol.Optional(CONF_FILTER, default=old_filter): cv.multi_select( { - key: f"{departure_filter['serviceName']}, {departure_filter['label']}" + key: ( + f"{departure_filter['serviceName']}," + f" {departure_filter['label']}" + ) for key, departure_filter in self.departure_filters.items() } ), diff --git a/homeassistant/components/hyperion/__init__.py b/homeassistant/components/hyperion/__init__.py index 8179b9b5188..c3cd473c3f4 100644 --- a/homeassistant/components/hyperion/__init__.py +++ b/homeassistant/components/hyperion/__init__.py @@ -153,9 +153,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: with suppress(ValueError): if AwesomeVersion(version) < AwesomeVersion(HYPERION_VERSION_WARN_CUTOFF): _LOGGER.warning( - "Using a Hyperion server version < %s is not recommended -- " - "some features may be unavailable or may not function correctly. " - "Please consider upgrading: %s", + ( + "Using a Hyperion server version < %s is not recommended --" + " some features may be unavailable or may not function" + " correctly. Please consider upgrading: %s" + ), HYPERION_VERSION_WARN_CUTOFF, HYPERION_RELEASES_URL, ) diff --git a/homeassistant/components/hyperion/const.py b/homeassistant/components/hyperion/const.py index 271618fb962..e7e4e7f70a4 100644 --- a/homeassistant/components/hyperion/const.py +++ b/homeassistant/components/hyperion/const.py @@ -26,9 +26,9 @@ NAME_SUFFIX_HYPERION_PRIORITY_LIGHT = "Priority" NAME_SUFFIX_HYPERION_COMPONENT_SWITCH = "Component" NAME_SUFFIX_HYPERION_CAMERA = "" -SIGNAL_INSTANCE_ADD = f"{DOMAIN}_instance_add_signal." "{}" -SIGNAL_INSTANCE_REMOVE = f"{DOMAIN}_instance_remove_signal." "{}" -SIGNAL_ENTITY_REMOVE = f"{DOMAIN}_entity_remove_signal." "{}" +SIGNAL_INSTANCE_ADD = f"{DOMAIN}_instance_add_signal.{{}}" +SIGNAL_INSTANCE_REMOVE = f"{DOMAIN}_instance_remove_signal.{{}}" +SIGNAL_ENTITY_REMOVE = f"{DOMAIN}_entity_remove_signal.{{}}" TYPE_HYPERION_CAMERA = "hyperion_camera" TYPE_HYPERION_LIGHT = "hyperion_light" diff --git a/homeassistant/components/hyperion/light.py b/homeassistant/components/hyperion/light.py index 49177ac94c6..ba1dbfbafc2 100644 --- a/homeassistant/components/hyperion/light.py +++ b/homeassistant/components/hyperion/light.py @@ -292,8 +292,10 @@ class HyperionBaseLight(LightEntity): component = const.KEY_COMPONENTID_FROM_NAME[effect] else: _LOGGER.warning( - "Use of Hyperion effect '%s' is deprecated and will be removed " - "in a future release. Please use '%s' instead", + ( + "Use of Hyperion effect '%s' is deprecated and will be removed " + "in a future release. Please use '%s' instead" + ), effect, const.KEY_COMPONENTID_TO_NAME[effect], ) @@ -433,8 +435,10 @@ class HyperionBaseLight(LightEntity): self._update_effect_list() _LOGGER.debug( - "Hyperion full state update: On=%s,Brightness=%i,Effect=%s " - "(%i effects total),Color=%s", + ( + "Hyperion full state update: On=%s,Brightness=%i,Effect=%s " + "(%i effects total),Color=%s" + ), self.is_on, self._brightness, self._effect, diff --git a/homeassistant/components/influxdb/__init__.py b/homeassistant/components/influxdb/__init__.py index 4fd6eb58fdd..d342a9d3aca 100644 --- a/homeassistant/components/influxdb/__init__.py +++ b/homeassistant/components/influxdb/__init__.py @@ -135,18 +135,21 @@ def validate_version_specific_config(conf: dict) -> dict: if conf[CONF_API_VERSION] == API_VERSION_2: if CONF_TOKEN not in conf: raise vol.Invalid( - f"{CONF_TOKEN} and {CONF_BUCKET} are required when {CONF_API_VERSION} is {API_VERSION_2}" + f"{CONF_TOKEN} and {CONF_BUCKET} are required when" + f" {CONF_API_VERSION} is {API_VERSION_2}" ) if CONF_USERNAME in conf: raise vol.Invalid( - f"{CONF_USERNAME} and {CONF_PASSWORD} are only allowed when {CONF_API_VERSION} is {DEFAULT_API_VERSION}" + f"{CONF_USERNAME} and {CONF_PASSWORD} are only allowed when" + f" {CONF_API_VERSION} is {DEFAULT_API_VERSION}" ) else: if CONF_TOKEN in conf: raise vol.Invalid( - f"{CONF_TOKEN} and {CONF_BUCKET} are only allowed when {CONF_API_VERSION} is {API_VERSION_2}" + f"{CONF_TOKEN} and {CONF_BUCKET} are only allowed when" + f" {CONF_API_VERSION} is {API_VERSION_2}" ) return conf diff --git a/homeassistant/components/influxdb/sensor.py b/homeassistant/components/influxdb/sensor.py index dfb5ee57b6a..24625a66099 100644 --- a/homeassistant/components/influxdb/sensor.py +++ b/homeassistant/components/influxdb/sensor.py @@ -83,7 +83,8 @@ def validate_query_format_for_version(conf: dict) -> dict: if conf[CONF_API_VERSION] == API_VERSION_2: if CONF_QUERIES_FLUX not in conf: raise vol.Invalid( - f"{CONF_QUERIES_FLUX} is required when {CONF_API_VERSION} is {API_VERSION_2}" + f"{CONF_QUERIES_FLUX} is required when {CONF_API_VERSION} is" + f" {API_VERSION_2}" ) for query in conf[CONF_QUERIES_FLUX]: @@ -95,7 +96,8 @@ def validate_query_format_for_version(conf: dict) -> dict: else: if CONF_QUERIES not in conf: raise vol.Invalid( - f"{CONF_QUERIES} is required when {CONF_API_VERSION} is {DEFAULT_API_VERSION}" + f"{CONF_QUERIES} is required when {CONF_API_VERSION} is" + f" {DEFAULT_API_VERSION}" ) for query in conf[CONF_QUERIES]: @@ -270,7 +272,10 @@ class InfluxFluxSensorData: self.value = None self.full_query = None - self.query_prefix = f'from(bucket:"{bucket}") |> range(start: {range_start}, stop: {range_stop}) |>' + self.query_prefix = ( + f'from(bucket:"{bucket}") |> range(start: {range_start}, stop:' + f" {range_stop}) |>" + ) if imports is not None: for i in imports: self.query_prefix = f'import "{i}" {self.query_prefix}' @@ -334,7 +339,10 @@ class InfluxQLSensorData: _LOGGER.error(RENDERING_WHERE_ERROR_MESSAGE, ex) return - self.query = f"select {self.group}({self.field}) as {INFLUX_CONF_VALUE} from {self.measurement} where {where_clause}" + self.query = ( + f"select {self.group}({self.field}) as {INFLUX_CONF_VALUE} from" + f" {self.measurement} where {where_clause}" + ) _LOGGER.debug(RUNNING_QUERY_MESSAGE, self.query)