diff --git a/homeassistant/components/rachio/__init__.py b/homeassistant/components/rachio/__init__.py index 0d582b0c2e99..2030512ab313 100644 --- a/homeassistant/components/rachio/__init__.py +++ b/homeassistant/components/rachio/__init__.py @@ -226,7 +226,7 @@ class RachioIro: def __str__(self) -> str: """Display the controller as a string.""" - return 'Rachio controller "{}"'.format(self.name) + return f'Rachio controller "{self.name}"' @property def controller_id(self) -> str: diff --git a/homeassistant/components/rachio/binary_sensor.py b/homeassistant/components/rachio/binary_sensor.py index 01d38a931c47..f74e3ca18021 100644 --- a/homeassistant/components/rachio/binary_sensor.py +++ b/homeassistant/components/rachio/binary_sensor.py @@ -87,12 +87,12 @@ class RachioControllerOnlineBinarySensor(RachioControllerBinarySensor): @property def name(self) -> str: """Return the name of this sensor including the controller name.""" - return "{} online".format(self._controller.name) + return f"{self._controller.name} online" @property def unique_id(self) -> str: """Return a unique id for this entity.""" - return "{}-online".format(self._controller.controller_id) + return f"{self._controller.controller_id}-online" @property def device_class(self) -> str: diff --git a/homeassistant/components/rachio/switch.py b/homeassistant/components/rachio/switch.py index b65e6bf60442..80c227a6df69 100644 --- a/homeassistant/components/rachio/switch.py +++ b/homeassistant/components/rachio/switch.py @@ -72,7 +72,7 @@ class RachioSwitch(SwitchDevice): @property def name(self) -> str: """Get a name for this switch.""" - return "Switch on {}".format(self._controller.name) + return f"Switch on {self._controller.name}" @property def is_on(self) -> bool: @@ -113,12 +113,12 @@ class RachioStandbySwitch(RachioSwitch): @property def name(self) -> str: """Return the name of the standby switch.""" - return "{} in standby mode".format(self._controller.name) + return f"{self._controller.name} in standby mode" @property def unique_id(self) -> str: """Return a unique id by combining controller id and purpose.""" - return "{}-standby".format(self._controller.controller_id) + return f"{self._controller.controller_id}-standby" @property def icon(self) -> str: @@ -183,7 +183,7 @@ class RachioZone(RachioSwitch): @property def unique_id(self) -> str: """Return a unique id by combining controller id and zone number.""" - return "{}-zone-{}".format(self._controller.controller_id, self.zone_id) + return f"{self._controller.controller_id}-zone-{self.zone_id}" @property def icon(self) -> str: diff --git a/homeassistant/components/rainbird/switch.py b/homeassistant/components/rainbird/switch.py index a1b82bc1af74..868e8ff4c7d6 100644 --- a/homeassistant/components/rainbird/switch.py +++ b/homeassistant/components/rainbird/switch.py @@ -53,7 +53,7 @@ class RainBirdSwitch(SwitchDevice): self._rainbird = rb self._devid = dev_id self._zone = int(dev.get(CONF_ZONE)) - self._name = dev.get(CONF_FRIENDLY_NAME, "Sprinkler {}".format(self._zone)) + self._name = dev.get(CONF_FRIENDLY_NAME, f"Sprinkler {self._zone}") self._state = None self._duration = dev.get(CONF_TRIGGER_TIME) self._attributes = {"duration": self._duration, "zone": self._zone} diff --git a/homeassistant/components/rainmachine/__init__.py b/homeassistant/components/rainmachine/__init__.py index b04384dc81dd..183872087a72 100644 --- a/homeassistant/components/rainmachine/__init__.py +++ b/homeassistant/components/rainmachine/__init__.py @@ -41,9 +41,9 @@ _LOGGER = logging.getLogger(__name__) DATA_LISTENER = "listener" -PROGRAM_UPDATE_TOPIC = "{0}_program_update".format(DOMAIN) -SENSOR_UPDATE_TOPIC = "{0}_data_update".format(DOMAIN) -ZONE_UPDATE_TOPIC = "{0}_zone_update".format(DOMAIN) +PROGRAM_UPDATE_TOPIC = f"{DOMAIN}_program_update" +SENSOR_UPDATE_TOPIC = f"{DOMAIN}_data_update" +ZONE_UPDATE_TOPIC = f"{DOMAIN}_zone_update" CONF_CONTROLLERS = "controllers" CONF_PROGRAM_ID = "program_id" diff --git a/homeassistant/components/recollect_waste/sensor.py b/homeassistant/components/recollect_waste/sensor.py index 0c3833528dc6..118b6fb37097 100644 --- a/homeassistant/components/recollect_waste/sensor.py +++ b/homeassistant/components/recollect_waste/sensor.py @@ -66,7 +66,7 @@ class RecollectWasteSensor(Entity): @property def unique_id(self) -> str: """Return a unique ID.""" - return "{}{}".format(self.client.place_id, self.client.service_id) + return f"{self.client.place_id}{self.client.service_id}" @property def state(self): diff --git a/homeassistant/components/reddit/sensor.py b/homeassistant/components/reddit/sensor.py index 0e95bea9091d..f9c8140f60db 100644 --- a/homeassistant/components/reddit/sensor.py +++ b/homeassistant/components/reddit/sensor.py @@ -94,7 +94,7 @@ class RedditSensor(Entity): @property def name(self): """Return the name of the sensor.""" - return "reddit_{}".format(self._subreddit) + return f"reddit_{self._subreddit}" @property def state(self): diff --git a/homeassistant/components/rejseplanen/sensor.py b/homeassistant/components/rejseplanen/sensor.py index 3172e614166b..61cb319fd11e 100644 --- a/homeassistant/components/rejseplanen/sensor.py +++ b/homeassistant/components/rejseplanen/sensor.py @@ -220,7 +220,7 @@ class PublicTransportData: and due_at_time is not None and route is not None ): - due_at = "{} {}".format(due_at_date, due_at_time) + due_at = f"{due_at_date} {due_at_time}" departure_data = { ATTR_DUE_IN: due_in_minutes(due_at), diff --git a/homeassistant/components/remember_the_milk/__init__.py b/homeassistant/components/remember_the_milk/__init__.py index 3d340d9c07e6..c92a246da147 100644 --- a/homeassistant/components/remember_the_milk/__init__.py +++ b/homeassistant/components/remember_the_milk/__init__.py @@ -87,13 +87,13 @@ def _create_instance( component.add_entities([entity]) hass.services.register( DOMAIN, - "{}_create_task".format(account_name), + f"{account_name}_create_task", entity.create_task, schema=SERVICE_SCHEMA_CREATE_TASK, ) hass.services.register( DOMAIN, - "{}_complete_task".format(account_name), + f"{account_name}_complete_task", entity.complete_task, schema=SERVICE_SCHEMA_COMPLETE_TASK, ) @@ -137,7 +137,7 @@ def _register_new_account( configurator.request_done(request_id) request_id = configurator.async_request_config( - "{} - {}".format(DOMAIN, account_name), + f"{DOMAIN} - {account_name}", callback=register_account_callback, description="You need to log in to Remember The Milk to" + "connect your account. \n\n" diff --git a/homeassistant/components/repetier/__init__.py b/homeassistant/components/repetier/__init__.py index 1643966b33ee..6f72a6b7ddc5 100644 --- a/homeassistant/components/repetier/__init__.py +++ b/homeassistant/components/repetier/__init__.py @@ -239,7 +239,7 @@ class PrinterAPI: info["name"] = printer.slug info["printer_name"] = self.conf_name - known = "{}-{}".format(printer.slug, sensor_type) + known = f"{printer.slug}-{sensor_type}" if known in self._known_entities: continue diff --git a/homeassistant/components/rflink/light.py b/homeassistant/components/rflink/light.py index 56ae6f8675fb..682d45f8f420 100644 --- a/homeassistant/components/rflink/light.py +++ b/homeassistant/components/rflink/light.py @@ -300,7 +300,7 @@ class ToggleRflinkLight(SwitchableRflinkDevice, Light): @property def entity_id(self): """Return entity id.""" - return "light.{}".format(self.name) + return f"light.{self.name}" def _handle_event(self, event): """Adjust state if Rflink picks up a remote command for this device.""" diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index 0c9a98143c80..79b3054ecf27 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -106,7 +106,7 @@ def setup(hass, config): slugify(event.device.id_string.lower()), event.device.__class__.__name__, event.device.subtype, - "".join("{0:02x}".format(x) for x in event.data), + "".join(f"{x:02x}" for x in event.data), ) # Callback to HA registered components. @@ -270,7 +270,7 @@ def get_new_device(event, config, device): if not config[ATTR_AUTOMATIC_ADD]: return - pkt_id = "".join("{0:02x}".format(x) for x in event.data) + pkt_id = "".join(f"{x:02x}" for x in event.data) _LOGGER.debug( "Automatic add %s rfxtrx device (Class: %s Sub: %s Packet_id: %s)", device_id, diff --git a/homeassistant/components/rfxtrx/binary_sensor.py b/homeassistant/components/rfxtrx/binary_sensor.py index d4ed874156e9..8f1c7e6fa55f 100644 --- a/homeassistant/components/rfxtrx/binary_sensor.py +++ b/homeassistant/components/rfxtrx/binary_sensor.py @@ -116,7 +116,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): poss_id = slugify(poss_dev.event.device.id_string.lower()) _LOGGER.debug("Found possible matching device ID: %s", poss_id) - pkt_id = "".join("{0:02x}".format(x) for x in event.data) + pkt_id = "".join(f"{x:02x}" for x in event.data) sensor = RfxtrxBinarySensor(event, pkt_id) sensor.hass = hass rfxtrx.RFX_DEVICES[device_id] = sensor diff --git a/homeassistant/components/rfxtrx/sensor.py b/homeassistant/components/rfxtrx/sensor.py index 69397263a627..5941b00764b8 100644 --- a/homeassistant/components/rfxtrx/sensor.py +++ b/homeassistant/components/rfxtrx/sensor.py @@ -98,7 +98,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): if not config[CONF_AUTOMATIC_ADD]: return - pkt_id = "".join("{0:02x}".format(x) for x in event.data) + pkt_id = "".join(f"{x:02x}" for x in event.data) _LOGGER.info("Automatic add rfxtrx.sensor: %s", pkt_id) data_type = "" @@ -141,7 +141,7 @@ class RfxtrxSensor(Entity): @property def name(self): """Get the name of the sensor.""" - return "{} {}".format(self._name, self.data_type) + return f"{self._name} {self.data_type}" @property def device_state_attributes(self): diff --git a/homeassistant/components/ring/binary_sensor.py b/homeassistant/components/ring/binary_sensor.py index 1b06a1d47d10..6806df0408fb 100644 --- a/homeassistant/components/ring/binary_sensor.py +++ b/homeassistant/components/ring/binary_sensor.py @@ -73,7 +73,7 @@ class RingBinarySensor(BinarySensorDevice): ) self._device_class = SENSOR_TYPES.get(self._sensor_type)[2] self._state = None - self._unique_id = "{}-{}".format(self._data.id, self._sensor_type) + self._unique_id = f"{self._data.id}-{self._sensor_type}" @property def name(self): diff --git a/homeassistant/components/ring/light.py b/homeassistant/components/ring/light.py index bd7ea3a36797..5805114252e0 100644 --- a/homeassistant/components/ring/light.py +++ b/homeassistant/components/ring/light.py @@ -56,7 +56,7 @@ class RingLight(Light): @property def name(self): """Name of the light.""" - return "{} light".format(self._device.name) + return f"{self._device.name} light" @property def unique_id(self): diff --git a/homeassistant/components/ring/sensor.py b/homeassistant/components/ring/sensor.py index 9950609c10fd..af661f4571c2 100644 --- a/homeassistant/components/ring/sensor.py +++ b/homeassistant/components/ring/sensor.py @@ -121,7 +121,7 @@ class RingSensor(Entity): ) self._state = None self._tz = str(hass.config.time_zone) - self._unique_id = "{}-{}".format(self._data.id, self._sensor_type) + self._unique_id = f"{self._data.id}-{self._sensor_type}" async def async_added_to_hass(self): """Register callbacks.""" diff --git a/homeassistant/components/ring/switch.py b/homeassistant/components/ring/switch.py index 3b6bd4ea0243..cbbecb1a4039 100644 --- a/homeassistant/components/ring/switch.py +++ b/homeassistant/components/ring/switch.py @@ -38,7 +38,7 @@ class BaseRingSwitch(SwitchDevice): """Initialize the switch.""" self._device = device self._device_type = device_type - self._unique_id = "{}-{}".format(self._device.id, self._device_type) + self._unique_id = f"{self._device.id}-{self._device_type}" async def async_added_to_hass(self): """Register callbacks.""" @@ -53,7 +53,7 @@ class BaseRingSwitch(SwitchDevice): @property def name(self): """Name of the device.""" - return "{} {}".format(self._device.name, self._device_type) + return f"{self._device.name} {self._device_type}" @property def unique_id(self): diff --git a/homeassistant/components/roku/__init__.py b/homeassistant/components/roku/__init__.py index e6dd05b93286..aa13814ee6b7 100644 --- a/homeassistant/components/roku/__init__.py +++ b/homeassistant/components/roku/__init__.py @@ -78,7 +78,7 @@ def scan_for_rokus(hass): "Name: {0}
Host: {1}
".format( r_info.userdevicename if r_info.userdevicename - else "{} {}".format(r_info.modelname, r_info.serial_num), + else f"{r_info.modelname} {r_info.serial_num}", roku.host, ) ) diff --git a/homeassistant/components/roku/media_player.py b/homeassistant/components/roku/media_player.py index 03060361020c..d69b0eddb71d 100644 --- a/homeassistant/components/roku/media_player.py +++ b/homeassistant/components/roku/media_player.py @@ -92,7 +92,7 @@ class RokuDevice(MediaPlayerDevice): """Return the name of the device.""" if self._device_info.user_device_name: return self._device_info.user_device_name - return "Roku {}".format(self._device_info.serial_num) + return f"Roku {self._device_info.serial_num}" @property def state(self): diff --git a/homeassistant/components/roku/remote.py b/homeassistant/components/roku/remote.py index 0bb840e95313..f443b7e8e74e 100644 --- a/homeassistant/components/roku/remote.py +++ b/homeassistant/components/roku/remote.py @@ -36,7 +36,7 @@ class RokuRemote(remote.RemoteDevice): """Return the name of the device.""" if self._device_info.user_device_name: return self._device_info.user_device_name - return "Roku {}".format(self._device_info.serial_num) + return f"Roku {self._device_info.serial_num}" @property def unique_id(self): diff --git a/homeassistant/components/roomba/vacuum.py b/homeassistant/components/roomba/vacuum.py index 766fd72cdbab..291658e19f4b 100644 --- a/homeassistant/components/roomba/vacuum.py +++ b/homeassistant/components/roomba/vacuum.py @@ -327,7 +327,7 @@ class RoombaVacuum(VacuumDevice): pos_y = pos_state.get("point", {}).get("y") theta = pos_state.get("theta") if all(item is not None for item in [pos_x, pos_y, theta]): - position = "({}, {}, {})".format(pos_x, pos_y, theta) + position = f"({pos_x}, {pos_y}, {theta})" self._state_attrs[ATTR_POSITION] = position # Not all Roombas have a bin full sensor diff --git a/homeassistant/components/route53/__init__.py b/homeassistant/components/route53/__init__.py index 906f09a56491..3dffc3ffd9e3 100644 --- a/homeassistant/components/route53/__init__.py +++ b/homeassistant/components/route53/__init__.py @@ -104,7 +104,7 @@ def _update_route53( { "Action": "UPSERT", "ResourceRecordSet": { - "Name": "{}.{}".format(record, domain), + "Name": f"{record}.{domain}", "Type": "A", "TTL": ttl, "ResourceRecords": [{"Value": ipaddress}], diff --git a/homeassistant/components/rova/sensor.py b/homeassistant/components/rova/sensor.py index c39bf5ca4f3f..fe0b5dead84d 100644 --- a/homeassistant/components/rova/sensor.py +++ b/homeassistant/components/rova/sensor.py @@ -96,7 +96,7 @@ class RovaSensor(Entity): @property def name(self): """Return the name.""" - return "{}_{}".format(self.platform_name, self.sensor_key) + return f"{self.platform_name}_{self.sensor_key}" @property def icon(self): diff --git a/homeassistant/components/rtorrent/sensor.py b/homeassistant/components/rtorrent/sensor.py index f2533e3dc862..ed16331e9128 100644 --- a/homeassistant/components/rtorrent/sensor.py +++ b/homeassistant/components/rtorrent/sensor.py @@ -79,7 +79,7 @@ class RTorrentSensor(Entity): @property def name(self): """Return the name of the sensor.""" - return "{} {}".format(self.client_name, self._name) + return f"{self.client_name} {self._name}" @property def state(self): diff --git a/homeassistant/components/sabnzbd/sensor.py b/homeassistant/components/sabnzbd/sensor.py index 642dd27b1d82..58624c758d9c 100644 --- a/homeassistant/components/sabnzbd/sensor.py +++ b/homeassistant/components/sabnzbd/sensor.py @@ -42,7 +42,7 @@ class SabnzbdSensor(Entity): @property def name(self): """Return the name of the sensor.""" - return "{} {}".format(self._client_name, self._name) + return f"{self._client_name} {self._name}" @property def state(self): diff --git a/homeassistant/components/samsungtv/media_player.py b/homeassistant/components/samsungtv/media_player.py index 934ee94e65df..2821a05261b3 100644 --- a/homeassistant/components/samsungtv/media_player.py +++ b/homeassistant/components/samsungtv/media_player.py @@ -84,7 +84,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): tv_name = discovery_info.get("name") model = discovery_info.get("model_name") host = discovery_info.get("host") - name = "{} ({})".format(tv_name, model) + name = f"{tv_name} ({model})" port = DEFAULT_PORT timeout = DEFAULT_TIMEOUT mac = None diff --git a/homeassistant/components/scsgate/__init__.py b/homeassistant/components/scsgate/__init__.py index acb7f78a2aaf..739a2949d17a 100644 --- a/homeassistant/components/scsgate/__init__.py +++ b/homeassistant/components/scsgate/__init__.py @@ -77,11 +77,11 @@ class SCSGate: """Handle a messages seen on the bus.""" from scsgate.messages import StateMessage, ScenarioTriggeredMessage - self._logger.debug("Received message {}".format(message)) + self._logger.debug(f"Received message {message}") if not isinstance(message, StateMessage) and not isinstance( message, ScenarioTriggeredMessage ): - msg = "Ignored message {} - not relevant type".format(message) + msg = f"Ignored message {message} - not relevant type" self._logger.debug(msg) return @@ -97,7 +97,7 @@ class SCSGate: try: self._devices[message.entity].process_event(message) except Exception as exception: # pylint: disable=broad-except - msg = "Exception while processing event: {}".format(exception) + msg = f"Exception while processing event: {exception}" self._logger.error(msg) else: self._logger.info( diff --git a/homeassistant/components/sense/sensor.py b/homeassistant/components/sense/sensor.py index 8ad289b92000..36474620b03f 100644 --- a/homeassistant/components/sense/sensor.py +++ b/homeassistant/components/sense/sensor.py @@ -80,7 +80,7 @@ class Sense(Entity): def __init__(self, data, name, sensor_type, is_production, update_call): """Initialize the Sense sensor.""" name_type = PRODUCTION_NAME if is_production else CONSUMPTION_NAME - self._name = "{} {}".format(name, name_type) + self._name = f"{name} {name_type}" self._data = data self._sensor_type = sensor_type self.update_sensor = update_call diff --git a/homeassistant/components/serial_pm/sensor.py b/homeassistant/components/serial_pm/sensor.py index 809526724877..1d46b05d46e0 100644 --- a/homeassistant/components/serial_pm/sensor.py +++ b/homeassistant/components/serial_pm/sensor.py @@ -51,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): if config.get(CONF_NAME) is not None: name = "{} PM{}".format(config.get(CONF_NAME), pmname) else: - name = "PM{}".format(pmname) + name = f"PM{pmname}" dev.append(ParticulateMatterSensor(coll, name, pmname)) add_entities(dev) diff --git a/homeassistant/components/seventeentrack/sensor.py b/homeassistant/components/seventeentrack/sensor.py index 14539e342f18..33abe2f1f861 100644 --- a/homeassistant/components/seventeentrack/sensor.py +++ b/homeassistant/components/seventeentrack/sensor.py @@ -120,7 +120,7 @@ class SeventeenTrackSummarySensor(Entity): @property def name(self): """Return the name.""" - return "Seventeentrack Packages {0}".format(self._status) + return f"Seventeentrack Packages {self._status}" @property def state(self): @@ -203,7 +203,7 @@ class SeventeenTrackPackageSensor(Entity): name = self._friendly_name if not name: name = self._tracking_number - return "Seventeentrack Package: {0}".format(name) + return f"Seventeentrack Package: {name}" @property def state(self): diff --git a/homeassistant/components/shiftr/__init__.py b/homeassistant/components/shiftr/__init__.py index a7e82ef66cf6..8e698d283cfc 100644 --- a/homeassistant/components/shiftr/__init__.py +++ b/homeassistant/components/shiftr/__init__.py @@ -69,10 +69,7 @@ def setup(hass, config): if state.attributes: for attribute, data in state.attributes.items(): mqttc.publish( - "/{}/{}".format(topic, attribute), - str(data), - qos=0, - retain=False, + f"/{topic}/{attribute}", str(data), qos=0, retain=False ) except RuntimeError: pass diff --git a/homeassistant/components/shopping_list/__init__.py b/homeassistant/components/shopping_list/__init__.py index 075d819655b3..3c9cb4391a73 100644 --- a/homeassistant/components/shopping_list/__init__.py +++ b/homeassistant/components/shopping_list/__init__.py @@ -196,7 +196,7 @@ class AddItemIntent(intent.IntentHandler): intent_obj.hass.data[DOMAIN].async_add(item) response = intent_obj.create_response() - response.async_set_speech("I've added {} to your shopping list".format(item)) + response.async_set_speech(f"I've added {item} to your shopping list") intent_obj.hass.bus.async_fire(EVENT) return response diff --git a/homeassistant/components/sigfox/sensor.py b/homeassistant/components/sigfox/sensor.py index 0961017b65c1..b890880389c2 100644 --- a/homeassistant/components/sigfox/sensor.py +++ b/homeassistant/components/sigfox/sensor.py @@ -90,7 +90,7 @@ class SigfoxAPI: """Get the device_id of each device registered.""" devices = [] for unique_type in device_types: - location_url = "devicetypes/{}/devices".format(unique_type) + location_url = f"devicetypes/{unique_type}/devices" url = urljoin(API_URL, location_url) response = requests.get(url, auth=self._auth, timeout=10) devices_data = json.loads(response.text)["data"] @@ -117,12 +117,12 @@ class SigfoxDevice(Entity): self._device_id = device_id self._auth = auth self._message_data = {} - self._name = "{}_{}".format(name, device_id) + self._name = f"{name}_{device_id}" self._state = None def get_last_message(self): """Return the last message from a device.""" - device_url = "devices/{}/messages?limit=1".format(self._device_id) + device_url = f"devices/{self._device_id}/messages?limit=1" url = urljoin(API_URL, device_url) response = requests.get(url, auth=self._auth, timeout=10) data = json.loads(response.text)["data"][0] diff --git a/homeassistant/components/sky_hub/device_tracker.py b/homeassistant/components/sky_hub/device_tracker.py index eea97fb37fb0..c8969add244a 100644 --- a/homeassistant/components/sky_hub/device_tracker.py +++ b/homeassistant/components/sky_hub/device_tracker.py @@ -34,7 +34,7 @@ class SkyHubDeviceScanner(DeviceScanner): _LOGGER.info("Initialising Sky Hub") self.host = config.get(CONF_HOST, "192.168.1.254") self.last_results = {} - self.url = "http://{}/".format(self.host) + self.url = f"http://{self.host}/" # Test the router is accessible data = _get_skyhub_data(self.url) diff --git a/homeassistant/components/skybell/camera.py b/homeassistant/components/skybell/camera.py index 87cfdce6dfca..87dc3c0bf8d7 100644 --- a/homeassistant/components/skybell/camera.py +++ b/homeassistant/components/skybell/camera.py @@ -57,7 +57,7 @@ class SkybellCamera(SkybellDevice, Camera): SkybellDevice.__init__(self, device) Camera.__init__(self) if name is not None: - self._name = "{} {}".format(self._device.name, name) + self._name = f"{self._device.name} {name}" else: self._name = self._device.name self._url = None diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index 5b6bc57be9d6..56e10b03d2ad 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -50,7 +50,7 @@ def _check_sensor_schema(conf): sensor, ) elif sensor not in valid: - raise vol.Invalid("{} does not exist".format(sensor)) + raise vol.Invalid(f"{sensor} does not exist") return conf @@ -217,7 +217,7 @@ class SMAsensor(Entity): update = False for sens in self._sub_sensors: # Can be remove from 0.99 - newval = "{} {}".format(sens.value, sens.unit) + newval = f"{sens.value} {sens.unit}" if self._attr[sens.name] != newval: update = True self._attr[sens.name] = newval @@ -231,4 +231,4 @@ class SMAsensor(Entity): @property def unique_id(self): """Return a unique identifier for this sensor.""" - return "sma-{}-{}".format(self._sensor.key, self._sensor.name) + return f"sma-{self._sensor.key}-{self._sensor.name}" diff --git a/homeassistant/components/smappee/sensor.py b/homeassistant/components/smappee/sensor.py index cdbd1d18c299..28abf759d098 100644 --- a/homeassistant/components/smappee/sensor.py +++ b/homeassistant/components/smappee/sensor.py @@ -139,7 +139,7 @@ class SmappeeSensor(Entity): else: location_name = "Local" - return "{} {} {}".format(SENSOR_PREFIX, location_name, self._name) + return f"{SENSOR_PREFIX} {location_name} {self._name}" @property def icon(self): diff --git a/homeassistant/components/smartthings/binary_sensor.py b/homeassistant/components/smartthings/binary_sensor.py index 1ddbee6b827c..1e90709fc82c 100644 --- a/homeassistant/components/smartthings/binary_sensor.py +++ b/homeassistant/components/smartthings/binary_sensor.py @@ -66,12 +66,12 @@ class SmartThingsBinarySensor(SmartThingsEntity, BinarySensorDevice): @property def name(self) -> str: """Return the name of the binary sensor.""" - return "{} {}".format(self._device.label, self._attribute) + return f"{self._device.label} {self._attribute}" @property def unique_id(self) -> str: """Return a unique ID.""" - return "{}.{}".format(self._device.device_id, self._attribute) + return f"{self._device.device_id}.{self._attribute}" @property def is_on(self): diff --git a/homeassistant/components/smartthings/sensor.py b/homeassistant/components/smartthings/sensor.py index 423c141e4dab..3a6f9167054a 100644 --- a/homeassistant/components/smartthings/sensor.py +++ b/homeassistant/components/smartthings/sensor.py @@ -283,12 +283,12 @@ class SmartThingsSensor(SmartThingsEntity): @property def name(self) -> str: """Return the name of the binary sensor.""" - return "{} {}".format(self._device.label, self._name) + return f"{self._device.label} {self._name}" @property def unique_id(self) -> str: """Return a unique ID.""" - return "{}.{}".format(self._device.device_id, self._attribute) + return f"{self._device.device_id}.{self._attribute}" @property def state(self): diff --git a/homeassistant/components/smartthings/smartapp.py b/homeassistant/components/smartthings/smartapp.py index b64ba690d41d..d205c1d245cb 100644 --- a/homeassistant/components/smartthings/smartapp.py +++ b/homeassistant/components/smartthings/smartapp.py @@ -112,7 +112,7 @@ def _get_app_template(hass: HomeAssistantType): cloudhook_url = hass.data[DOMAIN][CONF_CLOUDHOOK_URL] if cloudhook_url is not None: endpoint = "via Nabu Casa" - description = "{} {}".format(hass.config.location_name, endpoint) + description = f"{hass.config.location_name} {endpoint}" return { "app_name": APP_NAME_PREFIX + str(uuid4()), diff --git a/homeassistant/components/smarty/binary_sensor.py b/homeassistant/components/smarty/binary_sensor.py index 2d79700db785..8723f0248d34 100644 --- a/homeassistant/components/smarty/binary_sensor.py +++ b/homeassistant/components/smarty/binary_sensor.py @@ -69,9 +69,7 @@ class BoostSensor(SmartyBinarySensor): def __init__(self, name, smarty): """Alarm Sensor Init.""" - super().__init__( - name="{} Boost State".format(name), device_class=None, smarty=smarty - ) + super().__init__(name=f"{name} Boost State", device_class=None, smarty=smarty) def update(self) -> None: """Update state.""" @@ -84,9 +82,7 @@ class AlarmSensor(SmartyBinarySensor): def __init__(self, name, smarty): """Alarm Sensor Init.""" - super().__init__( - name="{} Alarm".format(name), device_class="problem", smarty=smarty - ) + super().__init__(name=f"{name} Alarm", device_class="problem", smarty=smarty) def update(self) -> None: """Update state.""" @@ -99,9 +95,7 @@ class WarningSensor(SmartyBinarySensor): def __init__(self, name, smarty): """Warning Sensor Init.""" - super().__init__( - name="{} Warning".format(name), device_class="problem", smarty=smarty - ) + super().__init__(name=f"{name} Warning", device_class="problem", smarty=smarty) def update(self) -> None: """Update state.""" diff --git a/homeassistant/components/smarty/sensor.py b/homeassistant/components/smarty/sensor.py index 16d910beeb5b..bf647777b528 100644 --- a/homeassistant/components/smarty/sensor.py +++ b/homeassistant/components/smarty/sensor.py @@ -88,7 +88,7 @@ class SupplyAirTemperatureSensor(SmartySensor): def __init__(self, name, smarty): """Supply Air Temperature Init.""" super().__init__( - name="{} Supply Air Temperature".format(name), + name=f"{name} Supply Air Temperature", device_class=DEVICE_CLASS_TEMPERATURE, unit_of_measurement=TEMP_CELSIUS, smarty=smarty, @@ -106,7 +106,7 @@ class ExtractAirTemperatureSensor(SmartySensor): def __init__(self, name, smarty): """Supply Air Temperature Init.""" super().__init__( - name="{} Extract Air Temperature".format(name), + name=f"{name} Extract Air Temperature", device_class=DEVICE_CLASS_TEMPERATURE, unit_of_measurement=TEMP_CELSIUS, smarty=smarty, @@ -124,7 +124,7 @@ class OutdoorAirTemperatureSensor(SmartySensor): def __init__(self, name, smarty): """Outdoor Air Temperature Init.""" super().__init__( - name="{} Outdoor Air Temperature".format(name), + name=f"{name} Outdoor Air Temperature", device_class=DEVICE_CLASS_TEMPERATURE, unit_of_measurement=TEMP_CELSIUS, smarty=smarty, @@ -142,7 +142,7 @@ class SupplyFanSpeedSensor(SmartySensor): def __init__(self, name, smarty): """Supply Fan Speed RPM Init.""" super().__init__( - name="{} Supply Fan Speed".format(name), + name=f"{name} Supply Fan Speed", device_class=None, unit_of_measurement=None, smarty=smarty, @@ -160,7 +160,7 @@ class ExtractFanSpeedSensor(SmartySensor): def __init__(self, name, smarty): """Extract Fan Speed RPM Init.""" super().__init__( - name="{} Extract Fan Speed".format(name), + name=f"{name} Extract Fan Speed", device_class=None, unit_of_measurement=None, smarty=smarty, @@ -178,7 +178,7 @@ class FilterDaysLeftSensor(SmartySensor): def __init__(self, name, smarty): """Filter Days Left Init.""" super().__init__( - name="{} Filter Days Left".format(name), + name=f"{name} Filter Days Left", device_class=DEVICE_CLASS_TIMESTAMP, unit_of_measurement=None, smarty=smarty, diff --git a/homeassistant/components/smhi/weather.py b/homeassistant/components/smhi/weather.py index 29a8c3009445..5f6722b72a6d 100644 --- a/homeassistant/components/smhi/weather.py +++ b/homeassistant/components/smhi/weather.py @@ -102,7 +102,7 @@ class SmhiWeather(WeatherEntity): @property def unique_id(self) -> str: """Return a unique id.""" - return "{}, {}".format(self._latitude, self._longitude) + return f"{self._latitude}, {self._longitude}" @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self) -> None: diff --git a/homeassistant/components/smtp/notify.py b/homeassistant/components/smtp/notify.py index 7336b4577fa3..8a96865ab8db 100644 --- a/homeassistant/components/smtp/notify.py +++ b/homeassistant/components/smtp/notify.py @@ -182,7 +182,7 @@ class MailNotificationService(BaseNotificationService): msg["Subject"] = subject msg["To"] = ",".join(self.recipients) if self._sender_name: - msg["From"] = "{} <{}>".format(self._sender_name, self._sender) + msg["From"] = f"{self._sender_name} <{self._sender}>" else: msg["From"] = self._sender msg["X-Mailer"] = "HomeAssistant" @@ -225,18 +225,18 @@ def _build_multipart_msg(message, images): msg.attach(msg_alt) body_txt = MIMEText(message) msg_alt.attach(body_txt) - body_text = ["

{}


".format(message)] + body_text = [f"

{message}


"] for atch_num, atch_name in enumerate(images): - cid = "image{}".format(atch_num) - body_text.append('
'.format(cid)) + cid = f"image{atch_num}" + body_text.append(f'
') try: with open(atch_name, "rb") as attachment_file: file_bytes = attachment_file.read() try: attachment = MIMEImage(file_bytes) msg.attach(attachment) - attachment.add_header("Content-ID", "<{}>".format(cid)) + attachment.add_header("Content-ID", f"<{cid}>") except TypeError: _LOGGER.warning( "Attachment %s has an unknown MIME type. " @@ -271,7 +271,7 @@ def _build_html_msg(text, html, images): with open(atch_name, "rb") as attachment_file: attachment = MIMEImage(attachment_file.read(), filename=name) msg.attach(attachment) - attachment.add_header("Content-ID", "<{}>".format(name)) + attachment.add_header("Content-ID", f"<{name}>") except FileNotFoundError: _LOGGER.warning( "Attachment %s [#%s] not found. Skipping", atch_name, atch_num diff --git a/homeassistant/components/snapcast/media_player.py b/homeassistant/components/snapcast/media_player.py index 454201319adf..81cd6538578c 100644 --- a/homeassistant/components/snapcast/media_player.py +++ b/homeassistant/components/snapcast/media_player.py @@ -98,7 +98,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return # Note: Host part is needed, when using multiple snapservers - hpid = "{}:{}".format(host, port) + hpid = f"{host}:{port}" groups = [SnapcastGroupDevice(group, hpid) for group in server.groups] clients = [SnapcastClientDevice(client, hpid) for client in server.clients] @@ -114,7 +114,7 @@ class SnapcastGroupDevice(MediaPlayerDevice): """Initialize the Snapcast group device.""" group.set_callback(self.schedule_update_ha_state) self._group = group - self._uid = "{}{}_{}".format(GROUP_PREFIX, uid_part, self._group.identifier) + self._uid = f"{GROUP_PREFIX}{uid_part}_{self._group.identifier}" @property def state(self): @@ -133,7 +133,7 @@ class SnapcastGroupDevice(MediaPlayerDevice): @property def name(self): """Return the name of the device.""" - return "{}{}".format(GROUP_PREFIX, self._group.identifier) + return f"{GROUP_PREFIX}{self._group.identifier}" @property def source(self): @@ -163,7 +163,7 @@ class SnapcastGroupDevice(MediaPlayerDevice): @property def device_state_attributes(self): """Return the state attributes.""" - name = "{} {}".format(self._group.friendly_name, GROUP_SUFFIX) + name = f"{self._group.friendly_name} {GROUP_SUFFIX}" return {"friendly_name": name} @property @@ -204,7 +204,7 @@ class SnapcastClientDevice(MediaPlayerDevice): """Initialize the Snapcast client device.""" client.set_callback(self.schedule_update_ha_state) self._client = client - self._uid = "{}{}_{}".format(CLIENT_PREFIX, uid_part, self._client.identifier) + self._uid = f"{CLIENT_PREFIX}{uid_part}_{self._client.identifier}" @property def unique_id(self): @@ -223,7 +223,7 @@ class SnapcastClientDevice(MediaPlayerDevice): @property def name(self): """Return the name of the device.""" - return "{}{}".format(CLIENT_PREFIX, self._client.identifier) + return f"{CLIENT_PREFIX}{self._client.identifier}" @property def source(self): @@ -260,7 +260,7 @@ class SnapcastClientDevice(MediaPlayerDevice): @property def device_state_attributes(self): """Return the state attributes.""" - name = "{} {}".format(self._client.friendly_name, CLIENT_SUFFIX) + name = f"{self._client.friendly_name} {CLIENT_SUFFIX}" return {"friendly_name": name} @property diff --git a/homeassistant/components/solaredge_local/sensor.py b/homeassistant/components/solaredge_local/sensor.py index 80bd8e1f61ed..8586d950e39c 100644 --- a/homeassistant/components/solaredge_local/sensor.py +++ b/homeassistant/components/solaredge_local/sensor.py @@ -67,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): platform_name = config[CONF_NAME] # Create new SolarEdge object to retrieve data - api = SolarEdge("http://{}/".format(ip_address)) + api = SolarEdge(f"http://{ip_address}/") # Check if api can be reached and site is active try: diff --git a/homeassistant/components/solax/sensor.py b/homeassistant/components/solax/sensor.py index 62c6a2a3a514..0c1cfcf21da3 100644 --- a/homeassistant/components/solax/sensor.py +++ b/homeassistant/components/solax/sensor.py @@ -35,7 +35,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= idx, unit = solax.INVERTER_SENSORS[sensor] if unit == "C": unit = TEMP_CELSIUS - uid = "{}-{}".format(serial, idx) + uid = f"{serial}-{idx}" devices.append(Inverter(uid, serial, sensor, unit)) endpoint.sensors = devices async_add_entities(devices) @@ -97,7 +97,7 @@ class Inverter(Entity): @property def name(self): """Name of this inverter attribute.""" - return "Solax {} {}".format(self.serial, self.key) + return f"Solax {self.serial} {self.key}" @property def unit_of_measurement(self): diff --git a/homeassistant/components/somfy/config_flow.py b/homeassistant/components/somfy/config_flow.py index 7e6645c31e2f..9f3c58c8ffba 100644 --- a/homeassistant/components/somfy/config_flow.py +++ b/homeassistant/components/somfy/config_flow.py @@ -73,7 +73,7 @@ class SomfyFlowHandler(config_entries.ConfigFlow): client_id = self.hass.data[DOMAIN][CLIENT_ID] client_secret = self.hass.data[DOMAIN][CLIENT_SECRET] - redirect_uri = "{}{}".format(self.hass.config.api.base_url, AUTH_CALLBACK_PATH) + redirect_uri = f"{self.hass.config.api.base_url}{AUTH_CALLBACK_PATH}" api = SomfyApi(client_id, client_secret, redirect_uri) self.hass.http.register_view(SomfyAuthCallbackView()) @@ -95,7 +95,7 @@ class SomfyFlowHandler(config_entries.ConfigFlow): code = self.code from pymfy.api.somfy_api import SomfyApi - redirect_uri = "{}{}".format(self.hass.config.api.base_url, AUTH_CALLBACK_PATH) + redirect_uri = f"{self.hass.config.api.base_url}{AUTH_CALLBACK_PATH}" api = SomfyApi(client_id, client_secret, redirect_uri) token = await self.hass.async_add_executor_job(api.request_token, None, code) _LOGGER.info("Successfully authenticated Somfy") diff --git a/homeassistant/components/sonos/media_player.py b/homeassistant/components/sonos/media_player.py index 70461ad15d2f..41472413a077 100644 --- a/homeassistant/components/sonos/media_player.py +++ b/homeassistant/components/sonos/media_player.py @@ -606,7 +606,7 @@ class SonosEntity(MediaPlayerDevice): # media_artist = "Station - Artist - Title" # detect this case and trim from the front of # media_artist for cosmetics - trim = "{title} - ".format(title=self._media_title) + trim = f"{self._media_title} - " chars = min(len(self._media_artist), len(trim)) if self._media_artist[:chars].upper() == trim[:chars].upper(): diff --git a/homeassistant/components/speedtestdotnet/const.py b/homeassistant/components/speedtestdotnet/const.py index 90a89fcda2c6..69aadb7ac6c8 100644 --- a/homeassistant/components/speedtestdotnet/const.py +++ b/homeassistant/components/speedtestdotnet/const.py @@ -1,7 +1,7 @@ """Consts used by Speedtest.net.""" DOMAIN = "speedtestdotnet" -DATA_UPDATED = "{}_data_updated".format(DOMAIN) +DATA_UPDATED = f"{DOMAIN}_data_updated" SENSOR_TYPES = { "ping": ["Ping", "ms"], diff --git a/homeassistant/components/spotcrime/sensor.py b/homeassistant/components/spotcrime/sensor.py index 4498fd47e694..fc3a7592af31 100644 --- a/homeassistant/components/spotcrime/sensor.py +++ b/homeassistant/components/spotcrime/sensor.py @@ -29,7 +29,7 @@ CONF_DAYS = "days" DEFAULT_DAYS = 1 NAME = "spotcrime" -EVENT_INCIDENT = "{}_incident".format(NAME) +EVENT_INCIDENT = f"{NAME}_incident" SCAN_INTERVAL = timedelta(minutes=30) diff --git a/homeassistant/components/spotify/media_player.py b/homeassistant/components/spotify/media_player.py index 74a0dc0c9c0c..31fdc09af803 100644 --- a/homeassistant/components/spotify/media_player.py +++ b/homeassistant/components/spotify/media_player.py @@ -99,7 +99,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Spotify platform.""" import spotipy.oauth2 - callback_url = "{}{}".format(hass.config.api.base_url, AUTH_CALLBACK_PATH) + callback_url = f"{hass.config.api.base_url}{AUTH_CALLBACK_PATH}" cache = config.get(CONF_CACHE_PATH, hass.config.path(DEFAULT_CACHE_PATH)) oauth = spotipy.oauth2.SpotifyOAuth( config.get(CONF_CLIENT_ID), diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index 5f3a91bcf2f9..9e62e7ee0dbc 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -208,7 +208,7 @@ class LogitechMediaServer: if self._username is None else aiohttp.BasicAuth(self._username, self._password) ) - url = "http://{}:{}/jsonrpc.js".format(self.host, self.port) + url = f"http://{self.host}:{self.port}/jsonrpc.js" data = json.dumps( {"id": "1", "method": "slim.request", "params": [player, command]} ) @@ -288,9 +288,7 @@ class SqueezeBoxDevice(MediaPlayerDevice): async def async_update(self): """Retrieve the current state of the player.""" tags = "adKl" - response = await self.async_query( - "status", "-", "1", "tags:{tags}".format(tags=tags) - ) + response = await self.async_query("status", "-", "1", f"tags:{tags}") if response is False: return diff --git a/homeassistant/components/srp_energy/sensor.py b/homeassistant/components/srp_energy/sensor.py index a9873c76afe7..f1d1787b7b48 100644 --- a/homeassistant/components/srp_energy/sensor.py +++ b/homeassistant/components/srp_energy/sensor.py @@ -87,7 +87,7 @@ class SrpEnergy(Entity): if self._state is None: return None - return "{0:.2f}".format(self._state) + return f"{self._state:.2f}" @property def name(self): diff --git a/homeassistant/components/startca/sensor.py b/homeassistant/components/startca/sensor.py index d4104dd3dcf4..5e370ed7b632 100644 --- a/homeassistant/components/startca/sensor.py +++ b/homeassistant/components/startca/sensor.py @@ -86,7 +86,7 @@ class StartcaSensor(Entity): @property def name(self): """Return the name of the sensor.""" - return "{} {}".format(self.client_name, self._name) + return f"{self.client_name} {self._name}" @property def state(self): diff --git a/homeassistant/components/steam_online/sensor.py b/homeassistant/components/steam_online/sensor.py index 924afedfbd5f..6c9c5ac6079e 100644 --- a/homeassistant/components/steam_online/sensor.py +++ b/homeassistant/components/steam_online/sensor.py @@ -80,7 +80,7 @@ class SteamSensor(Entity): @property def entity_id(self): """Return the entity ID.""" - return "sensor.steam_{}".format(self._account) + return f"sensor.steam_{self._account}" @property def state(self): diff --git a/homeassistant/components/stiebel_eltron/climate.py b/homeassistant/components/stiebel_eltron/climate.py index f2e6209d21db..ce16b10f5488 100644 --- a/homeassistant/components/stiebel_eltron/climate.py +++ b/homeassistant/components/stiebel_eltron/climate.py @@ -139,7 +139,7 @@ class StiebelEltron(ClimateDevice): @property def current_humidity(self): """Return the current humidity.""" - return float("{0:.1f}".format(self._current_humidity)) + return float(f"{self._current_humidity:.1f}") @property def hvac_modes(self): diff --git a/homeassistant/components/stream/__init__.py b/homeassistant/components/stream/__init__.py index 50cc1d8169d6..2ae8dd5f7140 100644 --- a/homeassistant/components/stream/__init__.py +++ b/homeassistant/components/stream/__init__.py @@ -217,9 +217,7 @@ async def async_handle_record_service(hass, call): # Check for file access if not hass.config.is_allowed_path(video_path): - raise HomeAssistantError( - "Can't write {}, no access to path!".format(video_path) - ) + raise HomeAssistantError(f"Can't write {video_path}, no access to path!") # Check for active stream streams = hass.data[DOMAIN][ATTR_STREAMS] @@ -231,9 +229,7 @@ async def async_handle_record_service(hass, call): # Add recorder recorder = stream.outputs.get("recorder") if recorder: - raise HomeAssistantError( - "Stream already recording to {}!".format(recorder.video_path) - ) + raise HomeAssistantError(f"Stream already recording to {recorder.video_path}!") recorder = stream.add_provider("recorder") recorder.video_path = video_path diff --git a/homeassistant/components/stream/hls.py b/homeassistant/components/stream/hls.py index ab8779151588..c9e62f53a578 100644 --- a/homeassistant/components/stream/hls.py +++ b/homeassistant/components/stream/hls.py @@ -64,10 +64,7 @@ class M3U8Renderer: @staticmethod def render_preamble(track): """Render preamble.""" - return [ - "#EXT-X-VERSION:3", - "#EXT-X-TARGETDURATION:{}".format(track.target_duration), - ] + return ["#EXT-X-VERSION:3", f"#EXT-X-TARGETDURATION:{track.target_duration}"] @staticmethod def render_playlist(track, start_time): @@ -84,7 +81,7 @@ class M3U8Renderer: playlist.extend( [ "#EXTINF:{:.04f},".format(float(segment.duration)), - "./segment/{}.ts".format(segment.sequence), + f"./segment/{segment.sequence}.ts", ] ) diff --git a/homeassistant/components/streamlabswater/binary_sensor.py b/homeassistant/components/streamlabswater/binary_sensor.py index fd0ccb57aa60..78b2ceb40441 100644 --- a/homeassistant/components/streamlabswater/binary_sensor.py +++ b/homeassistant/components/streamlabswater/binary_sensor.py @@ -58,7 +58,7 @@ class StreamlabsAwayMode(BinarySensorDevice): @property def name(self): """Return the name for away mode.""" - return "{} {}".format(self._location_name, NAME_AWAY_MODE) + return f"{self._location_name} {NAME_AWAY_MODE}" @property def is_on(self): diff --git a/homeassistant/components/streamlabswater/sensor.py b/homeassistant/components/streamlabswater/sensor.py index 69196c288f60..e7168f8ec0b5 100644 --- a/homeassistant/components/streamlabswater/sensor.py +++ b/homeassistant/components/streamlabswater/sensor.py @@ -79,7 +79,7 @@ class StreamLabsDailyUsage(Entity): @property def name(self): """Return the name for daily usage.""" - return "{} {}".format(self._location_name, NAME_DAILY_USAGE) + return f"{self._location_name} {NAME_DAILY_USAGE}" @property def icon(self): @@ -107,7 +107,7 @@ class StreamLabsMonthlyUsage(StreamLabsDailyUsage): @property def name(self): """Return the name for monthly usage.""" - return "{} {}".format(self._location_name, NAME_MONTHLY_USAGE) + return f"{self._location_name} {NAME_MONTHLY_USAGE}" @property def state(self): @@ -121,7 +121,7 @@ class StreamLabsYearlyUsage(StreamLabsDailyUsage): @property def name(self): """Return the name for yearly usage.""" - return "{} {}".format(self._location_name, NAME_YEARLY_USAGE) + return f"{self._location_name} {NAME_YEARLY_USAGE}" @property def state(self): diff --git a/homeassistant/components/swiss_hydrological_data/sensor.py b/homeassistant/components/swiss_hydrological_data/sensor.py index bbac046d62ef..2d5d0e8de3f3 100644 --- a/homeassistant/components/swiss_hydrological_data/sensor.py +++ b/homeassistant/components/swiss_hydrological_data/sensor.py @@ -101,7 +101,7 @@ class SwissHydrologicalDataSensor(Entity): @property def unique_id(self) -> str: """Return a unique, friendly identifier for this entity.""" - return "{0}_{1}".format(self._station, self._condition) + return f"{self._station}_{self._condition}" @property def unit_of_measurement(self): diff --git a/homeassistant/components/swiss_public_transport/sensor.py b/homeassistant/components/swiss_public_transport/sensor.py index fedcb3003b05..3cf8babf5548 100644 --- a/homeassistant/components/swiss_public_transport/sensor.py +++ b/homeassistant/components/swiss_public_transport/sensor.py @@ -110,7 +110,7 @@ class SwissPublicTransportSensor(Entity): ATTR_DEPARTURE_TIME2: self._opendata.connections[2]["departure"], ATTR_START: self._opendata.from_name, ATTR_TARGET: self._opendata.to_name, - ATTR_REMAINING_TIME: "{}".format(self._remaining_time), + ATTR_REMAINING_TIME: f"{self._remaining_time}", ATTR_ATTRIBUTION: ATTRIBUTION, } return attr diff --git a/homeassistant/components/swisscom/device_tracker.py b/homeassistant/components/swisscom/device_tracker.py index 3775854fade0..98965af15136 100644 --- a/homeassistant/components/swisscom/device_tracker.py +++ b/homeassistant/components/swisscom/device_tracker.py @@ -74,7 +74,7 @@ class SwisscomDeviceScanner(DeviceScanner): def get_swisscom_data(self): """Retrieve data from Swisscom and return parsed result.""" - url = "http://{}/ws".format(self.host) + url = f"http://{self.host}/ws" headers = {CONTENT_TYPE: "application/x-sah-ws-4-call+json"} data = """ {"service":"Devices", "method":"get", diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index f52935c02ec8..a758a5843472 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -65,7 +65,7 @@ class SwitcherControl(SwitchDevice): @property def unique_id(self) -> str: """Return a unique ID.""" - return "{}-{}".format(self._device_data.device_id, self._device_data.mac_addr) + return f"{self._device_data.device_id}-{self._device_data.mac_addr}" @property def is_on(self) -> bool: diff --git a/homeassistant/components/syncthru/sensor.py b/homeassistant/components/syncthru/sensor.py index 0a50eec75c26..1258732223b0 100644 --- a/homeassistant/components/syncthru/sensor.py +++ b/homeassistant/components/syncthru/sensor.py @@ -18,12 +18,10 @@ TONER_COLORS = COLORS TRAYS = range(1, 6) OUTPUT_TRAYS = range(0, 6) DEFAULT_MONITORED_CONDITIONS = [] -DEFAULT_MONITORED_CONDITIONS.extend(["toner_{}".format(key) for key in TONER_COLORS]) -DEFAULT_MONITORED_CONDITIONS.extend(["drum_{}".format(key) for key in DRUM_COLORS]) -DEFAULT_MONITORED_CONDITIONS.extend(["tray_{}".format(key) for key in TRAYS]) -DEFAULT_MONITORED_CONDITIONS.extend( - ["output_tray_{}".format(key) for key in OUTPUT_TRAYS] -) +DEFAULT_MONITORED_CONDITIONS.extend([f"toner_{key}" for key in TONER_COLORS]) +DEFAULT_MONITORED_CONDITIONS.extend([f"drum_{key}" for key in DRUM_COLORS]) +DEFAULT_MONITORED_CONDITIONS.extend([f"tray_{key}" for key in TRAYS]) +DEFAULT_MONITORED_CONDITIONS.extend([f"output_tray_{key}" for key in OUTPUT_TRAYS]) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { @@ -81,16 +79,16 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= devices = [SyncThruMainSensor(printer, name)] for key in supp_toner: - if "toner_{}".format(key) in monitored: + if f"toner_{key}" in monitored: devices.append(SyncThruTonerSensor(printer, name, key)) for key in supp_drum: - if "drum_{}".format(key) in monitored: + if f"drum_{key}" in monitored: devices.append(SyncThruDrumSensor(printer, name, key)) for key in supp_tray: - if "tray_{}".format(key) in monitored: + if f"tray_{key}" in monitored: devices.append(SyncThruInputTraySensor(printer, name, key)) for key in supp_output_tray: - if "output_tray_{}".format(key) in monitored: + if f"output_tray_{key}" in monitored: devices.append(SyncThruOutputTraySensor(printer, name, key)) async_add_entities(devices, True) @@ -173,10 +171,10 @@ class SyncThruTonerSensor(SyncThruSensor): def __init__(self, syncthru, name, color): """Initialize the sensor.""" super().__init__(syncthru, name) - self._name = "{} Toner {}".format(name, color) + self._name = f"{name} Toner {color}" self._color = color self._unit_of_measurement = "%" - self._id_suffix = "_toner_{}".format(color) + self._id_suffix = f"_toner_{color}" def update(self): """Get the latest data from SyncThru and update the state.""" @@ -193,10 +191,10 @@ class SyncThruDrumSensor(SyncThruSensor): def __init__(self, syncthru, name, color): """Initialize the sensor.""" super().__init__(syncthru, name) - self._name = "{} Drum {}".format(name, color) + self._name = f"{name} Drum {color}" self._color = color self._unit_of_measurement = "%" - self._id_suffix = "_drum_{}".format(color) + self._id_suffix = f"_drum_{color}" def update(self): """Get the latest data from SyncThru and update the state.""" @@ -213,9 +211,9 @@ class SyncThruInputTraySensor(SyncThruSensor): def __init__(self, syncthru, name, number): """Initialize the sensor.""" super().__init__(syncthru, name) - self._name = "{} Tray {}".format(name, number) + self._name = f"{name} Tray {number}" self._number = number - self._id_suffix = "_tray_{}".format(number) + self._id_suffix = f"_tray_{number}" def update(self): """Get the latest data from SyncThru and update the state.""" @@ -234,9 +232,9 @@ class SyncThruOutputTraySensor(SyncThruSensor): def __init__(self, syncthru, name, number): """Initialize the sensor.""" super().__init__(syncthru, name) - self._name = "{} Output Tray {}".format(name, number) + self._name = f"{name} Output Tray {number}" self._number = number - self._id_suffix = "_output_tray_{}".format(number) + self._id_suffix = f"_output_tray_{number}" def update(self): """Get the latest data from SyncThru and update the state.""" diff --git a/homeassistant/components/synologydsm/sensor.py b/homeassistant/components/synologydsm/sensor.py index 17295f152506..e19f6ada8097 100644 --- a/homeassistant/components/synologydsm/sensor.py +++ b/homeassistant/components/synologydsm/sensor.py @@ -184,7 +184,7 @@ class SynoNasSensor(Entity): def name(self): """Return the name of the sensor, if any.""" if self.monitor_device is not None: - return "{} ({})".format(self.var_name, self.monitor_device) + return f"{self.var_name} ({self.monitor_device})" return self.var_name @property diff --git a/homeassistant/components/sytadin/sensor.py b/homeassistant/components/sytadin/sensor.py index 4296f2d5b05b..b7c94933a399 100644 --- a/homeassistant/components/sytadin/sensor.py +++ b/homeassistant/components/sytadin/sensor.py @@ -86,7 +86,7 @@ class SytadinSensor(Entity): @property def name(self): """Return the name of the sensor.""" - return "{} {}".format(self._name, self._option) + return f"{self._name} {self._option}" @property def state(self):