History stats - week sensor setup

hello,
how do I change the following week stats to start on Sunday?
I know that I need to add “6” but I don’t know were.

start: “{{ as_timestamp( now().replace(hour=0, minute=0, second=0) ) - now().weekday() * 86400 }}”
end: “{{ now() }}”

Thanks :slight_smile:

Monday is the start of the week as defined by ISO 8601, and that’s what python uses.
You can do - (now().weekday()+1), but then you’ll have to check if you are sunday, or start will go up to the sunday of last week.

were should I put the 6 for Sunday?

There is no put. The weekday() function returns 0 for Monday and 6 for Sunday.