Weekday and month sensor

thats because you are using single quotes to encapsulate your template. You need to mix quotes. Single on the inside, double on the outside. Or double on the inside single on the outside.

- platform: template
  sensors:
    dayoftheweek:
      value_template: "{{ ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][now().weekday()] }}"

The next thing to note is this will not update every day because it doesn’t have an entity to tether to. I suggest loading the time and date platform and using that. So your final solution would be:

sensor:
  - platform: time_date
    display_options:
      - 'time'
  - platform: template
    sensors:
      dayoftheweek:
        value_template: "{{ ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][now().weekday()] }}"
        entity_id: sensor.time

Also as a side note in regards to this comment:

You can ensure that it works from the template editor by using a second line instead of making it single like, like so:

- platform: template
  sensors:
    dayoftheweek:
      value_template: >
        {{ ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][now().weekday()] }}

This method does not require the outside quotes, so you can write the code as-is.

9 Likes