mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Improve formatting in component files (#135261)
* Improve formatting in component files * Apply suggestions from code review
This commit is contained in:
parent
eba090c9ef
commit
24c70caf33
@ -66,7 +66,7 @@ class AdvantageAirZoneMotion(AdvantageAirZoneEntity, BinarySensorEntity):
|
|||||||
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
||||||
"""Initialize an Advantage Air Zone Motion sensor."""
|
"""Initialize an Advantage Air Zone Motion sensor."""
|
||||||
super().__init__(instance, ac_key, zone_key)
|
super().__init__(instance, ac_key, zone_key)
|
||||||
self._attr_name = f'{self._zone["name"]} motion'
|
self._attr_name = f"{self._zone['name']} motion"
|
||||||
self._attr_unique_id += "-motion"
|
self._attr_unique_id += "-motion"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -84,7 +84,7 @@ class AdvantageAirZoneMyZone(AdvantageAirZoneEntity, BinarySensorEntity):
|
|||||||
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
||||||
"""Initialize an Advantage Air Zone MyZone sensor."""
|
"""Initialize an Advantage Air Zone MyZone sensor."""
|
||||||
super().__init__(instance, ac_key, zone_key)
|
super().__init__(instance, ac_key, zone_key)
|
||||||
self._attr_name = f'{self._zone["name"]} myZone'
|
self._attr_name = f"{self._zone['name']} myZone"
|
||||||
self._attr_unique_id += "-myzone"
|
self._attr_unique_id += "-myzone"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -103,7 +103,7 @@ class AdvantageAirZoneVent(AdvantageAirZoneEntity, SensorEntity):
|
|||||||
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
||||||
"""Initialize an Advantage Air Zone Vent Sensor."""
|
"""Initialize an Advantage Air Zone Vent Sensor."""
|
||||||
super().__init__(instance, ac_key, zone_key=zone_key)
|
super().__init__(instance, ac_key, zone_key=zone_key)
|
||||||
self._attr_name = f'{self._zone["name"]} vent'
|
self._attr_name = f"{self._zone['name']} vent"
|
||||||
self._attr_unique_id += "-vent"
|
self._attr_unique_id += "-vent"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -131,7 +131,7 @@ class AdvantageAirZoneSignal(AdvantageAirZoneEntity, SensorEntity):
|
|||||||
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
||||||
"""Initialize an Advantage Air Zone wireless signal sensor."""
|
"""Initialize an Advantage Air Zone wireless signal sensor."""
|
||||||
super().__init__(instance, ac_key, zone_key)
|
super().__init__(instance, ac_key, zone_key)
|
||||||
self._attr_name = f'{self._zone["name"]} signal'
|
self._attr_name = f"{self._zone['name']} signal"
|
||||||
self._attr_unique_id += "-signal"
|
self._attr_unique_id += "-signal"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -165,7 +165,7 @@ class AdvantageAirZoneTemp(AdvantageAirZoneEntity, SensorEntity):
|
|||||||
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
def __init__(self, instance: AdvantageAirData, ac_key: str, zone_key: str) -> None:
|
||||||
"""Initialize an Advantage Air Zone Temp Sensor."""
|
"""Initialize an Advantage Air Zone Temp Sensor."""
|
||||||
super().__init__(instance, ac_key, zone_key)
|
super().__init__(instance, ac_key, zone_key)
|
||||||
self._attr_name = f'{self._zone["name"]} temperature'
|
self._attr_name = f"{self._zone['name']} temperature"
|
||||||
self._attr_unique_id += "-temp"
|
self._attr_unique_id += "-temp"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -155,8 +155,7 @@ class AirthingsHeaterEnergySensor(
|
|||||||
self._id = airthings_device.device_id
|
self._id = airthings_device.device_id
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
configuration_url=(
|
configuration_url=(
|
||||||
"https://dashboard.airthings.com/devices/"
|
f"https://dashboard.airthings.com/devices/{airthings_device.device_id}"
|
||||||
f"{airthings_device.device_id}"
|
|
||||||
),
|
),
|
||||||
identifiers={(DOMAIN, airthings_device.device_id)},
|
identifiers={(DOMAIN, airthings_device.device_id)},
|
||||||
name=airthings_device.name,
|
name=airthings_device.name,
|
||||||
|
@ -50,7 +50,7 @@ SENSOR_DESCRIPTIONS = (
|
|||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value_fn=lambda settings, status, measurements, history: int(
|
value_fn=lambda settings, status, measurements, history: int(
|
||||||
history.get(
|
history.get(
|
||||||
f'Outdoor {"AQI(US)" if settings["is_aqi_usa"] else "AQI(CN)"}', -1
|
f"Outdoor {'AQI(US)' if settings['is_aqi_usa'] else 'AQI(CN)'}", -1
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
translation_key="outdoor_air_quality_index",
|
translation_key="outdoor_air_quality_index",
|
||||||
|
@ -636,9 +636,9 @@ class AutomationEntity(BaseAutomationEntity, RestoreEntity):
|
|||||||
alias = ""
|
alias = ""
|
||||||
if "trigger" in run_variables:
|
if "trigger" in run_variables:
|
||||||
if "description" in run_variables["trigger"]:
|
if "description" in run_variables["trigger"]:
|
||||||
reason = f' by {run_variables["trigger"]["description"]}'
|
reason = f" by {run_variables['trigger']['description']}"
|
||||||
if "alias" in run_variables["trigger"]:
|
if "alias" in run_variables["trigger"]:
|
||||||
alias = f' trigger \'{run_variables["trigger"]["alias"]}\''
|
alias = f" trigger '{run_variables['trigger']['alias']}'"
|
||||||
self._logger.debug("Automation%s triggered%s", alias, reason)
|
self._logger.debug("Automation%s triggered%s", alias, reason)
|
||||||
|
|
||||||
# Create a new context referring to the old context.
|
# Create a new context referring to the old context.
|
||||||
|
@ -20,7 +20,7 @@ class BalboaEntity(Entity):
|
|||||||
"""Initialize the control."""
|
"""Initialize the control."""
|
||||||
mac = client.mac_address
|
mac = client.mac_address
|
||||||
model = client.model
|
model = client.model
|
||||||
self._attr_unique_id = f'{model}-{key}-{mac.replace(":","")[-6:]}'
|
self._attr_unique_id = f"{model}-{key}-{mac.replace(':', '')[-6:]}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, mac)},
|
identifiers={(DOMAIN, mac)},
|
||||||
name=model,
|
name=model,
|
||||||
|
@ -136,7 +136,7 @@ def _extract_blueprint_from_community_topic(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return ImportedBlueprint(
|
return ImportedBlueprint(
|
||||||
f'{post["username"]}/{topic["slug"]}', block_content, blueprint
|
f"{post['username']}/{topic['slug']}", block_content, blueprint
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ def async_describe_events(
|
|||||||
"""Describe bthome logbook event."""
|
"""Describe bthome logbook event."""
|
||||||
data = event.data
|
data = event.data
|
||||||
device = dev_reg.async_get(data["device_id"])
|
device = dev_reg.async_get(data["device_id"])
|
||||||
name = device and device.name or f'BTHome {data["address"]}'
|
name = device and device.name or f"BTHome {data['address']}"
|
||||||
if properties := data["event_properties"]:
|
if properties := data["event_properties"]:
|
||||||
message = f"{data['event_class']} {data['event_type']}: {properties}"
|
message = f"{data['event_class']} {data['event_type']}: {properties}"
|
||||||
else:
|
else:
|
||||||
|
@ -42,7 +42,7 @@ def datapoints_greater_than_degree(value: dict) -> dict:
|
|||||||
if len(value[CONF_DATAPOINTS]) <= value[CONF_DEGREE]:
|
if len(value[CONF_DATAPOINTS]) <= value[CONF_DEGREE]:
|
||||||
raise vol.Invalid(
|
raise vol.Invalid(
|
||||||
f"{CONF_DATAPOINTS} must have at least"
|
f"{CONF_DATAPOINTS} must have at least"
|
||||||
f" {value[CONF_DEGREE]+1} {CONF_DATAPOINTS}"
|
f" {value[CONF_DEGREE] + 1} {CONF_DATAPOINTS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
@ -266,7 +266,7 @@ class Doods(ImageProcessingEntity):
|
|||||||
|
|
||||||
# Draw detected objects
|
# Draw detected objects
|
||||||
for instance in values:
|
for instance in values:
|
||||||
box_label = f'{label} {instance["score"]:.1f}%'
|
box_label = f"{label} {instance['score']:.1f}%"
|
||||||
# Already scaled, use 1 for width and height
|
# Already scaled, use 1 for width and height
|
||||||
draw_box(
|
draw_box(
|
||||||
draw,
|
draw,
|
||||||
|
@ -85,7 +85,7 @@ class DukeEnergyCoordinator(DataUpdateCoordinator[None]):
|
|||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
id_prefix = f"{meter["serviceType"].lower()}_{serial_number}"
|
id_prefix = f"{meter['serviceType'].lower()}_{serial_number}"
|
||||||
consumption_statistic_id = f"{DOMAIN}:{id_prefix}_energy_consumption"
|
consumption_statistic_id = f"{DOMAIN}:{id_prefix}_energy_consumption"
|
||||||
self._statistic_ids.add(consumption_statistic_id)
|
self._statistic_ids.add(consumption_statistic_id)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
@ -136,7 +136,7 @@ class DukeEnergyCoordinator(DataUpdateCoordinator[None]):
|
|||||||
)
|
)
|
||||||
|
|
||||||
name_prefix = (
|
name_prefix = (
|
||||||
f"Duke Energy " f"{meter["serviceType"].capitalize()} {serial_number}"
|
f"Duke Energy {meter['serviceType'].capitalize()} {serial_number}"
|
||||||
)
|
)
|
||||||
consumption_metadata = StatisticMetaData(
|
consumption_metadata = StatisticMetaData(
|
||||||
has_mean=False,
|
has_mean=False,
|
||||||
|
@ -603,7 +603,7 @@ class Thermostat(ClimateEntity):
|
|||||||
"""Return the remote sensor device name_by_user or name for the thermostat."""
|
"""Return the remote sensor device name_by_user or name for the thermostat."""
|
||||||
return sorted(
|
return sorted(
|
||||||
[
|
[
|
||||||
f'{item["name_by_user"]} ({item["id"]})'
|
f"{item['name_by_user']} ({item['id']})"
|
||||||
for item in self.remote_sensor_ids_names
|
for item in self.remote_sensor_ids_names
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -873,7 +873,7 @@ class Thermostat(ClimateEntity):
|
|||||||
translation_placeholders={
|
translation_placeholders={
|
||||||
"options": ", ".join(
|
"options": ", ".join(
|
||||||
[
|
[
|
||||||
f'{item["name_by_user"]} ({item["id"]})'
|
f"{item['name_by_user']} ({item['id']})"
|
||||||
for item in self.remote_sensor_ids_names
|
for item in self.remote_sensor_ids_names
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -34,7 +34,7 @@ class EcobeeNotifyEntity(EcobeeBaseEntity, NotifyEntity):
|
|||||||
"""Initialize the thermostat."""
|
"""Initialize the thermostat."""
|
||||||
super().__init__(data, thermostat_index)
|
super().__init__(data, thermostat_index)
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{self.thermostat["identifier"]}_notify_{thermostat_index}"
|
f"{self.thermostat['identifier']}_notify_{thermostat_index}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_message(self, message: str, title: str | None = None) -> None:
|
def send_message(self, message: str, title: str | None = None) -> None:
|
||||||
|
@ -133,7 +133,7 @@ async def _async_migrate_unique_ids(hass: HomeAssistant, entry: ConfigEntry) ->
|
|||||||
and mac_matches_by_one(entity_mac, unique_id)
|
and mac_matches_by_one(entity_mac, unique_id)
|
||||||
):
|
):
|
||||||
# Old format {dhcp_mac}....., New format {discovery_mac}....
|
# Old format {dhcp_mac}....., New format {discovery_mac}....
|
||||||
new_unique_id = f"{unique_id}{entity_unique_id[len(unique_id):]}"
|
new_unique_id = f"{unique_id}{entity_unique_id[len(unique_id) :]}"
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
|
@ -794,7 +794,7 @@ class LoggerSensor(_FroniusSensorEntity):
|
|||||||
"unit"
|
"unit"
|
||||||
)
|
)
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f'{logger_data["unique_identifier"]["value"]}-{description.key}'
|
f"{logger_data['unique_identifier']['value']}-{description.key}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -815,7 +815,7 @@ class MeterSensor(_FroniusSensorEntity):
|
|||||||
if (meter_uid := meter_data["serial"]["value"]) == "n.a.":
|
if (meter_uid := meter_data["serial"]["value"]) == "n.a.":
|
||||||
meter_uid = (
|
meter_uid = (
|
||||||
f"{coordinator.solar_net.solar_net_device_id}:"
|
f"{coordinator.solar_net.solar_net_device_id}:"
|
||||||
f'{meter_data["model"]["value"]}'
|
f"{meter_data['model']['value']}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
@ -849,7 +849,7 @@ class OhmpilotSensor(_FroniusSensorEntity):
|
|||||||
sw_version=device_data["software"]["value"],
|
sw_version=device_data["software"]["value"],
|
||||||
via_device=(DOMAIN, coordinator.solar_net.solar_net_device_id),
|
via_device=(DOMAIN, coordinator.solar_net.solar_net_device_id),
|
||||||
)
|
)
|
||||||
self._attr_unique_id = f'{device_data["serial"]["value"]}-{description.key}'
|
self._attr_unique_id = f"{device_data['serial']['value']}-{description.key}"
|
||||||
|
|
||||||
|
|
||||||
class PowerFlowSensor(_FroniusSensorEntity):
|
class PowerFlowSensor(_FroniusSensorEntity):
|
||||||
@ -883,7 +883,7 @@ class StorageSensor(_FroniusSensorEntity):
|
|||||||
super().__init__(coordinator, description, solar_net_id)
|
super().__init__(coordinator, description, solar_net_id)
|
||||||
storage_data = self._device_data()
|
storage_data = self._device_data()
|
||||||
|
|
||||||
self._attr_unique_id = f'{storage_data["serial"]["value"]}-{description.key}'
|
self._attr_unique_id = f"{storage_data['serial']['value']}-{description.key}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, storage_data["serial"]["value"])},
|
identifiers={(DOMAIN, storage_data["serial"]["value"])},
|
||||||
manufacturer=storage_data["manufacturer"]["value"],
|
manufacturer=storage_data["manufacturer"]["value"],
|
||||||
|
@ -124,8 +124,7 @@ class HarmonyData(HarmonySubscriberMixin):
|
|||||||
except (ValueError, AttributeError) as err:
|
except (ValueError, AttributeError) as err:
|
||||||
await self._client.close()
|
await self._client.close()
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
f"{self.name}: Error {err} while connected HUB at:"
|
f"{self.name}: Error {err} while connected HUB at: {self._address}:8088"
|
||||||
f" {self._address}:8088"
|
|
||||||
) from err
|
) from err
|
||||||
if not connected:
|
if not connected:
|
||||||
await self._client.close()
|
await self._client.close()
|
||||||
|
@ -195,7 +195,7 @@ class ClimateAehW4a1(ClimateEntity):
|
|||||||
fan_mode = status["wind_status"]
|
fan_mode = status["wind_status"]
|
||||||
self._attr_fan_mode = AC_TO_HA_FAN_MODES[fan_mode]
|
self._attr_fan_mode = AC_TO_HA_FAN_MODES[fan_mode]
|
||||||
|
|
||||||
swing_mode = f'{status["up_down"]}{status["left_right"]}'
|
swing_mode = f"{status['up_down']}{status['left_right']}"
|
||||||
self._attr_swing_mode = AC_TO_HA_SWING[swing_mode]
|
self._attr_swing_mode = AC_TO_HA_SWING[swing_mode]
|
||||||
|
|
||||||
if self._attr_hvac_mode in (HVACMode.COOL, HVACMode.HEAT):
|
if self._attr_hvac_mode in (HVACMode.COOL, HVACMode.HEAT):
|
||||||
|
@ -21,7 +21,7 @@ class HiveEntity(Entity):
|
|||||||
self.hive = hive
|
self.hive = hive
|
||||||
self.device = hive_device
|
self.device = hive_device
|
||||||
self._attr_name = self.device["haName"]
|
self._attr_name = self.device["haName"]
|
||||||
self._attr_unique_id = f'{self.device["hiveID"]}-{self.device["hiveType"]}'
|
self._attr_unique_id = f"{self.device['hiveID']}-{self.device['hiveType']}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.device["device_id"])},
|
identifiers={(DOMAIN, self.device["device_id"])},
|
||||||
model=self.device["deviceData"]["model"],
|
model=self.device["deviceData"]["model"],
|
||||||
|
@ -102,8 +102,8 @@ class AccessoryIIDStorage:
|
|||||||
char_hap_type: str | None = uuid_to_hap_type(char_uuid) if char_uuid else None
|
char_hap_type: str | None = uuid_to_hap_type(char_uuid) if char_uuid else None
|
||||||
# Allocation key must be a string since we are saving it to JSON
|
# Allocation key must be a string since we are saving it to JSON
|
||||||
allocation_key = (
|
allocation_key = (
|
||||||
f'{service_hap_type}_{service_unique_id or ""}_'
|
f"{service_hap_type}_{service_unique_id or ''}_"
|
||||||
f'{char_hap_type or ""}_{char_unique_id or ""}'
|
f"{char_hap_type or ''}_{char_unique_id or ''}"
|
||||||
)
|
)
|
||||||
# AID must be a string since JSON keys cannot be int
|
# AID must be a string since JSON keys cannot be int
|
||||||
aid_str = str(aid)
|
aid_str = str(aid)
|
||||||
|
@ -48,7 +48,7 @@ class DeviceTriggerAccessory(HomeAccessory):
|
|||||||
for idx, trigger in enumerate(device_triggers):
|
for idx, trigger in enumerate(device_triggers):
|
||||||
type_: str = trigger["type"]
|
type_: str = trigger["type"]
|
||||||
subtype: str | None = trigger.get("subtype")
|
subtype: str | None = trigger.get("subtype")
|
||||||
unique_id = f'{type_}-{subtype or ""}'
|
unique_id = f"{type_}-{subtype or ''}"
|
||||||
entity_id: str | None = None
|
entity_id: str | None = None
|
||||||
if (entity_id_or_uuid := trigger.get("entity_id")) and (
|
if (entity_id_or_uuid := trigger.get("entity_id")) and (
|
||||||
entry := ent_reg.async_get(entity_id_or_uuid)
|
entry := ent_reg.async_get(entity_id_or_uuid)
|
||||||
@ -122,7 +122,7 @@ class DeviceTriggerAccessory(HomeAccessory):
|
|||||||
"""
|
"""
|
||||||
reason = ""
|
reason = ""
|
||||||
if "trigger" in run_variables and "description" in run_variables["trigger"]:
|
if "trigger" in run_variables and "description" in run_variables["trigger"]:
|
||||||
reason = f' by {run_variables["trigger"]["description"]}'
|
reason = f" by {run_variables['trigger']['description']}"
|
||||||
_LOGGER.debug("Button triggered%s - %s", reason, run_variables)
|
_LOGGER.debug("Button triggered%s - %s", reason, run_variables)
|
||||||
idx = int(run_variables["trigger"]["idx"])
|
idx = int(run_variables["trigger"]["idx"])
|
||||||
self.triggers[idx].set_value(0)
|
self.triggers[idx].set_value(0)
|
||||||
|
@ -323,8 +323,7 @@ class HKDevice:
|
|||||||
self.hass,
|
self.hass,
|
||||||
self.async_update_available_state,
|
self.async_update_available_state,
|
||||||
timedelta(seconds=BLE_AVAILABILITY_CHECK_INTERVAL),
|
timedelta(seconds=BLE_AVAILABILITY_CHECK_INTERVAL),
|
||||||
name=f"HomeKit Device {self.unique_id} BLE availability "
|
name=f"HomeKit Device {self.unique_id} BLE availability check poll",
|
||||||
"check poll",
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# BLE devices always get an RSSI sensor as well
|
# BLE devices always get an RSSI sensor as well
|
||||||
|
@ -43,7 +43,7 @@ class IHCEntity(Entity):
|
|||||||
self.suggested_area = product.get("group")
|
self.suggested_area = product.get("group")
|
||||||
if "id" in product:
|
if "id" in product:
|
||||||
product_id = product["id"]
|
product_id = product["id"]
|
||||||
self.device_id = f"{controller_id}_{product_id }"
|
self.device_id = f"{controller_id}_{product_id}"
|
||||||
# this will name the device the same way as the IHC visual application: Product name + position
|
# this will name the device the same way as the IHC visual application: Product name + position
|
||||||
self.device_name = product["name"]
|
self.device_name = product["name"]
|
||||||
if self.ihc_position:
|
if self.ihc_position:
|
||||||
|
@ -66,7 +66,7 @@ class IstaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
else:
|
else:
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
assert info
|
assert info
|
||||||
title = f"{info["firstName"]} {info["lastName"]}".strip()
|
title = f"{info['firstName']} {info['lastName']}".strip()
|
||||||
await self.async_set_unique_id(info["activeConsumptionUnit"])
|
await self.async_set_unique_id(info["activeConsumptionUnit"])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -45,7 +45,7 @@ from .models import IsyData
|
|||||||
def time_string(i: int) -> str:
|
def time_string(i: int) -> str:
|
||||||
"""Return a formatted ramp rate time string."""
|
"""Return a formatted ramp rate time string."""
|
||||||
if i >= 60:
|
if i >= 60:
|
||||||
return f"{(float(i)/60):.1f} {UnitOfTime.MINUTES}"
|
return f"{(float(i) / 60):.1f} {UnitOfTime.MINUTES}"
|
||||||
return f"{i} {UnitOfTime.SECONDS}"
|
return f"{i} {UnitOfTime.SECONDS}"
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ def short_address(address: str) -> str:
|
|||||||
|
|
||||||
def name_from_discovery(discovery: MicroBotAdvertisement) -> str:
|
def name_from_discovery(discovery: MicroBotAdvertisement) -> str:
|
||||||
"""Get the name from a discovery."""
|
"""Get the name from a discovery."""
|
||||||
return f'{discovery.data["local_name"]} {short_address(discovery.address)}'
|
return f"{discovery.data['local_name']} {short_address(discovery.address)}"
|
||||||
|
|
||||||
|
|
||||||
class MicroBotConfigFlow(ConfigFlow, domain=DOMAIN):
|
class MicroBotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
@ -88,7 +88,7 @@ class KNXExposeSensor:
|
|||||||
self._remove_listener: Callable[[], None] | None = None
|
self._remove_listener: Callable[[], None] | None = None
|
||||||
self.device: ExposeSensor = ExposeSensor(
|
self.device: ExposeSensor = ExposeSensor(
|
||||||
xknx=self.xknx,
|
xknx=self.xknx,
|
||||||
name=f"{self.entity_id}__{self.expose_attribute or "state"}",
|
name=f"{self.entity_id}__{self.expose_attribute or 'state'}",
|
||||||
group_address=config[KNX_ADDRESS],
|
group_address=config[KNX_ADDRESS],
|
||||||
respond_to_read=config[CONF_RESPOND_TO_READ],
|
respond_to_read=config[CONF_RESPOND_TO_READ],
|
||||||
value_type=self.expose_type,
|
value_type=self.expose_type,
|
||||||
|
@ -101,8 +101,8 @@ class Plenticore:
|
|||||||
model=f"{prod1} {prod2}",
|
model=f"{prod1} {prod2}",
|
||||||
name=settings["scb:network"][hostname_id],
|
name=settings["scb:network"][hostname_id],
|
||||||
sw_version=(
|
sw_version=(
|
||||||
f'IOC: {device_local["Properties:VersionIOC"]}'
|
f"IOC: {device_local['Properties:VersionIOC']}"
|
||||||
f' MC: {device_local["Properties:VersionMC"]}'
|
f" MC: {device_local['Properties:VersionMC']}"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> list[Loca
|
|||||||
raise InvalidAuth from error
|
raise InvalidAuth from error
|
||||||
|
|
||||||
if not locations:
|
if not locations:
|
||||||
raise NoLocations(f'No locations found for account {data["username"]}')
|
raise NoLocations(f"No locations found for account {data['username']}")
|
||||||
|
|
||||||
return locations
|
return locations
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ def get_resource(domain_name: str, domain_data: ConfigType) -> str:
|
|||||||
if domain_name == "cover":
|
if domain_name == "cover":
|
||||||
return cast(str, domain_data["motor"])
|
return cast(str, domain_data["motor"])
|
||||||
if domain_name == "climate":
|
if domain_name == "climate":
|
||||||
return f'{domain_data["source"]}.{domain_data["setpoint"]}'
|
return f"{domain_data['source']}.{domain_data['setpoint']}"
|
||||||
if domain_name == "scene":
|
if domain_name == "scene":
|
||||||
return f'{domain_data["register"]}.{domain_data["scene"]}'
|
return f"{domain_data['register']}.{domain_data['scene']}"
|
||||||
raise ValueError("Unknown domain")
|
raise ValueError("Unknown domain")
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class LektricoFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self._serial_number = str(settings["serial_number"])
|
self._serial_number = str(settings["serial_number"])
|
||||||
self._device_type = settings["type"]
|
self._device_type = settings["type"]
|
||||||
self._board_revision = settings["board_revision"]
|
self._board_revision = settings["board_revision"]
|
||||||
self._name = f"{settings["type"]}_{self._serial_number}"
|
self._name = f"{settings['type']}_{self._serial_number}"
|
||||||
|
|
||||||
# Check if already configured
|
# Check if already configured
|
||||||
# Set unique id
|
# Set unique id
|
||||||
|
@ -168,7 +168,7 @@ class ThinQMQTT:
|
|||||||
async def async_handle_device_event(self, message: dict) -> None:
|
async def async_handle_device_event(self, message: dict) -> None:
|
||||||
"""Handle received mqtt message."""
|
"""Handle received mqtt message."""
|
||||||
unique_id = (
|
unique_id = (
|
||||||
f"{message["deviceId"]}_{list(message["report"].keys())[0]}"
|
f"{message['deviceId']}_{list(message['report'].keys())[0]}"
|
||||||
if message["deviceType"] == DeviceType.WASHTOWER
|
if message["deviceType"] == DeviceType.WASHTOWER
|
||||||
else message["deviceId"]
|
else message["deviceId"]
|
||||||
)
|
)
|
||||||
|
@ -101,7 +101,7 @@ async def async_browse_media(
|
|||||||
BrowseMedia(
|
BrowseMedia(
|
||||||
title=view["title"],
|
title=view["title"],
|
||||||
media_class=MediaClass.APP,
|
media_class=MediaClass.APP,
|
||||||
media_content_id=f'{info["url_path"]}/{view["path"]}',
|
media_content_id=f"{info['url_path']}/{view['path']}",
|
||||||
media_content_type=DOMAIN,
|
media_content_type=DOMAIN,
|
||||||
thumbnail="https://brands.home-assistant.io/_/lovelace/logo.png",
|
thumbnail="https://brands.home-assistant.io/_/lovelace/logo.png",
|
||||||
can_play=True,
|
can_play=True,
|
||||||
|
@ -53,7 +53,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
# Append the child device name to the end of the parent keypad
|
# Append the child device name to the end of the parent keypad
|
||||||
# name to create the entity name
|
# name to create the entity name
|
||||||
full_name = f'{parent_device_info.get("name")} {device_name}'
|
full_name = f"{parent_device_info.get('name')} {device_name}"
|
||||||
# Set the device_info to the same as the Parent Keypad
|
# Set the device_info to the same as the Parent Keypad
|
||||||
# The entities will be nested inside the keypad device
|
# The entities will be nested inside the keypad device
|
||||||
entities.append(
|
entities.append(
|
||||||
|
@ -44,7 +44,7 @@ class LutronCasetaLight(LutronCasetaUpdatableEntity, SwitchEntity):
|
|||||||
parent_keypad = keypads[device["parent_device"]]
|
parent_keypad = keypads[device["parent_device"]]
|
||||||
parent_device_info = parent_keypad["device_info"]
|
parent_device_info = parent_keypad["device_info"]
|
||||||
# Append the child device name to the end of the parent keypad name to create the entity name
|
# Append the child device name to the end of the parent keypad name to create the entity name
|
||||||
self._attr_name = f'{parent_device_info["name"]} {device["device_name"]}'
|
self._attr_name = f"{parent_device_info['name']} {device['device_name']}"
|
||||||
# Set the device_info to the same as the Parent Keypad
|
# Set the device_info to the same as the Parent Keypad
|
||||||
# The entities will be nested inside the keypad device
|
# The entities will be nested inside the keypad device
|
||||||
self._attr_device_info = parent_device_info
|
self._attr_device_info = parent_device_info
|
||||||
|
@ -67,8 +67,8 @@ async def validate_input(hass: HomeAssistant, data):
|
|||||||
|
|
||||||
# Return the validation result
|
# Return the validation result
|
||||||
address = (
|
address = (
|
||||||
f'{user_data["address"]["street"]} {user_data["address"]["house_number"]}'
|
f"{user_data['address']['street']} {user_data['address']['house_number']}"
|
||||||
f'{user_data["address"]["house_number_ext"]}'
|
f"{user_data['address']['house_number_ext']}"
|
||||||
)
|
)
|
||||||
return auth_token, {
|
return auth_token, {
|
||||||
"title": address,
|
"title": address,
|
||||||
|
@ -17,7 +17,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Set up ProgettiHWSW Automation from a config entry."""
|
"""Set up ProgettiHWSW Automation from a config entry."""
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][entry.entry_id] = ProgettiHWSWAPI(
|
hass.data[DOMAIN][entry.entry_id] = ProgettiHWSWAPI(
|
||||||
f'{entry.data["host"]}:{entry.data["port"]}'
|
f"{entry.data['host']}:{entry.data['port']}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check board validation again to load new values to API.
|
# Check board validation again to load new values to API.
|
||||||
|
@ -19,7 +19,7 @@ DATA_SCHEMA = vol.Schema(
|
|||||||
async def validate_input(hass: HomeAssistant, data):
|
async def validate_input(hass: HomeAssistant, data):
|
||||||
"""Validate the user host input."""
|
"""Validate the user host input."""
|
||||||
|
|
||||||
api_instance = ProgettiHWSWAPI(f'{data["host"]}:{data["port"]}')
|
api_instance = ProgettiHWSWAPI(f"{data['host']}:{data['port']}")
|
||||||
is_valid = await api_instance.check_board()
|
is_valid = await api_instance.check_board()
|
||||||
|
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
|
@ -32,7 +32,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: PyLoadConfigEntry) -> bo
|
|||||||
"""Set up pyLoad from a config entry."""
|
"""Set up pyLoad from a config entry."""
|
||||||
|
|
||||||
url = (
|
url = (
|
||||||
f"{"https" if entry.data[CONF_SSL] else "http"}://"
|
f"{'https' if entry.data[CONF_SSL] else 'http'}://"
|
||||||
f"{entry.data[CONF_HOST]}:{entry.data[CONF_PORT]}/"
|
f"{entry.data[CONF_HOST]}:{entry.data[CONF_PORT]}/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ async def validate_input(hass: HomeAssistant, user_input: dict[str, Any]) -> Non
|
|||||||
)
|
)
|
||||||
|
|
||||||
url = (
|
url = (
|
||||||
f"{"https" if user_input[CONF_SSL] else "http"}://"
|
f"{'https' if user_input[CONF_SSL] else 'http'}://"
|
||||||
f"{user_input[CONF_HOST]}:{user_input[CONF_PORT]}/"
|
f"{user_input[CONF_HOST]}:{user_input[CONF_PORT]}/"
|
||||||
)
|
)
|
||||||
pyload = PyLoadAPI(
|
pyload = PyLoadAPI(
|
||||||
|
@ -40,7 +40,7 @@ def _get_db_stats(instance: Recorder, database_name: str) -> dict[str, Any]:
|
|||||||
and (get_size := DIALECT_TO_GET_SIZE.get(dialect_name))
|
and (get_size := DIALECT_TO_GET_SIZE.get(dialect_name))
|
||||||
and (db_bytes := get_size(session, database_name))
|
and (db_bytes := get_size(session, database_name))
|
||||||
):
|
):
|
||||||
db_stats["estimated_db_size"] = f"{db_bytes/1024/1024:.2f} MiB"
|
db_stats["estimated_db_size"] = f"{db_bytes / 1024 / 1024:.2f} MiB"
|
||||||
return db_stats
|
return db_stats
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ def migrate_entity_ids(
|
|||||||
if host.api.supported(None, "UID") and not entity.unique_id.startswith(
|
if host.api.supported(None, "UID") and not entity.unique_id.startswith(
|
||||||
host.unique_id
|
host.unique_id
|
||||||
):
|
):
|
||||||
new_id = f"{host.unique_id}_{entity.unique_id.split("_", 1)[1]}"
|
new_id = f"{host.unique_id}_{entity.unique_id.split('_', 1)[1]}"
|
||||||
entity_reg.async_update_entity(entity.entity_id, new_unique_id=new_id)
|
entity_reg.async_update_entity(entity.entity_id, new_unique_id=new_id)
|
||||||
|
|
||||||
if entity.device_id in ch_device_ids:
|
if entity.device_id in ch_device_ids:
|
||||||
|
@ -57,7 +57,7 @@ def _rssi_convert(value: int | None) -> str | None:
|
|||||||
"""Rssi is given as dBm value."""
|
"""Rssi is given as dBm value."""
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
return f"{value*8-120}"
|
return f"{value * 8 - 120}"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
@ -12,7 +12,7 @@ from .coordinator import SenseCoordinator
|
|||||||
|
|
||||||
def sense_to_mdi(sense_icon: str) -> str:
|
def sense_to_mdi(sense_icon: str) -> str:
|
||||||
"""Convert sense icon to mdi icon."""
|
"""Convert sense icon to mdi icon."""
|
||||||
return f"mdi:{MDI_ICONS.get(sense_icon, "power-plug")}"
|
return f"mdi:{MDI_ICONS.get(sense_icon, 'power-plug')}"
|
||||||
|
|
||||||
|
|
||||||
class SenseEntity(CoordinatorEntity[SenseCoordinator]):
|
class SenseEntity(CoordinatorEntity[SenseCoordinator]):
|
||||||
|
@ -557,7 +557,7 @@ class RpcBluTrvClimate(ShellyRpcEntity, ClimateEntity):
|
|||||||
self._config = coordinator.device.config[f"{BLU_TRV_IDENTIFIER}:{id_}"]
|
self._config = coordinator.device.config[f"{BLU_TRV_IDENTIFIER}:{id_}"]
|
||||||
ble_addr: str = self._config["addr"]
|
ble_addr: str = self._config["addr"]
|
||||||
self._attr_unique_id = f"{ble_addr}-{self.key}"
|
self._attr_unique_id = f"{ble_addr}-{self.key}"
|
||||||
name = self._config["name"] or f"shellyblutrv-{ble_addr.replace(":", "")}"
|
name = self._config["name"] or f"shellyblutrv-{ble_addr.replace(':', '')}"
|
||||||
model_id = self._config.get("local_name")
|
model_id = self._config.get("local_name")
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
connections={(CONNECTION_BLUETOOTH, ble_addr)},
|
connections={(CONNECTION_BLUETOOTH, ble_addr)},
|
||||||
|
@ -42,7 +42,7 @@ def async_describe_events(
|
|||||||
if click_type in RPC_INPUTS_EVENTS_TYPES:
|
if click_type in RPC_INPUTS_EVENTS_TYPES:
|
||||||
rpc_coordinator = get_rpc_coordinator_by_device_id(hass, device_id)
|
rpc_coordinator = get_rpc_coordinator_by_device_id(hass, device_id)
|
||||||
if rpc_coordinator and rpc_coordinator.device.initialized:
|
if rpc_coordinator and rpc_coordinator.device.initialized:
|
||||||
key = f"input:{channel-1}"
|
key = f"input:{channel - 1}"
|
||||||
input_name = get_rpc_entity_name(rpc_coordinator.device, key)
|
input_name = get_rpc_entity_name(rpc_coordinator.device, key)
|
||||||
|
|
||||||
elif click_type in BLOCK_INPUTS_EVENTS_TYPES:
|
elif click_type in BLOCK_INPUTS_EVENTS_TYPES:
|
||||||
|
@ -137,7 +137,7 @@ def get_block_channel_name(device: BlockDevice, block: Block | None) -> str:
|
|||||||
else:
|
else:
|
||||||
base = ord("1")
|
base = ord("1")
|
||||||
|
|
||||||
return f"{entity_name} channel {chr(int(block.channel)+base)}"
|
return f"{entity_name} channel {chr(int(block.channel) + base)}"
|
||||||
|
|
||||||
|
|
||||||
def is_block_momentary_input(
|
def is_block_momentary_input(
|
||||||
@ -200,7 +200,7 @@ def get_block_input_triggers(
|
|||||||
subtype = "button"
|
subtype = "button"
|
||||||
else:
|
else:
|
||||||
assert block.channel
|
assert block.channel
|
||||||
subtype = f"button{int(block.channel)+1}"
|
subtype = f"button{int(block.channel) + 1}"
|
||||||
|
|
||||||
if device.settings["device"]["type"] in SHBTN_MODELS:
|
if device.settings["device"]["type"] in SHBTN_MODELS:
|
||||||
trigger_types = SHBTN_INPUTS_EVENTS_TYPES
|
trigger_types = SHBTN_INPUTS_EVENTS_TYPES
|
||||||
@ -409,7 +409,7 @@ def get_rpc_input_triggers(device: RpcDevice) -> list[tuple[str, str]]:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for trigger_type in RPC_INPUTS_EVENTS_TYPES:
|
for trigger_type in RPC_INPUTS_EVENTS_TYPES:
|
||||||
subtype = f"button{id_+1}"
|
subtype = f"button{id_ + 1}"
|
||||||
triggers.append((trigger_type, subtype))
|
triggers.append((trigger_type, subtype))
|
||||||
|
|
||||||
return triggers
|
return triggers
|
||||||
|
@ -44,7 +44,7 @@ class SlideButton(SlideEntity, ButtonEntity):
|
|||||||
def __init__(self, coordinator: SlideCoordinator) -> None:
|
def __init__(self, coordinator: SlideCoordinator) -> None:
|
||||||
"""Initialize the slide button."""
|
"""Initialize the slide button."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._attr_unique_id = f"{coordinator.data["mac"]}-calibrate"
|
self._attr_unique_id = f"{coordinator.data['mac']}-calibrate"
|
||||||
|
|
||||||
async def async_press(self) -> None:
|
async def async_press(self) -> None:
|
||||||
"""Send out a calibrate command."""
|
"""Send out a calibrate command."""
|
||||||
|
@ -47,7 +47,7 @@ class SlideSwitch(SlideEntity, SwitchEntity):
|
|||||||
def __init__(self, coordinator: SlideCoordinator) -> None:
|
def __init__(self, coordinator: SlideCoordinator) -> None:
|
||||||
"""Initialize the slide switch."""
|
"""Initialize the slide switch."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._attr_unique_id = f"{coordinator.data["mac"]}-touchgo"
|
self._attr_unique_id = f"{coordinator.data['mac']}-touchgo"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
@ -76,7 +76,7 @@ class SomaTilt(SomaEntity, CoverEntity):
|
|||||||
response = self.api.set_shade_position(self.device["mac"], 100)
|
response = self.api.set_shade_position(self.device["mac"], 100)
|
||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f'Error while closing the cover ({self.name}): {response["msg"]}'
|
f"Error while closing the cover ({self.name}): {response['msg']}"
|
||||||
)
|
)
|
||||||
self.set_position(0)
|
self.set_position(0)
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class SomaTilt(SomaEntity, CoverEntity):
|
|||||||
response = self.api.set_shade_position(self.device["mac"], -100)
|
response = self.api.set_shade_position(self.device["mac"], -100)
|
||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f'Error while opening the cover ({self.name}): {response["msg"]}'
|
f"Error while opening the cover ({self.name}): {response['msg']}"
|
||||||
)
|
)
|
||||||
self.set_position(100)
|
self.set_position(100)
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ class SomaTilt(SomaEntity, CoverEntity):
|
|||||||
response = self.api.stop_shade(self.device["mac"])
|
response = self.api.stop_shade(self.device["mac"])
|
||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f'Error while stopping the cover ({self.name}): {response["msg"]}'
|
f"Error while stopping the cover ({self.name}): {response['msg']}"
|
||||||
)
|
)
|
||||||
# Set cover position to some value where up/down are both enabled
|
# Set cover position to some value where up/down are both enabled
|
||||||
self.set_position(50)
|
self.set_position(50)
|
||||||
@ -109,7 +109,7 @@ class SomaTilt(SomaEntity, CoverEntity):
|
|||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f"Error while setting the cover position ({self.name}):"
|
f"Error while setting the cover position ({self.name}):"
|
||||||
f' {response["msg"]}'
|
f" {response['msg']}"
|
||||||
)
|
)
|
||||||
self.set_position(kwargs[ATTR_TILT_POSITION])
|
self.set_position(kwargs[ATTR_TILT_POSITION])
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ class SomaShade(SomaEntity, CoverEntity):
|
|||||||
response = self.api.set_shade_position(self.device["mac"], 100)
|
response = self.api.set_shade_position(self.device["mac"], 100)
|
||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f'Error while closing the cover ({self.name}): {response["msg"]}'
|
f"Error while closing the cover ({self.name}): {response['msg']}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def open_cover(self, **kwargs: Any) -> None:
|
def open_cover(self, **kwargs: Any) -> None:
|
||||||
@ -160,7 +160,7 @@ class SomaShade(SomaEntity, CoverEntity):
|
|||||||
response = self.api.set_shade_position(self.device["mac"], 0)
|
response = self.api.set_shade_position(self.device["mac"], 0)
|
||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f'Error while opening the cover ({self.name}): {response["msg"]}'
|
f"Error while opening the cover ({self.name}): {response['msg']}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def stop_cover(self, **kwargs: Any) -> None:
|
def stop_cover(self, **kwargs: Any) -> None:
|
||||||
@ -168,7 +168,7 @@ class SomaShade(SomaEntity, CoverEntity):
|
|||||||
response = self.api.stop_shade(self.device["mac"])
|
response = self.api.stop_shade(self.device["mac"])
|
||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f'Error while stopping the cover ({self.name}): {response["msg"]}'
|
f"Error while stopping the cover ({self.name}): {response['msg']}"
|
||||||
)
|
)
|
||||||
# Set cover position to some value where up/down are both enabled
|
# Set cover position to some value where up/down are both enabled
|
||||||
self.set_position(50)
|
self.set_position(50)
|
||||||
@ -182,7 +182,7 @@ class SomaShade(SomaEntity, CoverEntity):
|
|||||||
if not is_api_response_success(response):
|
if not is_api_response_success(response):
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f"Error while setting the cover position ({self.name}):"
|
f"Error while setting the cover position ({self.name}):"
|
||||||
f' {response["msg"]}'
|
f" {response['msg']}"
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
|
@ -166,7 +166,7 @@ class Segment:
|
|||||||
self.hls_playlist_parts.append(
|
self.hls_playlist_parts.append(
|
||||||
f"#EXT-X-PART:DURATION={part.duration:.3f},URI="
|
f"#EXT-X-PART:DURATION={part.duration:.3f},URI="
|
||||||
f'"./segment/{self.sequence}.{part_num}.m4s"'
|
f'"./segment/{self.sequence}.{part_num}.m4s"'
|
||||||
f'{",INDEPENDENT=YES" if part.has_keyframe else ""}'
|
f"{',INDEPENDENT=YES' if part.has_keyframe else ''}"
|
||||||
)
|
)
|
||||||
if self.complete:
|
if self.complete:
|
||||||
# Construct the final playlist_template. The placeholder will share a
|
# Construct the final playlist_template. The placeholder will share a
|
||||||
|
@ -460,7 +460,7 @@ class TimestampValidator:
|
|||||||
if packet.dts is None:
|
if packet.dts is None:
|
||||||
if self._missing_dts >= MAX_MISSING_DTS: # type: ignore[unreachable]
|
if self._missing_dts >= MAX_MISSING_DTS: # type: ignore[unreachable]
|
||||||
raise StreamWorkerError(
|
raise StreamWorkerError(
|
||||||
f"No dts in {MAX_MISSING_DTS+1} consecutive packets"
|
f"No dts in {MAX_MISSING_DTS + 1} consecutive packets"
|
||||||
)
|
)
|
||||||
self._missing_dts += 1
|
self._missing_dts += 1
|
||||||
return False
|
return False
|
||||||
|
@ -135,8 +135,8 @@ class DeviceConnectivity(SurePetcareBinarySensor):
|
|||||||
self._attr_is_on = bool(state)
|
self._attr_is_on = bool(state)
|
||||||
if state:
|
if state:
|
||||||
self._attr_extra_state_attributes = {
|
self._attr_extra_state_attributes = {
|
||||||
"device_rssi": f'{state["signal"]["device_rssi"]:.2f}',
|
"device_rssi": f"{state['signal']['device_rssi']:.2f}",
|
||||||
"hub_rssi": f'{state["signal"]["hub_rssi"]:.2f}',
|
"hub_rssi": f"{state['signal']['hub_rssi']:.2f}",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self._attr_extra_state_attributes = {}
|
self._attr_extra_state_attributes = {}
|
||||||
|
@ -114,7 +114,7 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||||||
if match := re.match(
|
if match := re.match(
|
||||||
rf"(?:{old_unique_id})-(?P<id>\d+)", entity_entry.unique_id
|
rf"(?:{old_unique_id})-(?P<id>\d+)", entity_entry.unique_id
|
||||||
):
|
):
|
||||||
entity_new_unique_id = f'{new_unique_id}-{match.group("id")}'
|
entity_new_unique_id = f"{new_unique_id}-{match.group('id')}"
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Migrating entity %s from %s to new id %s",
|
"Migrating entity %s from %s to new id %s",
|
||||||
entity_entry.entity_id,
|
entity_entry.entity_id,
|
||||||
|
@ -67,7 +67,7 @@ def short_address(address: str) -> str:
|
|||||||
|
|
||||||
def name_from_discovery(discovery: SwitchBotAdvertisement) -> str:
|
def name_from_discovery(discovery: SwitchBotAdvertisement) -> str:
|
||||||
"""Get the name from a discovery."""
|
"""Get the name from a discovery."""
|
||||||
return f'{discovery.data["modelFriendlyName"]} {short_address(discovery.address)}'
|
return f"{discovery.data['modelFriendlyName']} {short_address(discovery.address)}"
|
||||||
|
|
||||||
|
|
||||||
class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
@ -58,7 +58,7 @@ class TailwindDoorEntity(CoordinatorEntity[TailwindDataUpdateCoordinator]):
|
|||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, f"{coordinator.data.device_id}-{door_id}")},
|
identifiers={(DOMAIN, f"{coordinator.data.device_id}-{door_id}")},
|
||||||
via_device=(DOMAIN, coordinator.data.device_id),
|
via_device=(DOMAIN, coordinator.data.device_id),
|
||||||
name=f"Door {coordinator.data.doors[door_id].index+1}",
|
name=f"Door {coordinator.data.doors[door_id].index + 1}",
|
||||||
manufacturer="Tailwind",
|
manufacturer="Tailwind",
|
||||||
model=coordinator.data.product,
|
model=coordinator.data.product,
|
||||||
sw_version=coordinator.data.firmware_version,
|
sw_version=coordinator.data.firmware_version,
|
||||||
|
@ -93,7 +93,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
continue
|
continue
|
||||||
if isinstance(entry.options[key], str):
|
if isinstance(entry.options[key], str):
|
||||||
raise ConfigEntryError(
|
raise ConfigEntryError(
|
||||||
f"The '{entry.options.get(CONF_NAME) or ""}' number template needs to "
|
f"The '{entry.options.get(CONF_NAME) or ''}' number template needs to "
|
||||||
f"be reconfigured, {key} must be a number, got '{entry.options[key]}'"
|
f"be reconfigured, {key} must be a number, got '{entry.options[key]}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class TwinklyModeSelect(TwinklyEntity, SelectEntity):
|
|||||||
def __init__(self, coordinator: TwinklyCoordinator) -> None:
|
def __init__(self, coordinator: TwinklyCoordinator) -> None:
|
||||||
"""Initialize TwinklyModeSelect."""
|
"""Initialize TwinklyModeSelect."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._attr_unique_id = f"{coordinator.data.device_info["mac"]}_mode"
|
self._attr_unique_id = f"{coordinator.data.device_info['mac']}_mode"
|
||||||
self.client = coordinator.client
|
self.client = coordinator.client
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -97,14 +97,16 @@ def async_generate_url(
|
|||||||
) -> str:
|
) -> str:
|
||||||
"""Generate the full URL for a webhook_id."""
|
"""Generate the full URL for a webhook_id."""
|
||||||
return (
|
return (
|
||||||
f"{get_url(
|
f"{
|
||||||
hass,
|
get_url(
|
||||||
allow_internal=allow_internal,
|
hass,
|
||||||
allow_external=allow_external,
|
allow_internal=allow_internal,
|
||||||
allow_cloud=False,
|
allow_external=allow_external,
|
||||||
allow_ip=allow_ip,
|
allow_cloud=False,
|
||||||
prefer_external=prefer_external,
|
allow_ip=allow_ip,
|
||||||
)}"
|
prefer_external=prefer_external,
|
||||||
|
)
|
||||||
|
}"
|
||||||
f"{async_generate_path(webhook_id)}"
|
f"{async_generate_path(webhook_id)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
data = {CONF_HOST: self._host, CONF_CLIENT_SECRET: client.client_key}
|
data = {CONF_HOST: self._host, CONF_CLIENT_SECRET: client.client_key}
|
||||||
|
|
||||||
if not self._name:
|
if not self._name:
|
||||||
self._name = f"{DEFAULT_NAME} {client.system_info["modelName"]}"
|
self._name = f"{DEFAULT_NAME} {client.system_info['modelName']}"
|
||||||
return self.async_create_entry(title=self._name, data=data)
|
return self.async_create_entry(title=self._name, data=data)
|
||||||
|
|
||||||
return self.async_show_form(step_id="pairing", errors=errors)
|
return self.async_show_form(step_id="pairing", errors=errors)
|
||||||
|
@ -63,7 +63,7 @@ class WebSocketAdapter(logging.LoggerAdapter):
|
|||||||
def process(self, msg: str, kwargs: Any) -> tuple[str, Any]:
|
def process(self, msg: str, kwargs: Any) -> tuple[str, Any]:
|
||||||
"""Add connid to websocket log messages."""
|
"""Add connid to websocket log messages."""
|
||||||
assert self.extra is not None
|
assert self.extra is not None
|
||||||
return f'[{self.extra["connid"]}] {msg}', kwargs
|
return f"[{self.extra['connid']}] {msg}", kwargs
|
||||||
|
|
||||||
|
|
||||||
class WebSocketHandler:
|
class WebSocketHandler:
|
||||||
|
@ -86,7 +86,7 @@ class YaleDoorBatterySensor(YaleEntity, BinarySensorEntity):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Initiate Yale door battery Sensor."""
|
"""Initiate Yale door battery Sensor."""
|
||||||
super().__init__(coordinator, data)
|
super().__init__(coordinator, data)
|
||||||
self._attr_unique_id = f"{data["address"]}-battery"
|
self._attr_unique_id = f"{data['address']}-battery"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
@ -84,7 +84,7 @@ class YaleDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
contact["address"]: contact["_state"] for contact in door_windows
|
contact["address"]: contact["_state"] for contact in door_windows
|
||||||
}
|
}
|
||||||
_sensor_battery_map = {
|
_sensor_battery_map = {
|
||||||
f"{contact["address"]}-battery": contact["_battery"]
|
f"{contact['address']}-battery": contact["_battery"]
|
||||||
for contact in door_windows
|
for contact in door_windows
|
||||||
}
|
}
|
||||||
_temp_map = {temp["address"]: temp["status_temp"] for temp in temp_sensors}
|
_temp_map = {temp["address"]: temp["status_temp"] for temp in temp_sensors}
|
||||||
|
@ -163,11 +163,7 @@ class ZHAFirmwareUpdateEntity(
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self.entity_data.device_proxy.device.is_mains_powered:
|
if self.entity_data.device_proxy.device.is_mains_powered:
|
||||||
header = (
|
header = f"<ha-alert alert-type='info'>{OTA_MESSAGE_RELIABILITY}</ha-alert>"
|
||||||
"<ha-alert alert-type='info'>"
|
|
||||||
f"{OTA_MESSAGE_RELIABILITY}"
|
|
||||||
"</ha-alert>"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
header = (
|
header = (
|
||||||
"<ha-alert alert-type='info'>"
|
"<ha-alert alert-type='info'>"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user