Created
November 6, 2021 07:27
-
-
Save shauneccles/1d681dc4e5874e638c4c4624e0ba1721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from aiohttp import web | |
from ledfx.api import RestEndpoint | |
_LOGGER = logging.getLogger(__name__) | |
class DeviceStatusEndpoint(RestEndpoint): | |
ENDPOINT_PATH = "/api/device-status" | |
async def get(self) -> web.Response: | |
active_devices = [] | |
inactive_devices = [] | |
response = {} | |
for virtual in self._ledfx.virtuals.values(): | |
if virtual.active_effect: | |
active_devices.append(virtual.id) | |
else: | |
inactive_devices.append(virtual.id) | |
response["active"] = active_devices | |
response["inactive"] = inactive_devices | |
return web.json_response(data=response, status=200) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment