Input select in automation for weekday

Hi all, tried searching and different version but I can’t get it to work. I’m trying to have a notification on a day selected in a input_select. This automation without the template works, but as soon as I try to have the template I get different error.

Now this is what I have but it gives me : Invalid config for [automation]: extra keys not allowed @ data[‘condition’][0][‘data_template’]. Got None
not a valid value for dictionary value @ data[‘condition’][0][‘condition’]. Got None
required key not provided @ data[‘condition’][0][‘entity_id’]. Got None

Can someone help?

- id: '1522232863899'
  alias: Day notification
  trigger:
  - at: '11:30:00'
    platform: time
  condition:
  - condition: time
    data_template:
      weekday: >
        {% if is_state("input_select.compost_jour", "Lundi") %}
        - mon
        {%-elif is_state("input_select.compost_jour", "Mardi") %}
        - tue
        {%-elif is_state("input_select.compost_jour", "Mercredi") %}
        - wed
        {%-elif is_state("input_select.compost_jour", "Jeudi") %}
        - thu
        {%-elif is_state("input_select.compost_jour", "Vendredi") %}
        - fri
        {% endif %}
  action:
  - data:
      data:
        actions:
        - action: start_vac
          title: Yes
        - action: ''
          title: No
      message: Does it work ??
      title: Working
    service: notify.notifier_name

Thanks

You are trying to include a template in a Time Condition but it doesn’t support it.

If you want the condition to check if the current day’s name (in French) is the same as the one selected in input_select.compost_jour then this Template Condition should work:

  condition:
    condition: template
    value_template: >
      {% set jours = {0:'Lundi', 1:'Mardi', 2:'Mercredi', 3:'Jeudi', 4:'Vendredi', 5:'Samedi', 6:'Dimanche'} %}
      {% set jour = now().weekday() %}
      {% set nom = jours[jour] if jour in jours.keys() else 'unknown' %}
      {{ states('input_select.compost_jour') == nom }}

Works like a charm, thanks a lot!

1 Like

I was loocking for the same setup your solution is well apreciated, merci :slight_smile: