Hi, still learning with HA, and with a lot of searches, I set up a history stat for knowing how much TV is viewed in a month, that’s an easy one. With that I get a value, but not in hours minute format, so I search for a template to convert that value.
It worked perfect but after some time, the counter doesn’t go on, it reset about a day or so of hours watched.
This is what I have set up:
- platform: history_stats
name: TV ON
entity_id: media_player.sony_bravia_tv
state: "playing"
type: time
start: '{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: template
sensors:
tv_on_days:
friendly_name: "Horas TV mes"
value_template: "{{ state_attr('sensor.tv_on','value') }}"
Thank you!