Buttons¶
You can add various buttons, supported types: button and dropdown
buttons functions¶
| Name | Type | execution context | arguments | return type |
|---|---|---|---|---|
state:mapper |
function | button config | state, entity, climate_entity, hvac_mode | any |
source:__filter |
function | button config | source, state, entity, climate_entity, hvac_mode | object({ id..., name... }) array |
active |
function | button config | value, entity, climate_entity, hvac_mode | boolean |
disabled |
function | button config | value, entity, climate_entity, hvac_mode | boolean |
style |
function | button config | value, entity, climate_entity, hvac_mode | object |
toggle_action |
function | button config | state, entity, climate_entity, hvac_mode | promise |
change_action |
function | button config | selected_value, entity, climate_entity, hvac_mode | promise |
hide |
function | button config | state, entity, climate_entity, hvac_mode | boolean |
state - current button state value
entity - button entity
climate_entity - climate entity
hvac_mode - current hvac_mode
source - dropdown source object array: [ { id: 'id', name: 'name' }, ... ]
selected_value - selected dropdown value
execution context methods:
| Name | arguments | description | return type |
|---|---|---|---|
toggle_state |
sate | toggle state, example: this.toggle_state('on') => off |
string |
call_service |
domain, service, options, | call Home Assistant service | promise |
dropdown¶
Consider an example swing_mode configuration:
type: custom:mini-climate
entity: climate.my_ac
buttons:
swing_mode:
type: dropdown
icon: mdi:approximately-equal
state:
attribute: swing_mode
active: state => state !== 'off'
source:
'off': Off
horizontal: On
change_action: >
(selected, state, entity) => this.call_service('climate', 'set_swing_mode', { entity_id: entity.entity_id, swing_mode: selected })
button¶
Consider the example of adding buttons:
type: custom:mini-climate
entity: climate.my_ac
buttons:
turbo:
icon: mdi:weather-hurricane
hide: >
(state, entity) => !entity.attributes.turbo_al
state:
attribute: turbo
mapper: "state => (state ? 'on': 'off')"
disabled: (state, entity) => !entity.attributes.turbo_al
toggle_action: >
(state) => this.call_service('mqtt', 'publish', { payload: this.toggle_state(state), topic: 'my_ac/turbo/set', retain: false, qos: 1 })