Use the availability option to suppress reporting a value when any of the three sensors is unavailable. tom_l provided an example here:
Try this version:
- sensor:
- name: "house_energy_kWh"
unit_of_measurement: "kWh"
state_class: measurement
device_class: energy
state: >
{{ [ states('sensor.shellyem3_40F52000EDD0_channel_a_energy'),
states('sensor.shellyem3_40F52000EDD0_channel_b_energy'),
states('sensor.shellyem3_40F52000EDD0_channel_c_energy') ]
| map('float') | sum }}
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
availability: >
{{ not 'unavailable' in
[ states('sensor.shellyem3_40F52000EDD0_channel_a_energy'),
states('sensor.shellyem3_40F52000EDD0_channel_b_energy'),
states('sensor.shellyem3_40F52000EDD0_channel_c_energy') ] }}