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:
|
address:
|
||||||
# A valid ip address or hostname of the Philips Hue Bridge. This
|
# A valid ip address or hostname of the Philips Hue Bridge. This
|
||||||
# parameter must be provided.
|
# 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:
|
user:
|
||||||
# The api key used for request authorization. This option accepts
|
# The api key used for request authorization. This option accepts
|
||||||
# Jinja2 Templates, see the [secrets] section for details.
|
# Jinja2 Templates, see the [secrets] section for details.
|
||||||
|
|
|
@ -1381,7 +1381,7 @@ class MQTTDevice(PowerDevice):
|
||||||
class HueDevice(HTTPDevice):
|
class HueDevice(HTTPDevice):
|
||||||
|
|
||||||
def __init__(self, config: ConfigHelper) -> None:
|
def __init__(self, config: ConfigHelper) -> None:
|
||||||
super().__init__(config)
|
super().__init__(config, default_port=80)
|
||||||
self.device_id = config.get("device_id")
|
self.device_id = config.get("device_id")
|
||||||
self.device_type = config.get("device_type", "light")
|
self.device_type = config.get("device_type", "light")
|
||||||
if self.device_type == "group":
|
if self.device_type == "group":
|
||||||
|
@ -1394,7 +1394,7 @@ class HueDevice(HTTPDevice):
|
||||||
async def _send_power_request(self, state: str) -> str:
|
async def _send_power_request(self, state: str) -> str:
|
||||||
new_state = True if state == "on" else False
|
new_state = True if state == "on" else False
|
||||||
url = (
|
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"/{self.device_type}s/{quote(self.device_id)}"
|
||||||
f"/{quote(self.state_key)}"
|
f"/{quote(self.state_key)}"
|
||||||
)
|
)
|
||||||
|
@ -1410,7 +1410,7 @@ class HueDevice(HTTPDevice):
|
||||||
|
|
||||||
async def _send_status_request(self) -> str:
|
async def _send_status_request(self) -> str:
|
||||||
url = (
|
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"/{self.device_type}s/{quote(self.device_id)}"
|
||||||
)
|
)
|
||||||
ret = await self.client.request("GET", url)
|
ret = await self.client.request("GET", url)
|
||||||
|
|
Loading…
Reference in New Issue