Hello, i’ve been trying to work on this the past few days trying countless configurations and researching on google, but I can’t seem to get it to work correctly.
I have a lovelace card that lists all the lights in the house and how many hours each light has been turned on using individual histort_stats configurations for each entity.
What i’m trying to achieve is creating an additional history_stat that provides an average of all the lights in the ‘on’ status.
Here is my most recent attempt which is not currently working:
configuration.yaml:
template:
- sensor:
- name: "Average_Lights"
state: >
{% set A = states('sensor.light_hs.office_recessed')| float %}
{% set B = states('sensor.light_hs.kitchen_island')| float %}
{{ ((A + B) / 2) }}
sensors.yaml
Note: This is just a sample, there are around 30 light entities i’m tracking with HS.
These are currently working fine.
- platform: history_stats
name: dummy
state: "dummy"
entity_id: light.back_patio_fan
<<: &daily_total
state: "on"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
- platform: history_stats
name: light_hs.back_patio_fan
entity_id: light.back_patio_fan
<<: *daily_total
- platform: history_stats
name: light_hs.back_patio_recessed
entity_id: light.back_patio_recessed
<<: *daily_total
Lovelace Card:
This card works fine as well (Except the average bar), but adding it for reference.
type: custom:vertical-stack-in-card
cards:
- type: horizontal-stack
cards:
- type: vertical-stack
cards:
- type: custom:auto-entities
card:
type: custom:bar-card
max: 10
severity:
- color: '#40bf40'
from: 0
to: 3
- color: '#bf9540'
from: 3.01
to: 6
- color: '#bf4040'
from: 6.01
to: 10
show_header_toggle: false
title: Lights
height: 16
positions:
value: inside
indicator: outside
icon: inside
name: inside
sort:
method: state
numeric: true
reverse: true
filter:
include:
- entity_id: '*light.hs*'
- entity_id: '*average_lights*'
exclude:
- state: <= 0