I am searching for a way to get history_stats from this week so far. The documentation (History Stats - Home Assistant) shows an example how to start from today’s day with replacing hour, minute and second with a 0, the same works for this month, since i can also replace the day with a 1. However, the datetime object returned by the now() function does not have a weekday attribute which i could reset. It sure does expose the isoweekday, but this is apparently immutable.
There are some suggestions to use datetime methods (Python: give start and end of week data from a given date - Stack Overflow) but apparently the datetime module is not accessible from templates.
Has anybody a suggestion how i could set the start of the history_stats sensor to the beginning of the week (i.e. monday morning at 00:00)?
1 post - 1 participant