Part of the rest sensor is not refreshed in UI

Hi,

I noticed a very strange and annoying bug in HA. I think it started once I’ve updated to 0.80 (I’m on a 0.81.2 currently), but I’m not sure. I got a rest sensor that downloads weather data from my local server.

- platform: rest
  resource: 'http://redfish.pl/pogoda/?format=json'
  name: Pogoda
  json_attributes:
    - dwor
    - temperatura
    - odczuwalna
    - pokoj
    - salon
    - sypialnia
    - pm25
    - pm25_percent
    - pm10
    - pm10_percent
    - powietrze
    - powietrze_opis
    - wilgotnosc
    - cisnienie
    - czas
  value_template: '{{ value_json.dwor }}'
  unit_of_measurement: '°C'
  force_update: true

- platform: template
  sensors:
    rfw_outside:
      friendly_name: 'Dwór'
      unit_of_measurement: '°C'
      value_template: '{{ state_attr("sensor.pogoda", "dwor") }}'
    rfw_meteo:
      friendly_name: 'Meteo'
      unit_of_measurement: '°C'
      value_template: '{{ state_attr("sensor.pogoda", "temperatura") }}'
    rfw_feels_like:
      friendly_name: 'Odczuwalna'
      unit_of_measurement: '°C'
      value_template: '{{ state_attr("sensor.pogoda", "odczuwalna") }}'
    rfw_living_room:
      friendly_name: 'Salon'
      unit_of_measurement: '°C'
      value_template: '{{ state_attr("sensor.pogoda", "salon") }}'
    rfw_kids_room:
      friendly_name: 'Chłopaki'
      unit_of_measurement: '°C'
      value_template: '{{ state_attr("sensor.pogoda", "pokoj") }}'
    rfw_bedroom:
      friendly_name: 'Sypialnia'
      unit_of_measurement: '°C'
      value_template: '{{ state_attr("sensor.pogoda", "sypialnia") }}'
    rfw_caqi:
      friendly_name: 'CAQI'
      icon_template: mdi:factory
      value_template: '{{ state_attr("sensor.pogoda", "powietrze") }}'
    rfw_haqi:
      friendly_name: 'HomeKit AQI'
      unit_of_measurement: 'AQI'
      icon_template: mdi:factory
      value_template: '{{ state_attr("sensor.pogoda", "haqi") }}'
    rfw_caqi_text:
      friendly_name: 'Powietrze'
      icon_template: mdi:factory
      value_template: '{{ state_attr("sensor.pogoda", "powietrze_opis") }}'
    rfw_pm10:
      friendly_name: 'PM 10'
      icon_template: mdi:factory
      unit_of_measurement: 'μg/m3'
      value_template: '{{ state_attr("sensor.pogoda", "pm10") }}'
    rfw_pm10_percent:
      friendly_name: 'PM 10 (% normy)'
      icon_template: mdi:factory
      unit_of_measurement: '%'
      value_template: '{{ state_attr("sensor.pogoda", "pm10_percent") }}'
    rfw_pm10_text:
      friendly_name: 'PM 10'
      icon_template: mdi:factory
      value_template: '{{ state_attr("sensor.pogoda", "pm10") }} μg/m3 ({{ state_attr("sensor.pogoda", "pm10_percent") }}%)'
    rfw_pm25:
      friendly_name: 'PM 2.5'
      icon_template: mdi:factory
      unit_of_measurement: 'μg/m3'
      value_template: '{{ state_attr("sensor.pogoda", "pm25") }}'
    rfw_pm25_percent:
      friendly_name: 'PM 2.5 (% normy)'
      icon_template: mdi:factory
      unit_of_measurement: '%'
      value_template: '{{ state_attr("sensor.pogoda", "pm25_percent") }}'
    rfw_pm25_text:
      friendly_name: 'PM 2.5'
      icon_template: mdi:factory
      value_template: '{{ state_attr("sensor.pogoda", "pm25") }} μg/m3 ({{ state_attr("sensor.pogoda", "pm25_percent") }}%)'
    rfw_pressure:
      friendly_name: 'Ciśnienie'
      unit_of_measurement: 'mb'
      icon_template: mdi:gauge
      value_template: '{{ state_attr("sensor.pogoda", "cisnienie") }}'
    rfw_humidity:
      friendly_name: 'Wilgotność'
      unit_of_measurement: '%'
      device_class: humidity
      icon_template: mdi:water-percent 
      value_template: '{{ state_attr("sensor.pogoda", "wilgotnosc") }}'

When looking at the attributes in dev-state all seems ok:

But in the UI (both old and lovelace, also both in sensor state and history graph) the data is not updated (compare the PM 2.5, PM 10 and CAQI values):

It is best visible in PM 2.5:

As you can see, the HA states that the sensor has been updated 1 hour ago, but in the sensor details I can clearly see that the update took place few minutes ago. What’s even more interesting is that all the temperature values (dwor, temperatura and odczuwalna), but only those, get updated normally, every 5 minutes. The only way to update those in UI (and on graphs) is to restart HA.

It’s driving me mad, any ideas what could it be?

Translation that can help reading the screenshots:
- czas = time
- 1 godzina temu = 1 hour ago

Finally tracked it down. This was caused by lack of entity_id in sensor template which was introduced in 0.81.

How to setup this weather and air quality station?
What tools do you use?

I’m using 1-wire sensors connected to my server and a script which gets average values from different meteo station located thought the city I live in. For air quality I’m averaging values from few different air stations provided by Airly.

I am having the same issues, and I have the entity_id defined. Any other tips to troubleshoot?

So the main device updates, but the template values do not. here is my code - value_template: ‘{{ value_json.M06 }}’ updates - the rest do not.

  - platform: rest
    name: Sonnen Battery
    scan_interval: 10
    json_attributes:
      - M03
      - M04
      - M05
      - M06
      - M38
      - M39
    resource: !secret sonnen_url
    value_template: '{{ value_json.M06 }}'
  - platform: template
    sensors:
        sonnen_currentpvpower:
          friendly_name: 'Sonnen Battery Current Solar Power Production'
          value_template: "{{ state_attr('sensor.sonnen_battery', 'M03') }}"
          unit_of_measurement: 'W'
          entity_id: sensor.sonnen_currentpvpower
        sonnen_consumption:
          friendly_name: 'Sonnen Battery Current Power Consumption'
          value_template: "{{ state_attr('sensor.sonnen_battery', 'M04') }}"
          unit_of_measurement: 'W'
          entity_id: sensor.sonnen_consumption
        sonnen_soc:
          friendly_name: 'Sonnen Battery State of Charge'
          value_template: "{{ state_attr('sensor.sonnen_battery', 'M05') }}"
          unit_of_measurement: '%'
          entity_id: sensor.sonnen_soc
        sonnen_gridfeed:
          friendly_name: 'Sonnen Battery Current Grid Feed-In'
          value_template: "{{ state_attr('sensor.sonnen_battery', 'M38' | float / 1000) | round(2) }}"
          unit_of_measurement: 'kW'
          entity_id: sensor.sonnen_gridfeed
        sonnen_gridpurchase:
          friendly_name: 'Sonnen Battery Current Grid Consumption'
          value_template: "{{ state_attr('sensor.sonnen_battery', 'M39' | float / 1000) | round(2) }}"
          unit_of_measurement: 'kW'
          entity_id: sensor.sonnen_gridpurchase

entity_id should be sensor.sonnen_battery (the source that get’s updated that will trigger the update on the template sensor).

1 Like

@Cezex Perfect! Thank you. I mis understood what entity ID’s were for. Cheers!