flixlix / power-flow-card-plus

A power distribution card inspired by the official Energy Distribution card for Home Assistant
616 stars 74 forks source link

[FEATURE REQUEST] Combining data from multiple sensors in the UI without having to use template sensors #659

Open fencepost-error opened 4 months ago

fencepost-error commented 4 months ago

Is your feature request related to a problem? Please describe. At the moment it looks like the only way to combine data from multiple sensors, e.g. solar panel strings, batteries, etc, is to use template sensors to do the addition for you, which involves lots of playing around at the YAML level, copying and pasting sensor names around, etc.

Describe the solution you'd like It would be nice if the UI allowed you to add more than one sensor, a bit like the default Energy dashboard does with "Add battery system", "Add solar production", etc.

Describe alternatives you've considered Doing it via formulae in YAML also works, but given the number of times it's come up in discussions it seems like having it in the UI would make things easier for many people.

Additional context It's a convenience feature, but it would be very convenient to have.

dougle03 commented 4 months ago

+1 for this please.

fencepost-error commented 4 months ago

In the meantime, for people who want this right now, you can do it with template sensors, it just means doing things in YAML rather than via the UI, e.g to get total power consumption as a template sensor:

template:
  # Note double indentation step for sensor: -> name:
  - sensor:
      - name: "Power Total"
        unique_id: uniqueid__power_total
        unit_of_measurement: "W"
        device_class: energy
        state_class: measurement
        state: >
          {% set thing1 = states('sensor.thing1_power') | float %}
          {% set thing2 = states('sensor.thing2_power') | float %}
          {% set thing3 = states('sensor.thing3_power') | float %}
          {% set thing4 = states('sensor.thing4_power') | float %}
          {{ ( thing1 + thing2 + thing3 + thing4 ) | round(0) }}

Then select the template sensor as the value to display.

dougle03 commented 4 months ago

I did it a similar way to you: Just didn't bother creating variables first.. lol image

MarkoSchweizer commented 2 months ago

In the meantime, for people who want this right now, you can do it with template sensors, it just means doing things in YAML rather than via the UI, e.g to get total power consumption as a template sensor:

template:
  # Note double indentation step for sensor: -> name:
  - sensor:
      - name: "Power Total"
        unique_id: uniqueid__power_total
        unit_of_measurement: "W"
        device_class: energy
        state_class: measurement
        state: >
          {% set thing1 = states('sensor.thing1_power') | float %}
          {% set thing2 = states('sensor.thing2_power') | float %}
          {% set thing3 = states('sensor.thing3_power') | float %}
          {% set thing4 = states('sensor.thing4_power') | float %}
          {{ ( thing1 + thing2 + thing3 + thing4 ) | round(0) }}

Then select the template sensor as the value to display.

Hi

I am very new to Home Assistant. This is my first project. Could you please tell me, where do you put that code and how I get the new value in the power flow card.

Best regards Marko

escoand commented 1 month ago

see https://github.com/flixlix/power-flow-card-plus/pull/670

fencepost-error commented 1 week ago

I am very new to Home Assistant. This is my first project. Could you please tell me, where do you put that code and how I get the new value in the power flow card.

See this post which should cover everything you need to do.