String formatting and max line length - Part 5 (#84501)

Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
pull/84509/head
Franck Nijhof 2022-12-23 16:43:17 +01:00 committed by GitHub
parent 139dd22ce6
commit f39f3b612a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 296 additions and 139 deletions

View File

@ -108,8 +108,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
version = entry.version = 2
config_entries.async_update_entry(entry, data=data)
_LOGGER.info(
"PlayStation 4 Config Updated: \
Region changed to: %s",
"PlayStation 4 Config Updated: Region changed to: %s",
country,
)
@ -140,8 +139,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
)
entry.version = 3
_LOGGER.info(
"PlayStation 4 identifier for entity: %s \
has changed",
"PlayStation 4 identifier for entity: %s has changed",
entity_id,
)
config_entries.async_update_entry(entry)

View File

@ -81,9 +81,11 @@ class RecorderPool(SingletonThreadPool, NullPool): # type: ignore[misc]
def _do_get_db_connection_protected(self) -> Any:
report(
"accesses the database without the database executor; "
f"{ADVISE_MSG} "
"for faster database operations",
(
"accesses the database without the database executor; "
f"{ADVISE_MSG} "
"for faster database operations"
),
exclude_integrations={"recorder"},
error_if_core=False,
)

View File

@ -2434,8 +2434,8 @@ def correct_db_schema(
# Using LOCK=EXCLUSIVE to prevent the database from corrupting
# https://github.com/home-assistant/core/issues/56104
text(
"ALTER TABLE statistics_meta CONVERT TO "
"CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, LOCK=EXCLUSIVE"
"ALTER TABLE statistics_meta CONVERT TO CHARACTER SET utf8mb4"
" COLLATE utf8mb4_unicode_ci, LOCK=EXCLUSIVE"
)
)

View File

@ -225,9 +225,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
keepalive_idle_timer = config[DOMAIN][CONF_KEEPALIVE_IDLE]
if keepalive_idle_timer < 0:
_LOGGER.error(
"A bogus TCP Keepalive IDLE timer was provided (%d secs), "
"it will be disabled. "
"Recommended values: 60-3600 (seconds)",
(
"A bogus TCP Keepalive IDLE timer was provided (%d secs), "
"it will be disabled. "
"Recommended values: 60-3600 (seconds)"
),
keepalive_idle_timer,
)
keepalive_idle_timer = None

View File

