mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use literal string interpolation in integrations X-Z (f-strings) (#26395)
This commit is contained in:
parent
445c741b30
commit
dae6895a95
@ -143,7 +143,7 @@ def _retrieve_list(host, token, **kwargs):
|
|||||||
|
|
||||||
def _get_token(host, username, password):
|
def _get_token(host, username, password):
|
||||||
"""Get authentication token for the given host+username+password."""
|
"""Get authentication token for the given host+username+password."""
|
||||||
url = "http://{}/cgi-bin/luci/api/xqsystem/login".format(host)
|
url = f"http://{host}/cgi-bin/luci/api/xqsystem/login"
|
||||||
data = {"username": username, "password": password}
|
data = {"username": username, "password": password}
|
||||||
try:
|
try:
|
||||||
res = requests.post(url, data=data, timeout=5)
|
res = requests.post(url, data=data, timeout=5)
|
||||||
|
@ -232,7 +232,7 @@ class XiaomiDevice(Entity):
|
|||||||
self._state = None
|
self._state = None
|
||||||
self._is_available = True
|
self._is_available = True
|
||||||
self._sid = device["sid"]
|
self._sid = device["sid"]
|
||||||
self._name = "{}_{}".format(device_type, self._sid)
|
self._name = f"{device_type}_{self._sid}"
|
||||||
self._type = device_type
|
self._type = device_type
|
||||||
self._write_to_hub = xiaomi_hub.write_to_hub
|
self._write_to_hub = xiaomi_hub.write_to_hub
|
||||||
self._get_from_hub = xiaomi_hub.get_from_hub
|
self._get_from_hub = xiaomi_hub.get_from_hub
|
||||||
@ -247,7 +247,7 @@ class XiaomiDevice(Entity):
|
|||||||
self._data_key, self._sid # pylint: disable=no-member
|
self._data_key, self._sid # pylint: disable=no-member
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self._unique_id = "{}{}".format(self._type, self._sid)
|
self._unique_id = f"{self._type}{self._sid}"
|
||||||
|
|
||||||
def _add_push_data_job(self, *args):
|
def _add_push_data_job(self, *args):
|
||||||
self.hass.add_job(self.push_data, *args)
|
self.hass.add_job(self.push_data, *args)
|
||||||
@ -345,7 +345,7 @@ def _add_gateway_to_schema(xiaomi, schema):
|
|||||||
if gateway.sid == sid:
|
if gateway.sid == sid:
|
||||||
return gateway
|
return gateway
|
||||||
|
|
||||||
raise vol.Invalid("Unknown gateway sid {}".format(sid))
|
raise vol.Invalid(f"Unknown gateway sid {sid}")
|
||||||
|
|
||||||
gateways = list(xiaomi.gateways.values())
|
gateways = list(xiaomi.gateways.values())
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
@ -440,7 +440,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
miio_device = Device(host, token)
|
miio_device = Device(host, token)
|
||||||
device_info = miio_device.info()
|
device_info = miio_device.info()
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = "{}-{}".format(model, device_info.mac_address)
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"%s %s %s detected",
|
"%s %s %s detected",
|
||||||
model,
|
model,
|
||||||
|
@ -136,7 +136,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
miio_device = Device(host, token)
|
miio_device = Device(host, token)
|
||||||
device_info = miio_device.info()
|
device_info = miio_device.info()
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = "{}-{}".format(model, device_info.mac_address)
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"%s %s %s detected",
|
"%s %s %s detected",
|
||||||
model,
|
model,
|
||||||
@ -731,7 +731,7 @@ class XiaomiPhilipsEyecareLampAmbientLight(XiaomiPhilipsAbstractLight):
|
|||||||
|
|
||||||
def __init__(self, name, light, model, unique_id):
|
def __init__(self, name, light, model, unique_id):
|
||||||
"""Initialize the light device."""
|
"""Initialize the light device."""
|
||||||
name = "{} Ambient Light".format(name)
|
name = f"{name} Ambient Light"
|
||||||
if unique_id is not None:
|
if unique_id is not None:
|
||||||
unique_id = "{}-{}".format(unique_id, "ambient")
|
unique_id = "{}-{}".format(unique_id, "ambient")
|
||||||
super().__init__(name, light, model, unique_id)
|
super().__init__(name, light, model, unique_id)
|
||||||
|
@ -90,7 +90,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
try:
|
try:
|
||||||
device_info = device.info()
|
device_info = device.info()
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = "{}-{}".format(model, device_info.mac_address)
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"%s %s %s detected",
|
"%s %s %s detected",
|
||||||
model,
|
model,
|
||||||
|
@ -52,7 +52,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
air_quality_monitor = AirQualityMonitor(host, token)
|
air_quality_monitor = AirQualityMonitor(host, token)
|
||||||
device_info = air_quality_monitor.info()
|
device_info = air_quality_monitor.info()
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = "{}-{}".format(model, device_info.mac_address)
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"%s %s %s detected",
|
"%s %s %s detected",
|
||||||
model,
|
model,
|
||||||
|
@ -117,7 +117,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
miio_device = Device(host, token)
|
miio_device = Device(host, token)
|
||||||
device_info = miio_device.info()
|
device_info = miio_device.info()
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = "{}-{}".format(model, device_info.mac_address)
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"%s %s %s detected",
|
"%s %s %s detected",
|
||||||
model,
|
model,
|
||||||
@ -426,7 +426,7 @@ class ChuangMiPlugSwitch(XiaomiPlugGenericSwitch):
|
|||||||
|
|
||||||
def __init__(self, name, plug, model, unique_id, channel_usb):
|
def __init__(self, name, plug, model, unique_id, channel_usb):
|
||||||
"""Initialize the plug switch."""
|
"""Initialize the plug switch."""
|
||||||
name = "{} USB".format(name) if channel_usb else name
|
name = f"{name} USB" if channel_usb else name
|
||||||
|
|
||||||
if unique_id is not None and channel_usb:
|
if unique_id is not None and channel_usb:
|
||||||
unique_id = "{}-{}".format(unique_id, "usb")
|
unique_id = "{}-{}".format(unique_id, "usb")
|
||||||
|
@ -87,12 +87,12 @@ class XmppNotificationService(BaseNotificationService):
|
|||||||
async def async_send_message(self, message="", **kwargs):
|
async def async_send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
||||||
text = "{}: {}".format(title, message) if title else message
|
text = f"{title}: {message}" if title else message
|
||||||
data = kwargs.get(ATTR_DATA)
|
data = kwargs.get(ATTR_DATA)
|
||||||
timeout = data.get(ATTR_TIMEOUT, XEP_0363_TIMEOUT) if data else None
|
timeout = data.get(ATTR_TIMEOUT, XEP_0363_TIMEOUT) if data else None
|
||||||
|
|
||||||
await async_send_message(
|
await async_send_message(
|
||||||
"{}/{}".format(self._sender, self._resource),
|
f"{self._sender}/{self._resource}",
|
||||||
self._password,
|
self._password,
|
||||||
self._recipient,
|
self._recipient,
|
||||||
self._tls,
|
self._tls,
|
||||||
|
@ -114,7 +114,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
for recv in rxv.find():
|
for recv in rxv.find():
|
||||||
receivers.extend(recv.zone_controllers())
|
receivers.extend(recv.zone_controllers())
|
||||||
else:
|
else:
|
||||||
ctrl_url = "http://{}:80/YamahaRemoteControl/ctrl".format(host)
|
ctrl_url = f"http://{host}:80/YamahaRemoteControl/ctrl"
|
||||||
receivers = rxv.RXV(ctrl_url, name).zone_controllers()
|
receivers = rxv.RXV(ctrl_url, name).zone_controllers()
|
||||||
|
|
||||||
devices = []
|
devices = []
|
||||||
@ -276,7 +276,7 @@ class YamahaDevice(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def zone_id(self):
|
def zone_id(self):
|
||||||
"""Return a zone_id to ensure 1 media player per zone."""
|
"""Return a zone_id to ensure 1 media player per zone."""
|
||||||
return "{0}:{1}".format(self.receiver.ctrl_url, self._zone)
|
return f"{self.receiver.ctrl_url}:{self._zone}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
@ -410,6 +410,6 @@ class YamahaDevice(MediaPlayerDevice):
|
|||||||
# If both song and station is available, print both, otherwise
|
# If both song and station is available, print both, otherwise
|
||||||
# just the one we have.
|
# just the one we have.
|
||||||
if song and station:
|
if song and station:
|
||||||
return "{}: {}".format(station, song)
|
return f"{station}: {song}"
|
||||||
|
|
||||||
return song or station
|
return song or station
|
||||||
|
@ -128,7 +128,7 @@ class YamahaDevice(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return "{} ({})".format(self._name, self._zone.zone_id)
|
return f"{self._name} ({self._zone.zone_id})"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
@ -26,7 +26,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
DOMAIN = "yeelight"
|
DOMAIN = "yeelight"
|
||||||
DATA_YEELIGHT = DOMAIN
|
DATA_YEELIGHT = DOMAIN
|
||||||
DATA_UPDATED = "yeelight_{}_data_updated"
|
DATA_UPDATED = "yeelight_{}_data_updated"
|
||||||
DEVICE_INITIALIZED = "{}_device_initialized".format(DOMAIN)
|
DEVICE_INITIALIZED = f"{DOMAIN}_device_initialized"
|
||||||
|
|
||||||
DEFAULT_NAME = "Yeelight"
|
DEFAULT_NAME = "Yeelight"
|
||||||
DEFAULT_TRANSITION = 350
|
DEFAULT_TRANSITION = 350
|
||||||
|
@ -48,7 +48,7 @@ class YeelightNightlightModeSensor(BinarySensorDevice):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} nightlight".format(self._device.name)
|
return f"{self._device.name} nightlight"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
@ -165,7 +165,7 @@ def _cmd(func):
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Yeelight bulbs."""
|
"""Set up the Yeelight bulbs."""
|
||||||
data_key = "{}_lights".format(DATA_YEELIGHT)
|
data_key = f"{DATA_YEELIGHT}_lights"
|
||||||
|
|
||||||
if not discovery_info:
|
if not discovery_info:
|
||||||
return
|
return
|
||||||
@ -673,7 +673,7 @@ class YeelightAmbientLight(YeelightColorLight):
|
|||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the device if any."""
|
"""Return the name of the device if any."""
|
||||||
return "{} ambilight".format(self.device.name)
|
return f"{self.device.name} ambilight"
|
||||||
|
|
||||||
def _get_property(self, prop, default=None):
|
def _get_property(self, prop, default=None):
|
||||||
bg_prop = self.PROPERTIES_MAPPING.get(prop)
|
bg_prop = self.PROPERTIES_MAPPING.get(prop)
|
||||||
|
@ -50,7 +50,7 @@ class SunflowerBulb(Light):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the display name of this light."""
|
"""Return the display name of this light."""
|
||||||
return "sunflower_{}".format(self._light.zid)
|
return f"sunflower_{self._light.zid}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
|
@ -106,7 +106,7 @@ class YrSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} {}".format(self.client_name, self._name)
|
return f"{self.client_name} {self._name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
@ -168,7 +168,7 @@ class YrData:
|
|||||||
with async_timeout.timeout(10):
|
with async_timeout.timeout(10):
|
||||||
resp = await websession.get(self._url, params=self._urlparams)
|
resp = await websession.get(self._url, params=self._urlparams)
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
try_again("{} returned {}".format(resp.url, resp.status))
|
try_again(f"{resp.url} returned {resp.status}")
|
||||||
return
|
return
|
||||||
text = await resp.text()
|
text = await resp.text()
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class YahooWeatherSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} {}".format(self._client, self._name)
|
return f"{self._client} {self._name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
@ -124,7 +124,7 @@ class ZamgSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} {}".format(self.client_name, self.variable)
|
return f"{self.client_name} {self.variable}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
@ -212,7 +212,7 @@ class ZamgData:
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise ValueError("No weather data for station {}".format(self._station_id))
|
raise ValueError(f"No weather data for station {self._station_id}")
|
||||||
|
|
||||||
def get_data(self, variable):
|
def get_data(self, variable):
|
||||||
"""Get the data."""
|
"""Get the data."""
|
||||||
|
@ -19,7 +19,7 @@ CONF_ZPID = "zpid"
|
|||||||
|
|
||||||
DEFAULT_NAME = "Zestimate"
|
DEFAULT_NAME = "Zestimate"
|
||||||
NAME = "zestimate"
|
NAME = "zestimate"
|
||||||
ZESTIMATE = "{}:{}".format(DEFAULT_NAME, NAME)
|
ZESTIMATE = f"{DEFAULT_NAME}:{NAME}"
|
||||||
|
|
||||||
ICON = "mdi:home-variant"
|
ICON = "mdi:home-variant"
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class ZestimateDataSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} {}".format(self._name, self.address)
|
return f"{self._name} {self.address}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
@ -283,10 +283,10 @@ async def websocket_device_cluster_attributes(hass, connection, msg):
|
|||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Requested attributes for: %s %s %s %s",
|
"Requested attributes for: %s %s %s %s",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_ID, cluster_id),
|
f"{ATTR_CLUSTER_ID}: [{cluster_id}]",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_TYPE, cluster_type),
|
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]",
|
||||||
"{}: [{}]".format(ATTR_ENDPOINT_ID, endpoint_id),
|
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]",
|
||||||
"{}: [{}]".format(RESPONSE, cluster_attributes),
|
f"{RESPONSE}: [{cluster_attributes}]",
|
||||||
)
|
)
|
||||||
|
|
||||||
connection.send_result(msg[ID], cluster_attributes)
|
connection.send_result(msg[ID], cluster_attributes)
|
||||||
@ -337,10 +337,10 @@ async def websocket_device_cluster_commands(hass, connection, msg):
|
|||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Requested commands for: %s %s %s %s",
|
"Requested commands for: %s %s %s %s",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_ID, cluster_id),
|
f"{ATTR_CLUSTER_ID}: [{cluster_id}]",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_TYPE, cluster_type),
|
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]",
|
||||||
"{}: [{}]".format(ATTR_ENDPOINT_ID, endpoint_id),
|
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]",
|
||||||
"{}: [{}]".format(RESPONSE, cluster_commands),
|
f"{RESPONSE}: [{cluster_commands}]",
|
||||||
)
|
)
|
||||||
|
|
||||||
connection.send_result(msg[ID], cluster_commands)
|
connection.send_result(msg[ID], cluster_commands)
|
||||||
@ -381,11 +381,11 @@ async def websocket_read_zigbee_cluster_attributes(hass, connection, msg):
|
|||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Read attribute for: %s %s %s %s %s %s %s",
|
"Read attribute for: %s %s %s %s %s %s %s",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_ID, cluster_id),
|
f"{ATTR_CLUSTER_ID}: [{cluster_id}]",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_TYPE, cluster_type),
|
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]",
|
||||||
"{}: [{}]".format(ATTR_ENDPOINT_ID, endpoint_id),
|
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]",
|
||||||
"{}: [{}]".format(ATTR_ATTRIBUTE, attribute),
|
f"{ATTR_ATTRIBUTE}: [{attribute}]",
|
||||||
"{}: [{}]".format(ATTR_MANUFACTURER, manufacturer),
|
f"{ATTR_MANUFACTURER}: [{manufacturer}]",
|
||||||
"{}: [{}]".format(RESPONSE, str(success.get(attribute))),
|
"{}: [{}]".format(RESPONSE, str(success.get(attribute))),
|
||||||
"{}: [{}]".format("failure", failure),
|
"{}: [{}]".format("failure", failure),
|
||||||
)
|
)
|
||||||
@ -411,7 +411,7 @@ async def websocket_get_bindable_devices(hass, connection, msg):
|
|||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Get bindable devices: %s %s",
|
"Get bindable devices: %s %s",
|
||||||
"{}: [{}]".format(ATTR_SOURCE_IEEE, source_ieee),
|
f"{ATTR_SOURCE_IEEE}: [{source_ieee}]",
|
||||||
"{}: [{}]".format("bindable devices:", devices),
|
"{}: [{}]".format("bindable devices:", devices),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -435,8 +435,8 @@ async def websocket_bind_devices(hass, connection, msg):
|
|||||||
await async_binding_operation(zha_gateway, source_ieee, target_ieee, BIND_REQUEST)
|
await async_binding_operation(zha_gateway, source_ieee, target_ieee, BIND_REQUEST)
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"Issue bind devices: %s %s",
|
"Issue bind devices: %s %s",
|
||||||
"{}: [{}]".format(ATTR_SOURCE_IEEE, source_ieee),
|
f"{ATTR_SOURCE_IEEE}: [{source_ieee}]",
|
||||||
"{}: [{}]".format(ATTR_TARGET_IEEE, target_ieee),
|
f"{ATTR_TARGET_IEEE}: [{target_ieee}]",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -457,8 +457,8 @@ async def websocket_unbind_devices(hass, connection, msg):
|
|||||||
await async_binding_operation(zha_gateway, source_ieee, target_ieee, UNBIND_REQUEST)
|
await async_binding_operation(zha_gateway, source_ieee, target_ieee, UNBIND_REQUEST)
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"Issue unbind devices: %s %s",
|
"Issue unbind devices: %s %s",
|
||||||
"{}: [{}]".format(ATTR_SOURCE_IEEE, source_ieee),
|
f"{ATTR_SOURCE_IEEE}: [{source_ieee}]",
|
||||||
"{}: [{}]".format(ATTR_TARGET_IEEE, target_ieee),
|
f"{ATTR_TARGET_IEEE}: [{target_ieee}]",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -482,8 +482,8 @@ async def async_binding_operation(zha_gateway, source_ieee, target_ieee, operati
|
|||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"processing binding operation for: %s %s %s",
|
"processing binding operation for: %s %s %s",
|
||||||
"{}: [{}]".format(ATTR_SOURCE_IEEE, source_ieee),
|
f"{ATTR_SOURCE_IEEE}: [{source_ieee}]",
|
||||||
"{}: [{}]".format(ATTR_TARGET_IEEE, target_ieee),
|
f"{ATTR_TARGET_IEEE}: [{target_ieee}]",
|
||||||
"{}: {}".format("cluster", cluster_pair.source_cluster.cluster_id),
|
"{}: {}".format("cluster", cluster_pair.source_cluster.cluster_id),
|
||||||
)
|
)
|
||||||
bind_tasks.append(
|
bind_tasks.append(
|
||||||
@ -551,13 +551,13 @@ def async_load_api(hass):
|
|||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Set attribute for: %s %s %s %s %s %s %s",
|
"Set attribute for: %s %s %s %s %s %s %s",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_ID, cluster_id),
|
f"{ATTR_CLUSTER_ID}: [{cluster_id}]",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_TYPE, cluster_type),
|
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]",
|
||||||
"{}: [{}]".format(ATTR_ENDPOINT_ID, endpoint_id),
|
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]",
|
||||||
"{}: [{}]".format(ATTR_ATTRIBUTE, attribute),
|
f"{ATTR_ATTRIBUTE}: [{attribute}]",
|
||||||
"{}: [{}]".format(ATTR_VALUE, value),
|
f"{ATTR_VALUE}: [{value}]",
|
||||||
"{}: [{}]".format(ATTR_MANUFACTURER, manufacturer),
|
f"{ATTR_MANUFACTURER}: [{manufacturer}]",
|
||||||
"{}: [{}]".format(RESPONSE, response),
|
f"{RESPONSE}: [{response}]",
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.helpers.service.async_register_admin_service(
|
hass.helpers.service.async_register_admin_service(
|
||||||
@ -593,14 +593,14 @@ def async_load_api(hass):
|
|||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Issue command for: %s %s %s %s %s %s %s %s",
|
"Issue command for: %s %s %s %s %s %s %s %s",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_ID, cluster_id),
|
f"{ATTR_CLUSTER_ID}: [{cluster_id}]",
|
||||||
"{}: [{}]".format(ATTR_CLUSTER_TYPE, cluster_type),
|
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]",
|
||||||
"{}: [{}]".format(ATTR_ENDPOINT_ID, endpoint_id),
|
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]",
|
||||||
"{}: [{}]".format(ATTR_COMMAND, command),
|
f"{ATTR_COMMAND}: [{command}]",
|
||||||
"{}: [{}]".format(ATTR_COMMAND_TYPE, command_type),
|
f"{ATTR_COMMAND_TYPE}: [{command_type}]",
|
||||||
"{}: [{}]".format(ATTR_ARGS, args),
|
f"{ATTR_ARGS}: [{args}]",
|
||||||
"{}: [{}]".format(ATTR_MANUFACTURER, manufacturer),
|
f"{ATTR_MANUFACTURER}: [{manufacturer}]",
|
||||||
"{}: [{}]".format(RESPONSE, response),
|
f"{RESPONSE}: [{response}]",
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.helpers.service.async_register_admin_service(
|
hass.helpers.service.async_register_admin_service(
|
||||||
|
@ -87,7 +87,7 @@ class ZigbeeChannel(LogMixin):
|
|||||||
self._channel_name = cluster.ep_attribute
|
self._channel_name = cluster.ep_attribute
|
||||||
if self.CHANNEL_NAME:
|
if self.CHANNEL_NAME:
|
||||||
self._channel_name = self.CHANNEL_NAME
|
self._channel_name = self.CHANNEL_NAME
|
||||||
self._generic_id = "channel_0x{:04x}".format(cluster.cluster_id)
|
self._generic_id = f"channel_0x{cluster.cluster_id:04x}"
|
||||||
self._cluster = cluster
|
self._cluster = cluster
|
||||||
self._zha_device = device
|
self._zha_device = device
|
||||||
self._unique_id = "{}:{}:0x{:04x}".format(
|
self._unique_id = "{}:{}:0x{:04x}".format(
|
||||||
@ -299,9 +299,7 @@ class AttributeListeningChannel(ZigbeeChannel):
|
|||||||
"""Handle attribute updates on this cluster."""
|
"""Handle attribute updates on this cluster."""
|
||||||
if attrid == self.value_attribute:
|
if attrid == self.value_attribute:
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", value
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
value,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
|
@ -30,9 +30,7 @@ class DoorLockChannel(ZigbeeChannel):
|
|||||||
result = await self.get_attribute_value("lock_state", from_cache=True)
|
result = await self.get_attribute_value("lock_state", from_cache=True)
|
||||||
|
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", result
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
result,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -44,9 +42,7 @@ class DoorLockChannel(ZigbeeChannel):
|
|||||||
)
|
)
|
||||||
if attrid == self._value_attribute:
|
if attrid == self._value_attribute:
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", value
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
value,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
|
@ -198,7 +198,7 @@ class LevelControlChannel(ZigbeeChannel):
|
|||||||
def dispatch_level_change(self, command, level):
|
def dispatch_level_change(self, command, level):
|
||||||
"""Dispatch level change."""
|
"""Dispatch level change."""
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass, "{}_{}".format(self.unique_id, command), level
|
self._zha_device.hass, f"{self.unique_id}_{command}", level
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
@ -284,9 +284,7 @@ class OnOffChannel(ZigbeeChannel):
|
|||||||
"""Handle attribute updates on this cluster."""
|
"""Handle attribute updates on this cluster."""
|
||||||
if attrid == self.ON_OFF:
|
if attrid == self.ON_OFF:
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", value
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
value,
|
|
||||||
)
|
)
|
||||||
self._state = bool(value)
|
self._state = bool(value)
|
||||||
|
|
||||||
@ -355,9 +353,7 @@ class PowerConfigurationChannel(ZigbeeChannel):
|
|||||||
attr_id = attr
|
attr_id = attr
|
||||||
if attrid == attr_id:
|
if attrid == attr_id:
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", value
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
value,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
|
@ -72,9 +72,7 @@ class ElectricalMeasurementChannel(AttributeListeningChannel):
|
|||||||
# This is a polling channel. Don't allow cache.
|
# This is a polling channel. Don't allow cache.
|
||||||
result = await self.get_attribute_value("active_power", from_cache=False)
|
result = await self.get_attribute_value("active_power", from_cache=False)
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", result
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
result,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
|
@ -48,9 +48,7 @@ class FanChannel(ZigbeeChannel):
|
|||||||
result = await self.get_attribute_value("fan_mode", from_cache=True)
|
result = await self.get_attribute_value("fan_mode", from_cache=True)
|
||||||
|
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", result
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
result,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -62,9 +60,7 @@ class FanChannel(ZigbeeChannel):
|
|||||||
)
|
)
|
||||||
if attrid == self._value_attribute:
|
if attrid == self._value_attribute:
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", value
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
value,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
|
@ -43,9 +43,7 @@ class IASZoneChannel(ZigbeeChannel):
|
|||||||
if command_id == 0:
|
if command_id == 0:
|
||||||
state = args[0] & 3
|
state = args[0] & 3
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", state
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
state,
|
|
||||||
)
|
)
|
||||||
self.debug("Updated alarm state: %s", state)
|
self.debug("Updated alarm state: %s", state)
|
||||||
elif command_id == 1:
|
elif command_id == 1:
|
||||||
@ -91,9 +89,7 @@ class IASZoneChannel(ZigbeeChannel):
|
|||||||
if attrid == 2:
|
if attrid == 2:
|
||||||
value = value & 3
|
value = value & 3
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._zha_device.hass,
|
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", value
|
||||||
"{}_{}".format(self.unique_id, SIGNAL_ATTR_UPDATED),
|
|
||||||
value,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
|
@ -102,7 +102,7 @@ class ZHADevice(LogMixin):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return device name."""
|
"""Return device name."""
|
||||||
return "{} {}".format(self.manufacturer, self.model)
|
return f"{self.manufacturer} {self.model}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ieee(self):
|
def ieee(self):
|
||||||
@ -461,10 +461,10 @@ class ZHADevice(LogMixin):
|
|||||||
except DeliveryError as exc:
|
except DeliveryError as exc:
|
||||||
self.debug(
|
self.debug(
|
||||||
"failed to set attribute: %s %s %s %s %s",
|
"failed to set attribute: %s %s %s %s %s",
|
||||||
"{}: {}".format(ATTR_VALUE, value),
|
f"{ATTR_VALUE}: {value}",
|
||||||
"{}: {}".format(ATTR_ATTRIBUTE, attribute),
|
f"{ATTR_ATTRIBUTE}: {attribute}",
|
||||||
"{}: {}".format(ATTR_CLUSTER_ID, cluster_id),
|
f"{ATTR_CLUSTER_ID}: {cluster_id}",
|
||||||
"{}: {}".format(ATTR_ENDPOINT_ID, endpoint_id),
|
f"{ATTR_ENDPOINT_ID}: {endpoint_id}",
|
||||||
exc,
|
exc,
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
@ -493,13 +493,13 @@ class ZHADevice(LogMixin):
|
|||||||
|
|
||||||
self.debug(
|
self.debug(
|
||||||
"Issued cluster command: %s %s %s %s %s %s %s",
|
"Issued cluster command: %s %s %s %s %s %s %s",
|
||||||
"{}: {}".format(ATTR_CLUSTER_ID, cluster_id),
|
f"{ATTR_CLUSTER_ID}: {cluster_id}",
|
||||||
"{}: {}".format(ATTR_COMMAND, command),
|
f"{ATTR_COMMAND}: {command}",
|
||||||
"{}: {}".format(ATTR_COMMAND_TYPE, command_type),
|
f"{ATTR_COMMAND_TYPE}: {command_type}",
|
||||||
"{}: {}".format(ATTR_ARGS, args),
|
f"{ATTR_ARGS}: {args}",
|
||||||
"{}: {}".format(ATTR_CLUSTER_ID, cluster_type),
|
f"{ATTR_CLUSTER_ID}: {cluster_type}",
|
||||||
"{}: {}".format(ATTR_MANUFACTURER, manufacturer),
|
f"{ATTR_MANUFACTURER}: {manufacturer}",
|
||||||
"{}: {}".format(ATTR_ENDPOINT_ID, endpoint_id),
|
f"{ATTR_ENDPOINT_ID}: {endpoint_id}",
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def async_process_endpoint(
|
|||||||
|
|
||||||
component = None
|
component = None
|
||||||
profile_clusters = []
|
profile_clusters = []
|
||||||
device_key = "{}-{}".format(device.ieee, endpoint_id)
|
device_key = f"{device.ieee}-{endpoint_id}"
|
||||||
node_config = {}
|
node_config = {}
|
||||||
if CONF_DEVICE_CONFIG in config:
|
if CONF_DEVICE_CONFIG in config:
|
||||||
node_config = config[CONF_DEVICE_CONFIG].get(device_key, {})
|
node_config = config[CONF_DEVICE_CONFIG].get(device_key, {})
|
||||||
@ -281,12 +281,12 @@ def _async_handle_single_cluster_match(
|
|||||||
channels = []
|
channels = []
|
||||||
_async_create_cluster_channel(cluster, zha_device, is_new_join, channels=channels)
|
_async_create_cluster_channel(cluster, zha_device, is_new_join, channels=channels)
|
||||||
|
|
||||||
cluster_key = "{}-{}".format(device_key, cluster.cluster_id)
|
cluster_key = f"{device_key}-{cluster.cluster_id}"
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
"unique_id": cluster_key,
|
"unique_id": cluster_key,
|
||||||
"zha_device": zha_device,
|
"zha_device": zha_device,
|
||||||
"channels": channels,
|
"channels": channels,
|
||||||
"entity_suffix": "_{}".format(cluster.cluster_id),
|
"entity_suffix": f"_{cluster.cluster_id}",
|
||||||
"component": component,
|
"component": component,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ class ZHAGateway:
|
|||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"device - %s entering async_device_initialized - is_new_join: %s",
|
"device - %s entering async_device_initialized - is_new_join: %s",
|
||||||
"0x{:04x}:{}".format(device.nwk, device.ieee),
|
f"0x{device.nwk:04x}:{device.ieee}",
|
||||||
zha_device.status is not DeviceStatus.INITIALIZED,
|
zha_device.status is not DeviceStatus.INITIALIZED,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -348,13 +348,13 @@ class ZHAGateway:
|
|||||||
# new nwk or device was physically reset and added again without being removed
|
# new nwk or device was physically reset and added again without being removed
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"device - %s has been reset and readded or its nwk address changed",
|
"device - %s has been reset and readded or its nwk address changed",
|
||||||
"0x{:04x}:{}".format(device.nwk, device.ieee),
|
f"0x{device.nwk:04x}:{device.ieee}",
|
||||||
)
|
)
|
||||||
await self._async_device_rejoined(zha_device)
|
await self._async_device_rejoined(zha_device)
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"device - %s has joined the ZHA zigbee network",
|
"device - %s has joined the ZHA zigbee network",
|
||||||
"0x{:04x}:{}".format(device.nwk, device.ieee),
|
f"0x{device.nwk:04x}:{device.ieee}",
|
||||||
)
|
)
|
||||||
await self._async_device_joined(device, zha_device)
|
await self._async_device_joined(device, zha_device)
|
||||||
|
|
||||||
@ -413,9 +413,9 @@ class ZHAGateway:
|
|||||||
# to update it now
|
# to update it now
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"attempting to request fresh state for device - %s %s %s",
|
"attempting to request fresh state for device - %s %s %s",
|
||||||
"0x{:04x}:{}".format(zha_device.nwk, zha_device.ieee),
|
f"0x{zha_device.nwk:04x}:{zha_device.ieee}",
|
||||||
zha_device.name,
|
zha_device.name,
|
||||||
"with power source: {}".format(zha_device.power_source),
|
f"with power source: {zha_device.power_source}",
|
||||||
)
|
)
|
||||||
await zha_device.async_initialize(from_cache=False)
|
await zha_device.async_initialize(from_cache=False)
|
||||||
else:
|
else:
|
||||||
@ -427,7 +427,7 @@ class ZHAGateway:
|
|||||||
async def _async_device_rejoined(self, zha_device):
|
async def _async_device_rejoined(self, zha_device):
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"skipping discovery for previously discovered device - %s",
|
"skipping discovery for previously discovered device - %s",
|
||||||
"0x{:04x}:{}".format(zha_device.nwk, zha_device.ieee),
|
f"0x{zha_device.nwk:04x}:{zha_device.ieee}",
|
||||||
)
|
)
|
||||||
# we don't have to do this on a nwk swap but we don't have a way to tell currently
|
# we don't have to do this on a nwk swap but we don't have a way to tell currently
|
||||||
await zha_device.async_configure()
|
await zha_device.async_configure()
|
||||||
|
@ -189,7 +189,7 @@ class ZhaEntity(RestoreEntity, LogMixin, entity.Entity):
|
|||||||
unsub = async_dispatcher_connect(self.hass, signal, func)
|
unsub = async_dispatcher_connect(self.hass, signal, func)
|
||||||
else:
|
else:
|
||||||
unsub = async_dispatcher_connect(
|
unsub = async_dispatcher_connect(
|
||||||
self.hass, "{}_{}".format(channel.unique_id, signal), func
|
self.hass, f"{channel.unique_id}_{signal}", func
|
||||||
)
|
)
|
||||||
self._unsubs.append(unsub)
|
self._unsubs.append(unsub)
|
||||||
|
|
||||||
|
@ -206,5 +206,5 @@ class ZiggoMediaboxXLDevice(MediaPlayerDevice):
|
|||||||
if digits is None:
|
if digits is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.send_keys(["NUM_{}".format(digit) for digit in str(digits)])
|
self.send_keys([f"NUM_{digit}" for digit in str(digits)])
|
||||||
self._state = STATE_PLAYING
|
self._state = STATE_PLAYING
|
||||||
|
@ -64,7 +64,7 @@ def setup(hass, config):
|
|||||||
schema = "http"
|
schema = "http"
|
||||||
|
|
||||||
host_name = conf[CONF_HOST]
|
host_name = conf[CONF_HOST]
|
||||||
server_origin = "{}://{}".format(schema, host_name)
|
server_origin = f"{schema}://{host_name}"
|
||||||
zm_client = ZoneMinder(
|
zm_client = ZoneMinder(
|
||||||
server_origin,
|
server_origin,
|
||||||
conf.get(CONF_USERNAME),
|
conf.get(CONF_USERNAME),
|
||||||
|
@ -68,7 +68,7 @@ class ZMSensorMonitors(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} Status".format(self._monitor.name)
|
return f"{self._monitor.name} Status"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
@ -105,7 +105,7 @@ class ZMSensorEvents(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} {}".format(self._monitor.name, self.time_period.title)
|
return f"{self._monitor.name} {self.time_period.title}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
@ -53,7 +53,7 @@ class ZMSwitchMonitors(SwitchDevice):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the switch."""
|
"""Return the name of the switch."""
|
||||||
return "{} State".format(self._monitor.name)
|
return f"{self._monitor.name} State"
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the switch value."""
|
"""Update the switch value."""
|
||||||
|
@ -478,10 +478,10 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
|
|
||||||
def node_removed(node):
|
def node_removed(node):
|
||||||
node_id = node.node_id
|
node_id = node.node_id
|
||||||
node_key = "node-{}".format(node_id)
|
node_key = f"node-{node_id}"
|
||||||
_LOGGER.info("Node Removed: %s", hass.data[DATA_DEVICES][node_key])
|
_LOGGER.info("Node Removed: %s", hass.data[DATA_DEVICES][node_key])
|
||||||
for key in list(hass.data[DATA_DEVICES]):
|
for key in list(hass.data[DATA_DEVICES]):
|
||||||
if not key.startswith("{}-".format(node_id)):
|
if not key.startswith(f"{node_id}-"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
entity = hass.data[DATA_DEVICES][key]
|
entity = hass.data[DATA_DEVICES][key]
|
||||||
@ -586,11 +586,11 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
update_ids = service.data.get(const.ATTR_UPDATE_IDS)
|
update_ids = service.data.get(const.ATTR_UPDATE_IDS)
|
||||||
# We want to rename the device, the node entity,
|
# We want to rename the device, the node entity,
|
||||||
# and all the contained entities
|
# and all the contained entities
|
||||||
node_key = "node-{}".format(node_id)
|
node_key = f"node-{node_id}"
|
||||||
entity = hass.data[DATA_DEVICES][node_key]
|
entity = hass.data[DATA_DEVICES][node_key]
|
||||||
await entity.node_renamed(update_ids)
|
await entity.node_renamed(update_ids)
|
||||||
for key in list(hass.data[DATA_DEVICES]):
|
for key in list(hass.data[DATA_DEVICES]):
|
||||||
if not key.startswith("{}-".format(node_id)):
|
if not key.startswith(f"{node_id}-"):
|
||||||
continue
|
continue
|
||||||
entity = hass.data[DATA_DEVICES][key]
|
entity = hass.data[DATA_DEVICES][key]
|
||||||
await entity.value_renamed(update_ids)
|
await entity.value_renamed(update_ids)
|
||||||
@ -607,7 +607,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
"Renamed Z-Wave value (Node %d Value %d) to %s", node_id, value_id, name
|
"Renamed Z-Wave value (Node %d Value %d) to %s", node_id, value_id, name
|
||||||
)
|
)
|
||||||
update_ids = service.data.get(const.ATTR_UPDATE_IDS)
|
update_ids = service.data.get(const.ATTR_UPDATE_IDS)
|
||||||
value_key = "{}-{}".format(node_id, value_id)
|
value_key = f"{node_id}-{value_id}"
|
||||||
entity = hass.data[DATA_DEVICES][value_key]
|
entity = hass.data[DATA_DEVICES][value_key]
|
||||||
await entity.value_renamed(update_ids)
|
await entity.value_renamed(update_ids)
|
||||||
|
|
||||||
@ -1109,7 +1109,7 @@ class ZWaveDeviceEntityValues:
|
|||||||
if polling_intensity:
|
if polling_intensity:
|
||||||
self.primary.enable_poll(polling_intensity)
|
self.primary.enable_poll(polling_intensity)
|
||||||
|
|
||||||
platform = import_module(".{}".format(component), __name__)
|
platform = import_module(f".{component}", __name__)
|
||||||
|
|
||||||
device = platform.get_device(
|
device = platform.get_device(
|
||||||
node=self._node, values=self, node_config=node_config, hass=self._hass
|
node=self._node, values=self, node_config=node_config, hass=self._hass
|
||||||
@ -1149,9 +1149,7 @@ class ZWaveDeviceEntityValues:
|
|||||||
|
|
||||||
self._hass.data[DATA_DEVICES][device.unique_id] = device
|
self._hass.data[DATA_DEVICES][device.unique_id] = device
|
||||||
if component in SUPPORTED_PLATFORMS:
|
if component in SUPPORTED_PLATFORMS:
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(self._hass, f"zwave_new_{component}", device)
|
||||||
self._hass, "zwave_new_{}".format(component), device
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
await discovery.async_load_platform(
|
await discovery.async_load_platform(
|
||||||
self._hass,
|
self._hass,
|
||||||
@ -1316,4 +1314,4 @@ class ZWaveDeviceEntity(ZWaveBaseEntity):
|
|||||||
|
|
||||||
def compute_value_unique_id(node, value):
|
def compute_value_unique_id(node, value):
|
||||||
"""Compute unique_id a value would get if it were to get one."""
|
"""Compute unique_id a value would get if it were to get one."""
|
||||||
return "{}-{}".format(node.node_id, value.object_id)
|
return f"{node.node_id}-{value.object_id}"
|
||||||
|
@ -348,5 +348,5 @@ class ZWaveNodeEntity(ZWaveBaseEntity):
|
|||||||
|
|
||||||
def _compute_unique_id(self):
|
def _compute_unique_id(self):
|
||||||
if is_node_parsed(self.node) or self.node.is_ready:
|
if is_node_parsed(self.node) or self.node.is_ready:
|
||||||
return "node-{}".format(self.node_id)
|
return f"node-{self.node_id}"
|
||||||
return None
|
return None
|
||||||
|
@ -91,8 +91,8 @@ def check_value_schema(value, schema):
|
|||||||
def node_name(node):
|
def node_name(node):
|
||||||
"""Return the name of the node."""
|
"""Return the name of the node."""
|
||||||
if is_node_parsed(node):
|
if is_node_parsed(node):
|
||||||
return node.name or "{} {}".format(node.manufacturer_name, node.product_name)
|
return node.name or f"{node.manufacturer_name} {node.product_name}"
|
||||||
return "Unknown Node {}".format(node.node_id)
|
return f"Unknown Node {node.node_id}"
|
||||||
|
|
||||||
|
|
||||||
def node_device_id_and_name(node, instance=1):
|
def node_device_id_and_name(node, instance=1):
|
||||||
@ -100,7 +100,7 @@ def node_device_id_and_name(node, instance=1):
|
|||||||
name = node_name(node)
|
name = node_name(node)
|
||||||
if instance == 1:
|
if instance == 1:
|
||||||
return ((const.DOMAIN, node.node_id), name)
|
return ((const.DOMAIN, node.node_id), name)
|
||||||
name = "{} ({})".format(name, instance)
|
name = f"{name} ({instance})"
|
||||||
return ((const.DOMAIN, node.node_id, instance), name)
|
return ((const.DOMAIN, node.node_id, instance), name)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user