Weekday and month sensor

well your error points to it missing in configuration.yaml

Found it:

It was added in December 2018 in version 0.84. It’s mentioned in the release notes but to say “not prominently” would be an understatement.

In fact, it’s not linked to the initial PR but to a follow-up PR that fixes it.

FWIW I was a novice back then and this filter’s stealthy introduction would have definitely flown undetected past my radar. :slightly_smiling_face:

Hmm corrected but still got the error:

Error loading /config/configuration.yaml: while parsing a block mapping
in “/config/configuration.yaml”, line 671, column 5
expected , but found ‘,’
in “/config/configuration.yaml”, line 672, column 40

IIRC it’s the only function/filter/test that’s not included in the docs.

replace ", " with ,

Geeze I was chasing a browser-error gost. That error keeped popping up nomatther what I did, needed a big browser refresh. Dunno why. So the final code i’m using is below. Works in template editor, only thing in practical the state is “unknown”…wait tell me it will only fill in the states tonight at 00:00 right? :scream::man_facepalming: In the previous “old” example it worked right away…

template:
- trigger:
  - platform: time
    at: "00:00"
  sensor:
  - name: Dag
    state: "{{ now().strftime('%a') }}"
  - name: Maand
    state: "{{ now().strftime('%b') }}"
  - name: Datum
    state: "{{ now().day }}"
  - name: Dag-datum
    state: "{{ now().strftime('%a') }}, {{ now().day | ordinal }}"
  - name: Datum-1
    state: "{{ (now() - timedelta(days=1)).strftime('%a') }}, {{ (now() - timedelta(days=1)).day | ordinal }}"
  - name: Datum-2
    state: "{{ (now() - timedelta(days=2)).strftime('%a') }}, {{ (now() - timedelta(days=2)).day | ordinal }}"
  - name: Datum-3
    state: "{{ (now() - timedelta(days=3)).strftime('%a') }}, {{ (now() - timedelta(days=3)).day | ordinal }}"
  - name: Datum-4
    state: "{{ (now() - timedelta(days=4)).strftime('%a') }}, {{ (now() - timedelta(days=4)).day | ordinal }}"
  - name: Datum-5
    state: "{{ (now() - timedelta(days=5)).strftime('%a') }}, {{ (now() - timedelta(days=5)).day | ordinal }}"
  - name: Datum-6
    state: "{{ (now() - timedelta(days=6)).strftime('%a') }}, {{ (now() - timedelta(days=6)).day | ordinal }}"
  - name: Datum-7
    state: "{{ (now() - timedelta(days=7)).strftime('%a') }}, {{ (now() - timedelta(days=7)).day | ordinal }}"
  - name: Datum-8
    state: "{{ (now() - timedelta(days=8)).strftime('%a') }}, {{ (now() - timedelta(days=8)).day | ordinal }}"
  - name: Datum-9
    state: "{{ (now() - timedelta(days=9)).strftime('%a') }}, {{ (now() - timedelta(days=9)).day | ordinal }}"
  - name: Datum-10
    state: "{{ (now() - timedelta(days=10)).strftime('%a') }}, {{ (now() - timedelta(days=10)).day | ordinal }}"
  - name: Datum-11
    state: "{{ (now() - timedelta(days=11)).strftime('%a') }}, {{ (now() - timedelta(days=11)).day | ordinal }}"
  - name: Datum-12
    state: "{{ (now() - timedelta(days=12)).strftime('%a') }}, {{ (now() - timedelta(days=12)).day | ordinal }}"
  - name: Datum-13
    state: "{{ (now() - timedelta(days=13)).strftime('%a') }}, {{ (now() - timedelta(days=13)).day | ordinal }}"
  - name: Datum-14
    state: "{{ (now() - timedelta(days=14)).strftime('%a') }}, {{ (now() - timedelta(days=14)).day | ordinal }}"
1 Like

Yes, it will only calculate at midnight. Remove the trigger to have it calculate every minute. If you remove the trigger, make sure you put a - in front of the sensor line.

1 Like

Good afternoon, my apologies I’m new to home assistant and would love to implement your exact code. This is exactly what I’m looking for. Would you mint guiding me through the steps to implement this please?

please always use preformatted text when pasting code, so the quotes don’t get all screwed up (also tabs are preserved).
It’s a PITA to copy the code and replace them all manually :wink: