artem-sedykh / mini-climate-card

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

Row of buttons for preset modes ? #153

Open cartoristal opened 3 weeks ago

cartoristal commented 3 weeks ago

Hello! First of all : loving this card, it is great. I succcessfully managed to get a button leading to a dropdown to select the preset mode. I am wondering if there is a possibility to get a row of buttons instead ? I can only manage to have one toggle-button, but not multiple buttons (one for each preset mode).

Thanks !

type: custom:mini-climate 
entity: climate.pass_actuator_3
temperature:
  unit: °C
  round: 1
  source:
    entity: sensor.indoor_outdoor_meter_36c7
buttons:
  preset_mode:
    type: dropdown
    location: main
    icon: mdi:thermometer
    state:
      attribute: preset_mode
    active: state => state == 'comfort'
    source:
      frost_protection: frost_protection
      comfort: comfort
      comfort-1: comfort-1
    change_action: >
      (selected, state, entity) => this.call_service('climate',
      'set_preset_mode', { entity_id: entity.entity_id, preset_mode: selected })
regevbr commented 3 weeks ago

Here is an example:

image

type: custom:mini-climate
entity: climate.living_room
toggle:
  default: true
buttons:
  cool:
    icon: mdi:snowflake
    state:
      mapper: |
        (state) => state === 'cool' ? 'on' : 'off'
    toggle_action: >
      (state, entity) => this.call_service('climate', 'set_preset_mode', {
      entity_id: entity.entity_id, preset_mode: 'cool' })
  heat:
    icon: mdi:weather-sunny-alert
    state:
      mapper: |
        (state) => state === 'heat' ? 'on' : 'off'
    toggle_action: >
      (state, entity) => this.call_service('climate', 'set_preset_mode', {
      entity_id: entity.entity_id, preset_mode: 'heat' })
cartoristal commented 3 weeks ago

Amazing ! Thank you so much for taking the time : it works like a charm 👍

Still trying to figure out how to add the name of the currently selected preset (eco, frost_protection, comfort-2, comfort-1, comfort...) in an indicator. If you know how to do it - super interested in your thoughts. Otherwise, will keep looking and come back here with the solution