Temperature Difference with DarkSky

Hello,
I am trying to create a sensor which shows the temperature difference of one of my rooms with outside temperature.

      temp_difference:
        value_template:  {{ ( (states.sensor.temperature_158xxxxxx.state | float - 0.5 ) - (states.sensor.dark_sky_temperature.state | float ) ) | round(2) }}
        friendly_name: 'Outside temperature difference'
        entity_id: 
        - sensor.temperature_158xxxxxxx
        - sensor.dark_sky_temperature

This is the error I am getting:

Oct 12 19:16:30 raspberrypi hass[1534]: 2017-10-12 19:16:30 ERROR (Thread-2) [homeassistant.util.yaml] invalid key: "OrderedDict([('( (states.sensor.temperature_158xxxxxxx
Oct 12 19:16:30 raspberrypi hass[1534]:   in "/home/pi/.homeassistant/configuration.yaml", line 305, column 0
Oct 12 19:16:30 raspberrypi hass[1534]: 2017-10-12 19:16:30 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/pi/.homeassistant/configuration.yaml: invalid
Oct 12 19:16:30 raspberrypi hass[1534]:   in "/home/pi/.homeassistant/configuration.yaml", line 305, column 0
Oct 12 19:16:30 raspberrypi hass[1534]: Config directory: /home/pi/.homeassistant

Does anyone have an idea what the problem is? Thank you.

Plug your template into the Templates area on the HA frontend. Does it throw an error? (4th icon from the left under developer tools)

It works, yeah it was the first thing i tried.

After looking at some forum items with similar problems, the issue is fixed when i use quotes around the value template value.

So it becomes:

'{{ ( (states.sensor.temperature_158dxxxxxx.state | float - 0.5 ) - (states.sensor.dark_sky_temperature.state | float ) ) | round(2) }}'

Of course lol man I just put single quotes around everything now.

When I first started HA, I was putting too. Then after a while it didn’t seem to matter and I didn’t bother. This is the first problem I had related to quotes. I will start to put them now :slight_smile: