Template Sensor for Temperature Calibration - Invalid Config (Hue)

I’ve spent quite a while on trying to calibrate my temperature sensors but can’t figure out why I keep getting the error below. Code works in dev template tools.

I cannot figure out why it says invalid config for automation.

Finally given up and though it would be great to have a 2nd pair of eyes having a look at my code.

entries are in configuration.yaml.

Invalid config for [automation]: must contain at least one of service, service_template. @ data[‘action’]…

[calibrated_hue_motion_sensor_1_temperature] is an invalid option for [sensor.template]. Check: sensor.template->calibrated_hue_motion_sensor_1_temperature. (See ?, line ?). Invalid config for [sensor.template]:
[calibrated_hue_motion_sensor_2_temperature] is an invalid option for [sensor.template]. Check: sensor.template->calibrated_hue_motion_sensor_2_temperature. (See ?, line ?). Invalid config for [sensor.template]:
[calibrated_hue_motion_sensor_3_temperature] is an invalid option for [sensor.template]. Check: sensor.template->calibrated_hue_motion_sensor_3_temperature. (See ?, line ?).

# Calibrated Temperature Sensors
  - platform: template
    sensors:
      calibrated_hue_motion_sensor_1_temperature:
        unit_of_measurement: "°C"
        value_template: "{{ float(states('sensor.hue_motion_sensor_1_temperature')) +0.25 }}"
      calibrated_hue_motion_sensor_2_temperature:
        unit_of_measurement: "°C"
        value_template: "{{ float(states('sensor.hue_motion_sensor_2_temperature')) +3.43 }}"
      calibrated_hue_motion_sensor_3_temperature:
        unit_of_measurement: "°C"
        value_template: "{{ float(states('sensor.hue_motion_sensor_3_temperature')) +1.69 }}"

Thank you in advance!

# Calibrated Temperature Sensors
  - platform: template
    sensors:
      calibrated_hue_motion_sensor_1_temperature:
        unit_of_measurement: "°C"
        value_template: "{{ (states('sensor.hue_motion_sensor_1_temperature') | float) +0.25 }}"
      calibrated_hue_motion_sensor_2_temperature:
        unit_of_measurement: "°C"
        value_template: "{{ (states('sensor.hue_motion_sensor_2_temperature') | float) +3.43 }}"
      calibrated_hue_motion_sensor_3_temperature:
        unit_of_measurement: "°C"
        value_template: "{{ (states('sensor.hue_motion_sensor_3_temperature') | float ) +1.69 }}"

The automation error is strange. If above does not work, show your configuration.yaml

After starting to think out of the box I decided to investigate an automation I created a few days ago which utilised a service template. Superficially, it appears that creating an automation (in automations.yaml), then using the GUI to view it has caused it to re-format and throw up an error - a bug, which may/may not be related.

However it still doesn’t explain why my template sensors don’t show up. Even the example on the website.

# Example configuration.yaml entry
sensor:
  - platform: template
    sensors:
      solar_angle:
        friendly_name: "Sun angle"
        unit_of_measurement: 'degrees'
        value_template: "{{ state_attr('sun.sun', 'elevation') }}"

      sunrise:
        value_template: "{{ state_attr('sun.sun', 'next_rising') }}"

I’ll attempt to troubleshoot the automation first then get back to you if that doesn’t fix the template sensors. Appreciate your reply

Managed to get it working without having to modify {{ (states(‘sensor.hue_motion_sensor_1_temperature’) | float) +0.25 }} although that also works.

It appears the culprit was:

  • an automation created 2 days ago in automations.yaml, then opened in the GUI.
  • GUI then re-formatted the all the Jinja below “service_template: >”
  • I never knew it wasn’t working because the automation was running as expected, but only threw an error on config check
    It is my suspicion the garbled automation then interfered with sensor template when loading. How, is beyond me.

Thanks again for your reply and time spent looking through my code!

1 Like

May i ask, what was the procedure you followed to come up with the calibration offsets?

1 Like