Use literal string interpolation in integrations H-J (f-strings) (#26380)
This commit is contained in:
parent
13bb2ea35a
commit
f9edec19ad
59 changed files with 128 additions and 139 deletions
|
@ -66,7 +66,7 @@ class HabitipySensor(Entity):
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{0}_{1}_{2}".format(habitica.DOMAIN, self._name, self._sensor_name)
|
return f"{habitica.DOMAIN}_{self._name}_{self._sensor_name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
|
@ -323,7 +323,7 @@ class HangoutsBot:
|
||||||
}
|
}
|
||||||
|
|
||||||
self.hass.states.async_set(
|
self.hass.states.async_set(
|
||||||
"{}.conversations".format(DOMAIN),
|
f"{DOMAIN}.conversations",
|
||||||
len(self._conversation_list.get_all()),
|
len(self._conversation_list.get_all()),
|
||||||
attributes=conversations,
|
attributes=conversations,
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,7 +25,7 @@ class HelpIntent(intent.IntentHandler):
|
||||||
help_text = "I understand the following sentences:"
|
help_text = "I understand the following sentences:"
|
||||||
for intent_data in intents.values():
|
for intent_data in intents.values():
|
||||||
for sentence in intent_data["sentences"]:
|
for sentence in intent_data["sentences"]:
|
||||||
help_text += "\n'{}'".format(sentence)
|
help_text += f"\n'{sentence}'"
|
||||||
response.async_set_speech(help_text)
|
response.async_set_speech(help_text)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -61,7 +61,7 @@ class HaveIBeenPwnedSensor(Entity):
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "Breaches {}".format(self._email)
|
return f"Breaches {self._email}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
@ -151,7 +151,7 @@ class HaveIBeenPwnedData:
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
"""Get the latest data for current email from REST service."""
|
"""Get the latest data for current email from REST service."""
|
||||||
try:
|
try:
|
||||||
url = "{}{}?truncateResponse=false".format(URL, self._email)
|
url = f"{URL}{self._email}?truncateResponse=false"
|
||||||
header = {USER_AGENT: HA_USER_AGENT, "hibp-api-key": self._api_key}
|
header = {USER_AGENT: HA_USER_AGENT, "hibp-api-key": self._api_key}
|
||||||
_LOGGER.debug("Checking for breaches for email: %s", self._email)
|
_LOGGER.debug("Checking for breaches for email: %s", self._email)
|
||||||
req = requests.get(url, headers=header, allow_redirects=True, timeout=5)
|
req = requests.get(url, headers=header, allow_redirects=True, timeout=5)
|
||||||
|
|
|
@ -67,7 +67,7 @@ class HddTempSensor(Entity):
|
||||||
"""Initialize a HDDTemp sensor."""
|
"""Initialize a HDDTemp sensor."""
|
||||||
self.hddtemp = hddtemp
|
self.hddtemp = hddtemp
|
||||||
self.disk = disk
|
self.disk = disk
|
||||||
self._name = "{} {}".format(name, disk)
|
self._name = f"{name} {disk}"
|
||||||
self._state = None
|
self._state = None
|
||||||
self._details = None
|
self._details = None
|
||||||
self._unit = None
|
self._unit = None
|
||||||
|
|
|
@ -264,7 +264,7 @@ def setup(hass: HomeAssistant, base_config):
|
||||||
if isinstance(data[ATTR_ATT], (list,)):
|
if isinstance(data[ATTR_ATT], (list,)):
|
||||||
att = data[ATTR_ATT]
|
att = data[ATTR_ATT]
|
||||||
else:
|
else:
|
||||||
att = reduce(lambda x, y: "%s:%x" % (x, y), data[ATTR_ATT])
|
att = reduce(lambda x, y: f"{x}:{y:x}", data[ATTR_ATT])
|
||||||
else:
|
else:
|
||||||
att = ""
|
att = ""
|
||||||
command = CecCommand(cmd, dst, src, att)
|
command = CecCommand(cmd, dst, src, att)
|
||||||
|
@ -312,7 +312,7 @@ def setup(hass: HomeAssistant, base_config):
|
||||||
|
|
||||||
def _new_device(device):
|
def _new_device(device):
|
||||||
"""Handle new devices which are detected by HDMI network."""
|
"""Handle new devices which are detected by HDMI network."""
|
||||||
key = "{}.{}".format(DOMAIN, device.name)
|
key = f"{DOMAIN}.{device.name}"
|
||||||
hass.data[key] = device
|
hass.data[key] = device
|
||||||
ent_platform = base_config[DOMAIN][CONF_TYPES].get(key, platform)
|
ent_platform = base_config[DOMAIN][CONF_TYPES].get(key, platform)
|
||||||
discovery.load_platform(
|
discovery.load_platform(
|
||||||
|
@ -399,7 +399,7 @@ class CecDevice(Entity):
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return (
|
return (
|
||||||
"%s %s" % (self.vendor_name, self._device.osd_name)
|
f"{self.vendor_name} {self._device.osd_name}"
|
||||||
if (
|
if (
|
||||||
self._device.osd_name is not None
|
self._device.osd_name is not None
|
||||||
and self.vendor_name is not None
|
and self.vendor_name is not None
|
||||||
|
|
|
@ -10,7 +10,7 @@ from .const import DATA_DISCOVERED_HOSTS, DOMAIN
|
||||||
|
|
||||||
def format_title(host: str) -> str:
|
def format_title(host: str) -> str:
|
||||||
"""Format the title for config entries."""
|
"""Format the title for config entries."""
|
||||||
return "Controller ({})".format(host)
|
return f"Controller ({host})"
|
||||||
|
|
||||||
|
|
||||||
@config_entries.HANDLERS.register(DOMAIN)
|
@config_entries.HANDLERS.register(DOMAIN)
|
||||||
|
|
|
@ -183,7 +183,7 @@ class HeosMediaPlayer(MediaPlayerDevice):
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
if index is None:
|
if index is None:
|
||||||
raise ValueError("Invalid quick select '{}'".format(media_id))
|
raise ValueError(f"Invalid quick select '{media_id}'")
|
||||||
await self._player.play_quick_select(index)
|
await self._player.play_quick_select(index)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ class HeosMediaPlayer(MediaPlayerDevice):
|
||||||
playlists = await self._player.heos.get_playlists()
|
playlists = await self._player.heos.get_playlists()
|
||||||
playlist = next((p for p in playlists if p.name == media_id), None)
|
playlist = next((p for p in playlists if p.name == media_id), None)
|
||||||
if not playlist:
|
if not playlist:
|
||||||
raise ValueError("Invalid playlist '{}'".format(media_id))
|
raise ValueError(f"Invalid playlist '{media_id}'")
|
||||||
add_queue_option = (
|
add_queue_option = (
|
||||||
heos_const.ADD_QUEUE_ADD_TO_END
|
heos_const.ADD_QUEUE_ADD_TO_END
|
||||||
if kwargs.get(ATTR_MEDIA_ENQUEUE)
|
if kwargs.get(ATTR_MEDIA_ENQUEUE)
|
||||||
|
@ -215,11 +215,11 @@ class HeosMediaPlayer(MediaPlayerDevice):
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
if index is None:
|
if index is None:
|
||||||
raise ValueError("Invalid favorite '{}'".format(media_id))
|
raise ValueError(f"Invalid favorite '{media_id}'")
|
||||||
await self._player.play_favorite(index)
|
await self._player.play_favorite(index)
|
||||||
return
|
return
|
||||||
|
|
||||||
raise ValueError("Unsupported media type '{}'".format(media_type))
|
raise ValueError(f"Unsupported media type '{media_type}'")
|
||||||
|
|
||||||
@log_command_error("select source")
|
@log_command_error("select source")
|
||||||
async def async_select_source(self, source):
|
async def async_select_source(self, source):
|
||||||
|
|
|
@ -93,7 +93,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
else:
|
else:
|
||||||
protocol = "http"
|
protocol = "http"
|
||||||
|
|
||||||
url = "{}://{}".format(protocol, host)
|
url = f"{protocol}://{host}"
|
||||||
|
|
||||||
data = HikvisionData(hass, url, port, name, username, password)
|
data = HikvisionData(hass, url, port, name, username, password)
|
||||||
|
|
||||||
|
@ -196,11 +196,11 @@ class HikvisionBinarySensor(BinarySensorDevice):
|
||||||
self._channel = channel
|
self._channel = channel
|
||||||
|
|
||||||
if self._cam.type == "NVR":
|
if self._cam.type == "NVR":
|
||||||
self._name = "{} {} {}".format(self._cam.name, sensor, channel)
|
self._name = f"{self._cam.name} {sensor} {channel}"
|
||||||
else:
|
else:
|
||||||
self._name = "{} {}".format(self._cam.name, sensor)
|
self._name = f"{self._cam.name} {sensor}"
|
||||||
|
|
||||||
self._id = "{}.{}.{}".format(self._cam.cam_id, sensor, channel)
|
self._id = f"{self._cam.cam_id}.{sensor}.{channel}"
|
||||||
|
|
||||||
if delay is None:
|
if delay is None:
|
||||||
self._delay = 0
|
self._delay = 0
|
||||||
|
|
|
@ -44,8 +44,8 @@ class HitronCODADeviceScanner(DeviceScanner):
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
self.last_results = []
|
self.last_results = []
|
||||||
host = config[CONF_HOST]
|
host = config[CONF_HOST]
|
||||||
self._url = "http://{}/data/getConnectInfo.asp".format(host)
|
self._url = f"http://{host}/data/getConnectInfo.asp"
|
||||||
self._loginurl = "http://{}/goform/login".format(host)
|
self._loginurl = f"http://{host}/goform/login"
|
||||||
|
|
||||||
self._username = config.get(CONF_USERNAME)
|
self._username = config.get(CONF_USERNAME)
|
||||||
self._password = config.get(CONF_PASSWORD)
|
self._password = config.get(CONF_PASSWORD)
|
||||||
|
|
|
@ -26,8 +26,8 @@ class HiveBinarySensorEntity(BinarySensorDevice):
|
||||||
self.node_device_type = hivedevice["Hive_DeviceType"]
|
self.node_device_type = hivedevice["Hive_DeviceType"]
|
||||||
self.session = hivesession
|
self.session = hivesession
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
self.data_updatesource = "{}.{}".format(self.device_type, self.node_id)
|
self.data_updatesource = f"{self.device_type}.{self.node_id}"
|
||||||
self._unique_id = "{}-{}".format(self.node_id, self.device_type)
|
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||||
self.session.entities.append(self)
|
self.session.entities.append(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -42,7 +42,7 @@ class HiveBinarySensorEntity(BinarySensorDevice):
|
||||||
|
|
||||||
def handle_update(self, updatesource):
|
def handle_update(self, updatesource):
|
||||||
"""Handle the new update request."""
|
"""Handle the new update request."""
|
||||||
if "{}.{}".format(self.device_type, self.node_id) not in updatesource:
|
if f"{self.device_type}.{self.node_id}" not in updatesource:
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -54,8 +54,8 @@ class HiveClimateEntity(ClimateDevice):
|
||||||
self.thermostat_node_id = hivedevice["Thermostat_NodeID"]
|
self.thermostat_node_id = hivedevice["Thermostat_NodeID"]
|
||||||
self.session = hivesession
|
self.session = hivesession
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
self.data_updatesource = "{}.{}".format(self.device_type, self.node_id)
|
self.data_updatesource = f"{self.device_type}.{self.node_id}"
|
||||||
self._unique_id = "{}-{}".format(self.node_id, self.device_type)
|
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
@ -74,7 +74,7 @@ class HiveClimateEntity(ClimateDevice):
|
||||||
|
|
||||||
def handle_update(self, updatesource):
|
def handle_update(self, updatesource):
|
||||||
"""Handle the new update request."""
|
"""Handle the new update request."""
|
||||||
if "{}.{}".format(self.device_type, self.node_id) not in updatesource:
|
if f"{self.device_type}.{self.node_id}" not in updatesource:
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -82,7 +82,7 @@ class HiveClimateEntity(ClimateDevice):
|
||||||
"""Return the name of the Climate device."""
|
"""Return the name of the Climate device."""
|
||||||
friendly_name = "Heating"
|
friendly_name = "Heating"
|
||||||
if self.node_name is not None:
|
if self.node_name is not None:
|
||||||
friendly_name = "{} {}".format(self.node_name, friendly_name)
|
friendly_name = f"{self.node_name} {friendly_name}"
|
||||||
return friendly_name
|
return friendly_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -33,8 +33,8 @@ class HiveDeviceLight(Light):
|
||||||
self.light_device_type = hivedevice["Hive_Light_DeviceType"]
|
self.light_device_type = hivedevice["Hive_Light_DeviceType"]
|
||||||
self.session = hivesession
|
self.session = hivesession
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
self.data_updatesource = "{}.{}".format(self.device_type, self.node_id)
|
self.data_updatesource = f"{self.device_type}.{self.node_id}"
|
||||||
self._unique_id = "{}-{}".format(self.node_id, self.device_type)
|
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||||
self.session.entities.append(self)
|
self.session.entities.append(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -49,7 +49,7 @@ class HiveDeviceLight(Light):
|
||||||
|
|
||||||
def handle_update(self, updatesource):
|
def handle_update(self, updatesource):
|
||||||
"""Handle the new update request."""
|
"""Handle the new update request."""
|
||||||
if "{}.{}".format(self.device_type, self.node_id) not in updatesource:
|
if f"{self.device_type}.{self.node_id}" not in updatesource:
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -37,8 +37,8 @@ class HiveSensorEntity(Entity):
|
||||||
self.device_type = hivedevice["HA_DeviceType"]
|
self.device_type = hivedevice["HA_DeviceType"]
|
||||||
self.node_device_type = hivedevice["Hive_DeviceType"]
|
self.node_device_type = hivedevice["Hive_DeviceType"]
|
||||||
self.session = hivesession
|
self.session = hivesession
|
||||||
self.data_updatesource = "{}.{}".format(self.device_type, self.node_id)
|
self.data_updatesource = f"{self.device_type}.{self.node_id}"
|
||||||
self._unique_id = "{}-{}".format(self.node_id, self.device_type)
|
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||||
self.session.entities.append(self)
|
self.session.entities.append(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -53,7 +53,7 @@ class HiveSensorEntity(Entity):
|
||||||
|
|
||||||
def handle_update(self, updatesource):
|
def handle_update(self, updatesource):
|
||||||
"""Handle the new update request."""
|
"""Handle the new update request."""
|
||||||
if "{}.{}".format(self.device_type, self.node_id) not in updatesource:
|
if f"{self.device_type}.{self.node_id}" not in updatesource:
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -23,8 +23,8 @@ class HiveDevicePlug(SwitchDevice):
|
||||||
self.device_type = hivedevice["HA_DeviceType"]
|
self.device_type = hivedevice["HA_DeviceType"]
|
||||||
self.session = hivesession
|
self.session = hivesession
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
self.data_updatesource = "{}.{}".format(self.device_type, self.node_id)
|
self.data_updatesource = f"{self.device_type}.{self.node_id}"
|
||||||
self._unique_id = "{}-{}".format(self.node_id, self.device_type)
|
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||||
self.session.entities.append(self)
|
self.session.entities.append(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -39,7 +39,7 @@ class HiveDevicePlug(SwitchDevice):
|
||||||
|
|
||||||
def handle_update(self, updatesource):
|
def handle_update(self, updatesource):
|
||||||
"""Handle the new update request."""
|
"""Handle the new update request."""
|
||||||
if "{}.{}".format(self.device_type, self.node_id) not in updatesource:
|
if f"{self.device_type}.{self.node_id}" not in updatesource:
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -42,8 +42,8 @@ class HiveWaterHeater(WaterHeaterDevice):
|
||||||
self.node_name = hivedevice["Hive_NodeName"]
|
self.node_name = hivedevice["Hive_NodeName"]
|
||||||
self.device_type = hivedevice["HA_DeviceType"]
|
self.device_type = hivedevice["HA_DeviceType"]
|
||||||
self.session = hivesession
|
self.session = hivesession
|
||||||
self.data_updatesource = "{}.{}".format(self.device_type, self.node_id)
|
self.data_updatesource = f"{self.device_type}.{self.node_id}"
|
||||||
self._unique_id = "{}-{}".format(self.node_id, self.device_type)
|
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||||
self._unit_of_measurement = TEMP_CELSIUS
|
self._unit_of_measurement = TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -63,7 +63,7 @@ class HiveWaterHeater(WaterHeaterDevice):
|
||||||
|
|
||||||
def handle_update(self, updatesource):
|
def handle_update(self, updatesource):
|
||||||
"""Handle the new update request."""
|
"""Handle the new update request."""
|
||||||
if "{}.{}".format(self.device_type, self.node_id) not in updatesource:
|
if f"{self.device_type}.{self.node_id}" not in updatesource:
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -110,7 +110,7 @@ async def async_setup(hass: ha.HomeAssistant, config: dict) -> Awaitable[bool]:
|
||||||
hass.components.persistent_notification.async_create(
|
hass.components.persistent_notification.async_create(
|
||||||
"Config error. See dev-info panel for details.",
|
"Config error. See dev-info panel for details.",
|
||||||
"Config validating",
|
"Config validating",
|
||||||
"{0}.check_config".format(ha.DOMAIN),
|
f"{ha.DOMAIN}.check_config",
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -127,9 +127,7 @@ class Light(HomeAccessory):
|
||||||
self.set_state(0) # Turn off light
|
self.set_state(0) # Turn off light
|
||||||
return
|
return
|
||||||
params = {ATTR_ENTITY_ID: self.entity_id, ATTR_BRIGHTNESS_PCT: value}
|
params = {ATTR_ENTITY_ID: self.entity_id, ATTR_BRIGHTNESS_PCT: value}
|
||||||
self.call_service(
|
self.call_service(DOMAIN, SERVICE_TURN_ON, params, f"brightness at {value}%")
|
||||||
DOMAIN, SERVICE_TURN_ON, params, "brightness at {}%".format(value)
|
|
||||||
)
|
|
||||||
|
|
||||||
def set_color_temperature(self, value):
|
def set_color_temperature(self, value):
|
||||||
"""Set color temperature if call came from HomeKit."""
|
"""Set color temperature if call came from HomeKit."""
|
||||||
|
@ -137,7 +135,7 @@ class Light(HomeAccessory):
|
||||||
self._flag[CHAR_COLOR_TEMPERATURE] = True
|
self._flag[CHAR_COLOR_TEMPERATURE] = True
|
||||||
params = {ATTR_ENTITY_ID: self.entity_id, ATTR_COLOR_TEMP: value}
|
params = {ATTR_ENTITY_ID: self.entity_id, ATTR_COLOR_TEMP: value}
|
||||||
self.call_service(
|
self.call_service(
|
||||||
DOMAIN, SERVICE_TURN_ON, params, "color temperature at {}".format(value)
|
DOMAIN, SERVICE_TURN_ON, params, f"color temperature at {value}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_saturation(self, value):
|
def set_saturation(self, value):
|
||||||
|
@ -167,9 +165,7 @@ class Light(HomeAccessory):
|
||||||
{CHAR_HUE: False, CHAR_SATURATION: False, RGB_COLOR: True}
|
{CHAR_HUE: False, CHAR_SATURATION: False, RGB_COLOR: True}
|
||||||
)
|
)
|
||||||
params = {ATTR_ENTITY_ID: self.entity_id, ATTR_HS_COLOR: color}
|
params = {ATTR_ENTITY_ID: self.entity_id, ATTR_HS_COLOR: color}
|
||||||
self.call_service(
|
self.call_service(DOMAIN, SERVICE_TURN_ON, params, f"set color at {color}")
|
||||||
DOMAIN, SERVICE_TURN_ON, params, "set color at {}".format(color)
|
|
||||||
)
|
|
||||||
|
|
||||||
def update_state(self, new_state):
|
def update_state(self, new_state):
|
||||||
"""Update light after state change."""
|
"""Update light after state change."""
|
||||||
|
|
|
@ -209,7 +209,7 @@ class Thermostat(HomeAccessory):
|
||||||
DOMAIN_CLIMATE,
|
DOMAIN_CLIMATE,
|
||||||
SERVICE_SET_TEMPERATURE_THERMOSTAT,
|
SERVICE_SET_TEMPERATURE_THERMOSTAT,
|
||||||
params,
|
params,
|
||||||
"cooling threshold {}{}".format(temperature, self._unit),
|
f"cooling threshold {temperature}{self._unit}",
|
||||||
)
|
)
|
||||||
|
|
||||||
@debounce
|
@debounce
|
||||||
|
@ -230,7 +230,7 @@ class Thermostat(HomeAccessory):
|
||||||
DOMAIN_CLIMATE,
|
DOMAIN_CLIMATE,
|
||||||
SERVICE_SET_TEMPERATURE_THERMOSTAT,
|
SERVICE_SET_TEMPERATURE_THERMOSTAT,
|
||||||
params,
|
params,
|
||||||
"heating threshold {}{}".format(temperature, self._unit),
|
f"heating threshold {temperature}{self._unit}",
|
||||||
)
|
)
|
||||||
|
|
||||||
@debounce
|
@debounce
|
||||||
|
@ -244,7 +244,7 @@ class Thermostat(HomeAccessory):
|
||||||
DOMAIN_CLIMATE,
|
DOMAIN_CLIMATE,
|
||||||
SERVICE_SET_TEMPERATURE_THERMOSTAT,
|
SERVICE_SET_TEMPERATURE_THERMOSTAT,
|
||||||
params,
|
params,
|
||||||
"{}{}".format(temperature, self._unit),
|
f"{temperature}{self._unit}",
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_state(self, new_state):
|
def update_state(self, new_state):
|
||||||
|
@ -378,7 +378,7 @@ class WaterHeater(HomeAccessory):
|
||||||
DOMAIN_WATER_HEATER,
|
DOMAIN_WATER_HEATER,
|
||||||
SERVICE_SET_TEMPERATURE_WATER_HEATER,
|
SERVICE_SET_TEMPERATURE_WATER_HEATER,
|
||||||
params,
|
params,
|
||||||
"{}{}".format(temperature, self._unit),
|
f"{temperature}{self._unit}",
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_state(self, new_state):
|
def update_state(self, new_state):
|
||||||
|
|
|
@ -116,9 +116,7 @@ def validate_entity_config(values):
|
||||||
params = MEDIA_PLAYER_SCHEMA(feature)
|
params = MEDIA_PLAYER_SCHEMA(feature)
|
||||||
key = params.pop(CONF_FEATURE)
|
key = params.pop(CONF_FEATURE)
|
||||||
if key in feature_list:
|
if key in feature_list:
|
||||||
raise vol.Invalid(
|
raise vol.Invalid(f"A feature can be added only once for {entity}")
|
||||||
"A feature can be added only once for {}".format(entity)
|
|
||||||
)
|
|
||||||
feature_list[key] = params
|
feature_list[key] = params
|
||||||
config[CONF_FEATURE_LIST] = feature_list
|
config[CONF_FEATURE_LIST] = feature_list
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ class HomeKitEntity(Entity):
|
||||||
# Callback to allow entity to configure itself based on this
|
# Callback to allow entity to configure itself based on this
|
||||||
# characteristics metadata (valid values, value ranges, features, etc)
|
# characteristics metadata (valid values, value ranges, features, etc)
|
||||||
setup_fn_name = escape_characteristic_name(short_name)
|
setup_fn_name = escape_characteristic_name(short_name)
|
||||||
setup_fn = getattr(self, "_setup_{}".format(setup_fn_name), None)
|
setup_fn = getattr(self, f"_setup_{setup_fn_name}", None)
|
||||||
if not setup_fn:
|
if not setup_fn:
|
||||||
return
|
return
|
||||||
# pylint: disable=not-callable
|
# pylint: disable=not-callable
|
||||||
|
@ -128,7 +128,7 @@ class HomeKitEntity(Entity):
|
||||||
|
|
||||||
# Callback to update the entity with this characteristic value
|
# Callback to update the entity with this characteristic value
|
||||||
char_name = escape_characteristic_name(self._char_names[iid])
|
char_name = escape_characteristic_name(self._char_names[iid])
|
||||||
update_fn = getattr(self, "_update_{}".format(char_name), None)
|
update_fn = getattr(self, f"_update_{char_name}", None)
|
||||||
if not update_fn:
|
if not update_fn:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class HomeKitEntity(Entity):
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the ID of this device."""
|
"""Return the ID of this device."""
|
||||||
serial = self._accessory_info["serial-number"]
|
serial = self._accessory_info["serial-number"]
|
||||||
return "homekit-{}-{}".format(serial, self._iid)
|
return f"homekit-{serial}-{self._iid}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""Constants for the homekit_controller component."""
|
"""Constants for the homekit_controller component."""
|
||||||
DOMAIN = "homekit_controller"
|
DOMAIN = "homekit_controller"
|
||||||
|
|
||||||
KNOWN_DEVICES = "{}-devices".format(DOMAIN)
|
KNOWN_DEVICES = f"{DOMAIN}-devices"
|
||||||
CONTROLLER = "{}-controller".format(DOMAIN)
|
CONTROLLER = f"{DOMAIN}-controller"
|
||||||
ENTITY_MAP = "{}-entity-map".format(DOMAIN)
|
ENTITY_MAP = f"{DOMAIN}-entity-map"
|
||||||
|
|
||||||
HOMEKIT_DIR = ".homekit"
|
HOMEKIT_DIR = ".homekit"
|
||||||
PAIRING_FILE = "pairing.json"
|
PAIRING_FILE = "pairing.json"
|
||||||
|
|
|
@ -5,7 +5,7 @@ from homeassistant.core import callback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
ENTITY_MAP_STORAGE_KEY = "{}-entity-map".format(DOMAIN)
|
ENTITY_MAP_STORAGE_KEY = f"{DOMAIN}-entity-map"
|
||||||
ENTITY_MAP_STORAGE_VERSION = 1
|
ENTITY_MAP_STORAGE_VERSION = 1
|
||||||
ENTITY_MAP_SAVE_DELAY = 10
|
ENTITY_MAP_SAVE_DELAY = 10
|
||||||
|
|
||||||
|
|
|
@ -711,15 +711,15 @@ def _create_ha_id(name, channel, param, count):
|
||||||
|
|
||||||
# Has multiple elements/channels
|
# Has multiple elements/channels
|
||||||
if count > 1 and param is None:
|
if count > 1 and param is None:
|
||||||
return "{} {}".format(name, channel)
|
return f"{name} {channel}"
|
||||||
|
|
||||||
# With multiple parameters on first channel
|
# With multiple parameters on first channel
|
||||||
if count == 1 and param is not None:
|
if count == 1 and param is not None:
|
||||||
return "{} {}".format(name, param)
|
return f"{name} {param}"
|
||||||
|
|
||||||
# Multiple parameters with multiple channels
|
# Multiple parameters with multiple channels
|
||||||
if count > 1 and param is not None:
|
if count > 1 and param is not None:
|
||||||
return "{} {} {}".format(name, channel, param)
|
return f"{name} {channel} {param}"
|
||||||
|
|
||||||
|
|
||||||
def _hm_event_handler(hass, interface, device, caller, attribute, value):
|
def _hm_event_handler(hass, interface, device, caller, attribute, value):
|
||||||
|
|
|
@ -234,7 +234,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
device_registry = await dr.async_get_registry(hass)
|
device_registry = await dr.async_get_registry(hass)
|
||||||
home = hap.home
|
home = hap.home
|
||||||
# Add the HAP name from configuration if set.
|
# Add the HAP name from configuration if set.
|
||||||
hapname = home.label if not home.name else "{} {}".format(home.label, home.name)
|
hapname = home.label if not home.name else f"{home.label} {home.name}"
|
||||||
device_registry.async_get_or_create(
|
device_registry.async_get_or_create(
|
||||||
config_entry_id=home.id,
|
config_entry_id=home.id,
|
||||||
identifiers={(DOMAIN, home.id)},
|
identifiers={(DOMAIN, home.id)},
|
||||||
|
|
|
@ -112,7 +112,7 @@ class HomematicipAlarmControlPanel(AlarmControlPanel):
|
||||||
"""Return the name of the generic device."""
|
"""Return the name of the generic device."""
|
||||||
name = CONST_ALARM_CONTROL_PANEL_NAME
|
name = CONST_ALARM_CONTROL_PANEL_NAME
|
||||||
if self._home.name:
|
if self._home.name:
|
||||||
name = "{} {}".format(self._home.name, name)
|
name = f"{self._home.name} {name}"
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -131,7 +131,7 @@ class HomematicipAlarmControlPanel(AlarmControlPanel):
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
return "{}_{}".format(self.__class__.__name__, self._home.id)
|
return f"{self.__class__.__name__}_{self._home.id}"
|
||||||
|
|
||||||
|
|
||||||
def _get_zone_alarm_state(security_zone) -> bool:
|
def _get_zone_alarm_state(security_zone) -> bool:
|
||||||
|
|
|
@ -291,7 +291,7 @@ class HomematicipSecurityZoneSensorGroup(HomematicipGenericDevice, BinarySensorD
|
||||||
|
|
||||||
def __init__(self, home: AsyncHome, device, post: str = "SecurityZone") -> None:
|
def __init__(self, home: AsyncHome, device, post: str = "SecurityZone") -> None:
|
||||||
"""Initialize security zone group."""
|
"""Initialize security zone group."""
|
||||||
device.modelType = "HmIP-{}".format(post)
|
device.modelType = f"HmIP-{post}"
|
||||||
super().__init__(home, device, post)
|
super().__init__(home, device, post)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -92,9 +92,9 @@ class HomematicipGenericDevice(Entity):
|
||||||
"""Return the name of the generic device."""
|
"""Return the name of the generic device."""
|
||||||
name = self._device.label
|
name = self._device.label
|
||||||
if self._home.name is not None and self._home.name != "":
|
if self._home.name is not None and self._home.name != "":
|
||||||
name = "{} {}".format(self._home.name, name)
|
name = f"{self._home.name} {name}"
|
||||||
if self.post is not None and self.post != "":
|
if self.post is not None and self.post != "":
|
||||||
name = "{} {}".format(name, self.post)
|
name = f"{name} {self.post}"
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -110,7 +110,7 @@ class HomematicipGenericDevice(Entity):
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
return "{}_{}".format(self.__class__.__name__, self._device.id)
|
return f"{self.__class__.__name__}_{self._device.id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> Optional[str]:
|
def icon(self) -> Optional[str]:
|
||||||
|
|
|
@ -205,7 +205,7 @@ class HomematicipNotificationLight(HomematicipGenericDevice, Light):
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
return "{}_{}_{}".format(self.__class__.__name__, self.post, self._device.id)
|
return f"{self.__class__.__name__}_{self.post}_{self._device.id}"
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs):
|
async def async_turn_on(self, **kwargs):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
|
|
|
@ -93,7 +93,7 @@ class HomematicipGroupSwitch(HomematicipGenericDevice, SwitchDevice):
|
||||||
|
|
||||||
def __init__(self, home: AsyncHome, device, post: str = "Group") -> None:
|
def __init__(self, home: AsyncHome, device, post: str = "Group") -> None:
|
||||||
"""Initialize switching group."""
|
"""Initialize switching group."""
|
||||||
device.modelType = "HmIP-{}".format(post)
|
device.modelType = f"HmIP-{post}"
|
||||||
super().__init__(home, device, post)
|
super().__init__(home, device, post)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -149,12 +149,12 @@ class HomematicipMultiSwitch(HomematicipGenericDevice, SwitchDevice):
|
||||||
def __init__(self, home: AsyncHome, device, channel: int):
|
def __init__(self, home: AsyncHome, device, channel: int):
|
||||||
"""Initialize the multi switch device."""
|
"""Initialize the multi switch device."""
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
super().__init__(home, device, "Channel{}".format(channel))
|
super().__init__(home, device, f"Channel{channel}")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
return "{}_{}_{}".format(self.__class__.__name__, self.post, self._device.id)
|
return f"{self.__class__.__name__}_{self.post}_{self._device.id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
|
|
@ -106,7 +106,7 @@ class HomeworksDevice:
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique identifier."""
|
"""Return a unique identifier."""
|
||||||
return "homeworks.{}".format(self._addr)
|
return f"homeworks.{self._addr}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -318,7 +318,7 @@ class HoneywellUSThermostat(ClimateDevice):
|
||||||
# Get current mode
|
# Get current mode
|
||||||
mode = self._device.system_mode
|
mode = self._device.system_mode
|
||||||
# Set hold if this is not the case
|
# Set hold if this is not the case
|
||||||
if getattr(self._device, "hold_{}".format(mode)) is False:
|
if getattr(self._device, f"hold_{mode}") is False:
|
||||||
# Get next period key
|
# Get next period key
|
||||||
next_period_key = "{}NextPeriod".format(mode.capitalize())
|
next_period_key = "{}NextPeriod".format(mode.capitalize())
|
||||||
# Get next period raw value
|
# Get next period raw value
|
||||||
|
@ -326,11 +326,9 @@ class HoneywellUSThermostat(ClimateDevice):
|
||||||
# Get next period time
|
# Get next period time
|
||||||
hour, minute = divmod(next_period * 15, 60)
|
hour, minute = divmod(next_period * 15, 60)
|
||||||
# Set hold time
|
# Set hold time
|
||||||
setattr(
|
setattr(self._device, f"hold_{mode}", datetime.time(hour, minute))
|
||||||
self._device, "hold_{}".format(mode), datetime.time(hour, minute)
|
|
||||||
)
|
|
||||||
# Set temperature
|
# Set temperature
|
||||||
setattr(self._device, "setpoint_{}".format(mode), temperature)
|
setattr(self._device, f"setpoint_{mode}", temperature)
|
||||||
except somecomfort.SomeComfortError:
|
except somecomfort.SomeComfortError:
|
||||||
_LOGGER.error("Temperature %.1f out of range", temperature)
|
_LOGGER.error("Temperature %.1f out of range", temperature)
|
||||||
|
|
||||||
|
@ -375,17 +373,14 @@ class HoneywellUSThermostat(ClimateDevice):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# Set permanent hold
|
# Set permanent hold
|
||||||
setattr(self._device, "hold_{}".format(mode), True)
|
setattr(self._device, f"hold_{mode}", True)
|
||||||
# Set temperature
|
# Set temperature
|
||||||
setattr(
|
setattr(
|
||||||
self._device,
|
self._device, f"setpoint_{mode}", getattr(self, f"_{mode}_away_temp")
|
||||||
"setpoint_{}".format(mode),
|
|
||||||
getattr(self, "_{}_away_temp".format(mode)),
|
|
||||||
)
|
)
|
||||||
except somecomfort.SomeComfortError:
|
except somecomfort.SomeComfortError:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Temperature %.1f out of range",
|
"Temperature %.1f out of range", getattr(self, f"_{mode}_away_temp")
|
||||||
getattr(self, "_{}_away_temp".format(mode)),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _turn_away_mode_off(self) -> None:
|
def _turn_away_mode_off(self) -> None:
|
||||||
|
|
|
@ -194,4 +194,4 @@ class HpIloData:
|
||||||
hpilo.IloCommunicationError,
|
hpilo.IloCommunicationError,
|
||||||
hpilo.IloLoginFailed,
|
hpilo.IloLoginFailed,
|
||||||
) as error:
|
) as error:
|
||||||
raise ValueError("Unable to init HP ILO, {}".format(error))
|
raise ValueError(f"Unable to init HP ILO, {error}")
|
||||||
|
|
|
@ -570,8 +570,8 @@ def create_vapid_headers(vapid_email, subscription_info, vapid_private_key):
|
||||||
if vapid_email and vapid_private_key and ATTR_ENDPOINT in subscription_info:
|
if vapid_email and vapid_private_key and ATTR_ENDPOINT in subscription_info:
|
||||||
url = urlparse(subscription_info.get(ATTR_ENDPOINT))
|
url = urlparse(subscription_info.get(ATTR_ENDPOINT))
|
||||||
vapid_claims = {
|
vapid_claims = {
|
||||||
"sub": "mailto:{}".format(vapid_email),
|
"sub": f"mailto:{vapid_email}",
|
||||||
"aud": "{}://{}".format(url.scheme, url.netloc),
|
"aud": f"{url.scheme}://{url.netloc}",
|
||||||
}
|
}
|
||||||
vapid = Vapid.from_string(private_key=vapid_private_key)
|
vapid = Vapid.from_string(private_key=vapid_private_key)
|
||||||
return vapid.sign(vapid_claims)
|
return vapid.sign(vapid_claims)
|
||||||
|
|
|
@ -76,7 +76,7 @@ class HTU21DSensor(Entity):
|
||||||
|
|
||||||
def __init__(self, htu21d_client, name, variable, unit):
|
def __init__(self, htu21d_client, name, variable, unit):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._name = "{}_{}".format(name, variable)
|
self._name = f"{name}_{variable}"
|
||||||
self._variable = variable
|
self._variable = variable
|
||||||
self._unit_of_measurement = unit
|
self._unit_of_measurement = unit
|
||||||
self._client = htu21d_client
|
self._client = htu21d_client
|
||||||
|
|
|
@ -175,7 +175,7 @@ class HuaweiLteSensor(Entity):
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return unique ID for sensor."""
|
"""Return unique ID for sensor."""
|
||||||
return "{}-{}".format(self.data.mac, self.path)
|
return f"{self.data.mac}-{self.path}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
|
|
@ -119,12 +119,12 @@ class HuaweiDeviceScanner(DeviceScanner):
|
||||||
|
|
||||||
def _get_devices_response(self):
|
def _get_devices_response(self):
|
||||||
"""Get the raw string with the devices from the router."""
|
"""Get the raw string with the devices from the router."""
|
||||||
cnt = requests.post("http://{}/asp/GetRandCount.asp".format(self.host))
|
cnt = requests.post(f"http://{self.host}/asp/GetRandCount.asp")
|
||||||
cnt_str = str(cnt.content, cnt.apparent_encoding, errors="replace")
|
cnt_str = str(cnt.content, cnt.apparent_encoding, errors="replace")
|
||||||
|
|
||||||
_LOGGER.debug("Logging in")
|
_LOGGER.debug("Logging in")
|
||||||
cookie = requests.post(
|
cookie = requests.post(
|
||||||
"http://{}/login.cgi".format(self.host),
|
f"http://{self.host}/login.cgi",
|
||||||
data=[
|
data=[
|
||||||
("UserName", self.username),
|
("UserName", self.username),
|
||||||
("PassWord", self.password),
|
("PassWord", self.password),
|
||||||
|
@ -136,13 +136,13 @@ class HuaweiDeviceScanner(DeviceScanner):
|
||||||
_LOGGER.debug("Requesting lan user info update")
|
_LOGGER.debug("Requesting lan user info update")
|
||||||
# this request is needed or else some devices' state won't be updated
|
# this request is needed or else some devices' state won't be updated
|
||||||
requests.get(
|
requests.get(
|
||||||
"http://{}/html/bbsp/common/lanuserinfo.asp".format(self.host),
|
f"http://{self.host}/html/bbsp/common/lanuserinfo.asp",
|
||||||
cookies=cookie.cookies,
|
cookies=cookie.cookies,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER.debug("Requesting lan user info data")
|
_LOGGER.debug("Requesting lan user info data")
|
||||||
devices = requests.get(
|
devices = requests.get(
|
||||||
"http://{}/html/bbsp/common/GetLanUserDevInfo.asp".format(self.host),
|
f"http://{self.host}/html/bbsp/common/GetLanUserDevInfo.asp",
|
||||||
cookies=cookie.cookies,
|
cookies=cookie.cookies,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
{
|
{
|
||||||
"host": host,
|
"host": host,
|
||||||
# This format is the legacy format that Hue used for discovery
|
# This format is the legacy format that Hue used for discovery
|
||||||
"path": "phue-{}.conf".format(serial),
|
"path": f"phue-{serial}.conf",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
HOST = "https://www.hydroquebec.com"
|
HOST = "https://www.hydroquebec.com"
|
||||||
HOME_URL = "{}/portail/web/clientele/authentification".format(HOST)
|
HOME_URL = f"{HOST}/portail/web/clientele/authentification"
|
||||||
PROFILE_URL = "{}/portail/fr/group/clientele/" "portrait-de-consommation".format(HOST)
|
PROFILE_URL = "{}/portail/fr/group/clientele/" "portrait-de-consommation".format(HOST)
|
||||||
MONTHLY_MAP = (
|
MONTHLY_MAP = (
|
||||||
("period_total_bill", "montantFacturePeriode"),
|
("period_total_bill", "montantFacturePeriode"),
|
||||||
|
@ -164,7 +164,7 @@ class HydroQuebecSensor(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):
|
||||||
|
|
|
@ -28,7 +28,7 @@ def no_application_protocol(value):
|
||||||
"""Validate that value is without the application protocol."""
|
"""Validate that value is without the application protocol."""
|
||||||
protocol_separator = "://"
|
protocol_separator = "://"
|
||||||
if not value or protocol_separator in value:
|
if not value or protocol_separator in value:
|
||||||
raise vol.Invalid("Invalid host, {} is not allowed".format(protocol_separator))
|
raise vol.Invalid(f"Invalid host, {protocol_separator} is not allowed")
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
password = config.get(CONF_PASSWORD)
|
password = config.get(CONF_PASSWORD)
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
|
|
||||||
url = "http://{}".format(host)
|
url = f"http://{host}"
|
||||||
ialarm = IAlarmPanel(name, code, username, password, url)
|
ialarm = IAlarmPanel(name, code, username, password, url)
|
||||||
add_entities([ialarm], True)
|
add_entities([ialarm], True)
|
||||||
|
|
||||||
|
|
|
@ -281,10 +281,10 @@ class Icloud(DeviceScanner):
|
||||||
devicename = device.get(
|
devicename = device.get(
|
||||||
"deviceName", "SMS to %s" % device.get("phoneNumber")
|
"deviceName", "SMS to %s" % device.get("phoneNumber")
|
||||||
)
|
)
|
||||||
devicesstring += "{}: {};".format(i, devicename)
|
devicesstring += f"{i}: {devicename};"
|
||||||
|
|
||||||
_CONFIGURING[self.accountname] = configurator.request_config(
|
_CONFIGURING[self.accountname] = configurator.request_config(
|
||||||
"iCloud {}".format(self.accountname),
|
f"iCloud {self.accountname}",
|
||||||
self.icloud_trusted_device_callback,
|
self.icloud_trusted_device_callback,
|
||||||
description=(
|
description=(
|
||||||
"Please choose your trusted device by entering"
|
"Please choose your trusted device by entering"
|
||||||
|
@ -327,7 +327,7 @@ class Icloud(DeviceScanner):
|
||||||
return
|
return
|
||||||
|
|
||||||
_CONFIGURING[self.accountname] = configurator.request_config(
|
_CONFIGURING[self.accountname] = configurator.request_config(
|
||||||
"iCloud {}".format(self.accountname),
|
f"iCloud {self.accountname}",
|
||||||
self.icloud_verification_callback,
|
self.icloud_verification_callback,
|
||||||
description=("Please enter the validation code:"),
|
description=("Please enter the validation code:"),
|
||||||
entity_picture="/static/images/config_icloud.png",
|
entity_picture="/static/images/config_icloud.png",
|
||||||
|
@ -528,7 +528,7 @@ class Icloud(DeviceScanner):
|
||||||
"""Set the interval of the given devices."""
|
"""Set the interval of the given devices."""
|
||||||
devs = [devicename] if devicename else self.devices
|
devs = [devicename] if devicename else self.devices
|
||||||
for device in devs:
|
for device in devs:
|
||||||
devid = "{}.{}".format(DOMAIN, device)
|
devid = f"{DOMAIN}.{device}"
|
||||||
devicestate = self.hass.states.get(devid)
|
devicestate = self.hass.states.get(devid)
|
||||||
if interval is not None:
|
if interval is not None:
|
||||||
if devicestate is not None:
|
if devicestate is not None:
|
||||||
|
|
|
@ -210,9 +210,9 @@ class IgnSismologiaLocationEvent(GeolocationEvent):
|
||||||
def name(self) -> Optional[str]:
|
def name(self) -> Optional[str]:
|
||||||
"""Return the name of the entity."""
|
"""Return the name of the entity."""
|
||||||
if self._magnitude and self._region:
|
if self._magnitude and self._region:
|
||||||
return "M {:.1f} - {}".format(self._magnitude, self._region)
|
return f"M {self._magnitude:.1f} - {self._region}"
|
||||||
if self._magnitude:
|
if self._magnitude:
|
||||||
return "M {:.1f}".format(self._magnitude)
|
return f"M {self._magnitude:.1f}"
|
||||||
if self._region:
|
if self._region:
|
||||||
return self._region
|
return self._region
|
||||||
return self._title
|
return self._title
|
||||||
|
|
|
@ -61,7 +61,7 @@ def validate_name(config):
|
||||||
if CONF_NAME in config:
|
if CONF_NAME in config:
|
||||||
return config
|
return config
|
||||||
ihcid = config[CONF_ID]
|
ihcid = config[CONF_ID]
|
||||||
name = "ihc_{}".format(ihcid)
|
name = f"ihc_{ihcid}"
|
||||||
config[CONF_NAME] = name
|
config[CONF_NAME] = name
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ def get_discovery_info(component_setup, groups, controller_id):
|
||||||
if "setting" in node.attrib and node.attrib["setting"] == "yes":
|
if "setting" in node.attrib and node.attrib["setting"] == "yes":
|
||||||
continue
|
continue
|
||||||
ihc_id = int(node.attrib["id"].strip("_"), 0)
|
ihc_id = int(node.attrib["id"].strip("_"), 0)
|
||||||
name = "{}_{}".format(groupname, ihc_id)
|
name = f"{groupname}_{ihc_id}"
|
||||||
device = {
|
device = {
|
||||||
"ihc_id": ihc_id,
|
"ihc_id": ihc_id,
|
||||||
"ctrl_id": controller_id,
|
"ctrl_id": controller_id,
|
||||||
|
|
|
@ -118,7 +118,7 @@ class EmailReader:
|
||||||
if not self._unread_ids:
|
if not self._unread_ids:
|
||||||
search = "SINCE {0:%d-%b-%Y}".format(datetime.date.today())
|
search = "SINCE {0:%d-%b-%Y}".format(datetime.date.today())
|
||||||
if self._last_id is not None:
|
if self._last_id is not None:
|
||||||
search = "UID {}:*".format(self._last_id)
|
search = f"UID {self._last_id}:*"
|
||||||
|
|
||||||
_, data = self.connection.uid("search", None, search)
|
_, data = self.connection.uid("search", None, search)
|
||||||
self._unread_ids = deque(data[0].split())
|
self._unread_ids = deque(data[0].split())
|
||||||
|
|
|
@ -30,7 +30,7 @@ class InComfortClimate(ClimateDevice):
|
||||||
"""Initialize the climate device."""
|
"""Initialize the climate device."""
|
||||||
self._client = client
|
self._client = client
|
||||||
self._room = room
|
self._room = room
|
||||||
self._name = "Room {}".format(room.room_no)
|
self._name = f"Room {room.room_no}"
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Set up a listener when this entity is added to HA."""
|
"""Set up a listener when this entity is added to HA."""
|
||||||
|
|
|
@ -96,7 +96,7 @@ class IncomfortWaterHeater(WaterHeaterDevice):
|
||||||
def current_operation(self):
|
def current_operation(self):
|
||||||
"""Return the current operation mode."""
|
"""Return the current operation mode."""
|
||||||
if self._heater.is_failed:
|
if self._heater.is_failed:
|
||||||
return "Fault code: {}".format(self._heater.fault_code)
|
return f"Fault code: {self._heater.fault_code}"
|
||||||
|
|
||||||
return self._heater.display_text
|
return self._heater.display_text
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,7 @@ def setup(hass, config):
|
||||||
try:
|
try:
|
||||||
json["fields"][key] = float(value)
|
json["fields"][key] = float(value)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
new_key = "{}_str".format(key)
|
new_key = f"{key}_str"
|
||||||
new_value = str(value)
|
new_value = str(value)
|
||||||
json["fields"][new_key] = new_value
|
json["fields"][new_key] = new_value
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,7 @@ async def async_setup(hass, config):
|
||||||
|
|
||||||
def _send_load_aldb_signal(entity_id, reload):
|
def _send_load_aldb_signal(entity_id, reload):
|
||||||
"""Send the load All-Link database signal to INSTEON entity."""
|
"""Send the load All-Link database signal to INSTEON entity."""
|
||||||
signal = "{}_{}".format(entity_id, SIGNAL_LOAD_ALDB)
|
signal = f"{entity_id}_{SIGNAL_LOAD_ALDB}"
|
||||||
dispatcher_send(hass, signal, reload)
|
dispatcher_send(hass, signal, reload)
|
||||||
|
|
||||||
def print_aldb(service):
|
def print_aldb(service):
|
||||||
|
@ -322,7 +322,7 @@ async def async_setup(hass, config):
|
||||||
# For now this sends logs to the log file.
|
# For now this sends logs to the log file.
|
||||||
# Furture direction is to create an INSTEON control panel.
|
# Furture direction is to create an INSTEON control panel.
|
||||||
entity_id = service.data[CONF_ENTITY_ID]
|
entity_id = service.data[CONF_ENTITY_ID]
|
||||||
signal = "{}_{}".format(entity_id, SIGNAL_PRINT_ALDB)
|
signal = f"{entity_id}_{SIGNAL_PRINT_ALDB}"
|
||||||
dispatcher_send(hass, signal)
|
dispatcher_send(hass, signal)
|
||||||
|
|
||||||
def print_im_aldb(service):
|
def print_im_aldb(service):
|
||||||
|
@ -652,9 +652,9 @@ class InsteonEntity(Entity):
|
||||||
)
|
)
|
||||||
self._insteon_device_state.register_updates(self.async_entity_update)
|
self._insteon_device_state.register_updates(self.async_entity_update)
|
||||||
self.hass.data[DOMAIN][INSTEON_ENTITIES][self.entity_id] = self
|
self.hass.data[DOMAIN][INSTEON_ENTITIES][self.entity_id] = self
|
||||||
load_signal = "{}_{}".format(self.entity_id, SIGNAL_LOAD_ALDB)
|
load_signal = f"{self.entity_id}_{SIGNAL_LOAD_ALDB}"
|
||||||
async_dispatcher_connect(self.hass, load_signal, self._load_aldb)
|
async_dispatcher_connect(self.hass, load_signal, self._load_aldb)
|
||||||
print_signal = "{}_{}".format(self.entity_id, SIGNAL_PRINT_ALDB)
|
print_signal = f"{self.entity_id}_{SIGNAL_PRINT_ALDB}"
|
||||||
async_dispatcher_connect(self.hass, print_signal, self._print_aldb)
|
async_dispatcher_connect(self.hass, print_signal, self._print_aldb)
|
||||||
|
|
||||||
def _load_aldb(self, reload=False):
|
def _load_aldb(self, reload=False):
|
||||||
|
@ -679,7 +679,7 @@ class InsteonEntity(Entity):
|
||||||
if self._insteon_device_state.name in STATE_NAME_LABEL_MAP:
|
if self._insteon_device_state.name in STATE_NAME_LABEL_MAP:
|
||||||
label = STATE_NAME_LABEL_MAP[self._insteon_device_state.name]
|
label = STATE_NAME_LABEL_MAP[self._insteon_device_state.name]
|
||||||
else:
|
else:
|
||||||
label = "Group {:d}".format(self.group)
|
label = f"Group {self.group:d}"
|
||||||
return label
|
return label
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class IOSSensor(Entity):
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID of this sensor."""
|
"""Return the unique ID of this sensor."""
|
||||||
device_id = self._device[ios.ATTR_DEVICE_ID]
|
device_id = self._device[ios.ATTR_DEVICE_ID]
|
||||||
return "{}_{}".format(self.type, device_id)
|
return f"{self.type}_{device_id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
@ -100,11 +100,11 @@ class IOSSensor(Entity):
|
||||||
ios.ATTR_BATTERY_STATE_UNPLUGGED,
|
ios.ATTR_BATTERY_STATE_UNPLUGGED,
|
||||||
):
|
):
|
||||||
charging = False
|
charging = False
|
||||||
icon_state = "{}-off".format(DEFAULT_ICON_STATE)
|
icon_state = f"{DEFAULT_ICON_STATE}-off"
|
||||||
elif battery_state == ios.ATTR_BATTERY_STATE_UNKNOWN:
|
elif battery_state == ios.ATTR_BATTERY_STATE_UNKNOWN:
|
||||||
battery_level = None
|
battery_level = None
|
||||||
charging = False
|
charging = False
|
||||||
icon_state = "{}-unknown".format(DEFAULT_ICON_LEVEL)
|
icon_state = f"{DEFAULT_ICON_LEVEL}-unknown"
|
||||||
|
|
||||||
if self.type == "state":
|
if self.type == "state":
|
||||||
return icon_state
|
return icon_state
|
||||||
|
|
|
@ -46,7 +46,7 @@ class IotaBalanceSensor(IotaDevice):
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "{} Balance".format(self._name)
|
return f"{self._name} Balance"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.helpers.dispatcher import dispatcher_send
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
|
|
||||||
DOMAIN = "iperf3"
|
DOMAIN = "iperf3"
|
||||||
DATA_UPDATED = "{}_data_updated".format(DOMAIN)
|
DATA_UPDATED = f"{DOMAIN}_data_updated"
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ class IPMAWeather(WeatherEntity):
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique id."""
|
"""Return a unique id."""
|
||||||
return "{}, {}".format(self._station.latitude, self._station.longitude)
|
return f"{self._station.latitude}, {self._station.longitude}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def attribution(self):
|
def attribution(self):
|
||||||
|
|
|
@ -234,7 +234,7 @@ class IQVIAEntity(Entity):
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique, HASS-friendly identifier for this entity."""
|
"""Return a unique, HASS-friendly identifier for this entity."""
|
||||||
return "{0}_{1}".format(self._zip_code, self._type)
|
return f"{self._zip_code}_{self._type}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
|
|
@ -174,9 +174,9 @@ class IndexSensor(IQVIAEntity):
|
||||||
index = idx + 1
|
index = idx + 1
|
||||||
self._attrs.update(
|
self._attrs.update(
|
||||||
{
|
{
|
||||||
"{0}_{1}".format(ATTR_ALLERGEN_GENUS, index): attrs["Genus"],
|
f"{ATTR_ALLERGEN_GENUS}_{index}": attrs["Genus"],
|
||||||
"{0}_{1}".format(ATTR_ALLERGEN_NAME, index): attrs["Name"],
|
f"{ATTR_ALLERGEN_NAME}_{index}": attrs["Name"],
|
||||||
"{0}_{1}".format(ATTR_ALLERGEN_TYPE, index): attrs["PlantType"],
|
f"{ATTR_ALLERGEN_TYPE}_{index}": attrs["PlantType"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif self._type in (TYPE_ASTHMA_TODAY, TYPE_ASTHMA_TOMORROW):
|
elif self._type in (TYPE_ASTHMA_TODAY, TYPE_ASTHMA_TOMORROW):
|
||||||
|
@ -184,8 +184,8 @@ class IndexSensor(IQVIAEntity):
|
||||||
index = idx + 1
|
index = idx + 1
|
||||||
self._attrs.update(
|
self._attrs.update(
|
||||||
{
|
{
|
||||||
"{0}_{1}".format(ATTR_ALLERGEN_NAME, index): attrs["Name"],
|
f"{ATTR_ALLERGEN_NAME}_{index}": attrs["Name"],
|
||||||
"{0}_{1}".format(ATTR_ALLERGEN_AMOUNT, index): attrs["PPM"],
|
f"{ATTR_ALLERGEN_AMOUNT}_{index}": attrs["PPM"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif self._type == TYPE_DISEASE_TODAY:
|
elif self._type == TYPE_DISEASE_TODAY:
|
||||||
|
|
|
@ -343,7 +343,7 @@ def _categorize_programs(hass: HomeAssistant, programs: dict) -> None:
|
||||||
"""Categorize the ISY994 programs."""
|
"""Categorize the ISY994 programs."""
|
||||||
for domain in SUPPORTED_PROGRAM_DOMAINS:
|
for domain in SUPPORTED_PROGRAM_DOMAINS:
|
||||||
try:
|
try:
|
||||||
folder = programs[KEY_MY_PROGRAMS]["HA.{}".format(domain)]
|
folder = programs[KEY_MY_PROGRAMS][f"HA.{domain}"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -378,10 +378,10 @@ def _categorize_weather(hass: HomeAssistant, climate) -> None:
|
||||||
WeatherNode(
|
WeatherNode(
|
||||||
getattr(climate, attr),
|
getattr(climate, attr),
|
||||||
attr.replace("_", " "),
|
attr.replace("_", " "),
|
||||||
getattr(climate, "{}_units".format(attr)),
|
getattr(climate, f"{attr}_units"),
|
||||||
)
|
)
|
||||||
for attr in climate_attrs
|
for attr in climate_attrs
|
||||||
if "{}_units".format(attr) in climate_attrs
|
if f"{attr}_units" in climate_attrs
|
||||||
]
|
]
|
||||||
hass.data[ISY994_WEATHER].extend(weather_nodes)
|
hass.data[ISY994_WEATHER].extend(weather_nodes)
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ class ISYSensorDevice(ISYDevice):
|
||||||
int_prec = int(self._node.prec)
|
int_prec = int(self._node.prec)
|
||||||
decimal_part = str_val[-int_prec:]
|
decimal_part = str_val[-int_prec:]
|
||||||
whole_part = str_val[: len(str_val) - int_prec]
|
whole_part = str_val[: len(str_val) - int_prec]
|
||||||
val = float("{}.{}".format(whole_part, decimal_part))
|
val = float(f"{whole_part}.{decimal_part}")
|
||||||
raw_units = self.raw_unit_of_measurement
|
raw_units = self.raw_unit_of_measurement
|
||||||
if raw_units in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
if raw_units in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
||||||
val = self.hass.config.units.temperature(val, raw_units)
|
val = self.hass.config.units.temperature(val, raw_units)
|
||||||
|
|
|
@ -78,7 +78,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
cmddata = cmd[CONF_DATA].strip()
|
cmddata = cmd[CONF_DATA].strip()
|
||||||
if not cmddata:
|
if not cmddata:
|
||||||
cmddata = '""'
|
cmddata = '""'
|
||||||
cmddatas += "{}\n{}\n".format(cmdname, cmddata)
|
cmddatas += f"{cmdname}\n{cmddata}\n"
|
||||||
itachip2ir.addDevice(name, modaddr, connaddr, cmddatas)
|
itachip2ir.addDevice(name, modaddr, connaddr, cmddatas)
|
||||||
devices.append(ITachIP2IRRemote(itachip2ir, name))
|
devices.append(ITachIP2IRRemote(itachip2ir, name))
|
||||||
add_entities(devices, True)
|
add_entities(devices, True)
|
||||||
|
|
|
@ -84,13 +84,13 @@ class Itunes:
|
||||||
uri_scheme = "http://"
|
uri_scheme = "http://"
|
||||||
|
|
||||||
if self.port:
|
if self.port:
|
||||||
return "{}{}:{}".format(uri_scheme, self.host, self.port)
|
return f"{uri_scheme}{self.host}:{self.port}"
|
||||||
|
|
||||||
return "{}{}".format(uri_scheme, self.host)
|
return f"{uri_scheme}{self.host}"
|
||||||
|
|
||||||
def _request(self, method, path, params=None):
|
def _request(self, method, path, params=None):
|
||||||
"""Make the actual request and return the parsed response."""
|
"""Make the actual request and return the parsed response."""
|
||||||
url = "{}{}".format(self._base_url, path)
|
url = f"{self._base_url}{path}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if method == "GET":
|
if method == "GET":
|
||||||
|
|
|
@ -129,7 +129,7 @@ class JewishCalSensor(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 icon(self):
|
def icon(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue