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 = ["
{}
{message}