flixlix / power-flow-card-plus

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

[BUG] switch entity not shown as secondary info #583

Closed PulsarFX closed 5 months ago

PulsarFX commented 5 months ago

Previous to 0.2 it was possible to add a switch sensor to the secondary info. This is still possible to do, but the icon is not shown in the circle. Clicking this icon had opened the standard switch dialog for this entity.

old code:

  individual1:
    show_direction: true
    inverted_animation: false
    entity: sensor.steckdose_11_pc_power
    name: PC Büro
    icon: mdi:desktop-classic
    use_metadata: false
    secondary_info:
      entity: switch.steckdose_11_pc
      icon: mdi:electric-switch
    display_zero: true
    display_zero_state: false
clickable_entities: true

grafik

new code:

  individual:
    - entity: sensor.steckdose_11_pc_power
      name: PC Büro
      icon: mdi:desktop-classic
      secondary_info:
        entity: switch.steckdose_11_pc
        icon: mdi:electric-switch
        display_zero: true
        unit_white_space: false
        accept_negative: true
        decimals: 0
      color_value: false
      color_icon: false
      show_direction: false
      use_metadata: false
      display_zero: true
      display_zero_state: true
      calculate_flow_rate: false

grafik

Please make sure all of this applies and check the checkboxes, by writing "X" inside of them.

flixlix commented 5 months ago

hello @PulsarFX this is expected, because the card currently only supports numeric values for secondary info.

A workaround that would solve the issue is adding a template to your secondary sensor in addition to the sensor inside the entity property (this way you can still click inside the secondary info to see more info about your switch):

- entity: sensor.car_charger
  secondary_info:
    entity: switch.car_charger
    template: '{{states(''switch.car_charger'')}}'
    color_value: true
    unit_of_measurement: '%'
    icon: mdi:battery-low
    display_zero: true
    unit_white_space: true
    accept_negative: true
PulsarFX commented 5 months ago

Nice workaround. :-D It's important to have the entity for secondary_info set to the same as the template. Otherwise the details won't open. The modified code from my first post looks like this:

  individual:
    - entity: sensor.steckdose_11_pc_power
      name: PC Büro
      icon: mdi:desktop-classic
      secondary_info:
        entity: switch.steckdose_11_pc
        icon: mdi:electric-switch
        display_zero: true
        unit_white_space: false
        accept_negative: true
        decimals: 0
        template: '{{states(''switch.steckdose_11_pc'')}}'