I have a few nodes that use RFM69 radio to transmit the data to a gateway (ESP32 with ethernet). To integrate all this into HA, a custom integration was created.
It works fine, I see the gateway and nodes in HA as expected, but also I see such errors in the logs:
ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.config_entries: Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[13].data.store.94:3C:C6:3C:27:43_2_rssi=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_2_vcc=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_2_temperature=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_2_humidity=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_2_presssure=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_10_rssi=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_10_vcc=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_10_temperature=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_10_humidity=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>, $.data.entries[13].data.store.94:3C:C6:3C:27:43_10_presssure=(<class ‘custom_components.rfm_gateway.sensor.NodeSensor’>
I suppose it’s due to incorrect usage of hass.data
. Each time when the gateway receives a message, it composes the sensor entity and checks whether it already exists in hass.data[DOMAIN][config_entry.entry_id]['store']
. If yes, it uses an existing instance to update the value, if no - stores the instance. This approach was borrowed from existing integrations, but I’m not sure it is correct.
Is this normal to store instances in hass.data
or should I use a different approach (please suggest one)?