flixlix / power-flow-card-plus

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

[FEATURE REQUEST] Add more individual entities (dynamic?) #404

Open xkill opened 9 months ago

xkill commented 9 months ago

Is your feature request related to a problem? Please describe. I can only add two different individual devices.

Describe the solution you'd like I would like to more than two individual devices, for example: heater, air conditioner, dish-washer, ... so I see the power consumption of each individual device in one graph.

Describe alternatives you've considered Add the same card several times, each one with the different individual devices I want to monitor.

Additional context N/A

commentsonly commented 8 months ago

Steppin in because that's upon my wishlist aswell. For the time being all I could provide you is a way on how to show you 2 topmost consuming devices each time. Due to the limit with the 2 individuals only. But I think still way better but to show to idling ones while there's some others consuming lots more.

You'll need the custom:declutering-card since otherwise you'll end up with a some 1000-liner YAML. Hope your're familar with that one. And you'll need the custom:state-switch story goes like this:

On the card itself do something such as this:

type: custom:state-switch
default: ______
entity: template
template: >-
  {% set KA = 'sensor.tapo2232045003181_power' %}
  {% set EF = 'sensor.pps_entfeuchter_power' %}
  {% set GT = 'sensor.dect200_11630_0234372_power' %}

  {% set toplist = expand (
    "sensor.tapo2232045003181_power",
    "sensor.pps_entfeuchter_power",
    "sensor.dect200_11630_0234372_power") %}

  {% set toplist = toplist
    | sort(attribute = 'state', reverse = true)
    | map(attribute = 'entity_id')
    | list %}

  {% if ((toplist[0] == KA and toplist[1] == EF) or (toplist[1] == KA and toplist[0] == EF)) %} KA_EF
  {% elif ((toplist[0] == KA and toplist[1] == GT) or (toplist[1] == KA and toplist[0] == GT)) %} KA_GT  

  {% elif ((toplist[0] == EF and toplist[1] == GT) or (toplist[1] == EF and toplist[0] == GT)) %} EF_GT
  {% else %}
    "unknown"
  {% endif %}
states:
  KA_EF:
    type: custom:decluttering-card
    template: multi_power_flow_card_plus_template
    variables:
      - entity_ind1: sensor.tapo2232045003181_power
      - name_ind1: Klimaanlage
      - color_ind1: '#25A661'
      - icon_ind1: hvac
      - entity_ind2: sensor.pps_entfeuchter_power
      - name_ind2: Entfeuchter
      - color_ind2: '#FC6B6B'
      - icon_ind2: water-boiler
  KA_GT:
    type: custom:decluttering-card
    template: multi_power_flow_card_plus_template
    variables:
      - entity_ind1: sensor.tapo2232045003181_power
      - name_ind1: Klimaanlage
      - color_ind1: '#25A661'
      - icon_ind1: hvac
      - entity_ind2: sensor.dect200_11630_0234372_power
      - name_ind2: Gefriertruhe
      - color_ind2: '#22EEDD'
      - icon_ind2: fridge
  EF_GT:
    type: custom:decluttering-card
    template: multi_power_flow_card_plus_template
    variables:
      - entity_ind1: sensor.pps_entfeuchter_power
      - name_ind1: Entfeuchter
      - color_ind1: '#FC6B6B'
      - icon_ind1: water-boiler
      - entity_ind2: sensor.dect200_11630_0234372_power
      - name_ind2: Gefriertruhe
      - color_ind2: '#22EEDD'
      - icon_ind2: fridge

whereas the template in the RAW{} lovelace looks like this:

decluttering_templates:
  multi_power_flow_card_plus_template:
    card:
      type: custom:power-flow-card-plus
      entities:
        home:
          entity: sensor.pv_anlage_consumption_power
          color_icon: solar
        grid:
          icon: mdi:ab-testing
          name: Netzbezug
          entity:
            production: sensor.pv_anlage_grid_power_out
            consumption: sensor.pv_anlage_grid_power_in
        solar:
          icon: mdi:solar-panel-large
          entity: sensor.pv_anlage_photovoltaics_power
        battery:
          name: Speicher
          icon: mdi:battery
          entity:
            consumption: sensor.pv_anlage_battery_power_out
            production: sensor.pv_anlage_battery_power_in
          state_of_charge: sensor.byd_battery_box_premium_hv_state_of_charge
        individual1:
          entity: '[[entity_ind1]]'
          name: '[[name_ind1]]'
          color_icon: true
          display_zero: true
          color: '[[color_ind1]]'
          icon: mdi:[[icon_ind1]]
        individual2:
          entity: '[[entity_ind2]]'
          name: '[[name_ind2]]'
          color_icon: true
          display_zero: true
          color: '[[color_ind2]]'
          icon: mdi:[[icon_ind2]]
        w_decimals: 0
        kw_decimals: 2
        min_flow_rate: 0.75
        max_flow_rate: 6
        watt_threshold: 1000
        clickable_entities: false

