hi. i am coming back since i have given a try and i cannot make it work. Up to know i have a RPI that acts as broker. all i did is
Code: Select all
apt-get install mosquitto mosquitto-clients -y
pip install paho-mqtt
then i edited the /etc/mosquitto/mosquitto.conf and it has
Code: Select all
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
listener 1883
i have a number of ESP8266 with sensors that publish to the
, one as
, the other as
, next is
and the list continues.
it works fine for some time now and i see their status in an android application MQTT dashboard.
in the MQTT i see a 0 when door/window closes and 1 when it opens. i would like to execute a particular bash script when 0 and a different bash script when 1.
i am trying to play with
https://github.com/jpmens/mqtt-launcher/issues/13 but it fails to work and i am stuck. here is the config of the launcher.conf
Code: Select all
pi@rpiB:~/mqtt-launcher $ more launcher.conf
logfile = 'logfile'
mqtt_broker = 'localhost' # default: 'localhost'. If using TLS, this must be set to the domain name signed by yo
ur TLS certificate.
mqtt_port = 1883 # default: 1883
mqtt_clientid = 'mqtt-launcher-1'
mqtt_username = None
mqtt_password = None
mqtt_tls = None # default: No TLS
# mqtt_username = 'jane'
# mqtt_password = 'secret'
topiclist = {
# topic payload value program & arguments
"/device/alarm/sensor/livingroom" : {
'0' : [ 'close', '/home/pi/scrpts/scriptlivingroom_0.sh' ],
'1' : [ 'open', '/home/pi/scrpts/scriptlivingroom_1.sh'],
},
"/device/alarm/sensor/hallway" : {
'0' : [ 'close', '/home/pi/scrpts/scripthallway_0.sh' ],
'1' : [ 'open', '/home/pi/scrpts/scripthallway_1.sh']
},
}
pi@rpiB:~/mqtt-launcher $
and here is the error when i execute it
Code: Select all
pi@rpiB:~/mqtt-launcher $ python mqtt-launcher.py
Traceback (most recent call last):
File "mqtt-launcher.py", line 152, in <module>
mqttc.connect(cf.get('mqtt_broker', 'localhost'), int(cf.get('mqtt_port', '1883')), 60)
File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 839, in connect
return self.reconnect()
File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 962, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 111] Connection refused
pi@rpiB:~/mqtt-launcher $
What am i missing? May i have some help please?