mattieha / slider-button-card

A button card with integrated slider
MIT License
444 stars 70 forks source link

Option to display power consumption #13

Open bramstroker opened 3 years ago

bramstroker commented 3 years ago

I love this card, awesome job! Replaced all my light controls with this one.

Have one feature request, maybe you could consider implementing. I have power sensors of all my lights and other appliances. It would be nice to display the current consumption (Watt) in the slider-button-card. Introducing two options to control this: power_entity and maybe display_power.

mouth4war commented 3 years ago

This state information can be added to displayed state via an "additional state" option which will prompt for either a template or choose multiple entries from the entity's attributes.

bramstroker commented 3 years ago

@mouth4war would be nice to have some option for additional state. To have some more generic approach and not only for power consumption. however in this issue the power sensor is a different entity than the card entity, so your proposed solution won't work in this case.

Could be something like this maybe in the configuration. additional_state config option with the following possibilities:

entity -> Optional, when not passed the same entity as the card will be assumed state_attribute -> Required, attribute of the entity, or state when you want the state template -> Optional

So for the power sensor the configuration can be:

{
    "additional_state": {
        "entity": "my_power_sensor",
        "state_attribute": "state"
    }
}

Or for you humidity example:

{
    "additional_state": {
        "state_attribute": "humidity"
    }
}

Not sure about the feasibility of this approach. @mattieha, what do you think?

Also issue #84 could be intregrated somehow in this generic implementation

mouth4war commented 3 years ago

Good idea. Just need multiple addition attributes lines.