mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Use literal string interpolation in integrations A (f-strings) (#26377)
* Use literal string interpolation in integrations A (f-strings) * Black
This commit is contained in:
parent
3534b8a977
commit
ad51615718
@ -132,7 +132,7 @@ class AdGuardHomePercentageBlockedSensor(AdGuardHomeSensor):
|
||||
async def _adguard_update(self) -> None:
|
||||
"""Update AdGuard Home entity."""
|
||||
percentage = await self.adguard.stats.blocked_percentage()
|
||||
self._state = "{:.2f}".format(percentage)
|
||||
self._state = f"{percentage:.2f}"
|
||||
|
||||
|
||||
class AdGuardHomeReplacedParentalSensor(AdGuardHomeSensor):
|
||||
@ -205,7 +205,7 @@ class AdGuardHomeAverageProcessingTimeSensor(AdGuardHomeSensor):
|
||||
async def _adguard_update(self) -> None:
|
||||
"""Update AdGuard Home entity."""
|
||||
average = await self.adguard.stats.avg_processing_time()
|
||||
self._state = "{:.2f}".format(average)
|
||||
self._state = f"{average:.2f}"
|
||||
|
||||
|
||||
class AdGuardHomeRulesCountSensor(AdGuardHomeSensor):
|
||||
|
@ -194,7 +194,7 @@ class AirVisualSensor(Entity):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique, HASS-friendly identifier for this entity."""
|
||||
return "{0}_{1}_{2}".format(self._location_id, self._locale, self._type)
|
||||
return f"{self._location_id}_{self._locale}_{self._type}"
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
@ -210,7 +210,7 @@ class AirVisualSensor(Entity):
|
||||
return
|
||||
|
||||
if self._type == SENSOR_TYPE_LEVEL:
|
||||
aqi = data["aqi{0}".format(self._locale)]
|
||||
aqi = data[f"aqi{self._locale}"]
|
||||
[level] = [
|
||||
i
|
||||
for i in POLLUTANT_LEVEL_MAPPING
|
||||
@ -219,9 +219,9 @@ class AirVisualSensor(Entity):
|
||||
self._state = level["label"]
|
||||
self._icon = level["icon"]
|
||||
elif self._type == SENSOR_TYPE_AQI:
|
||||
self._state = data["aqi{0}".format(self._locale)]
|
||||
self._state = data[f"aqi{self._locale}"]
|
||||
elif self._type == SENSOR_TYPE_POLLUTANT:
|
||||
symbol = data["main{0}".format(self._locale)]
|
||||
symbol = data[f"main{self._locale}"]
|
||||
self._state = POLLUTANT_MAPPING[symbol]["label"]
|
||||
self._attrs.update(
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ class AladdinDevice(CoverDevice):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique ID."""
|
||||
return "{}-{}".format(self._device_id, self._number)
|
||||
return f"{self._device_id}-{self._number}"
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -140,27 +140,27 @@ class AlarmDecoderAlarmPanel(alarm.AlarmControlPanel):
|
||||
def alarm_disarm(self, code=None):
|
||||
"""Send disarm command."""
|
||||
if code:
|
||||
self.hass.data[DATA_AD].send("{!s}1".format(code))
|
||||
self.hass.data[DATA_AD].send(f"{code!s}1")
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
"""Send arm away command."""
|
||||
if code:
|
||||
self.hass.data[DATA_AD].send("{!s}2".format(code))
|
||||
self.hass.data[DATA_AD].send(f"{code!s}2")
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
"""Send arm home command."""
|
||||
if code:
|
||||
self.hass.data[DATA_AD].send("{!s}3".format(code))
|
||||
self.hass.data[DATA_AD].send(f"{code!s}3")
|
||||
|
||||
def alarm_arm_night(self, code=None):
|
||||
"""Send arm night command."""
|
||||
if code:
|
||||
self.hass.data[DATA_AD].send("{!s}33".format(code))
|
||||
self.hass.data[DATA_AD].send(f"{code!s}33")
|
||||
|
||||
def alarm_toggle_chime(self, code=None):
|
||||
"""Send toggle chime command."""
|
||||
if code:
|
||||
self.hass.data[DATA_AD].send("{!s}9".format(code))
|
||||
self.hass.data[DATA_AD].send(f"{code!s}9")
|
||||
|
||||
def alarm_keypress(self, keypress):
|
||||
"""Send custom keypresses."""
|
||||
|
@ -40,7 +40,7 @@ class AlexaInvalidEndpointError(AlexaError):
|
||||
|
||||
def __init__(self, endpoint_id):
|
||||
"""Initialize invalid endpoint error."""
|
||||
msg = "The endpoint {} does not exist".format(endpoint_id)
|
||||
msg = f"The endpoint {endpoint_id} does not exist"
|
||||
AlexaError.__init__(self, msg)
|
||||
self.endpoint_id = endpoint_id
|
||||
|
||||
@ -73,7 +73,7 @@ class AlexaTempRangeError(AlexaError):
|
||||
"maximumValue": {"value": max_temp, "scale": API_TEMP_UNITS[unit]},
|
||||
}
|
||||
payload = {"validRange": temp_range}
|
||||
msg = "The requested temperature {} is out of range".format(temp)
|
||||
msg = f"The requested temperature {temp} is out of range"
|
||||
|
||||
AlexaError.__init__(self, msg, payload)
|
||||
|
||||
|
@ -744,7 +744,7 @@ async def async_api_set_thermostat_mode(hass, config, directive, context):
|
||||
presets = entity.attributes.get(climate.ATTR_PRESET_MODES, [])
|
||||
|
||||
if ha_preset not in presets:
|
||||
msg = "The requested thermostat mode {} is not supported".format(ha_preset)
|
||||
msg = f"The requested thermostat mode {ha_preset} is not supported"
|
||||
raise AlexaUnsupportedThermostatModeError(msg)
|
||||
|
||||
service = climate.SERVICE_SET_PRESET_MODE
|
||||
@ -754,7 +754,7 @@ async def async_api_set_thermostat_mode(hass, config, directive, context):
|
||||
operation_list = entity.attributes.get(climate.ATTR_HVAC_MODES)
|
||||
ha_mode = next((k for k, v in API_THERMOSTAT_MODES.items() if v == mode), None)
|
||||
if ha_mode not in operation_list:
|
||||
msg = "The requested thermostat mode {} is not supported".format(mode)
|
||||
msg = f"The requested thermostat mode {mode} is not supported"
|
||||
raise AlexaUnsupportedThermostatModeError(msg)
|
||||
|
||||
service = climate.SERVICE_SET_HVAC_MODE
|
||||
|
@ -113,7 +113,7 @@ async def async_handle_message(hass, message):
|
||||
handler = HANDLERS.get(req_type)
|
||||
|
||||
if not handler:
|
||||
raise UnknownRequest("Received unknown request {}".format(req_type))
|
||||
raise UnknownRequest(f"Received unknown request {req_type}")
|
||||
|
||||
return await handler(hass, message)
|
||||
|
||||
|
@ -60,7 +60,7 @@ async def async_send_changereport_message(
|
||||
"""
|
||||
token = await config.async_get_access_token()
|
||||
|
||||
headers = {"Authorization": "Bearer {}".format(token)}
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
endpoint = alexa_entity.alexa_id()
|
||||
|
||||
@ -122,7 +122,7 @@ async def async_send_add_or_update_message(hass, config, entity_ids):
|
||||
"""
|
||||
token = await config.async_get_access_token()
|
||||
|
||||
headers = {"Authorization": "Bearer {}".format(token)}
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
endpoints = []
|
||||
|
||||
@ -152,7 +152,7 @@ async def async_send_delete_message(hass, config, entity_ids):
|
||||
"""
|
||||
token = await config.async_get_access_token()
|
||||
|
||||
headers = {"Authorization": "Bearer {}".format(token)}
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
endpoints = []
|
||||
|
||||
|
@ -168,7 +168,7 @@ class AlphaVantageForeignExchange(Entity):
|
||||
if CONF_NAME in config:
|
||||
self._name = config.get(CONF_NAME)
|
||||
else:
|
||||
self._name = "{}/{}".format(self._to_currency, self._from_currency)
|
||||
self._name = f"{self._to_currency}/{self._from_currency}"
|
||||
self._unit_of_measurement = self._to_currency
|
||||
self._icon = ICONS.get(self._from_currency, "USD")
|
||||
self.values = None
|
||||
|
@ -130,7 +130,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow):
|
||||
return oauth
|
||||
|
||||
def _cb_url(self):
|
||||
return "{}{}".format(self.hass.config.api.base_url, AUTH_CALLBACK_PATH)
|
||||
return f"{self.hass.config.api.base_url}{AUTH_CALLBACK_PATH}"
|
||||
|
||||
async def _get_authorize_url(self):
|
||||
oauth = self._generate_oauth()
|
||||
|
@ -492,7 +492,7 @@ class AmbientWeatherEntity(Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return "{0}_{1}".format(self._station_name, self._sensor_name)
|
||||
return f"{self._station_name}_{self._sensor_name}"
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
@ -502,7 +502,7 @@ class AmbientWeatherEntity(Entity):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique, unchanging string that represents this sensor."""
|
||||
return "{0}_{1}".format(self._mac_address, self._sensor_type)
|
||||
return f"{self._mac_address}_{self._sensor_type}"
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
|
@ -490,7 +490,7 @@ class AmcrestCam(Camera):
|
||||
self._api.go_to_preset(action="start", preset_point_number=preset)
|
||||
except AmcrestError as error:
|
||||
log_update_error(
|
||||
_LOGGER, "move", self.name, "camera to preset {}".format(preset), error
|
||||
_LOGGER, "move", self.name, f"camera to preset {preset}", error
|
||||
)
|
||||
|
||||
def _set_color_bw(self, cbw):
|
||||
@ -499,7 +499,7 @@ class AmcrestCam(Camera):
|
||||
self._api.day_night_color = _CBW.index(cbw)
|
||||
except AmcrestError as error:
|
||||
log_update_error(
|
||||
_LOGGER, "set", self.name, "camera color mode to {}".format(cbw), error
|
||||
_LOGGER, "set", self.name, f"camera color mode to {cbw}", error
|
||||
)
|
||||
else:
|
||||
self._color_bw = cbw
|
||||
|
@ -4,7 +4,7 @@ from .const import DOMAIN
|
||||
|
||||
def service_signal(service, ident=None):
|
||||
"""Encode service and identifier into signal."""
|
||||
signal = "{}_{}".format(DOMAIN, service)
|
||||
signal = f"{DOMAIN}_{service}"
|
||||
if ident:
|
||||
signal += "_{}".format(ident.replace(".", "_"))
|
||||
return signal
|
||||
|
@ -57,7 +57,7 @@ class AmpioSmogQuality(AirQualityEntity):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique_name."""
|
||||
return "ampio_smog_{}".format(self._station_id)
|
||||
return f"ampio_smog_{self._station_id}"
|
||||
|
||||
@property
|
||||
def particulate_matter_2_5(self):
|
||||
|
@ -25,7 +25,7 @@ class IPWebcamBinarySensor(AndroidIPCamEntity, BinarySensorDevice):
|
||||
|
||||
self._sensor = sensor
|
||||
self._mapped_name = KEY_MAP.get(self._sensor, self._sensor)
|
||||
self._name = "{} {}".format(name, self._mapped_name)
|
||||
self._name = f"{name} {self._mapped_name}"
|
||||
self._state = None
|
||||
self._unit = None
|
||||
|
||||
|
@ -39,7 +39,7 @@ class IPWebcamSensor(AndroidIPCamEntity):
|
||||
|
||||
self._sensor = sensor
|
||||
self._mapped_name = KEY_MAP.get(self._sensor, self._sensor)
|
||||
self._name = "{} {}".format(name, self._mapped_name)
|
||||
self._name = f"{name} {self._mapped_name}"
|
||||
self._state = None
|
||||
self._unit = None
|
||||
|
||||
|
@ -39,7 +39,7 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
|
||||
|
||||
self._setting = setting
|
||||
self._mapped_name = KEY_MAP.get(self._setting, self._setting)
|
||||
self._name = "{} {}".format(name, self._mapped_name)
|
||||
self._name = f"{name} {self._mapped_name}"
|
||||
self._state = False
|
||||
|
||||
@property
|
||||
|
@ -392,7 +392,7 @@ class ADBDevice(MediaPlayerDevice):
|
||||
"""Send an ADB command to an Android TV / Fire TV device."""
|
||||
key = self._keys.get(cmd)
|
||||
if key:
|
||||
self.aftv.adb_shell("input keyevent {}".format(key))
|
||||
self.aftv.adb_shell(f"input keyevent {key}")
|
||||
self._adb_response = None
|
||||
self.schedule_update_ha_state()
|
||||
return
|
||||
|
@ -81,7 +81,7 @@ class KafkaManager:
|
||||
self._hass = hass
|
||||
self._producer = AIOKafkaProducer(
|
||||
loop=hass.loop,
|
||||
bootstrap_servers="{0}:{1}".format(ip_address, port),
|
||||
bootstrap_servers=f"{ip_address}:{port}",
|
||||
compression_type="gzip",
|
||||
)
|
||||
self._topic = topic
|
||||
|
@ -50,7 +50,7 @@ def get_service(hass, config, discovery_info=None):
|
||||
|
||||
service = ApnsNotificationService(hass, name, topic, sandbox, cert_file)
|
||||
hass.services.register(
|
||||
DOMAIN, "apns_{}".format(name), service.register, schema=REGISTER_SERVICE_SCHEMA
|
||||
DOMAIN, f"apns_{name}", service.register, schema=REGISTER_SERVICE_SCHEMA
|
||||
)
|
||||
return service
|
||||
|
||||
@ -98,7 +98,7 @@ class ApnsDevice:
|
||||
The full id of a device that is tracked by the device
|
||||
tracking component.
|
||||
"""
|
||||
return "{}.{}".format(DEVICE_TRACKER_DOMAIN, self.tracking_id)
|
||||
return f"{DEVICE_TRACKER_DOMAIN}.{self.tracking_id}"
|
||||
|
||||
@property
|
||||
def disabled(self):
|
||||
@ -124,9 +124,9 @@ def _write_device(out, device):
|
||||
"""Write a single device to file."""
|
||||
attributes = []
|
||||
if device.name is not None:
|
||||
attributes.append("name: {}".format(device.name))
|
||||
attributes.append(f"name: {device.name}")
|
||||
if device.tracking_device_id is not None:
|
||||
attributes.append("tracking_device_id: {}".format(device.tracking_device_id))
|
||||
attributes.append(f"tracking_device_id: {device.tracking_device_id}")
|
||||
if device.disabled:
|
||||
attributes.append("disabled: True")
|
||||
|
||||
|
@ -213,7 +213,7 @@ class AppleTvDevice(MediaPlayerDevice):
|
||||
title = self._playing.title
|
||||
return title if title else "No title"
|
||||
|
||||
return "Establishing a connection to {0}...".format(self._name)
|
||||
return f"Establishing a connection to {self._name}..."
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
|
@ -70,7 +70,7 @@ def gps_accuracy(gps, posambiguity: int) -> int:
|
||||
|
||||
accuracy = round(dist_m)
|
||||
else:
|
||||
message = "APRS position ambiguity must be 0-4, not '{0}'.".format(posambiguity)
|
||||
message = f"APRS position ambiguity must be 0-4, not '{posambiguity}'."
|
||||
raise ValueError(message)
|
||||
|
||||
return accuracy
|
||||
@ -147,8 +147,7 @@ class AprsListenerThread(threading.Thread):
|
||||
)
|
||||
self.ais.connect()
|
||||
self.start_complete(
|
||||
True,
|
||||
"Connected to {0} with callsign {1}.".format(self.host, self.callsign),
|
||||
True, f"Connected to {self.host} with callsign {self.callsign}."
|
||||
)
|
||||
self.ais.consumer(callback=self.rx_msg, immortal=True)
|
||||
except (AprsConnectionError, LoginError) as err:
|
||||
|
@ -9,5 +9,5 @@ DEFAULT_PORT = 50000
|
||||
DEFAULT_NAME = "Arcam FMJ"
|
||||
DEFAULT_SCAN_INTERVAL = 5
|
||||
|
||||
DOMAIN_DATA_ENTRIES = "{}.entries".format(DOMAIN)
|
||||
DOMAIN_DATA_CONFIG = "{}.config".format(DOMAIN)
|
||||
DOMAIN_DATA_ENTRIES = f"{DOMAIN}.entries"
|
||||
DOMAIN_DATA_CONFIG = f"{DOMAIN}.config"
|
||||
|
@ -319,7 +319,7 @@ class ArcamFmj(MediaPlayerDevice):
|
||||
channel = self.media_channel
|
||||
|
||||
if channel:
|
||||
value = "{} - {}".format(source.name, channel)
|
||||
value = f"{source.name} - {channel}"
|
||||
else:
|
||||
value = source.name
|
||||
return value
|
||||
|
@ -73,9 +73,7 @@ class ArestBinarySensor(BinarySensorDevice):
|
||||
self._pin = pin
|
||||
|
||||
if self._pin is not None:
|
||||
request = requests.get(
|
||||
"{}/mode/{}/i".format(self._resource, self._pin), timeout=10
|
||||
)
|
||||
request = requests.get(f"{self._resource}/mode/{self._pin}/i", timeout=10)
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't set mode of %s", self._resource)
|
||||
|
||||
@ -112,9 +110,7 @@ class ArestData:
|
||||
def update(self):
|
||||
"""Get the latest data from aREST device."""
|
||||
try:
|
||||
response = requests.get(
|
||||
"{}/digital/{}".format(self._resource, self._pin), timeout=10
|
||||
)
|
||||
response = requests.get(f"{self._resource}/digital/{self._pin}", timeout=10)
|
||||
self.data = {"state": response.json()["return_value"]}
|
||||
except requests.exceptions.ConnectionError:
|
||||
_LOGGER.error("No route to device '%s'", self._resource)
|
||||
|
@ -148,9 +148,7 @@ class ArestSensor(Entity):
|
||||
self._renderer = renderer
|
||||
|
||||
if self._pin is not None:
|
||||
request = requests.get(
|
||||
"{}/mode/{}/i".format(self._resource, self._pin), timeout=10
|
||||
)
|
||||
request = requests.get(f"{self._resource}/mode/{self._pin}/i", timeout=10)
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't set mode of %s", self._resource)
|
||||
|
||||
@ -212,7 +210,7 @@ class ArestData:
|
||||
self.data = {"value": response.json()["return_value"]}
|
||||
except TypeError:
|
||||
response = requests.get(
|
||||
"{}/digital/{}".format(self._resource, self._pin), timeout=10
|
||||
f"{self._resource}/digital/{self._pin}", timeout=10
|
||||
)
|
||||
self.data = {"value": response.json()["return_value"]}
|
||||
self.available = True
|
||||
|
@ -114,7 +114,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
||||
super().__init__(resource, location, name)
|
||||
self._func = func
|
||||
|
||||
request = requests.get("{}/{}".format(self._resource, self._func), timeout=10)
|
||||
request = requests.get(f"{self._resource}/{self._func}", timeout=10)
|
||||
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't find function")
|
||||
@ -130,9 +130,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
request = requests.get(
|
||||
"{}/{}".format(self._resource, self._func),
|
||||
timeout=10,
|
||||
params={"params": "1"},
|
||||
f"{self._resource}/{self._func}", timeout=10, params={"params": "1"}
|
||||
)
|
||||
|
||||
if request.status_code == 200:
|
||||
@ -143,9 +141,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the device off."""
|
||||
request = requests.get(
|
||||
"{}/{}".format(self._resource, self._func),
|
||||
timeout=10,
|
||||
params={"params": "0"},
|
||||
f"{self._resource}/{self._func}", timeout=10, params={"params": "0"}
|
||||
)
|
||||
|
||||
if request.status_code == 200:
|
||||
@ -158,9 +154,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
||||
def update(self):
|
||||
"""Get the latest data from aREST API and update the state."""
|
||||
try:
|
||||
request = requests.get(
|
||||
"{}/{}".format(self._resource, self._func), timeout=10
|
||||
)
|
||||
request = requests.get(f"{self._resource}/{self._func}", timeout=10)
|
||||
self._state = request.json()["return_value"] != 0
|
||||
self._available = True
|
||||
except requests.exceptions.ConnectionError:
|
||||
@ -177,9 +171,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
||||
self._pin = pin
|
||||
self.invert = invert
|
||||
|
||||
request = requests.get(
|
||||
"{}/mode/{}/o".format(self._resource, self._pin), timeout=10
|
||||
)
|
||||
request = requests.get(f"{self._resource}/mode/{self._pin}/o", timeout=10)
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't set mode")
|
||||
self._available = False
|
||||
@ -188,8 +180,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
||||
"""Turn the device on."""
|
||||
turn_on_payload = int(not self.invert)
|
||||
request = requests.get(
|
||||
"{}/digital/{}/{}".format(self._resource, self._pin, turn_on_payload),
|
||||
timeout=10,
|
||||
f"{self._resource}/digital/{self._pin}/{turn_on_payload}", timeout=10
|
||||
)
|
||||
if request.status_code == 200:
|
||||
self._state = True
|
||||
@ -200,8 +191,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
||||
"""Turn the device off."""
|
||||
turn_off_payload = int(self.invert)
|
||||
request = requests.get(
|
||||
"{}/digital/{}/{}".format(self._resource, self._pin, turn_off_payload),
|
||||
timeout=10,
|
||||
f"{self._resource}/digital/{self._pin}/{turn_off_payload}", timeout=10
|
||||
)
|
||||
if request.status_code == 200:
|
||||
self._state = False
|
||||
@ -211,9 +201,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
||||
def update(self):
|
||||
"""Get the latest data from aREST API and update the state."""
|
||||
try:
|
||||
request = requests.get(
|
||||
"{}/digital/{}".format(self._resource, self._pin), timeout=10
|
||||
)
|
||||
request = requests.get(f"{self._resource}/digital/{self._pin}", timeout=10)
|
||||
status_value = int(self.invert)
|
||||
self._state = request.json()["return_value"] != status_value
|
||||
self._available = True
|
||||
|
@ -73,4 +73,4 @@ class AugustCamera(Camera):
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Get the unique id of the camera."""
|
||||
return "{:s}_camera".format(self._doorbell.device_id)
|
||||
return f"{self._doorbell.device_id:s}_camera"
|
||||
|
@ -93,4 +93,4 @@ class AugustLock(LockDevice):
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Get the unique id of the lock."""
|
||||
return "{:s}_lock".format(self._lock.device_id)
|
||||
return f"{self._lock.device_id:s}_lock"
|
||||
|
@ -64,7 +64,7 @@ class AuroraSensor(BinarySensorDevice):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return "{}".format(self._name)
|
||||
return f"{self._name}"
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -49,7 +49,7 @@ class AuroraABBSolarPVMonitorSensor(Entity):
|
||||
|
||||
def __init__(self, client, name, typename):
|
||||
"""Initialize the sensor."""
|
||||
self._name = "{} {}".format(name, typename)
|
||||
self._name = f"{name} {typename}"
|
||||
self.client = client
|
||||
self._state = None
|
||||
|
||||
|
@ -34,7 +34,7 @@ async def async_setup(hass):
|
||||
"""Create a setup flow. handler is a mfa module."""
|
||||
mfa_module = hass.auth.get_auth_mfa_module(handler)
|
||||
if mfa_module is None:
|
||||
raise ValueError("Mfa module {} is not found".format(handler))
|
||||
raise ValueError(f"Mfa module {handler} is not found")
|
||||
|
||||
user_id = data.pop("user_id")
|
||||
return await mfa_module.async_setup_flow(user_id)
|
||||
@ -80,9 +80,7 @@ def websocket_setup_mfa(
|
||||
if mfa_module is None:
|
||||
connection.send_message(
|
||||
websocket_api.error_message(
|
||||
msg["id"],
|
||||
"no_module",
|
||||
"MFA module {} is not found".format(mfa_module_id),
|
||||
msg["id"], "no_module", f"MFA module {mfa_module_id} is not found"
|
||||
)
|
||||
)
|
||||
return
|
||||
@ -117,7 +115,7 @@ def websocket_depose_mfa(
|
||||
websocket_api.error_message(
|
||||
msg["id"],
|
||||
"disable_failed",
|
||||
"Cannot disable MFA Module {}: {}".format(mfa_module_id, err),
|
||||
f"Cannot disable MFA Module {mfa_module_id}: {err}",
|
||||
)
|
||||
)
|
||||
return
|
||||
|
@ -150,7 +150,7 @@ class AwairSensor(Entity):
|
||||
"""Initialize the sensor."""
|
||||
self._uuid = device[CONF_UUID]
|
||||
self._device_class = SENSOR_TYPES[sensor_type]["device_class"]
|
||||
self._name = "Awair {}".format(self._device_class)
|
||||
self._name = f"Awair {self._device_class}"
|
||||
unit = SENSOR_TYPES[sensor_type]["unit_of_measurement"]
|
||||
self._unit_of_measurement = unit
|
||||
self._data = data
|
||||
@ -202,7 +202,7 @@ class AwairSensor(Entity):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique id of this entity."""
|
||||
return "{}_{}".format(self._uuid, self._type)
|
||||
return f"{self._uuid}_{self._type}"
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
@ -72,7 +72,7 @@ class AxisEventBase(AxisEntityBase):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the event."""
|
||||
return "{} {} {}".format(self.device.name, self.event.TYPE, self.event.id)
|
||||
return f"{self.device.name} {self.event.TYPE} {self.event.id}"
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
@ -82,4 +82,4 @@ class AxisEventBase(AxisEntityBase):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier for this device."""
|
||||
return "{}-{}-{}".format(self.device.serial, self.event.topic, self.event.id)
|
||||
return f"{self.device.serial}-{self.event.topic}-{self.event.id}"
|
||||
|
@ -92,4 +92,4 @@ class AxisCamera(AxisEntityBase, MjpegCamera):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier for this device."""
|
||||
return "{}-camera".format(self.device.serial)
|
||||
return f"{self.device.serial}-camera"
|
||||
|
@ -137,9 +137,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if entry.data[CONF_MODEL] == self.model
|
||||
]
|
||||
|
||||
self.name = "{}".format(self.model)
|
||||
self.name = f"{self.model}"
|
||||
for idx in range(len(same_model) + 1):
|
||||
self.name = "{} {}".format(self.model, idx)
|
||||
self.name = f"{self.model} {idx}"
|
||||
if self.name not in same_model:
|
||||
break
|
||||
|
||||
@ -150,7 +150,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
CONF_MODEL: self.model,
|
||||
}
|
||||
|
||||
title = "{} - {}".format(self.model, self.serial_number)
|
||||
title = f"{self.model} - {self.serial_number}"
|
||||
return self.async_create_entry(title=title, data=data)
|
||||
|
||||
async def _update_entry(self, entry, host):
|
||||
|
@ -65,7 +65,7 @@ class AxisNetworkDevice:
|
||||
connections={(CONNECTION_NETWORK_MAC, self.serial)},
|
||||
identifiers={(DOMAIN, self.serial)},
|
||||
manufacturer="Axis Communications AB",
|
||||
model="{} {}".format(self.model, self.product_type),
|
||||
model=f"{self.model} {self.product_type}",
|
||||
name=self.name,
|
||||
sw_version=self.fw_version,
|
||||
)
|
||||
@ -115,7 +115,7 @@ class AxisNetworkDevice:
|
||||
@property
|
||||
def event_new_address(self):
|
||||
"""Device specific event to signal new device address."""
|
||||
return "axis_new_address_{}".format(self.serial)
|
||||
return f"axis_new_address_{self.serial}"
|
||||
|
||||
@staticmethod
|
||||
async def async_new_address_callback(hass, entry):
|
||||
@ -131,7 +131,7 @@ class AxisNetworkDevice:
|
||||
@property
|
||||
def event_reachable(self):
|
||||
"""Device specific event to signal a change in connection status."""
|
||||
return "axis_reachable_{}".format(self.serial)
|
||||
return f"axis_reachable_{self.serial}"
|
||||
|
||||
@callback
|
||||
def async_connection_status_callback(self, status):
|
||||
@ -149,7 +149,7 @@ class AxisNetworkDevice:
|
||||
@property
|
||||
def event_new_sensor(self):
|
||||
"""Device specific event to signal new sensor available."""
|
||||
return "axis_add_sensor_{}".format(self.serial)
|
||||
return f"axis_add_sensor_{self.serial}"
|
||||
|
||||
@callback
|
||||
def async_event_callback(self, action, event_id):
|
||||
|
Loading…
x
Reference in New Issue
Block a user