Thanks for your reply.
I appli your code and it give me:
- id: '1593642521028'
alias: Aspirateur
description: ''
trigger:
- platform: template
value_template: 'value_template: "{{ states(''sensor.date_time'') == (states.input_datetime.heure_passage_aspirateur.attributes.timestamp
| int | timestamp_custom(''%H:%M'', True)) }}"'
condition:
{% if not is_state('input_select.aspi_'+nameday, 'Aucun')%} #check if a script is selected in the inputselect
action:
- data:
service_template: "script.{{ states('input_text.nameday') }}" #launch the script
nameday is a sensor value who gives the name of the day (tuesday for exemple)
there is something wrong in the condition but i can’t make it work.
condition:
condition: template
value_template: "{{ not is_state('input_select.aspi_'+nameday, 'Aucun') }}"
petro
(Petro)
July 21, 2020, 10:53am
23
where’s nameday coming from
it’s a date sensor:
nameday:
entity_id: sensor.date
value_template: "{{ now().strftime('%A') }}"
petro
(Petro)
July 21, 2020, 3:55pm
25
but it isn’t declared in the template.
Hello,
thanks but it’s not working
- id: '1595359780476'
alias: Programme Aspirateur
description: ''
trigger:
- platform: template
value_template: '{{ states(''sensor.time'') == states(''input_datetime.heure_passage_aspirateur'')[0:5]
}}'
condition:
condition: template
value_template: "{{ not is_state('input_select.aspi_'+nameday, 'Aucun') }}"
action:
- data:
message: it work
service: notify.notify
name of the input select of today:input_select.aspi_wednesday
Troon
(Troon)
July 23, 2020, 10:46am
29
You can’t just put nameday
in the template. It would need to be:
value_template: "{{ not is_state('input_select.aspi_'+(states('sensor.nameday')|lower), 'Aucun') }}"
If you use that nameday
sensor in a similar fashion elsewhere, it might be better to put the lowercase filter in the sensor:
nameday:
entity_id: sensor.date
value_template: "{{ now().strftime('%A')|lower }}"
petro
(Petro)
July 23, 2020, 11:43am
30
fyi, filters do not require parenthesis, it’s redundant. Filters are always applied to the object that precedes them.
1 Like
Hallelouya!!! it seem’s to work without the ( like petro said many thank’s
the lower case was already in the sensor config file but thanks for the tip.
1 Like
Why is now().strftime(’%w’) = 4 and now().weekday() = 3, thus off by 1 day? What am I missing here?
petro
(Petro)
November 19, 2020, 4:58pm
34
%w is based on Sunday being 0, now().weekday() is based on Monday being 0.