power: enable HTTP port option for Zigbee/Hue devices
Signed-off-by: Wolfgang Miller-Reichling <wolfgang+github@miller-reichling.de>
This commit is contained in:
parent
088d9ee59a
commit
7fc571643d
|
@ -1269,6 +1269,10 @@ The following options are available for `hue` device types:
|
|||
address:
|
||||
# A valid ip address or hostname of the Philips Hue Bridge. This
|
||||
# parameter must be provided.
|
||||
port:
|
||||
# A port number if an alternative Zigbee bridge is used on a HTTP port
|
||||
# different from the default 80/443
|
||||
#
|
||||
user:
|
||||
# The api key used for request authorization. This option accepts
|
||||
# Jinja2 Templates, see the [secrets] section for details.
|
||||
|
|
|
@ -1381,7 +1381,7 @@ class MQTTDevice(PowerDevice):
|
|||
class HueDevice(HTTPDevice):
|
||||
|
||||
def __init__(self, config: ConfigHelper) -> None:
|
||||
super().__init__(config)
|
||||
super().__init__(config, default_port=80)
|
||||
self.device_id = config.get("device_id")
|
||||
self.device_type = config.get("device_type", "light")
|
||||
if self.device_type == "group":
|
||||
|
@ -1394,7 +1394,7 @@ class HueDevice(HTTPDevice):
|
|||
async def _send_power_request(self, state: str) -> str:
|
||||
new_state = True if state == "on" else False
|
||||
url = (
|
||||
f"{self.protocol}://{quote(self.addr)}/api/{quote(self.user)}"
|
||||
f"{self.protocol}://{quote(self.addr)}:{self.port}/api/{quote(self.user)}"
|
||||
f"/{self.device_type}s/{quote(self.device_id)}"
|
||||
f"/{quote(self.state_key)}"
|
||||
)
|
||||
|
@ -1410,7 +1410,7 @@ class HueDevice(HTTPDevice):
|
|||
|
||||
async def _send_status_request(self) -> str:
|
||||
url = (
|
||||
f"{self.protocol}://{quote(self.addr)}/api/{quote(self.user)}"
|
||||
f"{self.protocol}://{quote(self.addr)}:{self.port}/api/{quote(self.user)}"
|
||||
f"/{self.device_type}s/{quote(self.device_id)}"
|
||||
)
|
||||
ret = await self.client.request("GET", url)
|
||||
|
|
Loading…
Reference in New Issue