Add the device power and device energy into attributes #25

This commit is contained in:
Jean-Marc Collin
2023-02-18 00:07:54 +01:00
parent 08d08e52de
commit 8bbcafdf4a
5 changed files with 72 additions and 20 deletions

View File

@@ -118,6 +118,17 @@ template:
unique_id: maison_occupee
state: "{{is_state('person.jmc', 'home') }}"
device_class: occupancy
- sensor:
- name: "Total énergie switch1"
unique_id: total_energie_switch1
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
state: >
{% set energy = state_attr('climate.thermostat_switch_1', 'total_energy') %}
{% if energy == 'unavailable' or energy is none%}unavailable{% else %}
{{ ((energy | float) / 1.0) | round(2, default=0) }}
{% endif %}
switch:
- platform: template