Closed cgorms closed 4 years ago
What's the output of mqtt.py on restart?
I may be experiencing this issue also - I'm not intergrated with Hoobs/MQTTthing.
I only have a single socket and my config uses bg1 as a device_type
I have the following output
[2020-04-18 23:53:47,766] DEBUG Connected to 'BG1' Broadlink device at '192.168.1.144' (MAC c8:f7:42:97:34:b6) and started listening for commands at MQTT topic having prefix 'broadlink/' [2020-04-18 23:53:47,767] DEBUG Connected to MQTT broker, subscribing to topic broadlink/# [2020-04-18 23:53:57,783] ERROR Error Traceback (most recent call last): File "mqtt.py", line 548, in broadlink_bg1_state_timer state = device.get_state() File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 368, in get_state return self._decode(response) File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 421, in _decode state = json.loads(payload[0x0e:0x0e+js_len]) File "/usr/lib/python3.5/json/__init__.py", line 312, in loads s.__class__.__name__)) TypeError: the JSON object must be str, not 'bytes' [2020-04-18 23:54:07,792] ERROR Error Traceback (most recent call last): File "mqtt.py", line 548, in broadlink_bg1_state_timer state = device.get_state() File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 368, in get_state return self._decode(response) File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 421, in _decode state = json.loads(payload[0x0e:0x0e+js_len]) File "/usr/lib/python3.5/json/__init__.py", line 312, in loads s.__class__.__name__)) TypeError: the JSON object must be str, not 'bytes' [2020-04-18 23:54:17,803] ERROR Error Traceback (most recent call last): File "mqtt.py", line 548, in broadlink_bg1_state_timer state = device.get_state() File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 368, in get_state return self._decode(response) File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 421, in _decode state = json.loads(payload[0x0e:0x0e+js_len]) File "/usr/lib/python3.5/json/__init__.py", line 312, in loads s.__class__.__name__)) TypeError: the JSON object must be str, not 'bytes'
I do get the current on/off status in broadlink/#
I resolve this by adding the following lines...
"accessory": "mqttthing",
"type": "outlet",
"url": "http://localhost:1883",
"topics": {
"setOn": "broadlink/BG1_00_00_00/power/1",
"getOn": {
"topic": "broadlink/BG1_00_00_00/state/pwr1",
**"apply": "return message == '1' ? 'ON' : 'OFF';"**
}
},
"onValue": "ON",
"offValue": "OFF",
"integerValue": true,
"mqttPubOptions": {
"retain": false
},
"logMqtt": false
Running Hoobs with MQTTThing, BG1 appears as an accessory and I can turn it on and off.
On a reboot of mqtt.py service BG1 not showing device status and also if manually triggered on/off at the socket it isn't updating the status.