mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 10:47:51 +00:00
Add delay in emulated_hue after PUT (#35307)
This commit is contained in:
parent
fa17e6d5ab
commit
2ac4d30736
@ -1,4 +1,5 @@
|
|||||||
"""Support for a Hue API to control Home Assistant."""
|
"""Support for a Hue API to control Home Assistant."""
|
||||||
|
import asyncio
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -223,14 +224,7 @@ class HueFullStateView(HomeAssistantView):
|
|||||||
|
|
||||||
json_response = {
|
json_response = {
|
||||||
"lights": create_list_of_entities(self.config, request),
|
"lights": create_list_of_entities(self.config, request),
|
||||||
"config": {
|
"config": create_config_model(self.config, request),
|
||||||
"mac": "00:00:00:00:00:00",
|
|
||||||
"swversion": "01003542",
|
|
||||||
"apiversion": "1.17.0",
|
|
||||||
"whitelist": {HUE_API_USERNAME: {"name": "HASS BRIDGE"}},
|
|
||||||
"ipaddress": f"{self.config.advertise_ip}:{self.config.advertise_port}",
|
|
||||||
"linkbutton": True,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.json(json_response)
|
return self.json(json_response)
|
||||||
@ -255,14 +249,7 @@ class HueConfigView(HomeAssistantView):
|
|||||||
if username != HUE_API_USERNAME:
|
if username != HUE_API_USERNAME:
|
||||||
return self.json(UNAUTHORIZED_USER)
|
return self.json(UNAUTHORIZED_USER)
|
||||||
|
|
||||||
json_response = {
|
json_response = create_config_model(self.config, request)
|
||||||
"mac": "00:00:00:00:00:00",
|
|
||||||
"swversion": "01003542",
|
|
||||||
"apiversion": "1.17.0",
|
|
||||||
"whitelist": {HUE_API_USERNAME: {"name": "HASS BRIDGE"}},
|
|
||||||
"ipaddress": f"{self.config.advertise_ip}:{self.config.advertise_port}",
|
|
||||||
"linkbutton": True,
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.json(json_response)
|
return self.json(json_response)
|
||||||
|
|
||||||
@ -555,6 +542,10 @@ class HueOneLightChangeView(HomeAssistantView):
|
|||||||
create_hue_success_response(entity_number, val, parsed[key])
|
create_hue_success_response(entity_number, val, parsed[key])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Echo fetches the state immediately after the PUT method returns.
|
||||||
|
# Waiting for a short time allows the changes to propagate.
|
||||||
|
await asyncio.sleep(0.25)
|
||||||
|
|
||||||
return self.json(json_response)
|
return self.json(json_response)
|
||||||
|
|
||||||
|
|
||||||
@ -751,6 +742,18 @@ def create_hue_success_response(entity_number, attr, value):
|
|||||||
return {"success": {success_key: value}}
|
return {"success": {success_key: value}}
|
||||||
|
|
||||||
|
|
||||||
|
def create_config_model(config, request):
|
||||||
|
"""Create a config resource."""
|
||||||
|
return {
|
||||||
|
"mac": "00:00:00:00:00:00",
|
||||||
|
"swversion": "01003542",
|
||||||
|
"apiversion": "1.17.0",
|
||||||
|
"whitelist": {HUE_API_USERNAME: {"name": "HASS BRIDGE"}},
|
||||||
|
"ipaddress": f"{config.advertise_ip}:{config.advertise_port}",
|
||||||
|
"linkbutton": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def create_list_of_entities(config, request):
|
def create_list_of_entities(config, request):
|
||||||
"""Create a list of all entities."""
|
"""Create a list of all entities."""
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user