DBuit / Homekit-panel-card

Homekit panel card for home assistant
MIT License
304 stars 54 forks source link

Request: State-based icons? #7

Closed millercentral closed 4 years ago

millercentral commented 4 years ago

Just got this working, and love it, thank you for the effort here! Question, can the icon be customized based on the entity state? So, for a lock, show mdi:lock when locked and mdi:lock-open-variant when unlocked, or for a garage cover, mdi:garage / mdi:garage-open, etc. Right now, it changes the icon color like a light for unlocked/open.

DBuit commented 4 years ago

Hey man, I just releaded V0.2.1 and i added the offIcon in configuration. so you can set a icon that is shown in the off state and the icon configuration is for the on state.

It will still change colors but it is a start.

stephannjo commented 4 years ago

Hey, didn't get the offIcon to work with - custom: plug. Does this support the offIcon as well?

millercentral commented 4 years ago

Update: I was able to make this work - thanks for the quick turnaround!

DBuit commented 4 years ago

@stephannjo are you using the last version of the card? can you share your configuration?

millercentral commented 4 years ago

Yes, I updated with HACS and then updated my lovelace-ui code:

  - badges: []
    cards:
      - entities:
          - entities:
              - entity: light.upstairs_landing
              - entity: light.main_floor_stairs
              - entity: light.master_bedroom
              - entity: light.master_bedroom_hallway
              - entity: switch.master_bedroom_closet
                icon: 'mdi:lightbulb'
              - entity: light.master_bath
              - entity: light.master_bath_sinks
              - entity: light.master_bath_shower
            title: Upstairs
          - entities:
              - entity: lock.kitchen_door_lock
                icon: 'mdi:lock-open-variant'
                offIcon: 'mdi:lock'
                offStates:
                  - locked
              - entity: light.dining_room
              - entity: light.living_room_lights
            title: Main Floor
          - entities:
              - entity: cover.garage_door
                icon: 'mdi:garage-open'
                offIcon: 'mdi:garage'
                offStates:
                  - closed
              - entity: light.front_porch_fixture_2
              - entity: light.front_porch_left_2
              - entity: light.front_porch_right_2
              - entity: switch.basement_side_porch
                icon: 'mdi:lightbulb'
            title: Outside
        type: 'custom:homekit-card'
        horizontalScroll: true

As DBuit says, the color still changes, but the icon is right which is nice for glancing.

stephannjo commented 4 years ago

Hi @DBuit : I updated the version and it seems to work except for custom buttons. Please find my config as a sample. I will try to use the switch as entity, which should work, but it won't as soon as I trigger a scene. Do you think it might be possible to add this for custom - buttons in optimistic mode?

          - custom: steckdose1
            name: Steckdose
            state: switch.bf29ab075b577eea23ylhe
            icon: mdi:power-plug
            offIcon: mdi:power-plug-off
            tap_action: 
              action: toggle
              entity: switch.bf29ab075b577eea23ylhe
DBuit commented 4 years ago

@stephannjo custom doesn't react to an state of an entity so it has no on or off state it can be used to make custom tiles with actions but it will never be off. i use it to make navigation buttons to go to other pages for example.

But i think you can just use the default way and do i like this:

- entity: switch.bf29ab075b577eea23ylhe
   name: Steckdose
   icon: mdi:power-plug
   offIcon: mdi:power-plug-off
   tap_action: 
     action: toggle
     entity: switch.bf29ab075b577eea23ylhe

And because it is an switch it can already be toggle by tapping it so you just use this:

- entity: switch.bf29ab075b577eea23ylhe
   name: Steckdose
   icon: mdi:power-plug
   offIcon: mdi:power-plug-off
DBuit commented 4 years ago

@stephannjo did this work for you as you wanted?

stephannjo commented 4 years ago

Yes works for me. Thanks again!

DBuit commented 4 years ago

Ok great! than i close this issue :)