String formatting and max line length - Part 3 (#84394)

This commit is contained in:
Franck Nijhof 2022-12-22 13:35:47 +01:00 committed by GitHub
parent 30df9e7706
commit baef267f33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 517 additions and 218 deletions

View File

@ -307,7 +307,8 @@ class InputNumber(collection.CollectionEntity, RestoreEntity):
if num_value < self._minimum or num_value > self._maximum:
raise vol.Invalid(
f"Invalid value for {self.entity_id}: {value} (range {self._minimum} - {self._maximum})"
f"Invalid value for {self.entity_id}: {value} (range {self._minimum} -"
f" {self._maximum})"
)
self._current_value = num_value

View File

@ -73,7 +73,10 @@ def _remove_duplicates(options: list[str], name: str | None) -> list[str]:
# Reject YAML configured input_select with duplicates from 2022.6
if len(unique_options) != len(options):
_LOGGER.warning(
"Input select '%s' with options %s had duplicated options, the duplicates have been removed",
(
"Input select '%s' with options %s had duplicated options, the"
" duplicates have been removed"
),
name or "<unnamed>",
options,
)

View File

@ -83,9 +83,15 @@ class InsteonEntity(Entity):
return DeviceInfo(
identifiers={(DOMAIN, str(self._insteon_device.address))},
manufacturer="SmartLabs, Inc",
model=f"{self._insteon_device.model} ({self._insteon_device.cat!r}, 0x{self._insteon_device.subcat:02x})",
model=(
f"{self._insteon_device.model} ({self._insteon_device.cat!r},"
f" 0x{self._insteon_device.subcat:02x})"
),
name=f"{self._insteon_device.description} {self._insteon_device.address}",
sw_version=f"{self._insteon_device.firmware:02x} Engine Version: {self._insteon_device.engine_version}",
sw_version=(
f"{self._insteon_device.firmware:02x} Engine Version:"
f" {self._insteon_device.engine_version}"
),
via_device=(DOMAIN, str(devices.modem.address)),
)

View File

@ -158,7 +158,10 @@ class IPMAWeather(WeatherEntity):
@property
def unique_id(self) -> str:
"""Return a unique id."""
return f"{self._location.station_latitude}, {self._location.station_longitude}, {self._mode}"
return (
f"{self._location.station_latitude}, {self._location.station_longitude},"
f" {self._mode}"
)
@property
def name(self):

View File

@ -90,7 +90,8 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
if not unique_id and info[CONF_SERIAL]:
_LOGGER.debug(
"Printer UUID is missing from IPP response. Falling back to IPP serial number"
"Printer UUID is missing from IPP response. Falling back to IPP serial"
" number"
)
unique_id = info[CONF_SERIAL]
elif not unique_id:
@ -154,7 +155,8 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
unique_id = self.discovery_info[CONF_UUID] = info[CONF_UUID]
elif not unique_id and info[CONF_SERIAL]:
_LOGGER.debug(
"Printer UUID is missing from discovery info and IPP response. Falling back to IPP serial number"
"Printer UUID is missing from discovery info and IPP response. Falling"
" back to IPP serial number"
)
unique_id = info[CONF_SERIAL]
elif not unique_id:

View File

@ -101,7 +101,9 @@ class IPPMarkerSensor(IPPSensor):
unique_id=unique_id,
icon="mdi:water",
key=f"marker_{marker_index}",
name=f"{coordinator.data.info.name} {coordinator.data.markers[marker_index].name}",
name=(
f"{coordinator.data.info.name} {coordinator.data.markers[marker_index].name}"
),
unit_of_measurement=PERCENTAGE,
)

View File

@ -105,11 +105,13 @@ class IslamicPrayerClient:
if now > dt_util.as_utc(midnight_dt):
next_update_at = midnight_dt + timedelta(days=1, minutes=1)
_LOGGER.debug(
"Midnight is after day the changes so schedule update for after Midnight the next day"
"Midnight is after day the changes so schedule update for after"
" Midnight the next day"
)
else:
_LOGGER.debug(
"Midnight is before the day changes so schedule update for the next start of day"
"Midnight is before the day changes so schedule update for the next"
" start of day"
)
next_update_at = dt_util.start_of_local_day(now + timedelta(days=1))

View File

