Mercurial > code > home > repos > homeauto
changeset 1563:71eec31da919
more theater output controls
Ignore-this: 34e105c3760b9df22d63eb0035aca19d
darcs-hash:095f5932e595b89d909c85018999fa926503abcd
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Fri, 14 Feb 2020 10:21:24 -0800 |
parents | c3d699b5759c |
children | ffbebd7902ee |
files | service/rdf_to_mqtt/Dockerfile service/rdf_to_mqtt/index.html service/rdf_to_mqtt/rdf_to_mqtt.py |
diffstat | 3 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/service/rdf_to_mqtt/Dockerfile Fri Feb 14 00:33:31 2020 -0800 +++ b/service/rdf_to_mqtt/Dockerfile Fri Feb 14 10:21:24 2020 -0800 @@ -6,7 +6,7 @@ RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple -r requirements.txt RUN pip3 install -U 'https://github.com/drewp/cyclone/archive/python3.zip?v3' -COPY *.py *.html *.css *.js ./ +COPY *.py *.html *.js ./ EXPOSE 10011:10011
--- a/service/rdf_to_mqtt/index.html Fri Feb 14 00:33:31 2020 -0800 +++ b/service/rdf_to_mqtt/index.html Fri Feb 14 10:21:24 2020 -0800 @@ -30,6 +30,13 @@ <div><button data-post="output?s=:livingLamp4&p=:brightness" data-body="0.0">Send (:livingLamp4 :brightness 0.0)</button></div> <div><button data-post="output?s=:livingLamp4&p=:brightness" data-body="1.0">Send (:livingLamp4 :brightness 1.0)</button></div> + <div><button data-post="output?s=:theater&p=:inputSelector" data-body="bd">Theater to chromecast</button></div> + <div><button data-post="output?s=:theater&p=:inputSelector" data-body="game">Theater to PS4</button></div> + <div><button data-post="output?s=:theater&p=:inputSelector" data-body="pc">Theater to VR</button></div> + <div><button data-post="output?s=:theater&p=:inputSelector" data-body="cbl">Theater to PS3</button></div> + <div><button data-post="output?s=:theater&p=:volumeChange" data-body="3">Theater volume up</button></div> + <div><button data-post="output?s=:theater&p=:volumeChange" data-body="-3">Theater volume down</button></div> + <script> Array.from(document.querySelectorAll("button")).forEach((el) => { el.addEventListener("click", (ev) => {
--- a/service/rdf_to_mqtt/rdf_to_mqtt.py Fri Feb 14 00:33:31 2020 -0800 +++ b/service/rdf_to_mqtt/rdf_to_mqtt.py Fri Feb 14 10:21:24 2020 -0800 @@ -14,48 +14,45 @@ from patchablegraph import PatchableGraph, CycloneGraphHandler, CycloneGraphEventsHandler from standardservice.logsetup import log, verboseLogging import rdf_over_http +from cycloneerr import PrettyErrorHandler ROOM = Namespace('http://projects.bigasterisk.com/room/') devs = { ROOM['kitchenLight']: { 'root': 'h801_skylight', - 'ctx': ROOM['kitchenH801'] }, ROOM['kitchenCounterLight']: { 'root': 'h801_counter', - 'ctx': ROOM['kitchenH801'] }, ROOM['livingLampShelf']: { 'root': 'sonoff_0/switch/sonoff_basic_relay/command', - 'ctx': ROOM['sonoff_0'], 'values': 'binary', }, ROOM['livingLamp1']: { 'root': 'sonoff_1/switch/sonoff_basic_relay/command', - 'ctx': ROOM['sonoff_1'], 'values': 'binary', }, ROOM['livingLamp2']: { 'root': 'sonoff_2/switch/sonoff_basic_relay/command', - 'ctx': ROOM['sonoff_2'], 'values': 'binary', }, ROOM['livingLamp3']: { 'root': 'sonoff_3/switch/sonoff_basic_relay/command', - 'ctx': ROOM['sonoff_3'], 'values': 'binary', }, ROOM['livingLamp4']: { 'root': 'sonoff_4/switch/sonoff_basic_relay/command', - 'ctx': ROOM['sonoff_4'], 'values': 'binary', }, ROOM['livingLamp5']: { 'root': 'sonoff_5/switch/sonoff_basic_relay/command', - 'ctx': ROOM['sonoff_5'], 'values': 'binary', }, + ROOM['theater']: { + 'root': 'theater_blaster/ir_out', + 'values': 'theaterOutputs', + }, #-t theater_blaster/ir_out -m 'input_game' #-t theater_blaster/ir_out -m 'input_bd' #-t theater_blaster/ir_out -m 'input_cbl' @@ -65,7 +62,7 @@ } -class OutputPage(cyclone.web.RequestHandler): +class OutputPage(PrettyErrorHandler, cyclone.web.RequestHandler): def put(self): for stmt in rdf_over_http.rdfStatementsFromRequest( self.request.arguments, @@ -79,7 +76,6 @@ for dev, attrs in devs.items(): if stmt[0] == ROOM['frontWindow']: ignored = ignored and self._publishFrontScreenText(stmt) - if stmt[0:2] == (dev, ROOM['brightness']): log.info(f'brightness request: {stmt}') brightness = stmt[2].toPython() @@ -89,6 +85,16 @@ else: self._publishRgbw(attrs, brightness) ignored = False + if stmt[0:2] == (dev, ROOM['inputSelector']): + self._publish(topic=attrs['root'], + message='input_'+str(stmt[2].toPython())) + ignored = False + if stmt[0:2] == (dev, ROOM['volumeChange']): + delta = int(stmt[2].toPython()) + which = 'up' if delta > 0 else 'down' + self._publish(topic=f'theater_blaster/ir_out/volume_{which}', + message=json.dumps({'timed': abs(delta)})) + ignored = False if ignored: log.warn("ignoring %s", stmt)