Having trouble with template formatting

So i am trying to figure out what is the correct formatting for this:

- condition: template
  value_template: '{{ "sensor.owm_temperature" >= sensor["280417a2e4d6ff_temperature"] }}'

This is kinda messed up because I have tried changing the formatting too many times. What are the correct quotes for making this work? I keep getting errors.

I had some progress

  - condition: template
    value_template: '{{ "sensor.owm_temperature" >= "sensor["280417a2e4d6ff_temperature"]" }}'

but now I cant find anything on that error:

Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token 'end of print statement', got 'integer') for dictionary value @ data['condition'][0]['value_template']. Got None
not a valid value for dictionary value @ data['condition'][0]['condition']. Got None
required key not provided @ data['condition'][0]['entity_id']. Got None.

Tried this?

value_template: '{{ states.sensor.owm_temperature.state >= states.sensor.280417a2e4d6ff_temperature.state }}'
1 Like

No, it didnt work with that, but it helped very much! Thank you a lot! I made it working.

here is what I did:

  - condition: template
    value_template: '{{ states.sensor.owm_temperature.state >= states.sensor["280417a2e4d6ff_temperature"].state }}'

The problem was to sort out the many numbers on the temperature sensor. It needs that -bracket-doublequote- thing to read the template, but the double quote was messing with the other double quotes I had on the same template. The whole template should be inside a single quote so if I used a double like u said, it wouldnt work. Anyway I tried your solution to be sure, but it didnt work anyways.
But I didnt think of using the “states” templating. Thank you for that!

1 Like

Just before you replied I changed my post to single quotes.

I forgot about sensors starting with numbers needing square brackets too. Sorry.

Good to see you got it working.

same error encountered and resolved using this tip:

from:

entity_id: '{{states.sensor.3f_bedroom_remote_aircon_settings.state}}'

to:

entity_id: '{{states.sensor["3f_bedroom_remote_aircon_settings"].state}}'

Can someone please help me with the following. It does not work since the watched_plates start with a number

sensor:
  - platform: template
    sensors:
      plate_recognizer:
        friendly_name: "234abc"
        value_template: "{{ state_attr('image_processing.platerecognizer_1', 'watched_plates').["234abc"] }}"

Get rid of the dot, and use single quotes within the outer doubles:

        value_template: "{{ state_attr('image_processing.platerecognizer_1', 'watched_plates')['234abc'] }}"