MQTT

From Wildsong
Revision as of 02:42, 4 January 2020 by Brian Wilson (talk | contribs)
Jump to navigationJump to search

I'm looking at MQTT right now in the context of Presence Detection.

There are some good books in Safari including "Hands-on MQTT Programming With Python".

My MQTT Server is in a docker container on Bellman.

I set up a Docker image of eclipse-mosquitto on Bellman. I can log into it and run commands to learn more.

sensors/thermostat/start sensors/thermostat/stop sensors/thermostat/temperature sensors/thermostat/setpoint

  1. julie arrived
  2. julie left

Listen for presence messages from anyone. QOS is set to 'at least once'. -d is for debug

docker exec -it mosquitto mosquitto_sub -t 'sensors/+/presence' -q 1 -d

Send a message.

docker exec -it mosquitto mosquitto_pub -t 'sensors/unifi/presence' -q 1 -d -m 'Julie arrived'

How should my messages look?

presence/SENSOR/NEWSTATE
where SENSOR = {unifi|dnsmasq} and NEWSTATE = {arrived|departed}
and the payload is one of ACTOR = {Julie|Brian|Unknown}

The publisher will translate input from the sensor (Unifi in this case) to the actor value (Julie or Brian). The subscribers don't usually need to know if the sensor was a phone or a facial recognition camera or RFID or... Some subscribers (the thermostat) don't care who the actor is, just whether or not anyone is home.