From 541f5e54dc257d6c4855f4a3d34385a2b5257c34 Mon Sep 17 00:00:00 2001 From: Alan Harper <475+aussiegeek@users.noreply.github.com> Date: Sun, 30 May 2021 00:08:24 +1000 Subject: [PATCH] power: Add https support for Home Assistant Signed-off-by: Alan Harper --- moonraker/components/power.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/moonraker/components/power.py b/moonraker/components/power.py index a4dd889..ed64315 100644 --- a/moonraker/components/power.py +++ b/moonraker/components/power.py @@ -281,7 +281,8 @@ class HTTPDevice(PowerDevice): config: ConfigHelper, default_port: int = -1, default_user: str = "", - default_password: str = "" + default_password: str = "", + default_protocol: str = "http" ) -> None: super().__init__(config) self.client = AsyncHTTPClient() @@ -290,6 +291,7 @@ class HTTPDevice(PowerDevice): self.port = config.getint("port", default_port) self.user = config.get("user", default_user) self.password = config.get("password", default_password) + self.protocol = config.get("protocol", default_protocol) async def initialize(self) -> None: await self.refresh_status() @@ -673,7 +675,7 @@ class HomeAssistant(HTTPDevice): else: raise self.server.error( f"Invalid homeassistant command: {command}") - url = f"http://{self.addr}:{self.port}/{out_cmd}" + url = f"{self.protocol}://{self.addr}:{self.port}/{out_cmd}" headers = { 'Authorization': f'Bearer {self.token}', 'Content-Type': 'application/json'