Newbie - Trying to debug configuration.yaml entries

I have 2 motion sensors in my garage, front and back. They both also have temperature sensors, but neither values are correct. Ultimately I will try and manipulate the temperature, but while I am learning HA, I found a snippet that simply adds the 2 sensor values together and divides by 2 to get an average.

But all i get is a new value of 0.0 which isn’t what I am expecting when the temps are say 20 and 16.

So here is my code block


  • sensor:
    • name: “Average Garage temperature”
      unit_of_measurement: “°C”
      state: >
      “{% set hive = states(‘ MOT003 7da50213 temperature’) | float %}
      {% set aqara = states(‘sensor.Garage_Motion_Sensor device_temperature’) | float %}
      {{ ((hive + aqara) / 2) | round(1) }}”

I dabble in bash script on Linux, so it was easy to stick an “echo $hive” into the script and see what comes out, but this all runs under the hood so I can’t see how to step through it.

Thanks in advance

A few notes on your config:

  • Post your code using the </> icon on your toolbar, that way we can see it as it is actually represented in HA, the bullets don’t tell us if your indenting is incorrect
  • The state: > doesn’t need quotes around what follows, just the {% %} where needed, this may be why you are getting a zero
  • There’s a built-in device for averaging called Min/Max that may serve you better than scripting it out - but I underhand you are learning and learning the code (and how to format it) is also valuable

The two entity_id values are invalid. Home Assistant uses a strict naming scheme and neither of them conform to it. They shouldn’t contain spaces or uppercase letters. Go to Developer Tools → States and double-check the spelling of the two entities you want to use in the template.

Here is a sensor’s entity_id


The entity’s domain is sensor and its object_id is kitchen_temperature. An entity’s object_id can contain lowercase alphanumeric characters and the underscore character. No accented characters, spaces, hyphens, etc are permitted.