RaspberryPi-Samples / py-my-key

Access control with RaspberryPi and NFC card reader
ISC License
1 stars 1 forks source link

Send events to a message queue #16

Open s-celles opened 8 years ago

s-celles commented 8 years ago

MQTT https://en.wikipedia.org/wiki/MQTT may be considered

So it will be possible to "subscribe" to a given reader and wait for a given event.

See Mosquitto http://mosquitto.org/ Paho http://www.eclipse.org/paho/

AMQP https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol could also be considered

see Pika https://pika.readthedocs.org/

Serializing SQLAlchemy objects such as Events will probably be necessary http://stackoverflow.com/questions/5022066/how-to-serialize-sqlalchemy-result-to-json http://codelike.com/blog/2015/07/19/how-to-serialize-sqlalchemy-objects-to-json-in-pyramid/

s-celles commented 8 years ago

This feature should be enabled only when for example mosquitto is installed

try:
    import mosquitto
    _HAS_MOSQUITTO = True
except ImportError:
    _HAS_MOSQUITTO = False

and we should serialize events and send them to queue only when mosquitto is installed

if _HAS_MOSQUITTO:
    ...

Configuration for mosquitto should be defined in https://github.com/RaspberryPi-Samples/py-my-key/blob/master/py_my_key/defaults.py