artem-sedykh / mini-climate-card

Minimalistic climate card for Home Assistant Lovelace UI
MIT License
262 stars 19 forks source link

Can't get swing mode to go grey when set to VerticalOff #93

Closed chicaneau closed 1 year ago

chicaneau commented 1 year ago

Hey,

so i use the lg smartthings custom component for my climate control for an air conditioner. I don't seem to be able to get the swing mode button to go grey when the swing_mode attribute is set to 'VerticalOff' there isn't a whole lot of documentation on mapping and I'm not even sure i need to use that or not.

I tried messing with style too, but I can't work out what state,entity,value refer to either.

Any ideas appreciated, cheers

  buttons:
    swing_mode:
      type: dropdown
      icon: mdi:approximately-equal
      state:
        attribute: swing_mode
        #mapper: "(state,entity) => (state ? 'on': 'off')"
      #style: >
      #  (value) => (value = 'VerticalOff' ? { color: 'black'} : {})
      active: state => state !== 'off'
      source:
        VerticalOff: 'Off'
        VerticalSwing: 'Vertical Swing'
      change_action: >
        (selected, state, entity) => this.call_service('climate', 'set_swing_mode', { entity_id: entity.entity_id, swing_mode: selected })
regevbr commented 1 year ago

This should work:


buttons:
  swing_mode:
    type: dropdown
    icon: mdi:approximately-equal
    state:
      attribute: swing_mode
      mapper: >
        (state,entity) => (state === 'VerticalOff' ? 'off': 'on')
    source:
      VerticalOff: 'Off'
      VerticalSwing: 'Vertical Swing'
    active: >
      state => state !== 'off'
    change_action: >
      (selected, state, entity) => this.call_service('climate', 'set_swing_mode', { entity_id: entity.entity_id, swing_mode: selected })
chicaneau commented 1 year ago

Sweet! that works perfectly. Thanks so much @regevbr