Template error to fix

I begin to get an error about this template and till some days ago it was working properly.

  - condition: template
    value_template: {{ (as_timestamp(now()) as_timestamp(states.input_boolean.mauhome.last_updated))< 360 }}

Can someone help me to trace the error and fix it?

You appear to be missing an operator in that expression:

{{ (as_timestamp(now()) - as_timestamp(states.input_boolean.mauhome.last_updated))< 360 }}

Yes, thanks, changed and fixed… Question is: who or what changed this? :grinning:
BTW solved !

Sorry, now i get another error in this other template of the same automation:

  - condition: template
    value_template: {{ is_state('input_boolean.mauhome','on') }}

The entire condition is:

  condition:
  - condition: template
    value_template: {{ 10 + 30/60 < now().hour + now().minute/60 < 14 }}
  - condition: template
    value_template: {{ is_state('input_boolean.mauhome','on') }}
  - condition: template
    value_template: {{ (as_timestamp(now()) - as_timestamp(states.input_boolean.mauhome.last_updated))< 360 }}

I get gremlins in my files all the time. It’s caused by fat fingers in my case… :slight_smile:

And the error is …?

Error loading /config/configuration.yaml: while parsing a flow mapping
in "/config/automations.yaml", line 902, column 22
expected ',' or '}', but got '<scalar>'
in "/config/automations.yaml", line 902, column 62

Checking these templates in developer/models i don’t get any error, only when checking the configuration.yaml i get that error…

I don’t think that the error is actually caused by the condition section you posted. Mind to show the entire automation here?

Ok, here it is:

- alias: Qualcuno a Casa Accendi Radio
  trigger:
    platform: state
    entity_id: binary_sensor.door_window_sensor_158d000201b557
    to: 'on'
  condition:
    - condition: template
      value_template: {{ 10 + 30/60 < now().hour + now().minute/60 < 14 }}
    - condition: template
      value_template: {{ is_state('input_boolean.mauhome','on') }}
    - condition: template
      value_template: {{ (as_timestamp(now()) - as_timestamp(states.input_boolean.mauhome.last_updated))< 360 }}
  action:
  - service: script.accendi_onkyo
  - delay: 00:00:05
  - service: script.audio_video_1
  - service: input_boolean.turn_on
    entity_id:
    - input_boolean.radio_play
    - input_boolean.audio_video_1
  - service: media_player.play_media
    data_template:
      entity_id: media_player.salotto_audio
      media_content_id: '{{ ["http://icecast.unitedradio.it/Virgin.mp3", "http://rfcmedia.streamguys1.com/MusicPulse.mp3?aw_0_1st.playerid=RadioTime&aw_0_1st.skey=1533328727",
        "http://198.15.94.34:8006/stream", "http://tunein4.streamguys1.com/hhbeat?aw_0_1st.playerid=RadioTime&aw_0_1st.skey=1533328852",
        "http://tunein4.streamguys1.com/hhhrbfree1", "http://tunein4.streamguys1.com/2khtsfree1?aw_0_1st.playerid=RadioTime&aw_0_1st.skey=1533329308",
        "http://strm112.1.fm/60s_70s_mobile_mp3", "http://stream.srg-ssr.ch/m/rsj/mp3_128",
        "http://stream.beachlatinoradio.com:8030/;?d=", "http://icy-4.radioparadise.com/flac",
        "http://tunein4.streamguys1.com/poolsfree1", "http://stream.mandragola.com/rj_hiphop_rb",
        "http://peridot.streamguys.com:7150/Mirchi", "http://streaming.live365.com/b68000_128mp3",
        "http://149.255.59.162:8062/stream", "http://live.leanstream.co/CKBTFM-MP3",
        "http://streams.greenhost.nl:8080/jazz", "http://icepe5.infomaniak.ch/jazzblues-high.mp3",
        "http://listen.shoutcast.com/Classic-RockFlorida",  "http://broadcast.infomaniak.net/tsfjazz-high.mp3",  "http://str1.openstream.co/589?aw_0_1st.stationid=3139&aw_0_1st.publisherId=613&aw_0_1st.serverId=str1"
        "http://www.beatlesradio.com:8000/stream/1/",  "http://shoutcast.rtl.it:3020/stream/1/",
        "http://stream.radioparadise.com/mellow-320" "http://icy-4.radioparadise.com/rock-flac",
        "http://eagle.streemlion.com:4157/stream" "http://googeradio.dyndns-free.com:8000/listen",
        "http://s1.thailandstreaming.net:8020/kiss.mp3"] | random }}

You are missing a closing quote on the last template in the automation.

Sorry, i have that, it was not copied…

Here it is again completely:

  - service: media_player.play_media
    data_template:
      entity_id: media_player.salotto_audio
      media_content_id: '{{ ["http://icecast.unitedradio.it/Virgin.mp3", "http://rfcmedia.streamguys1.com/MusicPulse.mp3?aw_0_1st.playerid=RadioTime&aw_0_1st.skey=1533328727",
        "http://198.15.94.34:8006/stream", "http://tunein4.streamguys1.com/hhbeat?aw_0_1st.playerid=RadioTime&aw_0_1st.skey=1533328852",
        "http://tunein4.streamguys1.com/hhhrbfree1", "http://tunein4.streamguys1.com/2khtsfree1?aw_0_1st.playerid=RadioTime&aw_0_1st.skey=1533329308",
        "http://strm112.1.fm/60s_70s_mobile_mp3", "http://stream.srg-ssr.ch/m/rsj/mp3_128",
        "http://stream.beachlatinoradio.com:8030/;?d=", "http://icy-4.radioparadise.com/flac",
        "http://tunein4.streamguys1.com/poolsfree1", "http://stream.mandragola.com/rj_hiphop_rb",
        "http://peridot.streamguys.com:7150/Mirchi", "http://streaming.live365.com/b68000_128mp3",
        "http://149.255.59.162:8062/stream", "http://live.leanstream.co/CKBTFM-MP3",
        "http://streams.greenhost.nl:8080/jazz", "http://icepe5.infomaniak.ch/jazzblues-high.mp3",
        "http://listen.shoutcast.com/Classic-RockFlorida",  "http://broadcast.infomaniak.net/tsfjazz-high.mp3",  "http://str1.openstream.co/589?aw_0_1st.stationid=3139&aw_0_1st.publisherId=613&aw_0_1st.serverId=str1"
        "http://www.beatlesradio.com:8000/stream/1/",  "http://shoutcast.rtl.it:3020/stream/1/",
        "http://stream.radioparadise.com/mellow-320" "http://icy-4.radioparadise.com/rock-flac",
        "http://eagle.streemlion.com:4157/stream" "http://googeradio.dyndns-free.com:8000/listen",
        "http://s1.thailandstreaming.net:8020/kiss.mp3"] | random }}

        '

Try removing the single quotes here and at the end.

Ah. Then it all looks fine as templates go - sorry.

No way… always same error…

It seems solved putting double quotes in all the templates…

    - condition: template
      value_template: "{{ 10 + 30/60 < now().hour + now().minute/60 < 14 }}"
    - condition: template
      value_template: "{{ is_state('input_boolean.mauhome','on') }}"
    - condition: template
      value_template: "{{ (as_timestamp(now()) - as_timestamp(states.input_boolean.mauhome.last_updated))< 360 }}"

In this way i get no error !

1 Like

Try moving that quote to end of the last line on the template. I think that blank line is breaking it.