@ -282,8 +282,10 @@ async def _async_create_bridge_with_updated_data(
if model_requires_encryption(model) and method != METHOD_ENCRYPTED_WEBSOCKET:
LOGGER.info(
"Detected model %s for %s. Some televisions from H and J series use "
"an encrypted protocol but you are using %s which may not be supported",
(
"Detected model %s for %s. Some televisions from H and J series use "
"an encrypted protocol but you are using %s which may not be supported"
),
model,
host,
method,

View File

@ -503,9 +503,11 @@ class SamsungTVWSBridge(
return RESULT_SUCCESS
except ConnectionClosedError as err:
LOGGER.info(
"Working but unsupported config: %s, error: '%s'; this may "
"be an indication that access to the TV has been denied. Please "
"check the Device Connection Manager on your TV",
(
"Working but unsupported config: %s, error: '%s'; this may be"
" an indication that access to the TV has been denied. Please"
" check the Device Connection Manager on your TV"
),
config,
err,
)
@ -590,8 +592,10 @@ class SamsungTVWSBridge(
self._remote = None
except ConnectionFailure as err:
LOGGER.warning(
"Unexpected ConnectionFailure trying to get remote for %s, "
"please report this issue: %s",
(
"Unexpected ConnectionFailure trying to get remote for %s, "
"please report this issue: %s"
),
self.host,
repr(err),
)
@ -633,8 +637,10 @@ class SamsungTVWSBridge(
message := data.get("message")
) == "unrecognized method value : ms.remote.control":
LOGGER.error(
"Your TV seems to be unsupported by SamsungTVWSBridge"
" and needs a PIN: '%s'. Updating config entry",
(
"Your TV seems to be unsupported by SamsungTVWSBridge"
" and needs a PIN: '%s'. Updating config entry"
),
message,
)
self._notify_update_config_entry(
@ -780,7 +786,10 @@ class SamsungTVEncryptedBridge(
else:
if self._model and not self._power_off_warning_logged:
LOGGER.warning(
"Unknown power_off command for %s (%s): sending KEY_POWEROFF and KEY_POWER",
(
"Unknown power_off command for %s (%s): sending KEY_POWEROFF"
" and KEY_POWER"
),
self._model,
self.host,
)

View File

@ -69,7 +69,8 @@ def valid_schedule(schedule: list[dict[str, str]]) -> list[dict[str, str]]:
for time_range in schedule:
if time_range[CONF_FROM] >= time_range[CONF_TO]:
raise vol.Invalid(
f"Invalid time range, from {time_range[CONF_FROM]} is after {time_range[CONF_TO]}"
f"Invalid time range, from {time_range[CONF_FROM]} is after"
f" {time_range[CONF_TO]}"
)
# Check if the from time of the event is after the to time of the previous event

View File

@ -142,7 +142,8 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
await self._async_refresh()
else:
raise HomeAssistantError(
f"Failed to set_temperature {temperature} on body {self.body['body_type']['value']}"
f"Failed to set_temperature {temperature} on body"
f" {self.body['body_type']['value']}"
)
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
@ -156,7 +157,8 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
await self._async_refresh()
else:
raise HomeAssistantError(
f"Failed to set_hvac_mode {mode} on body {self.body['body_type']['value']}"
f"Failed to set_hvac_mode {mode} on body"
f" {self.body['body_type']['value']}"
)
async def async_set_preset_mode(self, preset_mode: str) -> None:
@ -170,7 +172,8 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
await self._async_refresh()
else:
raise HomeAssistantError(
f"Failed to set_preset_mode {mode} on body {self.body['body_type']['value']}"
f"Failed to set_preset_mode {mode} on body"
f" {self.body['body_type']['value']}"
)
async def async_added_to_hass(self) -> None:

View File

@ -129,7 +129,9 @@ class ScreenlogicConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
vol.Required(GATEWAY_SELECT_KEY): vol.In(
{
**unconfigured_gateways,
GATEWAY_MANUAL_ENTRY: "Manually configure a ScreenLogic gateway",
GATEWAY_MANUAL_ENTRY: (
"Manually configure a ScreenLogic gateway"
),
}
)
}

View File

@ -48,7 +48,8 @@ def async_load_screenlogic_services(hass: HomeAssistant):
)
):
raise HomeAssistantError(
f"Failed to call service '{SERVICE_SET_COLOR_MODE}'. Config entry for target not found"
f"Failed to call service '{SERVICE_SET_COLOR_MODE}'. Config entry for"
" target not found"
)
color_num = SUPPORTED_COLOR_MODES[service_call.data[ATTR_COLOR_MODE]]
for entry_id in screenlogic_entry_ids:

View File

@ -104,7 +104,8 @@ class SensiboSelect(SensiboDeviceBaseEntity, SelectEntity):
"""Set state to the selected option."""
if self.entity_description.key not in self.device_data.active_features:
raise HomeAssistantError(
f"Current mode {self.device_data.hvac_mode} doesn't support setting {self.entity_description.name}"
f"Current mode {self.device_data.hvac_mode} doesn't support setting"
f" {self.entity_description.name}"
)
await self.async_send_api_call(

View File

@ -184,7 +184,8 @@ class SensiboDeviceSwitch(SensiboDeviceBaseEntity, SwitchEntity):
"""Make service call to api for setting Climate React."""
if self.device_data.smart_type is None:
raise HomeAssistantError(
"Use Sensibo Enable Climate React Service once to enable switch or the Sensibo app"
"Use Sensibo Enable Climate React Service once to enable switch or the"
" Sensibo app"
)
new_state = bool(self.device_data.smart_on is False)
data: dict[str, Any] = {"enabled": new_state}

View File

@ -756,11 +756,12 @@ class SensorEntity(Entity):
report_issue = self._suggest_report_issue()
# This should raise in Home Assistant Core 2022.5
_LOGGER.warning(
"Entity %s (%s) with state_class %s has set last_reset. Setting "
"last_reset for entities with state_class other than 'total' is "
"not supported. "
"Please update your configuration if state_class is manually "
"configured, otherwise %s",
(
"Entity %s (%s) with state_class %s has set last_reset. Setting"
" last_reset for entities with state_class other than 'total'"
" is not supported. Please update your configuration if"
" state_class is manually configured, otherwise %s"
),
self.entity_id,
type(self),
self.state_class,
@ -968,10 +969,12 @@ class SensorEntity(Entity):
# This should raise in Home Assistant Core 2023.6
_LOGGER.warning(
"Entity %s (%s) is using native unit of measurement '%s' which "
"is not a valid unit for the device class ('%s') it is using; "
"Please update your configuration if your entity is manually "
"configured, otherwise %s",
(
"Entity %s (%s) is using native unit of measurement '%s' which "
"is not a valid unit for the device class ('%s') it is using; "
"Please update your configuration if your entity is manually "
"configured, otherwise %s"
),
self.entity_id,
type(self),
native_unit_of_measurement,

View File

@ -202,9 +202,11 @@ def _normalize_states(
f"({old_metadata['unit_of_measurement']})"
)
_LOGGER.warning(
"The unit of %s is changing, got multiple %s, generation of long term "
"statistics will be suppressed unless the unit is stable%s. "
"Go to %s to fix this",
(
"The unit of %s is changing, got multiple %s, generation of"
" long term statistics will be suppressed unless the unit is"
" stable%s. Go to %s to fix this"
),
entity_id,
all_units,
extra,
@ -226,11 +228,12 @@ def _normalize_states(
if entity_id not in hass.data[WARN_UNSUPPORTED_UNIT]:
hass.data[WARN_UNSUPPORTED_UNIT].add(entity_id)
_LOGGER.warning(
"The unit of %s (%s) can not be converted to the unit of previously "
"compiled statistics (%s). Generation of long term statistics "
"will be suppressed unless the unit changes back to %s or a "
"compatible unit. "
"Go to %s to fix this",
(
"The unit of %s (%s) can not be converted to the unit of"
" previously compiled statistics (%s). Generation of long term"
" statistics will be suppressed unless the unit changes back to"
" %s or a compatible unit. Go to %s to fix this"
),
entity_id,
state_unit,
statistics_unit,
@ -291,9 +294,11 @@ def warn_dip(
if domain in ["energy", "growatt_server", "solaredge"]:
return
_LOGGER.warning(
"Entity %s %shas state class total_increasing, but its state is "
"not strictly increasing. Triggered by state %s (%s) with last_updated set to %s. "
"Please %s",
(
"Entity %s %shas state class total_increasing, but its state is not"
" strictly increasing. Triggered by state %s (%s) with last_updated set"
" to %s. Please %s"
),
entity_id,
f"from integration {domain} " if domain else "",
state.state,
@ -311,8 +316,10 @@ def warn_negative(hass: HomeAssistant, entity_id: str, state: State) -> None:
hass.data[WARN_NEGATIVE].add(entity_id)
domain = entity_sources(hass).get(entity_id, {}).get("domain")
_LOGGER.warning(
"Entity %s %shas state class total_increasing, but its state is "
"negative. Triggered by state %s with last_updated set to %s. Please %s",
(
"Entity %s %shas state class total_increasing, but its state is "
"negative. Triggered by state %s with last_updated set to %s. Please %s"
),
entity_id,
f"from integration {domain} " if domain else "",
state.state,
@ -472,11 +479,13 @@ def _compile_statistics( # noqa: C901
if entity_id not in hass.data[WARN_UNSTABLE_UNIT]:
hass.data[WARN_UNSTABLE_UNIT].add(entity_id)
_LOGGER.warning(
"The unit of %s (%s) can not be converted to the unit of previously "
"compiled statistics (%s). Generation of long term statistics "
"will be suppressed unless the unit changes back to %s or a "
"compatible unit. "
"Go to %s to fix this",
(
"The unit of %s (%s) can not be converted to the unit of"
" previously compiled statistics (%s). Generation of long"
" term statistics will be suppressed unless the unit"
" changes back to %s or a compatible unit. Go to %s to fix"
" this"
),
entity_id,
statistics_unit,
old_metadata[1]["unit_of_measurement"],
@ -531,13 +540,19 @@ def _compile_statistics( # noqa: C901
):
if old_state is None:
_LOGGER.info(
"Compiling initial sum statistics for %s, zero point set to %s",
(
"Compiling initial sum statistics for %s, zero point"
" set to %s"
),
entity_id,
fstate,
)
else:
_LOGGER.info(
"Detected new cycle for %s, last_reset set to %s (old last_reset %s)",
(
"Detected new cycle for %s, last_reset set to %s (old"
" last_reset %s)"
),
entity_id,
last_reset,
old_last_reset,
@ -557,8 +572,11 @@ def _compile_statistics( # noqa: C901
):
reset = True
_LOGGER.info(
"Detected new cycle for %s, value dropped from %s to %s, "
"triggered by state with last_updated set to %s",
(
"Detected new cycle for %s, value dropped from %s"
" to %s, triggered by state with last_updated set"
" to %s"
),
entity_id,
new_state,
state.last_updated.isoformat(),

View File

@ -98,7 +98,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# value, so if host isn't present, config entry will not be configured.
if not entry.data.get(CONF_HOST):
LOGGER.warning(
"The config entry %s probably comes from a custom integration, please remove it if you want to use core Shelly integration",
(
"The config entry %s probably comes from a custom integration, please"
" remove it if you want to use core Shelly integration"
),
entry.title,
)
return False

View File

@ -265,7 +265,8 @@ class BlockSleepingClimate(
except DeviceConnectionError as err:
self.coordinator.last_update_success = False
raise HomeAssistantError(
f"Setting state for entity {self.name} failed, state: {kwargs}, error: {repr(err)}"
f"Setting state for entity {self.name} failed, state: {kwargs}, error:"
f" {repr(err)}"
) from err
except InvalidAuthError:
self.coordinator.entry.async_start_reauth(self.hass)

View File

@ -347,7 +347,8 @@ class ShellyBlockEntity(CoordinatorEntity[ShellyBlockCoordinator]):
except DeviceConnectionError as err:
self.coordinator.last_update_success = False
raise HomeAssistantError(
f"Setting state for entity {self.name} failed, state: {kwargs}, error: {repr(err)}"
f"Setting state for entity {self.name} failed, state: {kwargs}, error:"
f" {repr(err)}"
) from err
except InvalidAuthError:
self.coordinator.entry.async_start_reauth(self.hass)
@ -399,11 +400,13 @@ class ShellyRpcEntity(CoordinatorEntity[ShellyRpcCoordinator]):
except DeviceConnectionError as err:
self.coordinator.last_update_success = False
raise HomeAssistantError(
f"Call RPC for {self.name} connection error, method: {method}, params: {params}, error: {repr(err)}"
f"Call RPC for {self.name} connection error, method: {method}, params:"
f" {params}, error: {repr(err)}"
) from err
except RpcCallError as err:
raise HomeAssistantError(
f"Call RPC for {self.name} request error, method: {method}, params: {params}, error: {repr(err)}"
f"Call RPC for {self.name} request error, method: {method}, params:"
f" {params}, error: {repr(err)}"
) from err
except InvalidAuthError:
self.coordinator.entry.async_start_reauth(self.hass)

View File

@ -53,7 +53,9 @@ def async_describe_events(
return {
LOGBOOK_ENTRY_NAME: "Shelly",
LOGBOOK_ENTRY_MESSAGE: f"'{click_type}' click event for {input_name} Input was fired",
LOGBOOK_ENTRY_MESSAGE: (
f"'{click_type}' click event for {input_name} Input was fired"
),
}
async_describe_event(DOMAIN, EVENT_SHELLY_CLICK, async_describe_shelly_click_event)

View File

@ -117,7 +117,8 @@ class BlockSleepingNumber(ShellySleepingBlockAttributeEntity, NumberEntity):
except DeviceConnectionError as err:
self.coordinator.last_update_success = False
raise HomeAssistantError(
f"Setting state for entity {self.name} failed, state: {params}, error: {repr(err)}"
f"Setting state for entity {self.name} failed, state: {params}, error:"
f" {repr(err)}"
) from err
except InvalidAuthError:
self.coordinator.entry.async_start_reauth(self.hass)

View File

@ -264,7 +264,8 @@ class ShoppingData:
# so all items left in the mapping should be checked items.
if all_items_mapping[key]["complete"] is False:
raise vol.Invalid(
"The item ids array doesn't contain all the unchecked shopping list items."
"The item ids array doesn't contain all the unchecked shopping list"
" items."
)
new_items.append(all_items_mapping[key])
self.items = new_items

View File

@ -151,7 +151,8 @@ class SignalNotificationService(BaseNotificationService):
> attachment_size_limit
):
raise ValueError(
"Attachment too large (Content-Length reports {}). Max size: {} bytes".format(
"Attachment too large (Content-Length reports {}). Max size: {}"
" bytes".format(
int(str(resp.headers.get("Content-Length"))),
CONF_MAX_ALLOWED_DOWNLOAD_SIZE_BYTES,
)
@ -163,9 +164,8 @@ class SignalNotificationService(BaseNotificationService):
size += len(chunk)
if size > attachment_size_limit:
raise ValueError(
"Attachment too large (Stream reports {}). Max size: {} bytes".format(
size, CONF_MAX_ALLOWED_DOWNLOAD_SIZE_BYTES
)
"Attachment too large (Stream reports {}). Max size: {}"
" bytes".format(size, CONF_MAX_ALLOWED_DOWNLOAD_SIZE_BYTES)
)
chunks.extend(chunk)

View File

@ -47,7 +47,10 @@ async def _async_set_actuator_position(
def _get_actuator_name(bed: SleepIQBed, actuator: SleepIQActuator) -> str:
if actuator.side:
return f"SleepNumber {bed.name} {actuator.side_full} {actuator.actuator_full} {ENTITY_TYPES[ACTUATOR]}"
return (
"SleepNumber"
f" {bed.name} {actuator.side_full} {actuator.actuator_full} {ENTITY_TYPES[ACTUATOR]}"
)
return f"SleepNumber {bed.name} {actuator.actuator_full} {ENTITY_TYPES[ACTUATOR]}"

View File

@ -92,7 +92,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if not validate_webhook_requirements(hass):
_LOGGER.warning(
"The 'base_url' of the 'http' integration must be configured and start with 'https://'"
"The 'base_url' of the 'http' integration must be configured and start with"
" 'https://'"
)
return False
@ -135,7 +136,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await device.status.refresh()
except ClientResponseError:
_LOGGER.debug(
"Unable to update status for device: %s (%s), the device will be excluded",
(
"Unable to update status for device: %s (%s), the device will"
" be excluded"
),
device.label,
device.device_id,
exc_info=True,
@ -161,7 +165,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except ClientResponseError as ex:
if ex.status in (HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN):
_LOGGER.exception(
"Unable to setup configuration entry '%s' - please reconfigure the integration",
(
"Unable to setup configuration entry '%s' - please reconfigure the"
" integration"
),
entry.title,
)
remove_entry = True
@ -194,7 +201,10 @@ async def async_get_entry_scenes(entry: ConfigEntry, api):
except ClientResponseError as ex:
if ex.status == HTTPStatus.FORBIDDEN:
_LOGGER.exception(
"Unable to load scenes for configuration entry '%s' because the access token does not have the required access",
(
"Unable to load scenes for configuration entry '%s' because the"
" access token does not have the required access"
),
entry.title,
)
else:
@ -237,7 +247,10 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
app_count = sum(1 for entry in all_entries if entry.data[CONF_APP_ID] == app_id)
if app_count > 1:
_LOGGER.debug(
"App %s was not removed because it is in use by other configuration entries",
(
"App %s was not removed because it is in use by other configuration"
" entries"
),
app_id,
)
return

View File

@ -236,7 +236,10 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateEntity):
modes.add(state)
else:
_LOGGER.debug(
"Device %s (%s) returned an invalid supported thermostat mode: %s",
(
"Device %s (%s) returned an invalid supported thermostat"
" mode: %s"
),
self._device.label,
self._device.device_id,
mode,

View File

@ -66,7 +66,9 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
reason="invalid_webhook_url",
description_placeholders={
"webhook_url": webhook_url,
"component_url": "https://www.home-assistant.io/integrations/smartthings/",
"component_url": (
"https://www.home-assistant.io/integrations/smartthings/"
),
},
)
@ -216,7 +218,9 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
description_placeholders={
"token_url": "https://account.smartthings.com/tokens",
"component_url": "https://www.home-assistant.io/integrations/smartthings/",
"component_url": (
"https://www.home-assistant.io/integrations/smartthings/"
),
},
)

View File

@ -338,7 +338,10 @@ async def smartapp_sync_subscriptions(
try:
await api.delete_subscription(installed_app_id, sub.subscription_id)
_LOGGER.debug(
"Removed subscription for '%s' under app '%s' because it was no longer needed",
(
"Removed subscription for '%s' under app '%s' because it was no"
" longer needed"
),
sub.capability,
installed_app_id,
)
@ -361,9 +364,11 @@ async def smartapp_sync_subscriptions(
capability_count = len(capabilities)
if capability_count > SUBSCRIPTION_WARNING_LIMIT:
_LOGGER.warning(
"Some device attributes may not receive push updates and there may be subscription "
"creation failures under app '%s' because %s subscriptions are required but "
"there is a limit of %s per app",
(
"Some device attributes may not receive push updates and there may be"
" subscription creation failures under app '%s' because %s"
" subscriptions are required but there is a limit of %s per app"
),
installed_app_id,
capability_count,
SUBSCRIPTION_WARNING_LIMIT,

View File

@ -154,16 +154,17 @@ class MailNotificationService(BaseNotificationService):
server = self.connect()
except (smtplib.socket.gaierror, ConnectionRefusedError):
_LOGGER.exception(
"SMTP server not found or refused connection (%s:%s). "
"Please check the IP address, hostname, and availability of your SMTP server",
(
"SMTP server not found or refused connection (%s:%s). Please check"
" the IP address, hostname, and availability of your SMTP server"
),
self._server,
self._port,
)
except smtplib.SMTPAuthenticationError:
_LOGGER.exception(
"Login not possible. "
"Please check your setting and/or your credentials"
"Login not possible. Please check your setting and/or your credentials"
)
return False

View File

@ -115,5 +115,6 @@ class SnoozFan(FanEntity, RestoreEntity):
self._async_write_state_changed()
elif result.status != SnoozCommandResultStatus.CANCELLED:
raise HomeAssistantError(
f"Command {command} failed with status {result.status.name} after {result.duration}"
f"Command {command} failed with status {result.status.name} after"
f" {result.duration}"
)

View File

@ -262,7 +262,8 @@ class SolarEdgePowerFlowDataService(SolarEdgeDataService):
if "connections" not in power_flow:
LOGGER.debug(
"Missing connections in power flow data. Assuming site does not have any"
"Missing connections in power flow data. Assuming site does not"
" have any"
)
return

View File

@ -64,7 +64,10 @@ class SolarlogData(update_coordinator.DataUpdateCoordinator):
)
self.logger.debug(
"Connection to Solarlog successful. Retrieving latest Solarlog update of %s",
(
"Connection to Solarlog successful. Retrieving latest Solarlog update"
" of %s"
),
data.time,
)

View File

@ -88,7 +88,10 @@ def soma_api_call(api_call):
if self.is_available:
self.is_available = False
_LOGGER.warning(
"Device is unreachable (%s). Error while fetching the state: %s",
(
"Device is unreachable (%s). Error while fetching the"
" state: %s"
),
self.name,
response_from_api["msg"],
)

View File

@ -98,7 +98,8 @@ class SomaTilt(SomaEntity, CoverEntity):
response = self.api.set_shade_position(self.device["mac"], target_api_position)
if not is_api_response_success(response):
raise HomeAssistantError(
f'Error while setting the cover position ({self.name}): {response["msg"]}'
f"Error while setting the cover position ({self.name}):"
f' {response["msg"]}'
)
self.set_position(kwargs[ATTR_TILT_POSITION])
@ -169,7 +170,8 @@ class SomaShade(SomaEntity, CoverEntity):
)
if not is_api_response_success(response):
raise HomeAssistantError(
f'Error while setting the cover position ({self.name}): {response["msg"]}'
f"Error while setting the cover position ({self.name}):"
f' {response["msg"]}'
)
async def async_update(self) -> None:

View File

@ -122,7 +122,9 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
entity_registry_enabled_default=False,
value_fn=len,
attributes_fn=lambda data: {
i.title: f"{getattr(i.statistics,'episodeFileCount', 0)}/{getattr(i.statistics, 'episodeCount', 0)} Episodes"
i.title: (
f"{getattr(i.statistics,'episodeFileCount', 0)}/{getattr(i.statistics, 'episodeCount', 0)} Episodes"
)
for i in data
},
),

View File

@ -52,7 +52,8 @@ async def async_setup_platform(
) -> None:
"""Set up from legacy configuration file. Obsolete."""
_LOGGER.error(
"Configuring Songpal through media_player platform is no longer supported. Convert to songpal platform or UI configuration"
"Configuring Songpal through media_player platform is no longer supported."
" Convert to songpal platform or UI configuration"
)

View File

@ -136,7 +136,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if deprecated_address := config.get(CONF_INTERFACE_ADDR):
_LOGGER.warning(
"'%s' is deprecated, enable %s in the Network integration (https://www.home-assistant.io/integrations/network/)",
(
"'%s' is deprecated, enable %s in the Network integration"
" (https://www.home-assistant.io/integrations/network/)"
),
CONF_INTERFACE_ADDR,
deprecated_address,
)
@ -365,7 +368,8 @@ class SonosDiscoveryManager:
"""Handle discovery via ssdp or zeroconf."""
if self._manual_config_required:
_LOGGER.warning(
"Automatic discovery is working, Sonos hosts in configuration.yaml are not needed"
"Automatic discovery is working, Sonos hosts in configuration.yaml are"
" not needed"
)
self._manual_config_required = False
if model in DISCOVERY_IGNORED_MODELS:

View File

@ -58,12 +58,21 @@ class SonosEntity(Entity):
"""Poll the entity if subscriptions fail."""
if not self.speaker.subscriptions_failed:
if soco_config.EVENT_ADVERTISE_IP:
listener_msg = f"{self.speaker.subscription_address} (advertising as {soco_config.EVENT_ADVERTISE_IP})"
listener_msg = (
f"{self.speaker.subscription_address}"
f" (advertising as {soco_config.EVENT_ADVERTISE_IP})"
)
else:
listener_msg = self.speaker.subscription_address
message = f"{self.speaker.zone_name} cannot reach {listener_msg}, falling back to polling, functionality may be limited"
message = (
f"{self.speaker.zone_name} cannot reach {listener_msg},"
" falling back to polling, functionality may be limited"
)
log_link_msg = f", see {SUB_FAIL_URL} for more details"
notification_link_msg = f'.\n\nSee <a href="{SUB_FAIL_URL}">Sonos documentation</a> for more details.'
notification_link_msg = (
f'.\n\nSee <a href="{SUB_FAIL_URL}">Sonos documentation</a>'
" for more details."
)
_LOGGER.warning(message + log_link_msg)
persistent_notification.async_create(
self.hass,

View File

@ -657,7 +657,10 @@ class SonosSpeaker:
return
if "BattChg" not in battery_dict:
_LOGGER.debug(
"Unknown device properties update for %s (%s), please report an issue: '%s'",
(
"Unknown device properties update for %s (%s),"
" please report an issue: '%s'"
),
self.zone_name,
self.model_name,
more_info,
@ -1047,7 +1050,8 @@ class SonosSpeaker:
speakers_set = {s for s in speakers if s.soco_snapshot}
if missing_snapshots := set(speakers) - speakers_set:
raise HomeAssistantError(
f"Restore failed, speakers are missing snapshots: {[s.zone_name for s in missing_snapshots]}"
"Restore failed, speakers are missing snapshots:"
f" {[s.zone_name for s in missing_snapshots]}"
)
if with_group:

View File

@ -255,7 +255,10 @@ class SonosAlarmEntity(SonosEntity, SwitchEntity):
@property
def name(self) -> str:
"""Return the name of the sensor."""
return f"{self.alarm.recurrence.capitalize()} alarm {str(self.alarm.start_time)[:5]}"
return (
f"{self.alarm.recurrence.capitalize()} alarm"
f" {str(self.alarm.start_time)[:5]}"
)
async def _async_fallback_poll(self) -> None:
"""Call the central alarm polling method."""
@ -424,7 +427,10 @@ def async_migrate_speech_enhancement_entity_unique_id(
if len(speech_enhancement_entries) > 1:
_LOGGER.warning(
"Migration of Speech Enhancement switches on %s failed, manual cleanup required: %s",
(
"Migration of Speech Enhancement switches on %s failed,"
" manual cleanup required: %s"
),
speaker.zone_name,
[e.entity_id for e in speech_enhancement_entries],
)

View File

@ -378,7 +378,8 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
if not self._scope_ok:
_LOGGER.debug(
"Spotify scopes are not set correctly, this can impact features such as media browsing"
"Spotify scopes are not set correctly, this can impact features such as"
" media browsing"
)
raise NotImplementedError

View File

@ -590,7 +590,8 @@ class SqueezeBoxEntity(MediaPlayerEntity):
async def async_sync(self, other_player):
"""Sync this Squeezebox player to another. Deprecated."""
_LOGGER.warning(
"Service squeezebox.sync is deprecated; use media_player.join_players instead"
"Service squeezebox.sync is deprecated; use media_player.join_players"
" instead"
)
await self.async_join_players([other_player])
@ -601,7 +602,8 @@ class SqueezeBoxEntity(MediaPlayerEntity):
async def async_unsync(self):
"""Unsync this Squeezebox player. Deprecated."""
_LOGGER.warning(
"Service squeezebox.unsync is deprecated; use media_player.unjoin_player instead"
"Service squeezebox.unsync is deprecated; use media_player.unjoin_player"
" instead"
)
await self.async_unjoin_player()

View File

@ -191,9 +191,8 @@ def valid_state_characteristic_configuration(config: dict[str, Any]) -> dict[str
not is_binary and characteristic not in STATS_NUMERIC_SUPPORT
):
raise vol.ValueInvalid(
"The configured characteristic '{}' is not supported for the configured source sensor".format(
characteristic
)
"The configured characteristic '{}' is not supported for the configured"
" source sensor".format(characteristic)
)
return config

View File

@ -180,7 +180,10 @@ class RecorderOutput(StreamOutput):
write_transform_matrix_and_rename(video_path)
except FileNotFoundError:
_LOGGER.error(
"Error writing to '%s'. There are likely multiple recordings writing to the same file",
(
"Error writing to '%s'. There are likely multiple recordings"
" writing to the same file"
),
video_path,
)

View File

@ -442,7 +442,8 @@ class TimestampValidator:
gap = packet.time_base * (prev_dts - packet.dts)
if gap > MAX_TIMESTAMP_GAP:
raise StreamWorkerError(
f"Timestamp overflow detected: last dts = {prev_dts}, dts = {packet.dts}"
f"Timestamp overflow detected: last dts = {prev_dts}, dts ="
f" {packet.dts}"
)
return False
self._last_dts[packet.stream] = packet.dts
@ -496,7 +497,8 @@ def stream_worker(
container = av.open(source, options=pyav_options, timeout=SOURCE_TIMEOUT)
except av.AVError as err:
raise StreamWorkerError(
f"Error opening stream ({err.type}, {err.strerror}) {redact_credentials(str(source))}"
f"Error opening stream ({err.type}, {err.strerror})"
f" {redact_credentials(str(source))}"
) from err
try:
video_stream = container.streams.video[0]

View File

@ -144,7 +144,8 @@ class SwitchBeeCoverEntity(SwitchBeeDeviceEntity[SwitchBeeShutter], CoverEntity)
await self.coordinator.api.set_state(self._device.id, kwargs[ATTR_POSITION])
except (SwitchBeeError, SwitchBeeTokenError) as exp:
raise HomeAssistantError(
f"Failed to set {self.name} position to {kwargs[ATTR_POSITION]}, error: {str(exp)}"
f"Failed to set {self.name} position to {kwargs[ATTR_POSITION]}, error:"
f" {str(exp)}"
) from exp
self._get_coordinator_device().position = kwargs[ATTR_POSITION]

View File

@ -98,7 +98,10 @@ class SwitchBeeDeviceEntity(SwitchBeeEntity[_DeviceTypeT]):
if self._is_online:
_LOGGER.warning(
"%s device is not responding, check the status in the SwitchBee mobile app",
(
"%s device is not responding, check the status in the SwitchBee"
" mobile app"
),
self.name,
)
self._is_online = False

View File

@ -141,7 +141,8 @@ class SwitcherDataUpdateCoordinator(update_coordinator.DataUpdateCoordinator):
async def _async_update_data(self) -> None:
"""Mark device offline if no data."""
raise update_coordinator.UpdateFailed(
f"Device {self.name} did not send update for {MAX_UPDATE_INTERVAL_SEC} seconds"
f"Device {self.name} did not send update for"
f" {MAX_UPDATE_INTERVAL_SEC} seconds"
)
@property

View File

@ -153,6 +153,5 @@ class SwitcherThermostatButtonEntity(
self.coordinator.last_update_success = False
self.async_write_ha_state()
raise HomeAssistantError(
f"Call api for {self.name} failed, "
f"response/error: {response or error}"
f"Call api for {self.name} failed, response/error: {response or error}"
)

View File

@ -153,7 +153,10 @@ class SyncthingClient:
)
except aiosyncthing.exceptions.SyncthingError:
_LOGGER.info(
"The syncthing server '%s' is not available. Sleeping %i seconds and retrying",
(
"The syncthing server '%s' is not available. Sleeping %i"
" seconds and retrying"
),
self._client.url,
RECONNECT_INTERVAL.total_seconds(),
)

View File

@ -98,7 +98,8 @@ class SynoApi:
self._with_surveillance_station = False
self.dsm.reset(SynoSurveillanceStation.API_KEY)
LOGGER.info(
"Surveillance Station found, but disabled due to missing user permissions"
"Surveillance Station found, but disabled due to missing user"
" permissions"
)
LOGGER.debug(

View File

@ -43,7 +43,10 @@ async def async_setup_services(hass: HomeAssistant) -> None:
return
LOGGER.debug("%s DSM with serial %s", call.service, serial)
LOGGER.warning(
"The %s service is deprecated and will be removed in future release. Please use the corresponding button entity",
(
"The %s service is deprecated and will be removed in future"
" release. Please use the corresponding button entity"
),
call.service,
)
dsm_device = hass.data[DOMAIN][serial]

View File

@ -66,7 +66,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
try:
if not await version.check_supported():
raise ConfigEntryNotReady(
f"You are not running a supported version of System Bridge. Please update to {SUPPORTED_VERSION} or higher."
"You are not running a supported version of System Bridge. Please"
f" update to {SUPPORTED_VERSION} or higher."
)
except AuthenticationException as exception:
_LOGGER.error("Authentication failed for %s: %s", entry.title, exception)

View File

@ -37,7 +37,8 @@ def async_register_info(
Deprecated.
"""
_LOGGER.warning(
"Calling system_health.async_register_info is deprecated; Add a system_health platform instead"
"Calling system_health.async_register_info is deprecated; Add a system_health"
" platform instead"
)
hass.data.setdefault(DOMAIN, {})
SystemHealthRegistration(hass, domain).async_register_info(info_callback)

View File

@ -407,7 +407,10 @@ async def async_setup_sensor_registry_updates(
"""Update all sensors in one executor jump."""
if _update_lock.locked():
_LOGGER.warning(
"Updating systemmonitor took longer than the scheduled update interval %s",
(
"Updating systemmonitor took longer than the scheduled update"
" interval %s"
),
scan_interval,
)
return

View File

@ -282,7 +282,10 @@ class TadoConnector:
):
"""Set a zone overlay."""
_LOGGER.debug(
"Set overlay for zone %s: overlay_mode=%s, temp=%s, duration=%s, type=%s, mode=%s fan_speed=%s swing=%s",
(
"Set overlay for zone %s: overlay_mode=%s, temp=%s, duration=%s,"
" type=%s, mode=%s fan_speed=%s swing=%s"
),
zone_id,
overlay_mode,
temperature,

View File

@ -598,7 +598,10 @@ class TadoClimate(TadoZoneEntity, ClimateEntity):
)
_LOGGER.debug(
"Switching to %s for zone %s (%d) with temperature %s °C and duration %s using overlay %s",
(
"Switching to %s for zone %s (%d) with temperature %s °C and duration"
" %s using overlay %s"
),
self._current_tado_hvac_mode,
self.zone_name,
self.zone_id,

View File

@ -67,7 +67,9 @@ class TadoZoneEntity(Entity):
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return DeviceInfo(
configuration_url=f"https://app.tado.com/en/main/home/zoneV2/{self.zone_id}",
configuration_url=(
f"https://app.tado.com/en/main/home/zoneV2/{self.zone_id}"
),
identifiers={(DOMAIN, self._device_zone_id)},
name=self.zone_name,
manufacturer=DEFAULT_NAME,

View File

@ -118,9 +118,10 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
if len(stations := data.get("stations", [])) == 0:
return self._show_form_user(user_input, errors={CONF_RADIUS: "no_stations"})
for station in stations:
self._stations[
station["id"]
] = f"{station['brand']} {station['street']} {station['houseNumber']} - ({station['dist']}km)"
self._stations[station["id"]] = (
f"{station['brand']} {station['street']} {station['houseNumber']} -"
f" ({station['dist']}km)"
)
self._data = user_input
@ -268,9 +269,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
)
if stations := nearby_stations.get("stations"):
for station in stations:
self._stations[
station["id"]
] = f"{station['brand']} {station['street']} {station['houseNumber']} - ({station['dist']}km)"
self._stations[station["id"]] = (
f"{station['brand']} {station['street']} {station['houseNumber']} -"
f" ({station['dist']}km)"
)
# add possible extra selected stations from import
for selected_station in self.config_entry.data[CONF_STATIONS]:

View File

@ -85,7 +85,10 @@ def warn_if_topic_duplicated(
for _, cfg in offenders
]
_LOGGER.warning(
"Multiple Tasmota devices are sharing the same topic '%s'. Offending devices: %s",
(
"Multiple Tasmota devices are sharing the same topic '%s'. Offending"
" devices: %s"
),
command_topic,
", ".join(offender_strings),
)

View File

@ -131,8 +131,10 @@ class TcpEntity(Entity):
readable, _, _ = select.select([sock], [], [], self._config[CONF_TIMEOUT])
if not readable:
_LOGGER.warning(
"Timeout (%s second(s)) waiting for a response after "
"sending %r to %s on port %s",
(
"Timeout (%s second(s)) waiting for a response after "
"sending %r to %s on port %s"
),
self._config[CONF_TIMEOUT],
self._config[CONF_PAYLOAD],
self._config[CONF_HOST],