Skip to content

Instantly share code, notes, and snippets.

@shauneccles
Created November 6, 2021 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shauneccles/1d681dc4e5874e638c4c4624e0ba1721 to your computer and use it in GitHub Desktop.
Save shauneccles/1d681dc4e5874e638c4c4624e0ba1721 to your computer and use it in GitHub Desktop.
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