Code Monkey home page Code Monkey logo

Comments (8)

jpmens avatar jpmens commented on August 16, 2024

Something rings a very vague bell (independently of mqtt-launcher) ... but I cannot grasp it.

Have you verified you don't have another client connected to your broker with the same MQTT clientId? (ClientIDs must be unique on a broker and strange things happen such as the broker kicking one then the other off before they reconnect)

Another thing to check: what version of Mosquitto are you using? Something really old?

from mqtt-launcher.

jpmens avatar jpmens commented on August 16, 2024

Also, make sure you run a mosquitto_sub -h 192.168.1.120 -v -t 'dak/#' against your broker on a 2nd terminal to watch what Node-Red is sending you

from mqtt-launcher.

hermannw avatar hermannw commented on August 16, 2024

Yes I learned about the ClientID the hard way. It took me quite a while to find out that two of my ESP8266 were using the same ID. So this is one of the first things I make sure.
The installation of this Pi Zero is fairly new. I am only running it for about six month. How can you check the version of Mosquitto? I just tried to do an update and got an error message from the Mosquitto repository. Got to check that...

I also made sure that MQTT messages were coming in as they should.

from mqtt-launcher.

hermannw avatar hermannw commented on August 16, 2024

After a few hours of searching I tracked the problem back to this line:

export DISPLAY=:0.0 && kweb -KHJEYPA+-rmfk http://dakboard.com/app?p=b5.... &

This line is starting an instance of kweb browser on the attached monitor.
I have no idea why, but when this line is executed from within my script or from a script started by my script, it brakes the connection between mqtt-launcher (paho?) and mosquitto. When this line is executed after my script is done, everything works. So I made a workaround to execute this line from a cronjob a minute later...

Hermann

from mqtt-launcher.

jpmens avatar jpmens commented on August 16, 2024

I'm not at all familiar with that or with what it does, but that doesn't matter.

If you were doing that from withing the rpi-hdmi script, then what's probably happening is that the controlling tty is being held open; you could try running that with nohup(1).

from mqtt-launcher.

hermannw avatar hermannw commented on August 16, 2024

Nope. Didn't do it.
Nonetheless, thank you for your help.
I'll keep trying.

Hermann

from mqtt-launcher.

Joyphor avatar Joyphor commented on August 16, 2024

I have exactly the same issue with some commands, but echo works.
If I run the other commands, the first one or two commands run, after that nothing happens anymore, also no new entries in the log file.

I'm on MacOS 10.14.1 (18B75). Python 2.7.15.

Here is my config:

logfile         = 'logfile.log'
mqtt_broker     = '192.168.0.250'       # 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-mac'
mqtt_username   = 'hassio'
mqtt_password   = 'xxxxxx'
mqtt_tls        = None              # default: No TLS
# mqtt_username = 'jane'
# mqtt_password = 'secret'

topiclist = {

    # topic                     payload value       program & arguments
    "Home/FL/mac"	:   {
                                'sleep'		:   [ 'pmset', 'sleepnow' ],
                                'screen_off'	:   [ 'pmset', 'displaysleepnow' ],
                                'screen_on'	:   [ 'caffeinate', '-u' ],
				'test'		:   [ 'echo', 'Hello' ],
                            },
    "prog/pwd"          :   {
                                None            :   [ 'pwd' ],
                            },
    "dev/1"             :   {
                                None            :   [ 'ls', '-l', '/' ],
                            },
    "dev/2"             :   {
                                None            :   [ "/bin/echo", "111", "*", "@!@", "222", "@!@", "333" ],
                            },
}

Logfile:

2018-12-03 04:12:17,321 Starting
2018-12-03 04:12:17,321 DEBUG MODE
2018-12-03 04:12:17,453 Connected to MQTT broker, subscribing to topics...
2018-12-03 04:12:21,634 Home/FL/mac 0 test
2018-12-03 04:12:21,635 Running t=Home/FL/mac: ['echo', 'Hello']
2018-12-03 04:12:22,804 Home/FL/mac 0 test
2018-12-03 04:12:22,804 Running t=Home/FL/mac: ['echo', 'Hello']
2018-12-03 04:12:23,655 Home/FL/mac 0 test
2018-12-03 04:12:23,656 Running t=Home/FL/mac: ['echo', 'Hello']
2018-12-03 04:12:27,199 Home/FL/mac 0 test
2018-12-03 04:12:27,199 Running t=Home/FL/mac: ['echo', 'Hello']
2018-12-03 04:12:29,218 Home/FL/mac 0 test
2018-12-03 04:12:29,219 Running t=Home/FL/mac: ['echo', 'Hello']
2018-12-03 04:18:07,492 Home/FL/mac 0 test
2018-12-03 04:18:07,492 Running t=Home/FL/mac: ['echo', 'Hello']
2018-12-03 04:21:01,379 Home/FL/mac 0 test
2018-12-03 04:21:01,381 Running t=Home/FL/mac: ['echo', 'Hello']
2018-12-03 04:21:09,361 Home/FL/mac 0 screen_off
2018-12-03 04:21:09,361 Running t=Home/FL/mac: ['pmset', 'displaysleepnow']
2018-12-03 04:21:12,398 Home/FL/mac 0 screen_on
2018-12-03 04:21:12,398 Running t=Home/FL/mac: ['caffeinate', '-u']

mqtt_sub:

Home/FL/mac test
Home/FL/mac/report Hello
Home/FL/mac test
Home/FL/mac/report Hello
Home/FL/mac test
Home/FL/mac/report Hello
Home/FL/mac test
Home/FL/mac/report Hello
Home/FL/mac test
Home/FL/mac/report Hello
Home/FL/mac test
Home/FL/mac/report Hello
Home/FL/mac test
Home/FL/mac/report Hello
Home/FL/mac screen_off
Home/FL/mac/report (null)
Home/FL/mac screen_on

Now the last command Running t=Home/FL/mac: ['caffeinate', '-u'] was run, but there was no corresponding report anymore via mqtt. There must be something happening between executing the command and sending the report via mqtt...

try:
        res = subprocess.check_output(cmd, stdin=None, stderr=subprocess.STDOUT, shell=False, universal_newlines=True, cwd='/tmp')
    except Exception, e:
        res = "*****> %s" % str(e)

the same happens if I format my commands like this "/usr/bin/pmset"

from mqtt-launcher.

jpmens avatar jpmens commented on August 16, 2024

So you are manipulating Mac power with this, am I understanding it correctly? I hope you don't expect me to debug what happens when you change power settings on the fly ...

Please provide a simple example with which I can reproduce the problem.

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.