I have a button that runs a script that turns on a Xiaomi smart fan with specific settings. The button controlling a script and not a device entity (not the fan itself) doesn’t reflect the state of the fan. In short, I would like the button to look active when the fan is running. How can I achieve this? Or the other way around - how to run a device with specific settings without requiring a script? Thanks!
Use a Template Switch
Thanks, I’ll look into it
Template switch worked perfectly, thanks again!
Related question: would it be possible to set the Hold action of this button to show the “more info” pane of the actual fan? The template switch is configured like this:
- platform: template
switches:
lr_fan:
value_template: "{{ is_state('fan.xiaomi_fan', 'on') }}"
turn_on:
service: script.xiaomi_fan_normal_operation
turn_off:
service: fan.turn_off
data:
entity_id: fan.xiaomi_fan
Holding this button now shows the “more info” of the “lr_fan
” entity, obviously. I’d like to have the Hold action display the “more info” pane of “fan.xiaomi_fan
” for additional adjustments.
EDIT: I used the ‘custom:button-card’ card from HACS that allows to set an arbitrary entity for the Hold action.