Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/actiontec/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def get_actiontec_data(self):
try:
telnet = telnetlib.Telnet(self.host)
telnet.read_until(b"Username: ")
telnet.write((self.username + "\n").encode("ascii"))
telnet.write((f"{self.username}\n").encode("ascii"))
telnet.read_until(b"Password: ")
telnet.write((self.password + "\n").encode("ascii"))
telnet.write((f"{self.password}\n").encode("ascii"))
prompt = telnet.read_until(b"Wireless Broadband Router> ").split(b"\n")[-1]
telnet.write(b"firewall mac_cache_dump\n")
telnet.write(b"\n")
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/aftership/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
CONF_TRACKING_NUMBER = "tracking_number"

DEFAULT_NAME = "aftership"
UPDATE_TOPIC = DOMAIN + "_update"
UPDATE_TOPIC = f"{DOMAIN}_update"

ICON = "mdi:package-variant-closed"

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/aqualogic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
_LOGGER = logging.getLogger(__name__)

DOMAIN = "aqualogic"
UPDATE_TOPIC = DOMAIN + "_update"
UPDATE_TOPIC = f"{DOMAIN}_update"
CONF_UNIT = "unit"
RECONNECT_INTERVAL = timedelta(seconds=10)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/arwn/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def discover_sensors(topic, payload):
unit = TEMP_CELSIUS
return ArwnSensor(name, "temp", unit)
if domain == "moisture":
name = parts[2] + " Moisture"
name = f"{parts[2]} Moisture"
return ArwnSensor(name, "moisture", unit, "mdi:water-percent")
if domain == "rain":
if len(parts) >= 3 and parts[2] == "today":
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/darksky/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ def convert_to_camel(data):
This is not pythonic, but needed for certain situations.
"""
components = data.split("_")
return components[0] + "".join(x.title() for x in components[1:])
capital_components = "".join(x.title() for x in components[1:])
return f"{components[0]}{capital_components}"


class DarkSkyData:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/denon/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def update(self):
"NSE8",
]
for line in self.telnet_request(telnet, "NSE", all_lines=True):
self._mediainfo += line[len(answer_codes.pop(0)) :] + "\n"
self._mediainfo += f"{line[len(answer_codes.pop(0)) :]}\n"
else:
self._mediainfo = self.source

Expand Down Expand Up @@ -257,7 +257,7 @@ def volume_down(self):

def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
self.telnet_command(f"MV{str(round(volume * self._volume_max)).zfill(2)}")
self.telnet_command(f"MV{round(volume * self._volume_max):02}")

def mute_volume(self, mute):
"""Mute (true) or unmute (false) media player."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/dublin_bus_transport/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def device_state_attributes(self):
if self._times is not None:
next_up = "None"
if len(self._times) > 1:
next_up = self._times[1][ATTR_ROUTE] + " in "
next_up = f"{self._times[1][ATTR_ROUTE]} in "
next_up += self._times[1][ATTR_DUE_IN]

