The unit of this entity changed from '' to ''

So I have cleared out the Developer Tools->Statistics errors list a few times and it seems I have several sensors that keep popping up in there. The latest one definitely seems like a bug because it seems to be telling me something meaningless:

The unit of this entity changed from '' to ''.

This is on sensors for Air Quality Index, defined in ESPHome descriptions like this:

  - platform: template
    name: ${friendly_name} Air Quality Index
    device_class: aqi
    state_class: measurement
    icon: mdi:pine-tree-fire
    accuracy_decimals: 0
    lambda: >
      if (id(${node_name}_pm_2_5_rolling_30_minute_average).state > 500.4) {
        return NAN;
      } else if (id(${node_name}_pm_2_5_rolling_30_minute_average).state >= 350.5) {
        id(i_high) = 500.0;
        id(i_low)  = 401.0;
        id(c_high) = 500.0;
        id(c_low)  = 350.5;
      } else if (id(${node_name}_pm_2_5_rolling_30_minute_average).state >= 250.5) {
        id(i_high) = 400.0;
        id(i_low)  = 301.0;
        id(c_high) = 350.4;
        id(c_low)  = 250.5;
        id(${node_name}_aqi_color).publish_state("Maroon");
      } else if (id(${node_name}_pm_2_5_rolling_30_minute_average).state >= 150.5) {
        id(i_high) = 300.0;
        id(i_low)  = 201.0;
        id(c_high) = 250.4;
        id(c_low)  = 150.5;
        id(${node_name}_aqi_color).publish_state("Purple");
      } else if (id(${node_name}_pm_2_5_rolling_30_minute_average).state >= 55.5) {
        id(i_high) = 200.0;
        id(i_low)  = 151.0;
        id(c_high) = 150.4;
        id(c_low)  = 55.5;
        id(${node_name}_aqi_color).publish_state("Red");
      } else if (id(${node_name}_pm_2_5_rolling_30_minute_average).state >= 35.5) {
        id(i_high) = 150.0;
        id(i_low)  = 101.0;
        id(c_high) = 55.4;
        id(c_low)  = 35.5;
        id(${node_name}_aqi_color).publish_state("Orange");
      } else if (id(${node_name}_pm_2_5_rolling_30_minute_average).state >= 12.1) {
        id(i_high) = 100.0;
        id(i_low)  = 51.0;
        id(c_high) = 35.4;
        id(c_low)  = 12.1;
        id(${node_name}_aqi_color).publish_state("Yellow");
      } else {
        id(i_high) = 50.0;
        id(i_low)  = 0.0;
        id(c_high) = 12.0;
        id(c_low)  = 0.0;
        id(${node_name}_aqi_color).publish_state("Green");
      }
      return round(((id(i_high) - id(i_low))/(id(c_high) - id(c_low))) * (id(${node_name}_pm_2_5_rolling_30_minute_average).state - id(c_low)) + id(i_low));

anyway, I’ve clicked the “Fix Issue” link once already and it clears it out for a while but then eventually comes back for an unknown reason. After it appears, I can no longer use the statistics chart for that sensor. Anyone know what I can do to resolve this and solve it from ever coming back?

1 Like

Sounds like a bug in the esphome integration or HA core.