Trying to get the week to start / reset on Sunday not Monday. See attached picture. not sure why it is multiplied by the seconds in a day. I’m defiantly missing something. Some knowledge would be appreciated. TY in advance.
as_timestamp()
is converting the datetime object to seconds… so the weekday value needs to be converted to seconds for the subtraction to be of like units.
I prefer sticking with datetime objects and methods:
{{ today_at() - timedelta(days= now().isoweekday())}}
So I set up a few new weekly sensors with start: as the time delta formula / code you suggested and the week sensor is still resetting on Monday night. Any thoughts?
Also, if I wanted to adjust the original start formula / code I posted to reset Sunday night how would I modify?
Thank you,
Are you sure? Here is an example from my config that resets every Sunday at 00:00… It renders an accurate count.
sensor:
- platform: history_stats
name: "Weekly Front Door Opening"
unique_id: front_door_opening_weekly_0002
entity_id: binary_sensor.sonoff_ds01_01_fr_door
state: "on"
type: count
start: '{{ today_at() - timedelta(days= now().isoweekday()) }}'
duration:
hours: 168
Using end: "{{ now() }}"
instead of a duration of 168 hours yields the same results… as expected.
Ok, so I have been looking into this and it looks like the sensor is resetting on Sunday @ 00:00:00 but the graph for that same sensor is resetting on Monday. On Monday the graph wont go to zero as it adds the time from Sunday
Below is a picture of the daily sensor and you can see the time on Sunday the 4th ( 1.86 h) is the lowest the above graph will go when the graph resets on Monday morning
Any solution to this? TY for your help.