Lambda sensor not logged in HA recorder

Hi,

I created a temperature sensor, measuring water supply and return temperature. I calculate the delta temprature using a lambda function.I see both supply and return temperature appear in HA and also the delta T (as sensor data). Strange thing now is that the HA recorder does log the supply and return temperature meaning I can see historical data. Delta T however is NOT logged by the HA recorder, meaning I can not see historical data.

Does anyone have a clue how I can make the delta T sensor to appear in HA recorder?

part of the ESPHOME code
sensor:

  • platform: dallas
    address: 0x****
    name: “Supply Temperature - Ta”
    id: Ta
    accuracy_decimals: 1
  • platform: dallas
    address: 0xf83c01f095c53a28
    name: “Return Temperature - Tr”
    id: Tr
    accuracy_decimals: 1
  • platform: template
    name: “Delta T”
    id: Td
    unit_of_measurement: °C
    update_interval: 60s
    lambda: |-
    return (id(Ta).state - (id(Tr).state - 0.25000));

My sensor templates are showing in recorder. Didn’t know you had to do anything?

Found the problem. I did comparison using developer tools and noticed the supply/return sensors did include device_class and state_class. The delta T sensor did not, so I added these in the ESPHome configuration. Now the delta T sensor also appears in recorder. Working code is included below.

sensor:

  • platform: dallas
    address: 0x***
    name: “Supply Temperature - Ta”
    id: Ta
    accuracy_decimals: 1
  • platform: dallas
    address: 0x*****
    name: “Return Temperature - Tr”
    id: Tr
    accuracy_decimals: 1
  • platform: template
    name: “Delta T”
    id: Td
    unit_of_measurement: “°C”
    device_class: “temperature”
    state_class: “measurement”
    update_interval: 60s
    lambda: |-
    return (id(Ta).state - (id(Tr).state - 0.25000));
1 Like