History Statistics for Current Month

Hi all,

Rather than using this for the last 30 days or the current week like in the examples… is there a way to show from the first day of the current month to now for the time period?

ie: Only showing the current months info?

start: '{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'

Not tested!

3 Likes

Thanks! I’ll give it a go.

Pretty sure that will work. That’s basically saying replace the current time with the first day of the month at midnight.

I’m using it like so:

- platform: history_stats
  type: time
  name: Watched TV This month
  entity_id: remote.harmony_hub_wz
  state: "on"
  start: "{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}"
  end: "{{ now() }}"

It seems to work at first glance, but during the month there are some weird jumps up or down, which I can’t explain.

Down jumps make no sense at all, but also the up jumps >24h within 1h are impossible!

Any idea what’s going wrong here?

History Stats use the recorded data in your DB. The old data (after 7 days) is removed, so history stats only use the last 7 days.