power: add support for custom Homeseer ports

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2024-03-01 05:43:22 -05:00
parent 9813011db2
commit f0ae51792f
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 3 additions and 1 deletions

View File

@ -449,6 +449,8 @@ class HTTPDevice(PowerDevice):
self.password = config.load_template(
"password", default_password).render()
self.protocol = config.get("protocol", default_protocol)
if self.port == -1:
self.port = 443 if self.protocol.lower() == "https" else 80
async def init_state(self) -> None:
async with self.request_lock:
@ -1109,7 +1111,7 @@ class HomeSeer(HTTPDevice):
query = urlencode(query_args)
url = (
f"{self.protocol}://{quote(self.user)}:{quote(self.password)}@"
f"{quote(self.addr)}/JSON?{query}"
f"{quote(self.addr)}:{self.port}/JSON?{query}"
)
return await self._send_http_command(url, request)