Open stefan2904 opened 8 years ago
=> follow up task: Trigger Audio (on licht.realraum.at) and/or light (todo)
demo zmq publisher:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import with_statement
import zmq.utils.jsonapi as json
import zmq
import time
######## r3 ZMQ ############
def sendR3Message(socket, structname, datadict):
socket.send_multipart([structname, json.dumps(datadict)])
#Start zmq connection to publish / forward sensor data
zmqctx = zmq.Context()
zmqctx.linger = 0
zmqpub = zmqctx.socket(zmq.PUB)
zmqpub.connect("tcp://zmqbroker.realraum.at:4243")
time.sleep(5)
#listen for sensor data and forward them
sendR3Message(zmqpub,"DemoZMQEvent",{"Parameter":True,"Ts":int(time.time())})
zmqpub.close()
zmqctx.destroy()
cool idea :) we could display that on the screen next to the shelf (whose content needs to be overhauled anyway... ical parsing instead of json, more sensors, separate display for twitterwall, etc) as well as react with audio events.
Issue should be renamed to "triggering mqtt event"
Documentation about MQTT Events currently lives here: http://realraum.at/wiki/doku.php?id=roomauto:mqtt_topics
I propose the three types of events the ircchanbot would send, could look like this:
MQTT Topic | JSON Object | Notes |
---|---|---|
realraum/ircchanbot/foodorderrequest | {"Who":string, "Preference":string, "Ts":int64} | e.g. "verr" likes to order food and prefers "Asian" |
realraum/ircchanbot/foodorderinvite | {"Who":string, "Where":string, "URL":string , "Ts":int64} | e.g. "xro" started a food order at "Volta" and this is their phone number "phone://+43316..." i.e. URL could look like: "http://mjam.at/..." or "phone://+43316..." |
realraum/ircchanbot/foodordereta | {"TSofInvite":int64, "ETA":int64, "Ts":int64} | The order is finished and they told us it will arrive at .. . Original food order is referenced by its TS, in case there are two orders going on in parallel. |
See https://github.com/realraum/door_and_sensors/blob/master/scripts/arduinosensors.py for example on connecting to mqtt and sending messages. Documentation for python here: https://pypi.python.org/pypi/paho-mqtt
the r3-statusapi daemon now adds an event for every foodordereta message. Now someone just hast do implement some display in kiosk.js and send the mqtt message.