mq3000
(Mq3000)
June 3, 2022, 4:23pm
1
I want to make a graph in Lovelace of the sum of all 3 signals.
Current code:
type: custom:mini-graph-card
name: POWER
entities:
- sensor.shelly_3em_channel_a_power
- sensor.shelly_3em_channel_b_power
- sensor.shelly_3em_channel_c_power
height: 300
line_width: 1
show:
labels: true
average: true
extrema: true
hours_to_show: 2
points_per_hour: 60
panel: true
With panel: true
tom_l
June 3, 2022, 4:26pm
2
This is not possible in the mini-graph card. Either create a template sensor that sums your sensors and graph that or use the Apexchats card that does have this functionality.
1 Like
mq3000
(Mq3000)
June 4, 2022, 8:49pm
4
The solution:
With File Editor open the file configuration.yaml and write following code:
template:
- sensor:
- name: Energy_total
unit_of_measurement: kWh
state: "{{ (states('sensor.shelly_3em_channel_a_power')|float + states('sensor.shelly_3em_channel_b_power')|float + states('sensor.shelly_3em_channel_c_power')|float) }}"
device_class: energy
Save, and reboot.
Then search for sensor.energy_total, this is your summation of all 3 sensors.
The Code will be then for mini-graph card:
type: custom:mini-graph-card
name: POWER
entities:
- sensor.shelly_3em_channel_a_power
- sensor.shelly_3em_channel_b_power
- sensor.shelly_3em_channel_c_power
- sensor.energy_total
height: 300
line_width: 1
show:
labels: true
average: true
extrema: true
hours_to_show: 2
points_per_hour: 600
panel: true
With panel: true
DONE
2 Likes
tom_l
June 5, 2022, 12:16am
5
You may want to add an availability template to your total sensor so that it only reports values when all the sensors are available. Also you have to define default values for the float filters or the template sensor may fail during startup.
template:
- sensor:
- name: Energy_total
unit_of_measurement: kWh
state: "{{ states('sensor.shelly_3em_channel_a_power')|float(0) + states('sensor.shelly_3em_channel_b_power')|float(0) + states('sensor.shelly_3em_channel_c_power')|float(0) }}"
availability: >
{{ states('sensor.shelly_3em_channel_a_power')|is_number and
states('sensor.shelly_3em_channel_b_power')|is_number and
states('sensor.shelly_3em_channel_c_power')|is_number }}
device_class: energy
1 Like
mq3000
(Mq3000)
June 5, 2022, 12:46pm
7
I made an error in the code.
It must be:
unit_of_measurement: W
NOT
kWh
I am trying to implement this as well (newbie), but have a few questions:
shouldn’t the device class be “power”?
It doesn’t work for me, value is 0W
template:
- sensor:
- name: power_total
unit_of_measurement: W
state: "{{ states('sensor.shelly_3em_channel_a_power')|float(0) + states('sensor.shelly_3em_channel_b_power')|float(0) + states('sensor.shelly_3em_channel_c_power')|float(0) }}"
availability: >
{{ states('sensor.shelly_3em_channel_a_power')|is_number and
states('sensor.shelly_3em_channel_b_power')|is_number and
states('sensor.shelly_3em_channel_c_power')|is_number }}
device_class: power
Thanks
mq3000
(Mq3000)
June 7, 2022, 1:59pm
9
markus.schloesser:
shouldn’t the device class be “power”?
It doesn’t work for me, value is 0W
Hi Markus hope this helps:
This is my final setting that works:
configuration.yaml
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template:
- sensor:
- name: energy_total
unit_of_measurement: W
state: "{{ (states('sensor.shelly_3em_channel_a_power')|float + states('sensor.shelly_3em_channel_b_power')|float + states('sensor.shelly_3em_channel_c_power')|float) }}"
availability: "{{ states('sensor.shelly_3em_channel_a_power')|is_number and states('sensor.shelly_3em_channel_b_power')|is_number and states('sensor.shelly_3em_channel_c_power')|is_number }}"
device_class: energy
- sensor:
- name: energy_null
unit_of_measurement: W
state: "{{ 0 }}"
device_class: energy
mini-graph-card
type: custom:mini-graph-card
name: Summe Leistung, 2h [W]
entities:
- sensor.energy_total
- sensor.energy_null
height: 300
line_width: 1
show:
labels: true
average: true
extrema: true
hours_to_show: 2
points_per_hour: 60
panel: true
With panel: true
tom_l
June 7, 2022, 2:17pm
10
As Markus said, this is wrong:
It should be:
device_class: power
Power is measured in W or kW.
Energy is measured in Wh, or kWh.
Same for this:
- sensor:
- name: energy_null
unit_of_measurement: W
state: "{{ 0 }}"
device_class: energy