UI-Lovelace-Minimalist / UI

UI-Lovelace-Minimalist is a "theme" for HomeAssistant
https://ui-lovelace-minimalist.github.io/UI/
Other
1.63k stars 430 forks source link

Please help with Fan colour button code error! #1342

Open drashish87 opened 1 year ago

drashish87 commented 1 year ago

Sorry to open a thread but the old one was closed and solution dint work unfortunately. I have been trying for over 3 days without success in getting Fan card to work properly. I have 4 modes in my fan. Normal , natural, sleep and auto. I want them to be coloured only based on the current mode the fan is working on so that by glancing i know which mode the fan is on currently. I would like to set Normal - blue , natural - yellow, auto - green and sleep purple coloured.

I am trying to recreate my Mushroom fan card with correct code & colour like this

Screenshot 2023-07-28 at 19 19 21

In minimalist UI but unable to get the icons to show colour.

Screenshot 2023-07-28 at 19 18 57

Can someone please advise what I am doing wrong. I have tried this code

  - type: 'custom:button-card'
    template: card_vertical_button
    entity: fan.smart_fan
    name: Normal
    icon: mdi:leaf
    show_last_changed: true
    tap_action:
      action: call-service
      service: fan.set_preset_mode
      service_data:
        entity_id: fan.smart_fan
        preset_mode: normal
    variables:
      ulm_card_vertical_button_state: on
      ulm_card_vertical_button_color: >
        [[[
          if (states['fan.smart_fan'].attributes.preset_mode == 'normal'){
            return 'blue';}
        return 'theme'
        ### 'theme' is the grey color variable in minimalist
        ]]]

Give this error

Screenshot 2023-07-28 at 19 21 16

This code works

- type: 'custom:button-card'
  template: card_vertical_button
  entity: fan.smart_fan
  name: Normal
  icon: mdi:leaf
  show_last_changed: true
  tap_action:
    action: call-service
    service: fan.set_preset_mode
    service_data:
      entity_id: fan.smart_fan
      preset_mode: normal
  variables:
    ulm_card_vertical_button_state: on
    ulm_card_vertical_button_color: >
      [[[
        if (states['fan.smart_fan'].attributes.preset_mode == 'normal'){
          return 'blue';
        }
        return 'theme';
      ]]]

But button is greyed out. I would really appreciate someone can advise on this.

Screenshot 2023-07-28 at 19 28 19
basbruss commented 1 year ago

Hi

does setting work?

variables:
    ulm_card_vertical_button_state: 'normal'
drashish87 commented 1 year ago

Hi

does setting work?

variables:
    ulm_card_vertical_button_state: 'normal'

Thank you for replying I tried your advise, the button still isn't changing colour and is still greyed out :(

drashish87 commented 1 year ago

So this code works great in Mushroom UI

      - type: custom:mushroom-template-card
        primary: Normal
        secondary: ''
        icon: mdi:wind-power-outline
        icon_color: |-
          {% if states['fan.smart_fan'].attributes.preset_mode == 'normal' %}
              blue
            {% else %}
              grey
            {% endif %}
        layout: vertical
        tap_action:
          action: call-service
          service: fan.set_preset_mode
          target:
            entity_id: fan.smart_fan
          data:
            preset_mode: normal

But struggling to replicate in Minimalist UI

This code keeps the icon grey irrespective fan is on or off

variables:
    ulm_card_vertical_button_state: 'normal'
variables:
     ulm_card_vertical_button_state: on
     ulm_card_vertical_button_color: >
       [[[
         if (states['fan.smart_fan'].attributes.preset_mode == 'normal'){
           return 'blue';}
       return 'theme'
       ### 'theme' is the grey color variable in minimalist
       ]]]

Any idea how to make vertical card understand the mode the fan is on and to only change the colour based on the mode active?