It's a hack for sure, and if being more skilled some sections might be possible lots easier. But I'm happy it does work. What it does .. it first takes my known consumers and sorts these by their consumption states. It then compares the toplist[0] most consuming entity against the others. Granted my original is lots longer since I got 8 consuming devices. And sadly the length of the yaml grows aswell because. 1.) the if .. elif section means, compare 1st against 2 others. if you take 4 devices you need to compare first against 3 others, 2nd against 2 others. and so on. For the simple reason that it doesn't matter which one's individual1 or individual2. 2.) you also need the 1 state entry in the states section for each combination.

My power flow card plus is around 75 line of YAML code. 8 consumers means 28 combinations of individual1 plus any other indiviual2 28 75lines of YAML is somewhat massive .. but it works. using the decluttering card it's more 11-12 lines of YAML for each state 28 ..... quite ok.

I wished that the entity-state would allow templating, better said I wished the power flow card plus would allow that if not simply allowing for defining up to 10 consumers and auto-selects the 2 topmost consumers from that list. Would be lots easier.

cobirnm commented 6 months ago

It's a hack for sure, and if being more skilled some sections might be possible lots easier. But I'm happy it does work. What it does .. it first takes my known consu

do you put all of this configuration in the card itself?

flixlix commented 6 months ago

Hey, good news! 📰

Just released this version as alpha: https://github.com/flixlix/power-flow-card-plus/releases/tag/v0.2.0-alpha

It implements up to 4 individual devices. I also plan on making the entities that are displayed, be dynamic in the future. With the almost complete rewrite, this shouldn't take too long. I'll be back, when I have this implemented.

commentsonly commented 6 months ago

Nice one 4 sure.

One comment …. It’ll be nice if you could think about portrait/landscape. For the simple reason I also use these cards on the mobile and making it wider isn’t such a good idea. I would have suggested, co2 footprint and solar being top Grid and house next And then below always 2 of the consumers. This offers the opportunity that the card itself could easily grow from 2, 4 ,6, whatsoever numbers of consumers.

Btw: have you tried my “workaround” using the decluttering card the state-switch? Currently fed uping 8 consumers .. I think I only posted a stripped down version in of the threads on your github.

But I’ll give the alpha a try. And I’m pretty sure you simply copy/paste this new features to the energy-flow-card-plus aswell 😊

Oh and don’t forget some do have more but 1 solar input … I recently had to help one with 2 fronius GEN24 and another smaller Fronius system since all of these got their separate smart meters means It’S not just a summary like the energy dashboard asks for but it would be nice to have multiple photovoltaics inputs as one is allowed to have multiple consumers.

For the long term ……. 4 sure.

Regards Stefan

Von: Luca Félix @.> Gesendet: Sonntag, 14. Januar 2024 23:35 An: flixlix/power-flow-card-plus @.> Cc: commentsonly @.>; Comment @.> Betreff: Re: [flixlix/power-flow-card-plus] [FEATURE REQUEST] Add more individual entities (dynamic?) (Issue #404)

Hey, good news! 📰

Just released this version as alpha: https://github.com/flixlix/power-flow-card-plus/releases/tag/v0.2.0-alpha

It implements up to 4 individual devices. I also plan on making the entities that are displayed, be dynamic in the future. With the almost complete rewrite, this shouldn't take too long. I'll be back, when I have this implemented.

— Reply to this email directly, view it on GitHubhttps://github.com/flixlix/power-flow-card-plus/issues/404#issuecomment-1891094105, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIRUO62AHOVPFIMIGVREAUDYORMPVAVCNFSM6AAAAAA6DVFAI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJRGA4TIMJQGU. You are receiving this because you commented.Message ID: @.**@.>>

dm82m commented 5 months ago

@flixlix thanks for implementing that, quite a great feature! I have one advanced wish: would it be possible to set a "parent" within the individual elements? currently they are all children of Home. What I want to achieve is, that one of the individual nodes can be set up to be a child of individual3 for example:

image