Incompatible code after update, what am I missing here?

Home Assistant shows an update is available for HA, ESPhome, along with each device. I update the first two, but now I am unable to update any of the devices. I have not changed the YAML code in months and it is still fully functional. This is the error I get:

INFO ESPHome 2024.12.4
INFO Reading configuration /config/esphome/wesp1.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block mapping
  in "/config/esphome/wesp1.yaml", line 161, column 5
expected <block end>, but found '<block mapping start>'
  in "/config/esphome/wesp1.yaml", line 169, column 6

This is the referenced area of code in the error, the first line is 161:

  - platform: template
    name: "Dew Point"
    lambda: |-
      return (243.5*(log(id(sen55_humidity).state/100)+((17.67*id(sen55_temperature).state)/
      (243.5+id(sen55_temperature).state)))/(17.67-log(id(sen55_humidity).state/100)-
      ((17.67*id(sen55_temperature).state)/(243.5+id(sen55_temperature).state))));
    unit_of_measurement: °C
    icon: 'mdi:thermometer-alert'
     filters:
       - lambda: return x * (9.0/5.0) + 32.0;
     unit_of_measurement: "°F"

I was reading through the releases, but I haven’t found anything that appears relevant. What am I missing?

1/24/25 update: code started working again.

Indentation on “filters” and “unit_of_measurement” does not look right to me? Shouldn’t that be in the same column as icon? And you have “unit_of_measurement” twice

Moving the indent to where you suggest results in this error:

INFO ESPHome 2024.12.4
INFO Reading configuration /config/esphome/wesp1.yaml...
ERROR Error while reading config: Invalid YAML syntax:

Duplicate key "unit_of_measurement"
  in "/config/esphome/wesp1.yaml", line 171, column 5
NOTE: Previous declaration here:
  in "/config/esphome/wesp1.yaml", line 167, column 5

Which the bottom portion is converting to Fahrenheit as changing unit of measurement above does not convert it in HA, just replaces the C with a F.

Removing the conversion/disabling(#) does make the code work, but results in it being in C again.

You do the conversion either here or in HA, but not both. The unit is declared only once and with " ".

  - platform: template
    name: "Dew Point"
    lambda: |-
      return (243.5*(log(id(sen55_humidity).state/100)+((17.67*id(sen55_temperature).state)/
      (243.5+id(sen55_temperature).state)))/(17.67-log(id(sen55_humidity).state/100)-
      ((17.67*id(sen55_temperature).state)/(243.5+id(sen55_temperature).state))));
    icon: 'mdi:thermometer-alert'
    filters:
       - lambda: return x * (9.0/5.0) + 32.0;
    unit_of_measurement: "°F"
1 Like

Came here to say this - also it’s a template sensor - why would you use a lambda filter???

- platform: template
   name: "Dew Point"
   lambda: |-
     return ((243.5*(log(id(sen55_humidity).state/100)+((17.67*id(sen55_temperature).state)/
     (243.5+id(sen55_temperature).state)))/(17.67-log(id(sen55_humidity).state/100)-
     ((17.67*id(sen55_temperature).state)/(243.5+id(sen55_temperature).state)))) * (9.0/5.0) + 32.0);
   icon: 'mdi:thermometer-alert'
   unit_of_measurement: "°F"