Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start adding support for sensors #305

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions emulated_hue/apiv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ async def async_update_group(self, request: web.Request, request_data: dict):
"groups", group_id, group_conf
)
return send_success_response(request.path, request_data, username)
@routes.get("/api/{username}/sensors")
@check_request()
async def async_get_sensors(self, request: web.Request, request_data: dict):
"""Handle requests to retrieve sensor status"""
sensors = self.__async_get_sensors()
return send_json_response(sensors)

@routes.put("/api/{username}/lights/{light_id}")
@check_request()
Expand Down Expand Up @@ -906,6 +912,14 @@ async def __async_get_group_lights(
)
yield entity_id

async def __async_get_sensors(self) -> dict:
"""Create a dict of all sensors."""
sensors = await self.ctl.config_instance.async_get_storage_value(
"sensors", default={}
)

return sensors

async def __async_whitelist_to_bridge_config(self) -> dict:
whitelist = await self.ctl.config_instance.async_get_storage_value(
"users", default={}
Expand Down