Closed biau closed 4 years ago
I also face the same problem and started looking for a reason.
I have the same issue (leading to AppDaemon 4 to disconnect from Hassio).
2020-07-08 03:24:43 WARNING (Recorder) [homeassistant.components.recorder] Event is not JSON serializable: <Event zigate.attribute_updated[L]: endpoint=1, cluster=0, addr=1a26, attribute=65281, data=0121db0b0421a81305210700062402000000006429be086521db180a210000, name=xiaomi, type=dict, value=1=3035, 4=5032, 5=7, 6=b'\x02\x00\x00\x00\x00', 100=2238, 101=6363, 10=0, ieee=00158d0003a279c2, device_type=lumi.sensor_ht, entity_id=zigate.00158d0003a279c2> 2020-07-08 03:24:43 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1697304112] Unable to serialize to JSON. Bad data found at $.event.data.value.6=b'\x02\x00\x00\x00\x00'(<class 'bytes'>
2020-07-08 03:27:05 WARNING (Recorder) [homeassistant.components.recorder] Event is not JSON serializable: <Event zigate.attribute_updated[L]: endpoint=1, cluster=0, addr=8dc2, attribute=65281, data=0121bd0b0421a81305210f00062402000000006429e3086521be190a210000, name=xiaomi, type=dict, value=1=3005, 4=5032, 5=15, 6=b'\x02\x00\x00\x00\x00', 100=2275, 101=6590, 10=0, ieee=00158d000358edfa, device_type=lumi.sensor_ht, entity_id=zigate.00158d000358edfa> 2020-07-08 03:27:05 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1698401456] Unable to serialize to JSON. Bad data found at $.event.data.value.6=b'\x02\x00\x00\x00\x00'(<class 'bytes'>
2020-07-08 03:34:30 WARNING (Recorder) [homeassistant.components.recorder] Event is not JSON serializable: <Event zigate.attribute_updated[L]: endpoint=1, cluster=0, addr=196b, attribute=65281, data=0121a90b0421a81305210d0006240200000000642959086521c8170a2135b5, name=xiaomi, type=dict, value=1=2985, 4=5032, 5=13, 6=b'\x02\x00\x00\x00\x00', 100=2137, 101=6088, 10=46389, ieee=00158d00034f8c03, device_type=lumi.sensor_ht, entity_id=zigate.00158d00034f8c03> 2020-07-08 03:34:30 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1697495760] Unable to serialize to JSON. Bad data found at $.event.data.value.6=b'\x02\x00\x00\x00\x00'(<class 'bytes'>
2020-07-08 03:50:08 WARNING (Recorder) [homeassistant.components.recorder] Event is not JSON serializable: <Event zigate.attribute_updated[L]: endpoint=1, cluster=0, addr=a616, attribute=65281, data=0121e50b0328150421a84305210c00062401000000000a2100006410000b210000, name=xiaomi, type=dict, value=1=3045, 3=21, 4=17320, 5=12, 6=b'\x01\x00\x00\x00\x00', 10=0, 100=False, 11=0, ieee=00158d0002b8cc52, device_type=lumi.sensor_motion.aq2, entity_id=zigate.00158d0002b8cc52> 2020-07-08 03:50:08 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1716570192] Unable to serialize to JSON. Bad data found at $.event.data.value.6=b'\x01\x00\x00\x00\x00'(<class 'bytes'>
To fix this temporarily, I have changed my copy of init.py I am not sure of the consequence but for a few days now it seems to work correctly.
def attribute_updated(**kwargs):
device = kwargs['device']
ieee = device.ieee
attribute = kwargs['attribute']
_LOGGER.debug('Update attribute for device {} {}'.format(device,
attribute))
entity = hass.data[DATA_ZIGATE_DEVICES].get(ieee)
event_data = attribute.copy()
if type(event_data.get('type')) == type:
event_data['type'] = event_data['type'].__name__
event_data['ieee'] = device.ieee
event_data['addr'] = device.addr
event_data['device_type'] = device.get_property_value('type')
if entity:
event_data['entity_id'] = entity.entity_id
#CS temp fix
if str(event_data['attribute']) != "65281":
hass.bus.fire('zigate.attribute_updated', event_data)
else:
_LOGGER.warning('ZIGATE CS SKIP ATTRIBUTE 65281')
It works! Thank you!
Hi,
Since I've updated hass and zigate to latest version I have an issue with nodered, it looks like the events node loose the connection with zigate.attribute_updated event. It works for some time and then stop with no reason. The only message relevant in nodered is : Received event for unknown subscription 3. Unsubscribing. (with no timestamp)
I can see that nodered is still connected to hass because I still receive events from other events:
It looks like the zigate send something wrong. I'll try to find in debug logs.
found it I think: