moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

Getting: onMessage' failed 'TypeError':'byte indices must be integers or slices, not str' #50

Closed htilly closed 5 years ago

htilly commented 5 years ago

I have successfully added the plugin but no lights shows up in the device list.

From the logs in docker I can see:

Connected from IPv4Address(type='TCP', host='172.17.0.1', port=33798) Data received: b'{"pollinterval": "30", "groups": "False", "action": "initGateway", "observe": "True"}' Initializing gateway Adding light with ID: 65538

And in the logs from domoticz I see:

2018-10-17 21:54:54.034 Status: (IKEA) Started. 2018-10-17 21:54:54.250 Status: (IKEA) Entering work loop. 2018-10-17 21:54:54.250 Status: (IKEA) Initialized version 1.0.6, author 'moroen' 2018-10-17 21:54:54.306 Error: (IKEA) 'onMessage' failed 'TypeError':'byte indices must be integers or slices, not str'. 2018-10-17 21:54:54.306 Error: (IKEA) ----> Line 290 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage 2018-10-17 21:54:54.306 Error: (IKEA) ----> Line 203 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage 2018-10-17 21:54:55.007 (IKEA) Processing 'WriteDirective' message 2018-10-17 21:54:55.011 (IKEA) Sending 85 bytes of data 2018-10-17 21:54:55.011 (IKEA) 7b 22 70 6f 6c 6c 69 6e 74 65 72 76 61 6c 22 3a 20 22 33 30 {"pollinterval":."30 2018-10-17 21:54:55.012 (IKEA) 22 2c 20 22 67 72 6f 75 70 73 22 3a 20 22 46 61 6c 73 65 22 ",."groups":."False" 2018-10-17 21:54:55.012 (IKEA) 2c 20 22 61 63 74 69 6f 6e 22 3a 20 22 69 6e 69 74 47 61 74 ,."action":."initGat 2018-10-17 21:54:55.012 (IKEA) 65 77 61 79 22 2c 20 22 6f 62 73 65 72 76 65 22 3a 20 22 54 eway",."observe":."T 2018-10-17 21:54:55.012 (IKEA) 72 75 65 22 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. rue"} 2018-10-17 21:54:55.075 (IKEA) Pushing 'ReadEvent' on to queue 2018-10-17 21:54:55.113 (IKEA) Processing 'ReadEvent' message 2018-10-17 21:54:55.113 (IKEA) Received 41 bytes of data 2018-10-17 21:54:55.114 (IKEA) 7b 22 73 74 61 74 75 73 22 3a 20 22 4f 6b 22 2c 20 22 61 63 {"status":."Ok",."ac 2018-10-17 21:54:55.114 (IKEA) 74 69 6f 6e 22 3a 20 22 69 6e 69 74 47 61 74 65 77 61 79 22 tion":."initGateway" 2018-10-17 21:54:55.114 (IKEA) 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. } 2018-10-17 21:54:55.114 (IKEA) Pushing 'onMessageCallback' on to queue 2018-10-17 21:54:55.114 (IKEA) Processing 'onMessageCallback' message 2018-10-17 21:54:55.114 (IKEA) Calling message handler 'onMessage'. 2018-10-17 21:54:55.114 Error: (IKEA) 'onMessage' failed 'TypeError':'byte indices must be integers or slices, not str'. 2018-10-17 21:54:55.115 Error: (IKEA) ----> Line 290 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage 2018-10-17 21:54:55.115 Error: (IKEA) ----> Line 203 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage 2018-10-17 21:55:03.752 (IKEA) Pushing 'onHeartbeatCallback' on to queue 2018-10-17 21:55:03.779 (IKEA) Processing 'onHeartbeatCallback' message 2018-10-17 21:55:03.779 (IKEA) Calling message handler 'onHeartbeat'. 2018-10-17 21:55:18.755 (IKEA) Pushing 'onHeartbeatCallback' on to queue 2018-10-17 21:55:18.804 (IKEA) Processing 'onHeartbeatCallback' message 2018-10-17 21:55:18.805 (IKEA) Calling message handler 'onHeartbeat'. 2018-10-17 21:55:33.758 (IKEA) Pushing 'onHeartbeatCallback' on to queue 2018-10-17 21:55:33.781 (IKEA) Processing 'onHeartbeatCallback' message 2018-10-17 21:55:33.781 (IKEA) Calling message handler 'onHeartbeat'. 2018-10-17 21:55:48.761 (IKEA) Pushing 'onHeartbeatCallback' on to queue 2018-10-17 21:55:48.808 (IKEA) Processing 'onHeartbeatCallback' message 2018-10-17 21:55:48.808 (IKEA) Calling message handler 'onHeartbeat'. 2018-10-17 21:56:03.764 (IKEA) Pushing 'onHeartbeatCallback' on to queue 2018-10-17 21:56:03.784 (IKEA) Processing 'onHeartbeatCallback' message 2018-10-17 21:56:03.785 (IKEA) Calling message handler 'onHeartbeat'.

moroen commented 5 years ago

These errors usually stem from mismatching the version of domoticz with the branch of the plugin... I would guess you're using the master branch of domoticz (stable) with the development branch of the plugin... You need to use domoticz stable with the master branch of the plugin, domoticz beta with the plugin's development branch

bilbolodz commented 5 years ago

Stable branch version has problem with Adaptor IP address. I'm running adaptor and Domoticz on two different machines, I've put adaptor IP into Domoticz but in logs I can see that plugin is trying to connect to 127.0.0.1 address. BTW.: "Apdaptor IP Address" is misspelled.

basrieter commented 5 years ago

Just edit the file and replace the 127.0.0.1 with the IP of the machine it needs to connect to. I had the same issue (running it in docker)

htilly commented 5 years ago

Updated domoticz to beta and problem solved! Closing.