maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:19am
1
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?
zoogara
(Daryl)
January 17, 2022, 10:26am
2
You appear to be missing an operator in that expression:
{{ (as_timestamp(now()) - as_timestamp(states.input_boolean.mauhome.last_updated))< 360 }}
maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:30am
3
Yes, thanks, changed and fixed… Question is: who or what changed this?
BTW solved !
maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:35am
4
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 }}
zoogara
(Daryl)
January 17, 2022, 10:37am
5
I get gremlins in my files all the time. It’s caused by fat fingers in my case…
maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:39am
7
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
maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:45am
8
Checking these templates in developer/models i don’t get any error, only when checking the configuration.yaml i get that error…
m0wlheld
(Christoph Dahlen)
January 17, 2022, 10:46am
9
I don’t think that the error is actually caused by the condition
section you posted. Mind to show the entire automation here?
maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:48am
10
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 }}
zoogara
(Daryl)
January 17, 2022, 10:51am
11
You are missing a closing quote on the last template in the automation.
maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:53am
12
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 }}
'
m0wlheld
(Christoph Dahlen)
January 17, 2022, 10:56am
13
maurizio53:
media_content_id: '{{
Try removing the single quotes here and at the end.
zoogara
(Daryl)
January 17, 2022, 10:57am
14
Ah. Then it all looks fine as templates go - sorry.
maurizio53
(Maurizio Fabiani)
January 17, 2022, 10:58am
15
No way… always same error…
maurizio53
(Maurizio Fabiani)
January 17, 2022, 11:04am
16
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
zoogara
(Daryl)
January 17, 2022, 11:04am
17
Try moving that quote to end of the last line on the template. I think that blank line is breaking it.