Comments (8)
Here is an example of the output in MQTT cli when there is a change in one of the doors/windows
/home/burglar/master_bedroom_window 0
/home/burglar/master_bedroom_window 1
/home/burglar/gront_door 1
/home/burglar/gront_door 0
0 means the door/windows is closed and 1 it is open. in case it is 0 run script_0.sh, in case it turns to 1 then execute script_1.sh.
May i have some help on this please?
from mqtt-launcher.
Show me what you've tried so far (and please remember to paste code within code fences here)
from mqtt-launcher.
Thanks a lot for the reply. here is the code fpr devices with some different name that mentioned before.
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 your 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
"open/close" : {
'0' : [ '/device/alarm/sensor/livingroom', '/home/pi/scrpts/scriptlivingroom_0.sh' ],
'1' : [ '/device/alarm/sensor/livingroom', '/home/pi/scrpts/scriptlivingroom_1.sh'],
'0' : [ '/device/alarm/sensor/hallway', '/home/pi/scrpts/scripthallway_0.sh' ],
'1' : [ '/device/alarm/sensor/hallway', '/home/pi/scrpts/scripthallway_1.sh'],
},
}
pi@rpiB:~/mqtt-launcher $
the /device/alarm/sensor/livingroom has a value of 0 or 1. the same goes for /device/alarm/sensor/hallway. 0 is closed and it needs to execute script that ends with 0 and 1 is open door and it needs to execute the script that ends with 1.
thanks in advance
from mqtt-launcher.
Look at your configuration.
Look under where it says # topic
Look under where it says program & arguments
And compare with the example in the README.
Hint: you've put your topic as program.
from mqtt-launcher.
i edited the conf and now it has the following format:
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 your 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 $
When i run the script, it fails.
pi@rpiB:~/mqtt-launcher $ ./mqtt-launcher.py
Cannot load configuration from file launcher.conf: invalid syntax (launcher.conf, line 23)
pi@rpiB:~/mqtt-launcher $
from mqtt-launcher.
Did you read the error message? Did you count the braces, both the opening and the closing ones?
from mqtt-launcher.
after correction
`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 your 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 the script
pi@rpiB:~/mqtt-launcher $ ./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 doing wrong???
from mqtt-launcher.
Did you read the error message? It says socket.error: [Errno 111] Connection refused
which means the program cannot connect to the host/TCP port you've specified.
from mqtt-launcher.
Related Issues (20)
- Run as SystemD Service HOT 4
- Difficulty running python script with mqtt-launcher HOT 9
- "Command returned non-zero exit status 2" HOT 2
- Seems to be missing mqtt messages HOT 1
- Open URL in Default Browser HOT 2
- What causes this loop? HOT 1
- bash script will not execute HOT 8
- Commands not being actioned HOT 7
- Keepalive, timeout and client disconnection HOT 3
- Possible to run programs in the background? HOT 1
- transfer number from topic to exec HOT 2
- Don't know why the command is not executed HOT 7
- Not a real issue - more a problem - maybe depends on Subprocess - Killall does not work in MQTT Command. HOT 11
- No matching param... HOT 2
- Usage of individual payload within arguments HOT 1
- Usage of payload within arguments HOT 1
- Script work under Windows with Python HOT 8
- Blocking commands result in queued actions.
- json support HOT 3
- Program arguments from payload HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt-launcher.