OpenEPaperLink / Home_Assistant_Integration

Home assistant Integration for the OpenEPaperLink project
Apache License 2.0
137 stars 32 forks source link

Unique ID needed for devices #37

Closed psfales closed 9 months ago

psfales commented 10 months ago

When starting HA, get a whole bunch of ERRORs like this. (Every sensor for every device)

2023-10-08 15:48:50.447 ERROR (MainThread) [homeassistant.components.sensor] Platform open_epaper_link does not generate unique IDs. ID 00000218D1E03B10_battery already exists - ignoring sensor.00000218d1e03b10_battery

jhbruhn commented 10 months ago

I can confirm this bug. Could this be happening because HA is creating the Hub (which connects to the WebSocket) and the stored entities simultaneously, and the websocket results in an on_message which reloads the integration and thus two integration loads are happening at the same time?

there is another bug due to this, if two status messages come in a short timespan, two reloads are running simultaneously. This seems to be a very fragile construct, is there a better way than reloading the whole integration?

jonasniesner commented 10 months ago

I know that a lot of this integration is not optimal, and the reload is one of these things. If someone knows a better way of doing this, i would be happy to implement it.

jhbruhn commented 10 months ago

If I understand it correctly, the way to go would be to use a DataUpdateCoordinator in combination with CoordinatorEntity based entities, which inherit the required update functionality from there.

Unfortunately I could not find an example for a push websocket based service yet, but the Frigate integration gets close: https://github.com/blakeblackshear/frigate-hass-integration/blob/master/custom_components/frigate/__init__.py

jonasniesner commented 9 months ago

I think this bug should be fixed now