maurizio53
(Maurizio Fabiani)
November 16, 2018, 12:08pm
1
I have these sensors configured:
- platform: time_date
display_options:
- 'time_date'
- 'time'
- 'date'
- 'date_time'
- 'beat'
- platform: template
sensors:
date_template:
entity_id: sensor.date
friendly_name: 'Oggi'
value_template: '{{ as_timestamp(now()) | timestamp_custom("%d/%m/%y", True) }}'
- platform: template
sensors:
date_month:
entity_id: sensor.time__date
value_template: "{{as_timestamp(now())|timestamp_custom('%B', True)}}"
But i get this error when checking configuration:
Invalid config for [sensor.template]: expected a dictionary for dictionary value @ data['sensors']['date_month']. Got None
expected a dictionary for dictionary value @ data['sensors']['entity_id']. Got 'sensor.time__date'
expected a dictionary for dictionary value @ data['sensors']['value_template']. Got "{{as_timestamp(now())|timestamp_custom('%B', True)}}". (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
How to solve?
JTPublic
(JT)
November 16, 2018, 12:19pm
2
Try removing the entity_id rows from platform: template.
tom_l
November 16, 2018, 12:19pm
3
Rule 3.
Put single quotes inside double quotes. So not like this:
maurizio53
(Maurizio Fabiani)
November 16, 2018, 12:21pm
4
I have that error after adding the sensor:
- platform: template
sensors:
date_month:
entity_id: sensor.time__date
value_template: "{{as_timestamp(now())|timestamp_custom('%B', True)}}"
So i think the problem is related to that sensor as the previous two are regularly workingâŚ
maurizio53
(Maurizio Fabiani)
November 16, 2018, 12:22pm
5
The entity_id is needed after 0.80.x release as the templates without an entity cannot be renewed⌠At lest this is what i read aboutâŚ
1 Like
tom_l
November 16, 2018, 12:23pm
6
Donât do that.
If you do not supply an entity_id
in the configuration you will need to run the service homeassistant.update_entity
to update the sensor.
JTPublic
(JT)
November 16, 2018, 12:24pm
7
Hmm, Iâm on 80.3. What version did this start?
maurizio53
(Maurizio Fabiani)
November 16, 2018, 12:25pm
8
Can you quote the right way to have the template with quotes? They are my nightmareâŚ
tom_l
November 16, 2018, 12:29pm
9
You got it right:
Also I think you have an extra underscore in this:
entity_id: sensor.time__date
Should it be this?:
entity_id: sensor.time_date
maurizio53
(Maurizio Fabiani)
November 16, 2018, 12:32pm
10
Hmm, i double-checked but that sensor has two underscores and i donât know why as the config says:
- platform: time_date
display_options:
- 'time_date'
- 'time'
- 'date'
- 'date_time'
- 'beat'
And in dev-state i have sensor.time__date
So if all is correct, why i get that error?
tom_l
November 16, 2018, 12:37pm
11
Huh. I just had a look at mine. It does the same thing. I have sensor.date__time
.
Ok so It must be something else. Iâll have another look.
tom_l
November 16, 2018, 12:49pm
12
Did you swap the single and double quotes in this template?
value_template: '{{ as_timestamp(now()) | timestamp_custom("%d/%m/%y", True) }}'
Should be:
value_template: "{{ as_timestamp(now()) | timestamp_custom('%d/%m/%y', True) }}"
maurizio53
(Maurizio Fabiani)
November 16, 2018, 1:06pm
13
hmm i donât think so as that sensor doesnât give me error⌠I get error only if i try to create this sensor:
- platform: template
sensors:
date_month:
entity_id: sensor.time__date
value_template: "{{as_timestamp(now()) | timestamp_custom('%B', True)}}"
this gives:
no error, template seems to the point. What does your error tell you here? btw, using the multiline > makes it easier to handle quotes.
maurizio53
(Maurizio Fabiani)
November 16, 2018, 1:14pm
15
Found it!
Indentation error⌠nothing more simplierâŚ
- platform: template
sensors:
date_month:
entity_id: sensor.time__date
friendly_name: 'Corrente Mese'
value_template: "{{as_timestamp(now()) | timestamp_custom('%B', True)}}"
In this way it worksâŚ
bingo, was just about to tell you⌠cool. Still, make life easier on yourself and ditch the quotes by using multiline. Always.
maurizio53
(Maurizio Fabiani)
November 16, 2018, 1:18pm
18
Yes, i will do always since nowâŚ
tom_l
November 16, 2018, 1:21pm
19
You should still follow the templating rules and fix it,
templating rules are you can not mix quotes or use the same in and outside the template. But he can use double quotes inside the template without issue, when using single quotes outside.
No issue at all if using the multiline >, in which case you only need quotes inside the template