diff --git a/homeassistant/components/adguard/sensor.py b/homeassistant/components/adguard/sensor.py index 17e53270f25..e0c86e42d26 100644 --- a/homeassistant/components/adguard/sensor.py +++ b/homeassistant/components/adguard/sensor.py @@ -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): diff --git a/homeassistant/components/airvisual/sensor.py b/homeassistant/components/airvisual/sensor.py index ec2dea69031..20e5196c0f1 100644 --- a/homeassistant/components/airvisual/sensor.py +++ b/homeassistant/components/airvisual/sensor.py @@ -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( { diff --git a/homeassistant/components/aladdin_connect/cover.py b/homeassistant/components/aladdin_connect/cover.py index 770b663e8a3..b3da4fb4cbc 100644 --- a/homeassistant/components/aladdin_connect/cover.py +++ b/homeassistant/components/aladdin_connect/cover.py @@ -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): diff --git a/homeassistant/components/alarmdecoder/alarm_control_panel.py b/homeassistant/components/alarmdecoder/alarm_control_panel.py index c05dfd30d21..288c1dfd1c7 100644 --- a/homeassistant/components/alarmdecoder/alarm_control_panel.py +++ b/homeassistant/components/alarmdecoder/alarm_control_panel.py @@ -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.""" diff --git a/homeassistant/components/alexa/errors.py b/homeassistant/components/alexa/errors.py index 56202b23e20..8c2fa692267 100644 --- a/homeassistant/components/alexa/errors.py +++ b/homeassistant/components/alexa/errors.py @@ -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) diff --git a/homeassistant/components/alexa/handlers.py b/homeassistant/components/alexa/handlers.py index cd5b56d60e2..1e636b96ee5 100644 --- a/homeassistant/components/alexa/handlers.py +++ b/homeassistant/components/alexa/handlers.py @@ -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 diff --git a/homeassistant/components/alexa/intent.py b/homeassistant/components/alexa/intent.py index edeb6865aad..4cb75c65bc9 100644 --- a/homeassistant/components/alexa/intent.py +++ b/homeassistant/components/alexa/intent.py @@ -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) diff --git a/homeassistant/components/alexa/state_report.py b/homeassistant/components/alexa/state_report.py index 1e22d5fc09f..e956abec7ad 100644 --- a/homeassistant/components/alexa/state_report.py +++ b/homeassistant/components/alexa/state_report.py @@ -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 = [] diff --git a/homeassistant/components/alpha_vantage/sensor.py b/homeassistant/components/alpha_vantage/sensor.py index 6d790e0719b..188567e4cf4 100644 --- a/homeassistant/components/alpha_vantage/sensor.py +++ b/homeassistant/components/alpha_vantage/sensor.py @@ -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 diff --git a/homeassistant/components/ambiclimate/config_flow.py b/homeassistant/components/ambiclimate/config_flow.py index db6d42d1d5c..99563dcb97d 100644 --- a/homeassistant/components/ambiclimate/config_flow.py +++ b/homeassistant/components/ambiclimate/config_flow.py @@ -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() diff --git a/homeassistant/components/ambient_station/__init__.py b/homeassistant/components/ambient_station/__init__.py index 82c29f79983..bff03eb422b 100644 --- a/homeassistant/components/ambient_station/__init__.py +++ b/homeassistant/components/ambient_station/__init__.py @@ -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.""" diff --git a/homeassistant/components/amcrest/camera.py b/homeassistant/components/amcrest/camera.py index 483bdb2c7cf..f75a5adbe9c 100644 --- a/homeassistant/components/amcrest/camera.py +++ b/homeassistant/components/amcrest/camera.py @@ -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 diff --git a/homeassistant/components/amcrest/helpers.py b/homeassistant/components/amcrest/helpers.py index d24d6e0e707..a40d6ace50a 100644 --- a/homeassistant/components/amcrest/helpers.py +++ b/homeassistant/components/amcrest/helpers.py @@ -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 diff --git a/homeassistant/components/ampio/air_quality.py b/homeassistant/components/ampio/air_quality.py index f55f20fc150..e63f59839a8 100644 --- a/homeassistant/components/ampio/air_quality.py +++ b/homeassistant/components/ampio/air_quality.py @@ -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): diff --git a/homeassistant/components/android_ip_webcam/binary_sensor.py b/homeassistant/components/android_ip_webcam/binary_sensor.py index d7bf009701d..0e9cca46afb 100644 --- a/homeassistant/components/android_ip_webcam/binary_sensor.py +++ b/homeassistant/components/android_ip_webcam/binary_sensor.py @@ -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 diff --git a/homeassistant/components/android_ip_webcam/sensor.py b/homeassistant/components/android_ip_webcam/sensor.py index 20f4acebca6..05c1fe16c61 100644 --- a/homeassistant/components/android_ip_webcam/sensor.py +++ b/homeassistant/components/android_ip_webcam/sensor.py @@ -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 diff --git a/homeassistant/components/android_ip_webcam/switch.py b/homeassistant/components/android_ip_webcam/switch.py index 5b2f5dad5e1..2d5f2412d85 100644 --- a/homeassistant/components/android_ip_webcam/switch.py +++ b/homeassistant/components/android_ip_webcam/switch.py @@ -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 diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index 2db210b56f3..d68f47b1b0a 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -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 diff --git a/homeassistant/components/apache_kafka/__init__.py b/homeassistant/components/apache_kafka/__init__.py index caf96c61fb8..e0c8b824913 100644 --- a/homeassistant/components/apache_kafka/__init__.py +++ b/homeassistant/components/apache_kafka/__init__.py @@ -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 diff --git a/homeassistant/components/apns/notify.py b/homeassistant/components/apns/notify.py index 0b95cb9f0cb..dbd45013a3c 100644 --- a/homeassistant/components/apns/notify.py +++ b/homeassistant/components/apns/notify.py @@ -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") diff --git a/homeassistant/components/apple_tv/media_player.py b/homeassistant/components/apple_tv/media_player.py index 3e77c7a1cfd..9ac5ba77f98 100644 --- a/homeassistant/components/apple_tv/media_player.py +++ b/homeassistant/components/apple_tv/media_player.py @@ -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): diff --git a/homeassistant/components/aprs/device_tracker.py b/homeassistant/components/aprs/device_tracker.py index c5ae8ed8414..86b0b6f48af 100644 --- a/homeassistant/components/aprs/device_tracker.py +++ b/homeassistant/components/aprs/device_tracker.py @@ -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: diff --git a/homeassistant/components/arcam_fmj/const.py b/homeassistant/components/arcam_fmj/const.py index b065e1a0833..dc5a576acec 100644 --- a/homeassistant/components/arcam_fmj/const.py +++ b/homeassistant/components/arcam_fmj/const.py @@ -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" diff --git a/homeassistant/components/arcam_fmj/media_player.py b/homeassistant/components/arcam_fmj/media_player.py index 971abc3e26d..231e9821dc6 100644 --- a/homeassistant/components/arcam_fmj/media_player.py +++ b/homeassistant/components/arcam_fmj/media_player.py @@ -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 diff --git a/homeassistant/components/arest/binary_sensor.py b/homeassistant/components/arest/binary_sensor.py index 96ffa371864..669a28b7078 100644 --- a/homeassistant/components/arest/binary_sensor.py +++ b/homeassistant/components/arest/binary_sensor.py @@ -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) diff --git a/homeassistant/components/arest/sensor.py b/homeassistant/components/arest/sensor.py index 533adeccb5e..2416eeb0ebb 100644 --- a/homeassistant/components/arest/sensor.py +++ b/homeassistant/components/arest/sensor.py @@ -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 diff --git a/homeassistant/components/arest/switch.py b/homeassistant/components/arest/switch.py index 558df89100e..e1a7edacb7e 100644 --- a/homeassistant/components/arest/switch.py +++ b/homeassistant/components/arest/switch.py @@ -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 diff --git a/homeassistant/components/august/camera.py b/homeassistant/components/august/camera.py index a8335d1aa52..2492eb75418 100644 --- a/homeassistant/components/august/camera.py +++ b/homeassistant/components/august/camera.py @@ -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" diff --git a/homeassistant/components/august/lock.py b/homeassistant/components/august/lock.py index e919c47dd4c..8b8c019eb2d 100644 --- a/homeassistant/components/august/lock.py +++ b/homeassistant/components/august/lock.py @@ -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" diff --git a/homeassistant/components/aurora/binary_sensor.py b/homeassistant/components/aurora/binary_sensor.py index 0d983f35e37..a69433c4186 100644 --- a/homeassistant/components/aurora/binary_sensor.py +++ b/homeassistant/components/aurora/binary_sensor.py @@ -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): diff --git a/homeassistant/components/aurora_abb_powerone/sensor.py b/homeassistant/components/aurora_abb_powerone/sensor.py index 456b5080484..05ed5fa99bf 100644 --- a/homeassistant/components/aurora_abb_powerone/sensor.py +++ b/homeassistant/components/aurora_abb_powerone/sensor.py @@ -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 diff --git a/homeassistant/components/auth/mfa_setup_flow.py b/homeassistant/components/auth/mfa_setup_flow.py index c18bc276a44..42dab7ebb5a 100644 --- a/homeassistant/components/auth/mfa_setup_flow.py +++ b/homeassistant/components/auth/mfa_setup_flow.py @@ -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 diff --git a/homeassistant/components/awair/sensor.py b/homeassistant/components/awair/sensor.py index 85b5a0be191..c899e009796 100644 --- a/homeassistant/components/awair/sensor.py +++ b/homeassistant/components/awair/sensor.py @@ -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): diff --git a/homeassistant/components/axis/axis_base.py b/homeassistant/components/axis/axis_base.py index 3864ac344e1..f22a169a102 100644 --- a/homeassistant/components/axis/axis_base.py +++ b/homeassistant/components/axis/axis_base.py @@ -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}" diff --git a/homeassistant/components/axis/camera.py b/homeassistant/components/axis/camera.py index e7e0f7459f3..a55e45dd374 100644 --- a/homeassistant/components/axis/camera.py +++ b/homeassistant/components/axis/camera.py @@ -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" diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py index f93e49d9818..3b5efe96760 100644 --- a/homeassistant/components/axis/config_flow.py +++ b/homeassistant/components/axis/config_flow.py @@ -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): diff --git a/homeassistant/components/axis/device.py b/homeassistant/components/axis/device.py index 465d8c73b74..3b91f7e1474 100644 --- a/homeassistant/components/axis/device.py +++ b/homeassistant/components/axis/device.py @@ -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):