@ -180,7 +180,8 @@ async def async_setup_entry(
await isy.initialize()
except asyncio.TimeoutError as err:
raise ConfigEntryNotReady(
f"Timed out initializing the ISY; device may be busy, trying again later: {err}"
"Timed out initializing the ISY; device may be busy, trying again later:"
f" {err}"
) from err
except ISYInvalidAuthError as err:
raise ConfigEntryAuthFailed(f"Invalid credentials for the ISY: {err}") from err
@ -190,7 +191,8 @@ async def async_setup_entry(
) from err
except ISYResponseParseError as err:
raise ConfigEntryNotReady(
f"Invalid XML response from ISY; Ensure the ISY is running the latest firmware: {err}"
"Invalid XML response from ISY; Ensure the ISY is running the latest"
f" firmware: {err}"
) from err
except TypeError as err:
raise ConfigEntryNotReady(

View File

@ -116,8 +116,10 @@ async def async_setup_entry(
parent_entity = entities_by_address.get(node.parent_node.address)
if not parent_entity:
_LOGGER.error(
"Node %s has a parent node %s, but no device "
"was created for the parent. Skipping",
(
"Node %s has a parent node %s, but no device "
"was created for the parent. Skipping"
),
node.address,
node.parent_node,
)

View File

@ -209,7 +209,8 @@ class ISYNodeEntity(ISYEntity):
"""Respond to an entity service command to request a Z-Wave device parameter from the ISY."""
if not hasattr(self._node, "protocol") or self._node.protocol != PROTO_ZWAVE:
raise HomeAssistantError(
f"Invalid service call: cannot request Z-Wave Parameter for non-Z-Wave device {self.entity_id}"
"Invalid service call: cannot request Z-Wave Parameter for non-Z-Wave"
f" device {self.entity_id}"
)
await self._node.get_zwave_parameter(parameter)
@ -219,7 +220,8 @@ class ISYNodeEntity(ISYEntity):
"""Respond to an entity service command to set a Z-Wave device parameter via the ISY."""
if not hasattr(self._node, "protocol") or self._node.protocol != PROTO_ZWAVE:
raise HomeAssistantError(
f"Invalid service call: cannot set Z-Wave Parameter for non-Z-Wave device {self.entity_id}"
"Invalid service call: cannot set Z-Wave Parameter for non-Z-Wave"
f" device {self.entity_id}"
)
await self._node.set_zwave_parameter(parameter, value, size)
await self._node.get_zwave_parameter(parameter)

View File

@ -352,7 +352,10 @@ def _categorize_programs(hass_isy_data: dict, programs: Programs) -> None:
actions = entity_folder.get_by_name(KEY_ACTIONS)
if not actions or actions.protocol != PROTO_PROGRAM:
_LOGGER.warning(
"Program %s entity '%s' not loaded, invalid/missing actions program",
(
"Program %s entity '%s' not loaded, invalid/missing actions"
" program"
),
platform,
entity_folder.name,
)

View File

@ -299,8 +299,10 @@ def async_setup_services(hass: HomeAssistant) -> None: # noqa: C901
entity_registry.async_remove(entity_id)
_LOGGER.debug(
"Cleaning up ISY994 Entities and devices: Config Entries: %s, Current Entries: %s, "
"Extra Entries Removed: %s",
(
"Cleaning up ISY994 Entities and devices: Config Entries: %s, Current"
" Entries: %s, Extra Entries Removed: %s"
),
len(config_ids),
len(current_unique_ids),
len(extra_entities),

View File

@ -31,7 +31,9 @@ class JuiceNetDevice(CoordinatorEntity):
def device_info(self) -> DeviceInfo:
"""Return device information about this JuiceNet Device."""
return DeviceInfo(
configuration_url=f"https://home.juice.net/Portal/Details?unitID={self.device.id}",
configuration_url=(
f"https://home.juice.net/Portal/Details?unitID={self.device.id}"
),
identifiers={(DOMAIN, self.device.id)},
manufacturer="JuiceNet",
name=self.device.name,

View File

@ -235,7 +235,9 @@ class KebaHandler(KebaKeContact):
self._set_fast_polling()
except (KeyError, ValueError) as ex:
_LOGGER.warning(
"Values are not correct for: failsafe_timeout, failsafe_fallback and/or "
"failsafe_persist: %s",
(
"Values are not correct for: failsafe_timeout, failsafe_fallback"
" and/or failsafe_persist: %s"
),
ex,
)

View File

@ -495,7 +495,10 @@ class KNXModule:
value = transcoder.from_knx(data)
except ConversionError as err:
_LOGGER.warning(
"Error in `knx_event` at decoding type '%s' from telegram %s\n%s",
(
"Error in `knx_event` at decoding type '%s' from"
" telegram %s\n%s"
),
transcoder.__name__,
telegram,
err,
@ -584,7 +587,10 @@ class KNXModule:
if group_address in self.service_exposures:
replaced_exposure = self.service_exposures.pop(group_address)
_LOGGER.warning(
"Service exposure_register replacing already registered exposure for '%s' - %s",
(
"Service exposure_register replacing already registered exposure"
" for '%s' - %s"
),
group_address,
replaced_exposure.device.name,
)

View File

@ -399,7 +399,10 @@ class KNXCommonFlow(ABC, FlowHandler):
],
)
return self.finish_flow(
title=f"Secure Routing as {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}"
title=(
"Secure Routing as"
f" {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}"
)
)
fields = {
@ -464,7 +467,10 @@ class KNXCommonFlow(ABC, FlowHandler):
self.new_entry_data[CONF_KNX_CONNECTION_TYPE]
== CONF_KNX_ROUTING_SECURE
):
title = f"Secure Routing as {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}"
title = (
"Secure Routing as"
f" {self.new_entry_data[CONF_KNX_INDIVIDUAL_ADDRESS]}"
)
else:
title = f"Secure Tunneling @ {self.new_entry_data[CONF_HOST]}"
return self.finish_flow(title=title)

View File

@ -74,7 +74,8 @@ def dpt_subclass_validator(dpt_base_class: type[DPTBase]) -> Callable[[Any], str
):
return value
raise vol.Invalid(
f"type '{value}' is not a valid DPT identifier for {dpt_base_class.__name__}."
f"type '{value}' is not a valid DPT identifier for"
f" {dpt_base_class.__name__}."
)
return dpt_value_validator
@ -94,8 +95,9 @@ def ga_validator(value: Any) -> str | int:
except CouldNotParseAddress:
pass
raise vol.Invalid(
f"value '{value}' is not a valid KNX group address '<main>/<middle>/<sub>', '<main>/<sub>' "
"or '<free>' (eg.'1/2/3', '9/234', '123'), nor xknx internal address 'i-<string>'."
f"value '{value}' is not a valid KNX group address '<main>/<middle>/<sub>',"
" '<main>/<sub>' or '<free>' (eg.'1/2/3', '9/234', '123'), nor xknx internal"
" address 'i-<string>'."
)
@ -104,7 +106,10 @@ ga_list_validator = vol.All(cv.ensure_list, [ga_validator])
ia_validator = vol.Any(
vol.All(str, str.strip, cv.matches_regex(IndividualAddress.ADDRESS_RE.pattern)),
vol.All(vol.Coerce(int), vol.Range(min=1, max=65535)),
msg="value does not match pattern for KNX individual address '<area>.<line>.<device>' (eg.'1.1.100')",
msg=(
"value does not match pattern for KNX individual address"
" '<area>.<line>.<device>' (eg.'1.1.100')"
),
)
@ -120,7 +125,8 @@ def ip_v4_validator(value: Any, multicast: bool | None = None) -> str:
raise vol.Invalid(f"value '{value}' is not a valid IPv4 address: {ex}") from ex
if multicast is not None and address.is_multicast != multicast:
raise vol.Invalid(
f"value '{value}' is not a valid IPv4 {'multicast' if multicast else 'unicast'} address"
f"value '{value}' is not a valid IPv4"
f" {'multicast' if multicast else 'unicast'} address"
)
return str(address)
@ -433,14 +439,18 @@ class ClimateSchema(KNXPlatformSchema):
vol.Inclusive(
CONF_SETPOINT_SHIFT_ADDRESS,
"setpoint_shift",
msg="'setpoint_shift_address' and 'setpoint_shift_state_address' "
"are required for setpoint_shift configuration",
msg=(
"'setpoint_shift_address' and 'setpoint_shift_state_address' "
"are required for setpoint_shift configuration"
),
): ga_list_validator,
vol.Inclusive(
CONF_SETPOINT_SHIFT_STATE_ADDRESS,
"setpoint_shift",
msg="'setpoint_shift_address' and 'setpoint_shift_state_address' "
"are required for setpoint_shift configuration",
msg=(
"'setpoint_shift_address' and 'setpoint_shift_state_address' "
"are required for setpoint_shift configuration"
),
): ga_list_validator,
vol.Optional(CONF_SETPOINT_SHIFT_MODE): vol.Maybe(
vol.All(vol.Upper, cv.enum(SetpointShiftMode))
@ -509,7 +519,10 @@ class CoverSchema(KNXPlatformSchema):
{
vol.Required(
vol.Any(CONF_MOVE_LONG_ADDRESS, CONF_POSITION_ADDRESS),
msg=f"At least one of '{CONF_MOVE_LONG_ADDRESS}' or '{CONF_POSITION_ADDRESS}' is required.",
msg=(
f"At least one of '{CONF_MOVE_LONG_ADDRESS}' or"
f" '{CONF_POSITION_ADDRESS}' is required."
),
): object,
},
extra=vol.ALLOW_EXTRA,
@ -669,17 +682,26 @@ class LightSchema(KNXPlatformSchema):
vol.Inclusive(
CONF_RED,
"individual_colors",
msg="'red', 'green' and 'blue' are required for individual colors configuration",
msg=(
"'red', 'green' and 'blue' are required for individual"
" colors configuration"
),
): INDIVIDUAL_COLOR_SCHEMA,
vol.Inclusive(
CONF_GREEN,
"individual_colors",
msg="'red', 'green' and 'blue' are required for individual colors configuration",
msg=(
"'red', 'green' and 'blue' are required for individual"
" colors configuration"
),
): INDIVIDUAL_COLOR_SCHEMA,
vol.Inclusive(
CONF_BLUE,
"individual_colors",
msg="'red', 'green' and 'blue' are required for individual colors configuration",
msg=(
"'red', 'green' and 'blue' are required for individual"
" colors configuration"
),
): INDIVIDUAL_COLOR_SCHEMA,
vol.Optional(CONF_WHITE): INDIVIDUAL_COLOR_SCHEMA,
},

View File

@ -145,8 +145,10 @@ class AlarmPanel:
self.connect_attempts = 0
self.connected = True
_LOGGER.info(
"Set up Konnected device %s. Open http://%s:%s in a "
"web browser to view device status",
(
"Set up Konnected device %s. Open http://%s:%s in a "
"web browser to view device status"
),
self.device_id,
self.host,
self.port,

View File

@ -78,7 +78,8 @@ class KrakenData:
except pykrakenapi.pykrakenapi.KrakenAPIError as error:
if "Unknown asset pair" in str(error):
_LOGGER.info(
"Kraken.com reported an unknown asset pair. Refreshing list of tradable asset pairs"
"Kraken.com reported an unknown asset pair. Refreshing list of"
" tradable asset pairs"
)
await self._async_refresh_tradable_asset_pairs()
else:
@ -87,7 +88,8 @@ class KrakenData:
) from error
except pykrakenapi.pykrakenapi.CallRateLimitError:
_LOGGER.warning(
"Exceeded the Kraken.com call rate limit. Increase the update interval to prevent this error"
"Exceeded the Kraken.com call rate limit. Increase the update interval"
" to prevent this error"
)
return None

View File

@ -111,7 +111,8 @@ async def async_setup_entry(
if description is None:
message = (
f"Unsupported sensor field: {field}\nPlease create an issue on "
"GitHub. https://github.com/home-assistant/core/issues/new?assignees=&la"
"GitHub."
" https://github.com/home-assistant/core/issues/new?assignees=&la"
"bels=&template=bug_report.yml&integration_name=LaCrosse%20View&integrat"
"ion_link=https://www.home-assistant.io/integrations/lacrosse_view/&addi"
f"tional_information=Field:%20{field}%0ASensor%20Model:%20{sensor.model}&"

View File

@ -99,8 +99,10 @@ async def async_setup_entry(
return False
except pypck.connection.PchkLicenseError:
_LOGGER.warning(
'Maximum number of connections on PCHK "%s" was '
"reached. An additional license key is required",
(
'Maximum number of connections on PCHK "%s" was '
"reached. An additional license key is required"
),
config_entry.title,
)
return False
@ -269,7 +271,10 @@ class LcnEntity(Entity):
def device_info(self) -> DeviceInfo | None:
"""Return device specific attributes."""
address = f"{'g' if self.address[2] else 'm'}{self.address[0]:03d}{self.address[1]:03d}"
model = f"LCN resource ({get_device_model(self.config[CONF_DOMAIN], self.config[CONF_DOMAIN_DATA])})"
model = (
"LCN resource"
f" ({get_device_model(self.config[CONF_DOMAIN], self.config[CONF_DOMAIN_DATA])})"
)
return {
"identifiers": {(DOMAIN, self.unique_id)},

View File

@ -81,8 +81,10 @@ class LcnFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_abort(reason="authentication_error")
except pypck.connection.PchkLicenseError:
_LOGGER.warning(
'Maximum number of connections on PCHK "%s" was '
"reached. An additional license key is required",
(
'Maximum number of connections on PCHK "%s" was '
"reached. An additional license key is required"
),
host_name,
)
return self.async_abort(reason="license_error")

View File

@ -104,7 +104,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
{
vol.Required(CONF_ADDRESS): vol.In(
{
service_info.address: f"{service_info.name} ({service_info.address})"
service_info.address: (
f"{service_info.name} ({service_info.address})"
)
for service_info in self._discovered_devices.values()
}
),

View File

@ -152,16 +152,20 @@ class Life360DeviceTracker(
if bad_last_seen or bad_accuracy:
if bad_last_seen:
LOGGER.warning(
"%s: Ignoring location update because "
"last_seen (%s) < previous last_seen (%s)",
(
"%s: Ignoring location update because "
"last_seen (%s) < previous last_seen (%s)"
),
self.entity_id,
last_seen,
prev_seen,
)
if bad_accuracy:
LOGGER.warning(
"%s: Ignoring location update because "
"expected GPS accuracy (%0.1f) is not met: %i",
(
"%s: Ignoring location update because "
"expected GPS accuracy (%0.1f) is not met: %i"
),
self.entity_id,
max_gps_acc,
self.location_accuracy,

View File

@ -143,7 +143,10 @@ class LIFXDiscoveryManager:
if migration_complete and migrating_was_in_progress:
self.migrating = False
_LOGGER.debug(
"LIFX migration complete, switching to normal discovery interval: %s",
(
"LIFX migration complete, switching to normal discovery"
" interval: %s"
),
DISCOVERY_INTERVAL,
)
self.async_setup_discovery_interval()

View File

@ -221,7 +221,10 @@ class LIFXLight(LIFXEntity, LightEntity):
Platform.SELECT, INFRARED_BRIGHTNESS
)
_LOGGER.warning(
"The 'infrared' attribute of 'lifx.set_state' is deprecated: call 'select.select_option' targeting '%s' instead",
(
"The 'infrared' attribute of 'lifx.set_state' is deprecated:"
" call 'select.select_option' targeting '%s' instead"
),
infrared_entity_id,
)
bulb.set_infrared(convert_8_to_16(kwargs[ATTR_INFRARED]))

View File

@ -110,7 +110,8 @@ def find_hsbk(hass: HomeAssistant, **kwargs: Any) -> list[float | int | None] |
if ATTR_KELVIN in kwargs:
_LOGGER.warning(
"The 'kelvin' parameter is deprecated. Please use 'color_temp_kelvin' for all service calls"
"The 'kelvin' parameter is deprecated. Please use 'color_temp_kelvin' for"
" all service calls"
)
kelvin = kwargs.pop(ATTR_KELVIN)
saturation = 0

View File

@ -89,8 +89,9 @@ DEPRECATED_GROUP = [
]
DEPRECATION_WARNING = (
"The use of other attributes than device state attributes is deprecated and will be removed in a future release. "
"Invalid attributes are %s. Read the logs for further details: https://www.home-assistant.io/integrations/scene/"
"The use of other attributes than device state attributes is deprecated and will be"
" removed in a future release. Invalid attributes are %s. Read the logs for further"
" details: https://www.home-assistant.io/integrations/scene/"
)

View File

@ -144,8 +144,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
persistent_notification.create(
hass,
(
f"Error: The cached access tokens are missing from {DEFAULT_CACHEDB}.<br />"
f"Please unload then re-add the Logi Circle integration to resolve."
"Error: The cached access tokens are missing from"
f" {DEFAULT_CACHEDB}.<br />Please unload then re-add the Logi Circle"
" integration to resolve."
),
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID,
@ -160,10 +161,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except AuthorizationFailed:
persistent_notification.create(
hass,
"Error: Failed to obtain an access token from the cached "
"refresh token.<br />"
"Token may have expired or been revoked.<br />"
"Please unload then re-add the Logi Circle integration to resolve",
(
"Error: Failed to obtain an access token from the cached "
"refresh token.<br />"
"Token may have expired or been revoked.<br />"
"Please unload then re-add the Logi Circle integration to resolve"
),
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID,
)

View File

@ -51,10 +51,7 @@ AUTHORITIES = [
"Westminster",
]
URL = (
"http://api.erg.kcl.ac.uk/AirQuality/Hourly/"
"MonitoringIndex/GroupName=London/Json"
)
URL = "http://api.erg.kcl.ac.uk/AirQuality/Hourly/MonitoringIndex/GroupName=London/Json"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{

View File

@ -113,7 +113,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
if yaml_resources is not None:
_LOGGER.warning(
"Lovelace is running in storage mode. Define resources via user interface"
"Lovelace is running in storage mode. Define resources via user"
" interface"
)
resource_collection = resources.ResourceStorageCollection(hass, default_config)
@ -220,7 +221,8 @@ async def create_yaml_resource_col(hass, yaml_resources):
else:
if CONF_RESOURCES in ll_conf:
_LOGGER.warning(
"Resources need to be specified in your configuration.yaml. Please see the docs"
"Resources need to be specified in your configuration.yaml. Please"
" see the docs"
)
yaml_resources = ll_conf[CONF_RESOURCES]

View File

@ -116,7 +116,9 @@ class SensorCommunitySensor(CoordinatorEntity, SensorEntity):
ATTR_SENSOR_ID: sensor_id,
}
self._attr_device_info = DeviceInfo(
configuration_url=f"https://devices.sensor.community/sensors/{sensor_id}/settings",
configuration_url=(
f"https://devices.sensor.community/sensors/{sensor_id}/settings"
),
identifiers={(DOMAIN, str(sensor_id))},
name=f"Sensor {sensor_id}",
manufacturer="Sensor.Community",

View File

@ -51,7 +51,9 @@ def async_describe_events(
if rev_button_map is None:
return {
LOGBOOK_ENTRY_NAME: f"{data[ATTR_AREA_NAME]} {data[ATTR_DEVICE_NAME]}",
LOGBOOK_ENTRY_MESSAGE: f"{data[ATTR_ACTION]} Error retrieving button description",
LOGBOOK_ENTRY_MESSAGE: (
f"{data[ATTR_ACTION]} Error retrieving button description"
),
}
button_description = rev_button_map.get(leap_button_number)

View File

@ -277,7 +277,8 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
if device.changeableValues.autoChangeoverActive:
if target_temp_low is None or target_temp_high is None:
raise HomeAssistantError(
"Could not find target_temp_low and/or target_temp_high in arguments"
"Could not find target_temp_low and/or target_temp_high in"
" arguments"
)
_LOGGER.debug("Set temperature: %s - %s", target_temp_low, target_temp_high)
try:

View File

@ -168,12 +168,18 @@ class MagicSeaweedSensor(SensorEntity):
elif sensor_type == "max_breaking_swell":
self._attr_native_value = forecast.swell_maxBreakingHeight
elif sensor_type == "swell_forecast":
summary = f"{forecast.swell_minBreakingHeight} - {forecast.swell_maxBreakingHeight}"
summary = (
f"{forecast.swell_minBreakingHeight} -"
f" {forecast.swell_maxBreakingHeight}"
)
self._attr_native_value = summary
if self.hour is None:
for hour, data in self.data.hourly.items():
occurs = hour
hr_summary = f"{data.swell_minBreakingHeight} - {data.swell_maxBreakingHeight} {data.swell_unit}"
hr_summary = (
f"{data.swell_minBreakingHeight} -"
f" {data.swell_maxBreakingHeight} {data.swell_unit}"
)
self._attr_extra_state_attributes[occurs] = hr_summary
if sensor_type != "swell_forecast":

View File

@ -7,7 +7,9 @@ config_entry_flow.register_webhook_flow(
DOMAIN,
"Mailgun Webhook",
{
"mailgun_url": "https://documentation.mailgun.com/en/latest/user_manual.html#webhooks",
"mailgun_url": (
"https://documentation.mailgun.com/en/latest/user_manual.html#webhooks"
),
"docs_url": "https://www.home-assistant.io/integrations/mailgun/",
},
)

View File

@ -69,7 +69,10 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
_LOGGER.error("Unable to connect to Max!Cube gateway: %s", str(ex))
persistent_notification.create(
hass,
f"Error: {ex}<br />You will need to restart Home Assistant after fixing.",
(
f"Error: {ex}<br />You will need to restart Home Assistant after"
" fixing."
),
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID,
)

View File

@ -393,12 +393,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
elif value[ATTR_MEDIA_ENQUEUE] is True:
value[ATTR_MEDIA_ENQUEUE] = MediaPlayerEnqueue.ADD
_LOGGER.warning(
"Playing media with enqueue set to True is deprecated. Use 'add' instead"
"Playing media with enqueue set to True is deprecated. Use 'add'"
" instead"
)
elif value[ATTR_MEDIA_ENQUEUE] is False:
value[ATTR_MEDIA_ENQUEUE] = MediaPlayerEnqueue.PLAY
_LOGGER.warning(
"Playing media with enqueue set to False is deprecated. Use 'play' instead"
"Playing media with enqueue set to False is deprecated. Use 'play'"
" instead"
)
return value

View File

@ -240,7 +240,8 @@ class AtaDeviceClimate(MelCloudClimate):
"""Set horizontal vane position."""
if position not in self._device.vane_horizontal_positions:
raise ValueError(
f"Invalid horizontal vane position {position}. Valid positions: [{self._device.vane_horizontal_positions}]."
f"Invalid horizontal vane position {position}. Valid positions:"
f" [{self._device.vane_horizontal_positions}]."
)
await self._device.set({ata.PROPERTY_VANE_HORIZONTAL: position})
@ -248,7 +249,8 @@ class AtaDeviceClimate(MelCloudClimate):
"""Set vertical vane position."""
if position not in self._device.vane_vertical_positions:
raise ValueError(
f"Invalid vertical vane position {position}. Valid positions: [{self._device.vane_vertical_positions}]."
f"Invalid vertical vane position {position}. Valid positions:"
f" [{self._device.vane_vertical_positions}]."
)
await self._device.set({ata.PROPERTY_VANE_VERTICAL: position})

View File

@ -36,8 +36,7 @@ from . import MetDataUpdateCoordinator
from .const import ATTR_MAP, CONDITIONS_MAP, CONF_TRACK_HOME, DOMAIN, FORECAST_MAP
ATTRIBUTION = (
"Weather forecast from met.no, delivered by the Norwegian "
"Meteorological Institute."
"Weather forecast from met.no, delivered by the Norwegian Meteorological Institute."
)
DEFAULT_NAME = "Met.no"

View File

@ -139,13 +139,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN][department] = True
else:
_LOGGER.warning(
"Weather alert for department %s won't be added with city %s, as it has already been added within another city",
(
"Weather alert for department %s won't be added with city %s, as it"
" has already been added within another city"
),
department,
entry.title,
)
else:
_LOGGER.warning(
"Weather alert not available: The city %s is not in metropolitan France or Andorre",
(
"Weather alert not available: The city %s is not in metropolitan France"
" or Andorre"
),
entry.title,
)
@ -172,7 +178,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
].data.position.get("dept")
hass.data[DOMAIN][department] = False
_LOGGER.debug(
"Weather alert for depatment %s unloaded and released. It can be added now by another city",
(
"Weather alert for depatment %s unloaded and released. It can be added"
" now by another city"
),
department,
)

View File

@ -143,7 +143,10 @@ class MinecraftServer:
self.online = True
except OSError as error:
_LOGGER.debug(
"Error occurred while trying to check the connection to '%s:%s' - OSError: %s",
(
"Error occurred while trying to check the connection to '%s:%s' -"
" OSError: %s"
),
self.host,
self.port,
error,

View File

@ -268,8 +268,10 @@ async def webhook_call_service(
)
except (vol.Invalid, ServiceNotFound, Exception) as ex:
_LOGGER.error(
"Error when calling service during mobile_app "
"webhook (device name: %s): %s",
(
"Error when calling service during mobile_app "
"webhook (device name: %s): %s"
),
config_entry.data[ATTR_DEVICE_NAME],
ex,
)

View File

@ -322,7 +322,10 @@ class BaseSwitch(BasePlatform, ToggleEntity, RestoreEntity):
self._attr_is_on = False
elif value is not None:
_LOGGER.error(
"Unexpected response from modbus device slave %s register %s, got 0x%2x",
(
"Unexpected response from modbus device slave %s register %s,"
" got 0x%2x"
),
self._slave,
self._verify_address,
value,

View File

@ -111,7 +111,7 @@ def struct_validator(config: dict[str, Any]) -> dict[str, Any]:
if count < regs_needed or (count % regs_needed) != 0:
raise vol.Invalid(
f"Error in sensor {name} swap({swap_type}) "
f"not possible due to the registers "
"not possible due to the registers "
f"count: {count}, needed: {regs_needed}"
)
@ -153,8 +153,10 @@ def scan_interval_validator(config: dict) -> dict:
continue
if scan_interval < 5:
_LOGGER.warning(
"%s %s scan_interval(%d) is lower than 5 seconds, "
"which may cause Home Assistant stability issues",
(
"%s %s scan_interval(%d) is lower than 5 seconds, "
"which may cause Home Assistant stability issues"
),
component,
entry.get(CONF_NAME),
scan_interval,
@ -198,11 +200,17 @@ def duplicate_entity_validator(config: dict) -> dict:
addr += "_" + str(entry[CONF_COMMAND_OFF])
addr += "_" + str(entry.get(CONF_SLAVE, 0))
if addr in addresses:
err = f"Modbus {component}/{name} address {addr} is duplicate, second entry not loaded!"
err = (
f"Modbus {component}/{name} address {addr} is duplicate, second"
" entry not loaded!"
)
_LOGGER.warning(err)
errors.append(index)
elif name in names:
err = f"Modbus {component}/{name}  is duplicate, second entry not loaded!"
err = (
f"Modbus {component}/{name}  is duplicate, second entry not"
" loaded!"
)
_LOGGER.warning(err)
errors.append(index)
else:

View File

@ -145,5 +145,8 @@ class ModernFormsDeviceEntity(CoordinatorEntity[ModernFormsDataUpdateCoordinator
name=self.coordinator.data.info.device_name,
manufacturer="Modern Forms",
model=self.coordinator.data.info.fan_type,
sw_version=f"{self.coordinator.data.info.firmware_version} / {self.coordinator.data.info.main_mcu_firmware_version}",
sw_version=(
f"{self.coordinator.data.info.firmware_version} /"
f" {self.coordinator.data.info.main_mcu_firmware_version}"
),
)

View File

@ -46,7 +46,10 @@ class Alpha2HeatControlValveOpeningSensor(
self._attr_unique_id = f"{heat_control_id}:valve_opening"
heat_control = self.coordinator.data["heat_controls"][heat_control_id]
heat_area = self.coordinator.data["heat_areas"][heat_control["_HEATAREA_ID"]]
self._attr_name = f"{heat_area['HEATAREA_NAME']} heat control {heat_control['NR']} valve opening"
self._attr_name = (
f"{heat_area['HEATAREA_NAME']} heat control {heat_control['NR']} valve"
" opening"
)
@property
def native_value(self) -> int:

View File

@ -135,8 +135,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
data = {**entry.data, CONF_INTERFACE: working_interface}
hass.config_entries.async_update_entry(entry, data=data)
_LOGGER.debug(
"Motion Blinds interface updated from %s to %s, "
"this should only occur after a network change",
(
"Motion Blinds interface updated from %s to %s, "
"this should only occur after a network change"
),
multicast_interface,
working_interface,
)

View File

@ -133,7 +133,10 @@ class ConnectMotionGateway:
return interface
_LOGGER.error(
"Could not find working interface for Motion Blinds host %s, using interface '%s'",
(
"Could not find working interface for Motion Blinds host %s, using"
" interface '%s'"
),
host,
self._interface,
)

View File

@ -89,8 +89,8 @@ SERVICE_SET_TEXT_OVERLAY: Final = "set_text_overlay"
SERVICE_ACTION: Final = "action"
SERVICE_SNAPSHOT: Final = "snapshot"
SIGNAL_CAMERA_ADD: Final = f"{DOMAIN}_camera_add_signal." "{}"
SIGNAL_CAMERA_REMOVE: Final = f"{DOMAIN}_camera_remove_signal." "{}"
SIGNAL_CAMERA_ADD: Final = f"{DOMAIN}_camera_add_signal.{{}}"
SIGNAL_CAMERA_REMOVE: Final = f"{DOMAIN}_camera_remove_signal.{{}}"
TYPE_MOTIONEYE_ACTION_SENSOR = f"{DOMAIN}_action_sensor"
TYPE_MOTIONEYE_MJPEG_CAMERA: Final = "motioneye_mjpeg_camera"

View File

@ -240,8 +240,10 @@ def _filter_entry_config(hass: HomeAssistant, entry: ConfigEntry) -> None:
}
if entry.data.keys() != filtered_data.keys():
_LOGGER.warning(
"The following unsupported configuration options were removed from the "
"MQTT config entry: %s",
(
"The following unsupported configuration options were removed from the "
"MQTT config entry: %s"
),
entry.data.keys() - filtered_data.keys(),
)
hass.config_entries.async_update_entry(entry, data=filtered_data)
@ -329,8 +331,10 @@ async def async_fetch_config(
override[CONF_CLIENT_KEY] = "-----PRIVATE KEY-----"
if override:
_LOGGER.warning(
"Deprecated configuration settings found in configuration.yaml. "
"These settings from your configuration entry will override: %s",
(
"Deprecated configuration settings found in configuration.yaml. "
"These settings from your configuration entry will override: %s"
),
override,
)
# Register a repair issue
@ -389,16 +393,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
msg_topic = valid_publish_topic(rendered_topic)
except (jinja2.TemplateError, TemplateError) as exc:
_LOGGER.error(
"Unable to publish: rendering topic template of %s "
"failed because %s",
(
"Unable to publish: rendering topic template of %s "
"failed because %s"
),
msg_topic_template,
exc,
)
return
except vol.Invalid as err:
_LOGGER.error(
"Unable to publish: topic template '%s' produced an "
"invalid topic '%s' after rendering (%s)",
(
"Unable to publish: topic template '%s' produced an "
"invalid topic '%s' after rendering (%s)"
),
msg_topic_template,
rendered_topic,
err,
@ -412,8 +420,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
).async_render()
except (jinja2.TemplateError, TemplateError) as exc:
_LOGGER.error(
"Unable to publish to %s: rendering payload template of "
"%s failed because %s",
(
"Unable to publish to %s: rendering payload template of "
"%s failed because %s"
),
msg_topic,
payload_template,
exc,

View File

@ -145,7 +145,10 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
self.hass, self._value_is_expired, expiration_at
)
_LOGGER.debug(
"State recovered after reload for %s, remaining time before expiring %s",
(
"State recovered after reload for %s, remaining time before"
" expiring %s"
),
self.entity_id,
expiration_at - time_now,
)
@ -215,7 +218,10 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
payload = self._value_template(msg.payload)
if not payload.strip(): # No output from template, ignore
_LOGGER.debug(
"Empty template output for entity: %s with state topic: %s. Payload: '%s', with value template '%s'",
(
"Empty template output for entity: %s with state topic: %s."
" Payload: '%s', with value template '%s'"
),
self._config[CONF_NAME],
self._config[CONF_STATE_TOPIC],
msg.payload,
@ -232,9 +238,15 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
else: # Payload is not for this entity
template_info = ""
if self._config.get(CONF_VALUE_TEMPLATE) is not None:
template_info = f", template output: '{str(payload)}', with value template '{str(self._config.get(CONF_VALUE_TEMPLATE))}'"
template_info = (
f", template output: '{str(payload)}', with value template"
f" '{str(self._config.get(CONF_VALUE_TEMPLATE))}'"
)
_LOGGER.info(
"No matching payload found for entity: %s with state topic: %s. Payload: '%s'%s",
(
"No matching payload found for entity: %s with state topic: %s."
" Payload: '%s'%s"
),
self._config[CONF_NAME],
self._config[CONF_STATE_TOPIC],
msg.payload,

View File

@ -121,7 +121,10 @@ async def async_publish(
if not isinstance(payload, bytes):
if not encoding:
_LOGGER.error(
"Can't pass-through payload for publishing %s on %s with no encoding set, need 'bytes' got %s",
(
"Can't pass-through payload for publishing %s on %s with no"
" encoding set, need 'bytes' got %s"
),
payload,
topic,
type(payload),
@ -221,8 +224,10 @@ async def async_subscribe(
if non_default == 3:
module = inspect.getmodule(msg_callback)
_LOGGER.warning(
"Signature of MQTT msg_callback '%s.%s' is deprecated, "
"this will stop working with HA core 2023.2",
(
"Signature of MQTT msg_callback '%s.%s' is deprecated, "
"this will stop working with HA core 2023.2"
),
module.__name__ if module else "<unknown>",
msg_callback.__name__,
)

View File

@ -145,8 +145,7 @@ PLATFORM_CONFIG_SCHEMA_BASE = vol.Schema(
CLIENT_KEY_AUTH_MSG = (
"client_key and client_cert must both be present in "
"the MQTT broker configuration"
"client_key and client_cert must both be present in the MQTT broker configuration"
)
CONFIG_SCHEMA_ENTRY = vol.Schema(

View File

@ -120,7 +120,8 @@ def validate_options(config: ConfigType) -> ConfigType:
"""
if CONF_SET_POSITION_TOPIC in config and CONF_GET_POSITION_TOPIC not in config:
raise vol.Invalid(
f"'{CONF_SET_POSITION_TOPIC}' must be set together with '{CONF_GET_POSITION_TOPIC}'."
f"'{CONF_SET_POSITION_TOPIC}' must be set together with"
f" '{CONF_GET_POSITION_TOPIC}'."
)
# if templates are set make sure the topic for the template is also set
@ -132,22 +133,26 @@ def validate_options(config: ConfigType) -> ConfigType:
if CONF_GET_POSITION_TEMPLATE in config and CONF_GET_POSITION_TOPIC not in config:
raise vol.Invalid(
f"'{CONF_GET_POSITION_TEMPLATE}' must be set together with '{CONF_GET_POSITION_TOPIC}'."
f"'{CONF_GET_POSITION_TEMPLATE}' must be set together with"
f" '{CONF_GET_POSITION_TOPIC}'."
)
if CONF_SET_POSITION_TEMPLATE in config and CONF_SET_POSITION_TOPIC not in config:
raise vol.Invalid(
f"'{CONF_SET_POSITION_TEMPLATE}' must be set together with '{CONF_SET_POSITION_TOPIC}'."
f"'{CONF_SET_POSITION_TEMPLATE}' must be set together with"
f" '{CONF_SET_POSITION_TOPIC}'."
)
if CONF_TILT_COMMAND_TEMPLATE in config and CONF_TILT_COMMAND_TOPIC not in config:
raise vol.Invalid(
f"'{CONF_TILT_COMMAND_TEMPLATE}' must be set together with '{CONF_TILT_COMMAND_TOPIC}'."
f"'{CONF_TILT_COMMAND_TEMPLATE}' must be set together with"
f" '{CONF_TILT_COMMAND_TOPIC}'."
)
if CONF_TILT_STATUS_TEMPLATE in config and CONF_TILT_STATUS_TOPIC not in config:
raise vol.Invalid(
f"'{CONF_TILT_STATUS_TEMPLATE}' must be set together with '{CONF_TILT_STATUS_TOPIC}'."
f"'{CONF_TILT_STATUS_TEMPLATE}' must be set together with"
f" '{CONF_TILT_STATUS_TOPIC}'."
)
return config
@ -388,7 +393,10 @@ class MqttCover(MqttEntity, CoverEntity):
self._state = STATE_CLOSED
else:
_LOGGER.warning(
"Payload is not supported (e.g. open, closed, opening, closing, stopped): %s",
(
"Payload is not supported (e.g. open, closed, opening, closing,"
" stopped): %s"
),
payload,
)
return
@ -414,7 +422,8 @@ class MqttCover(MqttEntity, CoverEntity):
if payload_dict and isinstance(payload_dict, dict):
if "position" not in payload_dict:
_LOGGER.warning(
"Template (position_template) returned JSON without position attribute"
"Template (position_template) returned JSON without position"
" attribute"
)
return
if "tilt_position" in payload_dict:

View File

@ -108,9 +108,12 @@ async def async_start( # noqa: C901
if not (match := TOPIC_MATCHER.match(topic_trimmed)):
if topic_trimmed.endswith("config"):
_LOGGER.warning(
"Received message on illegal discovery topic '%s'. The topic contains "
"not allowed characters. For more information see "
"https://www.home-assistant.io/docs/mqtt/discovery/#discovery-topic",
(
"Received message on illegal discovery topic '%s'. The topic"
" contains "
"not allowed characters. For more information see "
"https://www.home-assistant.io/docs/mqtt/discovery/#discovery-topic"
),
topic,
)
return

View File

@ -386,7 +386,10 @@ class MqttFan(MqttEntity, FanEntity):
)
except ValueError:
_LOGGER.warning(
"'%s' received on topic %s. '%s' is not a valid speed within the speed range",
(
"'%s' received on topic %s. '%s' is not a valid speed within"
" the speed range"
),
msg.payload,
msg.topic,
rendered_percentage_payload,
@ -394,7 +397,10 @@ class MqttFan(MqttEntity, FanEntity):
return
if percentage < 0 or percentage > 100:
_LOGGER.warning(
"'%s' received on topic %s. '%s' is not a valid speed within the speed range",
(
"'%s' received on topic %s. '%s' is not a valid speed within"
" the speed range"
),
msg.payload,
msg.topic,
rendered_percentage_payload,

View File

@ -244,9 +244,11 @@ def warn_for_legacy_schema(domain: str) -> Callable[[ConfigType], ConfigType]:
return config
_LOGGER.error(
"Manually configured MQTT %s(s) found under platform key '%s', "
"please move to the mqtt integration key, see "
"https://www.home-assistant.io/integrations/%s.mqtt/#new_format",
(
"Manually configured MQTT %s(s) found under platform key '%s', "
"please move to the mqtt integration key, see "
"https://www.home-assistant.io/integrations/%s.mqtt/#new_format"
),
domain,
domain,
domain,
@ -316,8 +318,10 @@ async def async_setup_entry_helper(
"""Discover and add an MQTT entity, automation or tag."""
if not mqtt_config_entry_enabled(hass):
_LOGGER.warning(
"MQTT integration is disabled, skipping setup of discovered item "
"MQTT %s, payload %s",
(
"MQTT integration is disabled, skipping setup of discovered item "
"MQTT %s, payload %s"
),
domain,
discovery_payload,
)

View File

@ -237,7 +237,10 @@ class MqttValueTemplate:
return rendered_payload
_LOGGER.debug(
"Rendering incoming payload '%s' with variables %s with default value '%s' and %s",
(
"Rendering incoming payload '%s' with variables %s with default value"
" '%s' and %s"
),
payload,
values,
default,

View File

@ -198,7 +198,10 @@ class MqttSensor(MqttEntity, RestoreSensor):
self.hass, self._value_is_expired, expiration_at
)
_LOGGER.debug(
"State recovered after reload for %s, remaining time before expiring %s",
(
"State recovered after reload for %s, remaining time before"
" expiring %s"
),
self.entity_id,
expiration_at - time_now,
)

View File

@ -249,13 +249,19 @@ class MqttSiren(MqttEntity, SirenEntity):
try:
json_payload = json_loads(payload)
_LOGGER.debug(
"JSON payload detected after processing payload '%s' on topic %s",
(
"JSON payload detected after processing payload '%s' on"
" topic %s"
),
json_payload,
msg.topic,
)
except JSON_DECODE_EXCEPTIONS:
_LOGGER.warning(
"No valid (JSON) payload detected after processing payload '%s' on topic %s",
(
"No valid (JSON) payload detected after processing payload"
" '%s' on topic %s"
),
json_payload,
msg.topic,
)

View File

@ -177,20 +177,29 @@ class MqttUpdate(MqttEntity, UpdateEntity, RestoreEntity):
json_payload = json_loads(payload)
if isinstance(json_payload, dict):
_LOGGER.debug(
"JSON payload detected after processing payload '%s' on topic %s",
(
"JSON payload detected after processing payload '%s' on"
" topic %s"
),
json_payload,
msg.topic,
)
else:
_LOGGER.debug(
"Non-dictionary JSON payload detected after processing payload '%s' on topic %s",
(
"Non-dictionary JSON payload detected after processing"
" payload '%s' on topic %s"
),
payload,
msg.topic,
)
json_payload = {"installed_version": payload}
except JSON_DECODE_EXCEPTIONS:
_LOGGER.debug(
"No valid (JSON) payload detected after processing payload '%s' on topic %s",
(
"No valid (JSON) payload detected after processing payload '%s'"
" on topic %s"
),
payload,
msg.topic,
)

View File

@ -84,8 +84,7 @@ def valid_subscribe_topic(topic: Any) -> str:
if index != len(validated_topic) - 1:
# If there are multiple wildcards, this will also trigger
raise vol.Invalid(
"Multi-level wildcard must be the last "
"character in the topic filter."
"Multi-level wildcard must be the last character in the topic filter."
)
if len(validated_topic) > 1 and validated_topic[index - 1] != "/":
raise vol.Invalid(

View File

@ -59,8 +59,10 @@ async def async_setup_scanner(
data = GPS_JSON_PAYLOAD_SCHEMA(json.loads(msg.payload))
except vol.MultipleInvalid:
_LOGGER.error(
"Skipping update for following data "
"because of missing or malformatted data: %s",
(
"Skipping update for following data "
"because of missing or malformatted data: %s"
),
msg.payload,
)
return

View File

@ -270,7 +270,9 @@ async def async_import_config(hass: HomeAssistant, entry: ConfigEntry) -> None:
severity=IssueSeverity.ERROR,
translation_key="removed_app_auth",
translation_placeholders={
"more_info_url": "https://www.home-assistant.io/more-info/nest-auth-deprecation",
"more_info_url": (
"https://www.home-assistant.io/more-info/nest-auth-deprecation"
),
"documentation_url": "https://www.home-assistant.io/integrations/nest/",
},
)
@ -333,7 +335,10 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
await subscriber.delete_subscription()
except (AuthException, SubscriberException) as err:
_LOGGER.warning(
"Unable to delete subscription '%s'; Will be automatically cleaned up by cloud console: %s",
(
"Unable to delete subscription '%s'; Will be automatically cleaned up"
" by cloud console: %s"
),
subscriber.subscriber_id,
err,
)

View File

@ -17,7 +17,9 @@ async def async_get_authorization_server(hass: HomeAssistant) -> AuthorizationSe
async def async_get_description_placeholders(hass: HomeAssistant) -> dict[str, str]:
"""Return description placeholders for the credentials dialog."""
return {
"oauth_consent_url": "https://console.cloud.google.com/apis/credentials/consent",
"oauth_consent_url": (
"https://console.cloud.google.com/apis/credentials/consent"
),
"more_info_url": "https://www.home-assistant.io/integrations/nest/",
"oauth_creds_url": "https://console.cloud.google.com/apis/credentials",
"redirect_url": "https://my.home-assistant.io/redirect/oauth",

View File

@ -333,7 +333,8 @@ class NestFlowHandler(
project_id = user_input[CONF_PROJECT_ID]
if project_id == self._data[CONF_CLOUD_PROJECT_ID]:
_LOGGER.error(
"Device Access Project ID and Cloud Project ID must not be the same, see documentation"
"Device Access Project ID and Cloud Project ID must not be the"
" same, see documentation"
)
errors[CONF_PROJECT_ID] = "wrong_project_id"
else:

View File

@ -192,8 +192,10 @@ async def async_setup_legacy_entry(hass: HomeAssistant, entry: ConfigEntry) -> b
eta_window = service.data.get(ATTR_ETA_WINDOW, timedelta(minutes=1))
eta_end = eta_begin + eta_window
_LOGGER.info(
"Setting ETA for trip: %s, "
"ETA window starts at: %s and ends at: %s",
(
"Setting ETA for trip: %s, "
"ETA window starts at: %s and ends at: %s"
),
trip_id,
eta_begin,
eta_end,
@ -221,8 +223,7 @@ async def async_setup_legacy_entry(hass: HomeAssistant, entry: ConfigEntry) -> b
structure.cancel_eta(trip_id)
else:
_LOGGER.info(
"No thermostats found in structure: %s, "
"unable to cancel ETA",
"No thermostats found in structure: %s, unable to cancel ETA",
structure.name,
)
@ -333,9 +334,11 @@ class NestLegacyDevice:
device.name_long
except KeyError:
_LOGGER.warning(
"Cannot retrieve device name for [%s]"
", please check your Nest developer "
"account permission settings",
(
"Cannot retrieve device name for [%s]"
", please check your Nest developer "
"account permission settings"
),
device.serial,
)
continue

View File

@ -48,8 +48,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
data = {**entry.data, CONF_PORT: router.port, CONF_SSL: router.ssl}
hass.config_entries.async_update_entry(entry, data=data)
_LOGGER.info(
"Netgear port-SSL combination updated from (%i, %r) to (%i, %r), "
"this should only occur after a firmware update",
(
"Netgear port-SSL combination updated from (%i, %r) to (%i, %r), "
"this should only occur after a firmware update"
),
port,
ssl,
router.port,

View File

@ -132,7 +132,10 @@ class NetgearRouter:
if self.method_version == 2 and self.track_devices:
if not self.api.get_attached_devices_2():
_LOGGER.error(
"Netgear Model '%s' in MODELS_V2 list, but failed to get attached devices using V2",
(
"Netgear Model '%s' in MODELS_V2 list, but failed to get"
" attached devices using V2"
),
self.model,
)
self.method_version = 1

View File

@ -51,11 +51,13 @@ async def async_get_source_ip(
if not all_ipv4s:
_LOGGER.warning(
"Because the system does not have any enabled IPv4 addresses, source address detection may be inaccurate"
"Because the system does not have any enabled IPv4 addresses, source"
" address detection may be inaccurate"
)
if source_ip is None:
raise HomeAssistantError(
"Could not determine source ip because the system does not have any enabled IPv4 addresses and creating a socket failed"
"Could not determine source ip because the system does not have any"
" enabled IPv4 addresses and creating a socket failed"
)
return source_ip

View File

@ -142,7 +142,10 @@ def async_get_source_ip(target_ip: str) -> str | None:
return cast(str, test_sock.getsockname()[0])
except Exception: # pylint: disable=broad-except
_LOGGER.debug(
"The system could not auto detect the source ip for %s on your operating system",
(
"The system could not auto detect the source ip for %s on your"
" operating system"
),
target_ip,
)
return None

View File

@ -587,7 +587,8 @@ class NextDnsSwitch(CoordinatorEntity[NextDnsSettingsUpdateCoordinator], SwitchE
ClientError,
) as err:
raise HomeAssistantError(
f"NextDNS API returned an error calling set_setting for {self.entity_id}: {err}"
"NextDNS API returned an error calling set_setting for"
f" {self.entity_id}: {err}"
) from err
if result:

View File

@ -97,16 +97,20 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
vol.Exclusive(
CONF_AREA,
"station_collection",
"Can only configure one specific station or "
"stations in a specific area pr sensor. "
"Please only configure station or area.",
(
"Can only configure one specific station or "
"stations in a specific area pr sensor. "
"Please only configure station or area."
),
): vol.All(cv.string, vol.In(CONF_ALLOWED_AREAS)),
vol.Exclusive(
CONF_STATION,
"station_collection",
"Can only configure one specific station or "
"stations in a specific area pr sensor. "
"Please only configure station or area.",
(
"Can only configure one specific station or "
"stations in a specific area pr sensor. "
"Please only configure station or area."
),
): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_SHOW_ON_MAP, default=False): cv.boolean,

View File

@ -343,7 +343,10 @@ class NmapDeviceScanner:
return
if device.first_offline + self.consider_home > now:
_LOGGER.debug(
"Device %s (%s) has NOT been offline (first offline at: %s) long enough to be considered not home: %s",
(
"Device %s (%s) has NOT been offline (first offline at: %s) long"
" enough to be considered not home: %s"
),
ipv4,
formatted_mac,
device.first_offline,
@ -351,7 +354,10 @@ class NmapDeviceScanner:
)
return
_LOGGER.debug(
"Device %s (%s) has been offline (first offline at: %s) long enough to be considered not home: %s",
(
"Device %s (%s) has been offline (first offline at: %s) long enough to"
" be considered not home: %s"
),
ipv4,
formatted_mac,
device.first_offline,

View File

@ -115,7 +115,8 @@ class NoboZone(ClimateEntity):
"""Set new target HVAC mode, if it's supported."""
if hvac_mode not in self.hvac_modes:
raise ValueError(
f"Zone {self._id} '{self._attr_name}' called with unsupported HVAC mode '{hvac_mode}'"
f"Zone {self._id} '{self._attr_name}' called with unsupported HVAC mode"
f" '{hvac_mode}'"
)
if hvac_mode == HVACMode.AUTO:
await self.async_set_preset_mode(PRESET_NONE)

View File

@ -151,8 +151,8 @@ def check_templates_warn(hass: HomeAssistant, tpl: template.Template) -> None:
hass.data["notify_template_warned"] = True
LOGGER.warning(
"Passing templates to notify service is deprecated and will be removed in 2021.12. "
"Automations and scripts handle templates automatically"
"Passing templates to notify service is deprecated and will be removed in"
" 2021.12. Automations and scripts handle templates automatically"
)
@ -301,7 +301,10 @@ class BaseNotificationService:
# Register the service description
service_desc = {
CONF_NAME: f"Send a notification via {target_name}",
CONF_DESCRIPTION: f"Sends a notification message using the {target_name} integration.",
CONF_DESCRIPTION: (
"Sends a notification message using the"
f" {target_name} integration."
),
CONF_FIELDS: self.services_dict[SERVICE_NOTIFY][CONF_FIELDS],
}
async_set_service_schema(self.hass, DOMAIN, target_name, service_desc)
@ -326,7 +329,9 @@ class BaseNotificationService:
# Register the service description
service_desc = {
CONF_NAME: f"Send a notification with {self._service_name}",
CONF_DESCRIPTION: f"Sends a notification message using the {self._service_name} service.",
CONF_DESCRIPTION: (
f"Sends a notification message using the {self._service_name} service."
),
CONF_FIELDS: self.services_dict[SERVICE_NOTIFY][CONF_FIELDS],
}
async_set_service_schema(self.hass, DOMAIN, self._service_name, service_desc)

View File

@ -209,8 +209,12 @@ class NumatoAPI:
f"Port {port} is not set up for numato device {device_id}."
)
msg = {
gpio.OUT: f"Trying to write to device {device_id} port {port} set up as input.",
gpio.IN: f"Trying to read from device {device_id} port {port} set up as output.",
gpio.OUT: (
f"Trying to write to device {device_id} port {port} set up as input."
),
gpio.IN: (
f"Trying to read from device {device_id} port {port} set up as output."
),
}
if self.ports_registered[(device_id, port)] != direction:
raise gpio.NumatoGpioError(msg[direction])

View File

@ -58,7 +58,10 @@ def setup_platform(
except NumatoGpioError as err:
_LOGGER.error(
"Failed to initialize binary sensor '%s' on Numato device %s port %s: %s",
(
"Failed to initialize binary sensor '%s' on Numato device %s"
" port %s: %s"
),
port_name,
device_id,
port,

View File

@ -376,7 +376,8 @@ async def async_set_value(entity: NumberEntity, service_call: ServiceCall) -> No
value = service_call.data["value"]
if value < entity.min_value or value > entity.max_value:
raise ValueError(
f"Value {value} for {entity.name} is outside valid range {entity.min_value} - {entity.max_value}"
f"Value {value} for {entity.name} is outside valid range"
f" {entity.min_value} - {entity.max_value}"
)
try:
native_value = entity.convert_to_native_value(value)
@ -436,9 +437,11 @@ class NumberEntityDescription(EntityDescription):
"https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue"
)
_LOGGER.warning(
"%s is setting deprecated attributes on an instance of "
"NumberEntityDescription, this is not valid and will be unsupported "
"from Home Assistant 2022.10. Please %s",
(
"%s is setting deprecated attributes on an instance of"
" NumberEntityDescription, this is not valid and will be"
" unsupported from Home Assistant 2022.10. Please %s"
),
module.__name__ if module else self.__class__.__name__,
report_issue,
)
@ -507,9 +510,11 @@ class NumberEntity(Entity):
"https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue"
)
_LOGGER.warning(
"%s::%s is overriding deprecated methods on an instance of "
"NumberEntity, this is not valid and will be unsupported "
"from Home Assistant 2022.10. Please %s",
(
"%s::%s is overriding deprecated methods on an instance of "
"NumberEntity, this is not valid and will be unsupported "
"from Home Assistant 2022.10. Please %s"
),
cls.__module__,
cls.__name__,
report_issue,
@ -772,8 +777,10 @@ class NumberEntity(Entity):
self._deprecated_number_entity_reported = True
report_issue = self._suggest_report_issue()
_LOGGER.warning(
"Entity %s (%s) is using deprecated NumberEntity features which will "
"be unsupported from Home Assistant Core 2022.10, please %s",
(
"Entity %s (%s) is using deprecated NumberEntity features which"
" will be unsupported from Home Assistant Core 2022.10, please %s"
),
self.entity_id,
type(self),
report_issue,

View File

@ -365,7 +365,8 @@ class OnkyoDevice(MediaPlayerEntity):
"""
# HA_VOL * (MAX VOL / 100) * MAX_RECEIVER_VOL
self.command(
f"volume {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}"
"volume"
f" {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}"
)
def volume_up(self) -> None:

View File

@ -213,7 +213,10 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
raise fault
LOGGER.debug(
"Couldn't get network interfaces from ONVIF deivice '%s'. Error: %s",
(
"Couldn't get network interfaces from ONVIF deivice '%s'."
" Error: %s"
),
self.onvif_config[CONF_NAME],
fault,
)

View File

@ -135,8 +135,10 @@ class ONVIFDevice:
await self.device.close()
except Fault as err:
LOGGER.error(
"Couldn't connect to camera '%s', please verify "
"that the credentials are correct. Error: %s",
(
"Couldn't connect to camera '%s', please verify "
"that the credentials are correct. Error: %s"
),
self.name,
err,
)
@ -230,9 +232,11 @@ class ONVIFDevice:
if self._dt_diff_seconds > 5:
LOGGER.warning(
"The date/time on %s (UTC) is '%s', "
"which is different from the system '%s', "
"this could lead to authentication issues",
(
"The date/time on %s (UTC) is '%s', "
"which is different from the system '%s', "
"this could lead to authentication issues"
),
self.name,
cam_date_utc,
system_date,
@ -384,7 +388,10 @@ class ONVIFDevice:
speed_val = speed
preset_val = preset
LOGGER.debug(
"Calling %s PTZ | Pan = %4.2f | Tilt = %4.2f | Zoom = %4.2f | Speed = %4.2f | Preset = %s",
(
"Calling %s PTZ | Pan = %4.2f | Tilt = %4.2f | Zoom = %4.2f | Speed ="
" %4.2f | Preset = %s"
),
move_mode,
pan_val,
tilt_val,
@ -461,7 +468,10 @@ class ONVIFDevice:
return
if preset_val not in profile.ptz.presets:
LOGGER.warning(
"PTZ preset '%s' does not exist on device '%s'. Available Presets: %s",
(
"PTZ preset '%s' does not exist on device '%s'. Available"
" Presets: %s"
),
preset_val,
self.name,
", ".join(profile.ptz.presets),

View File

@ -126,8 +126,10 @@ class EventManager:
await self._subscription.Unsubscribe()
except (XMLParseError, *SUBSCRIPTION_ERRORS) as err:
LOGGER.debug(
"Failed to unsubscribe ONVIF PullPoint subscription for '%s';"
" This is normal if the device restarted: %s",
(
"Failed to unsubscribe ONVIF PullPoint subscription for '%s';"
" This is normal if the device restarted: %s"
),
self.unique_id,
err,
)
@ -141,8 +143,10 @@ class EventManager:
# when we get an XMLParseError
LOGGER.log(
DEBUG if isinstance(err, XMLParseError) else WARNING,
"Failed to restart ONVIF PullPoint subscription for '%s'; "
"Retrying later: %s",
(
"Failed to restart ONVIF PullPoint subscription for '%s'; "
"Retrying later: %s"
),
self.unique_id,
err,
)
@ -194,7 +198,10 @@ class EventManager:
# when we get an XMLParseError
LOGGER.log(
DEBUG if isinstance(err, XMLParseError) else WARNING,
"Failed to fetch ONVIF PullPoint subscription messages for '%s': %s",
(
"Failed to fetch ONVIF PullPoint subscription messages for"
" '%s': %s"
),
self.unique_id,
err,
)

View File

@ -70,10 +70,12 @@ async def async_setup_entry(
if deprecated_sensors:
_LOGGER.warning(
"The following binary_sensor entities are deprecated and may "
"no longer behave as expected. They will be removed in a "
"future version. You can force removal of these entities by "
"disabling them and restarting Home Assistant.\n%s",
(
"The following binary_sensor entities are deprecated and may "
"no longer behave as expected. They will be removed in a "
"future version. You can force removal of these entities by "
"disabling them and restarting Home Assistant.\n%s"
),
pformat([s.entity_id for s in deprecated_sensors]),
)

View File

@ -73,10 +73,12 @@ async def async_setup_entry(
if deprecated_sensors:
_LOGGER.warning(
"The following sensor entities are deprecated and may no "
"longer behave as expected. They will be removed in a future "
"version. You can force removal of these entities by disabling "
"them and restarting Home Assistant.\n%s",
(
"The following sensor entities are deprecated and may no "
"longer behave as expected. They will be removed in a future "
"version. You can force removal of these entities by disabling "
"them and restarting Home Assistant.\n%s"
),
pformat([s.entity_id for s in deprecated_sensors]),
)

View File

@ -151,8 +151,7 @@ class OppleLight(LightEntity):
_LOGGER.debug("Update light %s success: power off", self._device.ip)
else:
_LOGGER.debug(
"Update light %s success: power on brightness %s "
"color temperature %s",
"Update light %s success: power on brightness %s color temperature %s",
self._device.ip,
self._brightness,
self._color_temp,

View File

@ -412,7 +412,9 @@ class OsramLightifyLight(Luminary):
"""Update static attributes of the luminary."""
super().update_static_attributes()
attrs = {
"device_type": f"{self._luminary.type_id()} ({self._luminary.devicename()})",
"device_type": (
f"{self._luminary.type_id()} ({self._luminary.devicename()})"
),
"firmware_version": self._luminary.version(),
}
if self._luminary.devicetype().name == "SENSOR":