Skip to content

Instantly share code, notes, and snippets.

@jannickfahlbusch
Created March 19, 2023 12:09
Show Gist options
  • Select an option

  • Save jannickfahlbusch/92be92952a86a45fda4dc8c4eafeb314 to your computer and use it in GitHub Desktop.

Select an option

Save jannickfahlbusch/92be92952a86a45fda4dc8c4eafeb314 to your computer and use it in GitHub Desktop.
Overall Power Home Assistant
template:
sensor:
- name: Overall Power
unit_of_measurement: "W"
device_class: energy
state_class: measurement
state: >
{% set ns = namespace(states=[]) %}
{% for s in states.sensor %}
{% if s.object_id.endswith('_power') and not s.object_id == "overall_power" %}
{% set ns.states = ns.states + [ s.state | float(0) ] %}
{% endif %}
{% endfor %}
{{ ns.states | sum | round(2) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment