pappajohan
(Pappajohan)
January 20, 2019, 5:31pm
1
Hi!
Since very recently I get this kind of errors that seem to be because of template sensors such as;
vakna_offset:
value_template: >
{% if as_timestamp(states.calendar.johan_stromquist.attributes.start_time) - as_timestamp( strptime(states.sensor.date__time.state, "%Y-%m-%d, %H:%M" ) ) < 12600 %}on{% else %}off{% endif %}
The errors are these;
Jan 19 19:21:55 hassbian hass[9836]: File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/template.py", line 196, in async_update
Jan 19 19:21:55 hassbian hass[9836]: self._state = self._template.async_render()
Jan 19 19:21:55 hassbian hass[9836]: File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/template.py", line 138, in async_render
Jan 19 19:21:55 hassbian hass[9836]: File "<template>", line 1, in top-level template code
Jan 19 19:21:55 hassbian hass[9836]: File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/template.py", line 546, in strptime
I have no clue, any help would be appreciated…
/Johan
finity
January 21, 2019, 2:34am
2
I just copied the template into my template editor and after I substituted my calendar entity it rendered fine.
Are you sure the calendar entity is correct? I would check there first. There was a breaking change that might have changed the name of that entity.
The indentation also looks off tho. you might try fixing that first if that’s the way the code actually is but I don’t think that would give you those errors.
westfa
January 21, 2019, 9:07pm
3
Hi,
I believe the “sensor.date__time” bit has changed to a single underscore. So it’s now “sensor.date_time”.
Iwan
pappajohan
(Pappajohan)
January 21, 2019, 10:12pm
4
Ha ha!
Thank you so much, Iwan!
I thought I had checked those things…
Now I will wake up in a warm and nice room again tomorrow!
/Johan
rotcop4u2
(Rotcop4u2)
January 22, 2019, 2:16pm
5
why did the developers decide to go back to that design? I now have date and time sensors that no longer work because the template needs an entity.
- platform: template
scan_interval: 30000
sensors:
floorplan_date:
friendly_name: 'Date'
value_template: >-
{{now().strftime("%A")}}, {{now().strftime("%B")}} {{now().strftime("%d")}}
clock_am_pm:
friendly_name: 'AM/PM'
value_template: >-
{{now().strftime("%p")}}
clock_day:
friendly_name: 'Day'
value_template: >-
{{now().strftime("%A")}}
clock_date:
friendly_name: 'Clock Date'
value_template: >-
{{now().strftime("%B")}} {{now().strftime("%d")}} {{now().year}}
- platform: template
sensors:
floorplan_time:
friendly_name: 'Time'
value_template: >-
{{now().strftime("%-I")}}:{{now().strftime("%M")}} {{now().strftime("%p")}}
clock_time:
friendly_name: 'Clock Time'
value_template: >-
{{now().strftime("%-I")}}:{{now().strftime("%M")}}
is anyone able to help me hash this out?.. or can I revert the .py file to read it the old way?
rotcop4u2
(Rotcop4u2)
January 22, 2019, 2:42pm
6
As of now I can only use an automation to call an entity update every minute. I’d like to avoid doing that though. Any help would be appreciated.
petro
(Petro)
January 22, 2019, 5:01pm
7
just add an entity that updates regulary, like sun.sun. This change happened quite a few versions ago btw.
Also, all your templates are alittle odd. You can shorten everything:
- platform: template
scan_interval: 30000
sensors:
floorplan_date:
friendly_name: 'Date'
entity_id: sun.sun
value_template: >-
{{now().strftime("%A, %B %d")}}
clock_am_pm:
friendly_name: 'AM/PM'
entity_id: sun.sun
value_template: >-
{{now().strftime("%p")}}
clock_day:
friendly_name: 'Day'
entity_id: sun.sun
value_template: >-
{{now().strftime("%A")}}
clock_date:
friendly_name: 'Clock Date'
entity_id: sun.sun
value_template: >-
{{now().strftime("%B %d %Y")}}
- platform: template
sensors:
floorplan_time:
friendly_name: 'Time'
entity_id: sun.sun
value_template: >-
{{now().strftime("%-I:%M %p")}}
clock_time:
friendly_name: 'Clock Time'
entity_id: sun.sun
value_template: >-
{{now().strftime("%-I:%M")}}
rotcop4u2
(Rotcop4u2)
January 22, 2019, 6:04pm
8
Thank you very much I didnt even think to use the sun.sun… and thank you for stream lining the templates. It’s greatly appreciated.
1 Like