jon1012/mihome

how to send command?

Closed this issue · 1 comments

once I publish either On or on by "mosquitto_pub -h localhost -p 1883 -q qos -t xiaomi/plug/plug1/158d0001570403/status/command -m ON"
it crash, please kindly take a look and help me out

Published to: xiaomi/plug/plug1/158d0001570403/status
Subscribe to xiaomi/plug/plug1/158d0001570403/status/command
Topic: xiaomi/plug/plug1/158d0001570403/status/command
Message: on
Unhandled exception in thread started by <bound method Client.loop_forever of <paho.mqtt.client.Client object at 0x76495ef0>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1378, in loop_forever
rc = self.loop(timeout, max_packets)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 897, in loop
rc = self.loop_read(max_packets)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1177, in loop_read
rc = self._packet_read()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1766, in _packet_read
rc = self._packet_handle()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2239, in _packet_handle
return self._handle_publish()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2414, in _handle_publish
self._handle_on_message(message)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2574, in _handle_on_message
self.on_message(self, self._userdata, message)
File "mihome_listen.py", line 38, in on_message
token = userdata[0][userdata[1][sid]['gateway_sid']]
KeyError: 'gateway_sid'

after I upgrade the fimrware, I got new issue on,
now I able to control plug, but after 10-15mins, code is stop with below look

Traceback (most recent call last):
File "mihome_listen.py", line 149, in
connector.check_incoming()
File "/home/pi/mihome/connector.py", line 49, in check_incoming
self.handle_incoming_data(payload)
File "/home/pi/mihome/connector.py", line 68, in handle_incoming_data
json.loads(payload["data"]))
File "mihome_listen.py", line 131, in
cb = lambda m, s, c, d: push_data(client, m, s, c, d, id2name, PATH_FMT)
File "mihome_listen.py", line 88, in push_data
client.publish(path, payload=value.upper(), qos=0)
AttributeError: 'int' object has no attribute 'upper'

`