Skip to content

Commit

Permalink
Merge pull request #114 from daroga0002/main
Browse files Browse the repository at this point in the history
chore: move to f strings
  • Loading branch information
anarion80 authored Sep 17, 2024
2 parents a85be2e + 82b30df commit 5e87606
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions custom_components/tech/tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
if user_id and token:
self.user_id = user_id
self.token = token
self.headers.setdefault("Authorization", "Bearer " + token)
self.headers.setdefault("Authorization", f"Bearer {token}")
self.authenticated = True
else:
self.authenticated = False
Expand Down Expand Up @@ -120,7 +120,7 @@ async def authenticate(self, username, password):
self.headers = {
"Accept": "application/json",
"Accept-Encoding": "gzip",
"Authorization": "Bearer " + self.token,
"Authorization": f"Bearer {self.token}",
}
except TechError as err:
raise TechLoginError(401, "Unauthorized") from err
Expand All @@ -138,7 +138,7 @@ async def list_modules(self):
"""
if self.authenticated:
# Construct the path for the user's modules
path = "users/" + self.user_id + "/modules"
path = f"users/{self.user_id}/modules"
# Make a GET request to retrieve the modules
result = await self.get(path)
else:
Expand All @@ -162,7 +162,7 @@ async def get_module_data(self, module_udid):
"""
_LOGGER.debug("Getting module data... %s", module_udid)
if self.authenticated:
path = "users/" + self.user_id + "/modules/" + module_udid
path = f"users/{self.user_id}/modules/{module_udid}"
result = await self.get(path)
else:
raise TechError(401, "Unauthorized")
Expand Down Expand Up @@ -193,7 +193,7 @@ async def get_translations(self, language):
_LOGGER.debug("Getting %s language.", language)

if self.authenticated:
path = "i18n/" + language
path = f"i18n/{language}"
result = await self.get(path)
else:
raise TechError(401, "Unauthorized")
Expand Down Expand Up @@ -334,7 +334,7 @@ async def set_const_temp(self, module_udid, zone_id, target_temp):
"""
_LOGGER.debug("Setting zone constant temperature...")
if self.authenticated:
path = "users/" + self.user_id + "/modules/" + module_udid + "/zones"
path = f"users/{self.user_id}/modules/{module_udid}/zones"
data = {
"mode": {
"id": self.modules[module_udid]["zones"][zone_id]["mode"]["id"],
Expand Down Expand Up @@ -366,7 +366,7 @@ async def set_zone(self, module_udid, zone_id, on=True):
"""
_LOGGER.debug("Turing zone on/off: %s", on)
if self.authenticated:
path = "users/" + self.user_id + "/modules/" + module_udid + "/zones"
path = f"users/{self.user_id}/modules/{module_udid}/zones"
data = {"zone": {"id": zone_id, "zoneState": "zoneOn" if on else "zoneOff"}}
_LOGGER.debug(data)
result = await self.post(path, json.dumps(data))
Expand Down

0 comments on commit 5e87606

Please sign in to comment.