WTH Sensor errors in log but sensors work anyway?

I am getting a bunch of these in the log:

2020-09-12 09:18:10 ERROR (SyncWorker_31) [custom_components.average.sensor] Unable to find an entity “sensor.tasmoadmin_memory”
2020-09-12 09:18:10 ERROR (SyncWorker_34) [custom_components.average.sensor] Unable to find an entity “sensor.ssh_web_terminal_memory”
2020-09-12 09:18:10 ERROR (SyncWorker_6) [custom_components.average.sensor] Unable to find an entity “sensor.configurator_memory”
2020-09-12 09:18:10 ERROR (SyncWorker_52) [custom_components.average.sensor] Unable to find an entity “sensor.samba_memory”

All or these are setup like this:

  - platform: rest
    name: Tasmoadmin Memory
    scan_interval: 900
    value_template: '{{ (value_json.memory_stats.usage /1024/1024) |round(2) }}'
    unit_of_measurement: 'MB'
  - platform: average
    name: tasmoadmin_memory_average
      - sensor.tasmoadmin_memory
      days: 2

So a rest sensor uses hadockermon to see how much memory every docker container is using and then the average (custom_component) averages that over the last 2 days. All of this is working perfectly but it seems that the average sensor is being created before the rest sensor has populated… but WTH how is this average then working at all if it is getting this error?

Like I said its all working correctly… just seems to be a timing issue and this should most likely be info or warning not an error in the log?

I think it might rely on historical data, so it still works.

I don’t think so… the average is being updated as is the rest sensor.

Are the errors on startup? If so, it could be that the average integration is being loaded before the rest integration and is looking for the sensor before it is fully set up.

Your logs refer to custom_components.average.sensor so this appears to be a custom integration. Is there a reason you are using this instead of the standard statistics sensor? That may handle that better.

Yes custom_component. I use it because I can set a start and end time (start at midnight) and end now whereas with stats sensor I can only set 24 hrs which means if i want stats for today average is better… (actually not an issue here… could use statistics)
You’re right though… average is being loaded before rest causing the error. Only on startup and even tough it gives an error it worked so it isn’t an error - should at worst be a warning or be smart enough to wait for average to load…

Try filter with a moving average.

I’m sure I could use that or the statistics integration… but these solutions both miss the point that the component is being initialised before the rest_sensor… so that causes an error BUT the component is STILL working so it’s not an error at all… a warning at worst but not an error. An error usually stops something working at all…