Hi,
I’ve got a large yaml file to track my media usage in hours and was wondering if this could be done a lot smaller?
It works but when I track multiple media sources AND in multiple chromecasts, it becomes EVEN bigger and only more confusing.
Is it true that the daily time convert is not needed anymore? Because I see that the history stats already keeps track of the time when the entity is “on”.
and the switch is still needed I think because of the attribute of the each chromecast entity.
sensor:
- platform: history_stats
name: chromecast_netflix_usage_daily
entity_id: switch.chromecast_netflix_usage
state: "on"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
switch:
- platform: template
switches:
chromecast_netflix_usage:
value_template: "{{ is_state('sensor.chromecast_appname', 'Netflix') }}"
turn_on:
service: switch.turn_on
target:
entity_id: switch.target
turn_off:
service: switch.turn_off
target:
entity_id: switch.target
template
- sensor:
- name: "Chromecast Netflix usage daily convert"
unique_id: chromecast_netflix_usage_daily_convert
icon: mdi:clock-time-eleven-outline
state: "{{ (states('sensor.chromecast_netflix_usage_daily') | float(0) * 3600)| timestamp_custom('%-H.%-M', false) }}"