eschava / broadlink-mqtt

MQTT client to control BroadLink devices
MIT License
224 stars 61 forks source link

auto run on pi3 #37

Closed cobra85ec closed 6 years ago

cobra85ec commented 6 years ago

tryin to auto run on pi3 keep getting error ... can u help..?

eschava commented 6 years ago

What error are you getting?

cobra85ec commented 6 years ago

this is what i did -sudo nano /etc/profile then added to the bottom. -python broadlink-mqtt/mqtt.py save it then -sudo reboot when i log back in with putty this is what i get..

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Fri Oct 26 06:46:52 2018 from 192.168.50.1 [2018-10-26 06:52:06,053] DEBUG Connected to RM2 Broadlink device at '192.168.50.179' (MAC e8:d4:50:77:0f:78) Traceback (most recent call last): File "broadlink-mqtt/mqtt.py", line 389, in 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

eschava commented 6 years ago

Looks like your mqtt server is run AFTER broadlink-mqtt Could you please confirm?

cobra85ec commented 6 years ago

i dont kno how to do that.... but is there a way to add a delay to the start up..?

eschava commented 6 years ago

Sorry, I'm not an expert in the Linux But you can try adding your line to /etc/rc.local, not /etc/profile

cobra85ec commented 6 years ago

i try that also same erro and i also try bashrc

eschava commented 6 years ago

I think /etc/profile is a bad option because it's run only when you log in using ssh, am I correct? Look, do you have success running broadlink-mqtt in manual mode?

cobra85ec commented 6 years ago

yes. ill try to local again.. and yes i can run command manual works fine.

plains203 commented 6 years ago

I added mine to /etc/rc.local The command I used is as follows. Your path will vary. nohup python /home/plains203/broadlink-mqtt/mqtt.py --mqtt >/dev/null 2>&1 & sleep 1

cobra85ec commented 6 years ago

nope not working...

cobra85ec commented 6 years ago

ok i got it. this let it wait 1min b4 it start after my node red which runs my mqtt server.. thank u guys very much. sudo nano /etc/rc.local then add this to the bottom after fi sleep 60 && python home/pi/broadlink-mqtt/mqtt.py