I have a sensor that tallies the energy over the week. It resets on Sunday 00:00:00.

The sensor itself shows the correct values and pattern.

Using a statistic graph (energy with weekly values over several weeks) brings the wrong results:

- it counts from Monday to Sunday
- it
**should count from Sunday to Saturday.**(my case)

**The result is wrong using the statistical card and Plotly** (which uses the card).

An Apex graph (where we can define more variables) it calculate correctly.

Here are the sensors, stats, graphs etc

(I opened a bug report - but if I am doing anything wrong please do help!

→ I suspect somewhere deep in the system Monday is defined as start day… because I had it so when I created HA first time; I then changed the day to Sunday **and** I added the CRON as can be seen… but it is ignored

)

Definitions:

I have defined in my Profile Sunday as first day. (I don’t suppose it is defined anywhere else)

Sensor

from the YAML file

```
mt1681_weekly_energy:
unique_id: "mt1681-weeky"
source: sensor.bitshake_smartmeterreader_mt681_total_in
name: From netz weekly
cron: "0 0 * * 7"
```

and the “origin”

```
sensor.bitshake_smartmeterreader_mt681_total_in:
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
```

This brings the correct measures over time:

Statistic Graph

The statistic graph counts the days from Monday till Saturday *although* I defined the cron and start of the week on Sunday.

Code for the graph:

```
chart_type: bar
period: week
type: statistics-graph
entities:
- sensor.from_netz_weekly
title: Consumed Weekly
days_to_show: 28
hide_legend: false
stat_types:
- change
```

Graphs - it can be seen the date is wrong eg 8th instead of 7th

How it should be (with Apex)