reaand
(Andrea)
October 11, 2018, 10:05pm
1
Hi,
i’m trying to use a platform template that I found here.
- platform: template
sensors:
traveltime:
friendly_name: TravelTimeToWork
value_template: '{{ now().weekday() in (0,1,2,3,4) and now().hour >=6 and now().hour <= 8 }}'
And it works, but if I try to duplicate it, like the code below the raspberry crashes.
- platform: template
sensors:
traveltime:
friendly_name: TravelTimeToWork
value_template: '{{ now().weekday() in (0,1,2,3,4) and now().hour >=6 and now().hour <= 8 }}'
- platform: template
sensors:
traveltime:
friendly_name: TravelTimeToHome
value_template: '{{ now().weekday() in (0,1,2,3,4) and now().hour >=16 and now().hour <= 18 }}'
What I’m doing wrong?
reaand
(Andrea)
October 11, 2018, 10:14pm
2
Now I’ve changed this way but it gives me an error:
ERROR (Thread-5) [homeassistant.util.yaml] YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key “traveltime” . Check lines 64 and 68.
- platform: template
sensors:
traveltime:
friendly_name: TravelTimeToWork
value_template: '{{ now().weekday() in (0,1,2,3,4) and now().hour >=6 and now().hour <= 8 }}'
traveltime:
friendly_name: TravelTimeToHome
value_template: '{{ now().weekday() in (0,1,2,3,4) and now().hour >=16 and now().hour <= 18 }}'
poebae
(Graham)
October 11, 2018, 10:28pm
3
You’re trying to set up two sensors with the same name.
You have to change one of the ‘traveltime:’ lines to something else.
1 Like
tom_l
October 11, 2018, 10:28pm
4
You have duplicate sensor names. Try this:
- platform: template
sensors:
traveltime_to_work:
friendly_name: Travel Time To Work
value_template: '{{ now().weekday() in (0,1,2,3,4) and now().hour >=6 and now().hour <= 8 }}'
traveltime_to_home:
friendly_name: Travel Time To Home
value_template: '{{ now().weekday() in (0,1,2,3,4) and now().hour >=16 and now().hour <= 18 }}'
reaand
(Andrea)
October 11, 2018, 10:37pm
5
That was so simple uff, Thank you!