Har fått en hel del hjälp här med mitt MQTT client på en Raspberry Pi
Har kommit så lång att den skriver ut ON eller OFF när en IR är på eller av på SK
Men har problem med python scriptet.
Den liksom krashar när jag vill den ska köra ett kommando.
Felet jag får är denna
Koden ser ut så härException in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 505, in run
self.__target(*self.__args, **self.__kwargs)
File "MQTT_SK.py", line 40, in incoming
lrsp = mqttc.loop(10.0, 1)
File "/home/pi/mosquitto/mosquitto.py", line 726, in loop
rc = self.loop_read(max_packets)
File "/home/pi/mosquitto/mosquitto.py", line 907, in loop_read
rc = self._packet_read()
File "/home/pi/mosquitto/mosquitto.py", line 1306, in _packet_read
rc = self._packet_handle()
File "/home/pi/mosquitto/mosquitto.py", line 1698, in _packet_handle
return self._handle_publish()
File "/home/pi/mosquitto/mosquitto.py", line 1812, in _handle_publish
self.on_message(self, self._userdata, message)
File "MQTT_SK.py", line 24, in on_message
subprocess.call(["vcgencmd display_power 1"])
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Code: Select all
def on_message(mosq, obj, msg):
global th_abort
global debug
if str(msg.topic).find('switchking') > 0:
event = str(msg.payload).split(',')
#print event
print msg.payload
if msg.payload == "ON":
subprocess.call(["vcgencmd display_power 1"])
if msg.payload == "OFF":
subprocess.call(["vcgencmd display_power 0"])
Den ska ju följa med automatisk så man ska inte behöva installera den om jag förstår rätt.
/UPDATE
Hade glömt shell=True