Combining history stats of multiple entities

Hi there !
Quite new to home assistant, but I managed to create my custom sensors and history stats.
So, here is the deal :
I have 10 sensors (10 individuals ESP 32) tracking the running time of individual machines in a workshop.
I managed to get history stats for all of them and it works fine, but I would like to combine them to get a single value at the end : the total running time.
Also, I would like to get the separated time for every “category” of machines (mill, lathe etc)
Here is what I got in my sensors.yaml configuration file :

  • platform: history_stats
    type: time
    unique_id: vf40occweek
    name: VF-40 Occupied Week
    entity_id: sensor.vf4_0_machine_state
    state: “Running”
    start: ‘{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() *( 86400) }}’
    end: ‘{{ now() }}’

(this for each machine)

Thanks in advance for your help !

You can use a template helper to sum up all the sensors.

Thanks, I finally found out that there is a “combine state of several sensors” helper… I didn’t know helpers were a thing and was doing everything through YAML
Thanks a lot !