Mercurial > code > home > repos > light-bridge
changeset 10:140633abfa2a
route colors from PUT to Light.setColor
author | drewp@bigasterisk.com |
---|---|
date | Sun, 28 Jan 2024 16:53:35 -0800 |
parents | 9f427d8073c3 |
children | 028ed39aa78f |
files | light_bridge.py |
diffstat | 1 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/light_bridge.py Sun Jan 28 16:53:08 2024 -0800 +++ b/light_bridge.py Sun Jan 28 16:53:35 2024 -0800 @@ -5,6 +5,7 @@ import logging import time from functools import partial +from color import Color from patchablegraph import PatchableGraph from patchablegraph.handler import GraphEvents, StaticGraph @@ -23,6 +24,8 @@ async def output(lights: Lights, request: Request) -> JSONResponse: light = lights.byName(request.query_params['light']) + body = (await request.body()).decode('utf8') + await light.setColor(Color.fromHex(body)) return JSONResponse(light.to_dict())