return {
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/dwd_weather_warnings/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def device_state_attributes(self):
else:
raise Exception("Unknown warning type")

data["warning_count"] = self._api.data[prefix + "_warning_count"]
data["warning_count"] = self._api.data[f"{prefix}_warning_count"]
i = 0
for event in self._api.data[prefix + "_warnings"]:
for event in self._api.data[f"{prefix}_warnings"]:
i = i + 1

data[f"warning_{i}_name"] = event["event"]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ecobee/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EcobeeBinarySensor(BinarySensorDevice):
def __init__(self, data, sensor_name, sensor_index):
"""Initialize the Ecobee sensor."""
self.data = data
self._name = sensor_name + " Occupancy"
self._name = f"{sensor_name} Occupancy"
self.sensor_name = sensor_name
self.index = sensor_index
self._state = None
Expand Down
6 changes: 1 addition & 5 deletions homeassistant/components/econet/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ def __init__(self, water_heater):
self.ha_state_to_econet[value] = key
for mode in self.supported_modes:
if mode not in ECONET_STATE_TO_HA:
error = (
"Invalid operation mode mapping. "
+ mode
+ " doesn't map. Please report this."
)
error = f"Invalid operation mode mapping. {mode} doesn't map. Please report this."
_LOGGER.error(error)

@property
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/group/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def get_entity_ids(
if not domain_filter:
return cast(List[str], entity_ids)

domain_filter = domain_filter.lower() + "."
domain_filter = f"{domain_filter.lower()}."

return [ent_id for ent_id in entity_ids if ent_id.startswith(domain_filter)]

Expand Down
6 changes: 1 addition & 5 deletions homeassistant/components/hydrawise/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ def update(self):
if relay["nicetime"] == "Not scheduled":
self._state = "not_scheduled"
else:
self._state = (
relay["nicetime"].split(",")[0]
+ " "
+ relay["nicetime"].split(" ")[3]
)
self._state = f"{relay['nicetime'].split(',')[0]} {relay['nicetime'].split(' ')[3]}"

@property
def icon(self):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hyperion/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def json_request(self, request, wait_for_response=False):
sock.close()
return False

sock.send(bytearray(json.dumps(request) + "\n", "utf-8"))
sock.send(bytearray(f"{json.dumps(request)}\n", "utf-8"))
try:
buf = sock.recv(4096)
except socket.timeout:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/influxdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def event_to_json(event):
elif key != "unit_of_measurement" or include_uom:
# If the key is already in fields
if key in json["fields"]:
key = key + "_"
key = f"{key}_"
# Prevent column data errors in influxDB.
# For each value we try to cast it as float
# But if we can not do it we store the value
Expand Down
8 changes: 5 additions & 3 deletions homeassistant/components/irish_rail_transport/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ def device_state_attributes(self):
if self._times:
next_up = "None"
if len(self._times) > 1:
next_up = self._times[1][ATTR_ORIGIN] + " to "
next_up += self._times[1][ATTR_DESTINATION] + " in "
next_up += self._times[1][ATTR_DUE_IN]
next_up = (
f"{self._times[1][ATTR_ORIGIN]} to "
f"{self._times[1][ATTR_DESTINATION]} in "
f"{self._times[1][ATTR_DUE_IN]}"
)

return {
ATTR_ATTRIBUTION: ATTRIBUTION,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/knx/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def async_add_entities_config(hass, config, async_add_entities):
"""Set up climate for KNX platform configured within platform."""
climate_mode = XknxClimateMode(
hass.data[DATA_KNX].xknx,
name=config[CONF_NAME] + " Mode",
name=f"{config[CONF_NAME]} Mode",
group_address_operation_mode=config.get(CONF_OPERATION_MODE_ADDRESS),
group_address_operation_mode_state=config.get(
CONF_OPERATION_MODE_STATE_ADDRESS
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/life360/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _prefix(value):
if not value:
return ""
if not value.endswith("_"):
return value + "_"
return f"{value}_"
return value


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def get(cls, name):
def get_default(cls, entity_id):
"""Return the default turn-on profile for the given light."""
# pylint: disable=unsupported-membership-test
name = entity_id + ".default"
name = f"{entity_id}.default"
if name in cls._all:
return name
name = "group.all_lights.default"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mobile_app/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
ATTR_SENSOR_UNIQUE_ID = "unique_id"
ATTR_SENSOR_UOM = "unit_of_measurement"

SIGNAL_SENSOR_UPDATE = DOMAIN + "_sensor_update"
SIGNAL_SENSOR_UPDATE = f"{DOMAIN}_sensor_update"
SIGNAL_LOCATION_UPDATE = DOMAIN + "_location_update_{}"
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def async_device_message_received(msg):
hass.data[CONFIG_ENTRY_IS_SETUP] = set()

await mqtt.async_subscribe(
hass, discovery_topic + "/#", async_device_message_received, 0
hass, f"{discovery_topic}/#", async_device_message_received, 0
)

return True
2 changes: 1 addition & 1 deletion homeassistant/components/mychevy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

DOMAIN = "mychevy"
UPDATE_TOPIC = DOMAIN
ERROR_TOPIC = DOMAIN + "_error"
ERROR_TOPIC = f"{DOMAIN}_error"

MYCHEVY_SUCCESS = "success"
MYCHEVY_ERROR = "error"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nest/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
for variable in conditions:
if variable in _BINARY_TYPES_DEPRECATED:
wstr = (
variable + " is no a longer supported "
f"{variable} is no a longer supported "
"monitored_conditions. See "
"https://www.home-assistant.io/integrations/binary_sensor.nest/ "
"for valid options."
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nest/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
)
else:
wstr = (
variable + " is no a longer supported "
f"{variable} is no a longer supported "
"monitored_conditions. See "
"https://www.home-assistant.io/integrations/"
"binary_sensor.nest/ for valid options."
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ombi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def urlbase(value) -> str:
value = str(value).strip("/")
if not value:
return value
return value + "/"
return f"{value}/"


SUBMIT_MOVIE_REQUEST_SERVICE_SCHEMA = vol.Schema({vol.Required(ATTR_NAME): cv.string})
Expand Down