Hello,
let say i have 3 smart plug with below details :
-Plug1 current is 100mA
-Plug2 current is 200mA
-Plug3 current is 300mA
then i create helper ’ Combine the state of several sensors’ and i got result 600mA. But if one of three devices is down the result showing as ‘unknow’, so can we ignore if there any down devices? I want the helper showing 500mA (with assumption Plug1 is down) rather than showing ‘unknown’ value.
Only if you do it in YAML.
How i can edit in yaml?
There are several ways to accomplish this, depending on if you want to use helpers or sensor templates or a statistics sensor. For example, if you wanted to create a sensor template you could do this:
template:
- sensor:
- name: "Total Current"
unit_of_measurement: "mA"
state: >
{{ int(states('sensor.plug1_current'),0) + int(states('sensor.plug2_current'),0) + int(states('sensor.plug3_current'),0) }}
That would always be the total sum value of all three plugs, and the int
statement makes sure that if it’s invalid that it reports as 0.
Again, this is one of several ways and even the Jinja2 is one of many ways to do this, this was just a quick bit of code to show you how to do it.