Giter VIP home page Giter VIP logo

Comments (8)

atuxnull avatar atuxnull commented on June 30, 2024

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.

jpmens avatar jpmens commented on June 30, 2024

Show me what you've tried so far (and please remember to paste code within code fences here)

from mqtt-launcher.

atuxnull avatar atuxnull commented on June 30, 2024

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.

jpmens avatar jpmens commented on June 30, 2024

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.

atuxnull avatar atuxnull commented on June 30, 2024

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.

jpmens avatar jpmens commented on June 30, 2024

Did you read the error message? Did you count the braces, both the opening and the closing ones?

from mqtt-launcher.

atuxnull avatar atuxnull commented on June 30, 2024

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.

jpmens avatar jpmens commented on June 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.