How Can I add Button to Add control/Switch Operation modes (auto, silent, favorite, idle)

Hi,
I am new to Home assistant
I managed to add Xiaomi Air purifier 2 to HA successfully!!
I am able to ON & OFF the device using Home Assistant UI
I want to add a button(s) to change the Operation Mode of the Xiaomi Air purifier 2 in Home assistant for which I have created Input select options with modes ‘Auto’, ‘Silent’, ‘Favorite’
Now I have the following issues.

  1. I am Not able to trigger the Mode change from any options that are selected in Input select.
    The automation is not able to call the service FAN.SET_SPEED
    As per documentation , I understand we can call the following
    Fan speed. Valid values are ‘Auto’, ‘Silent’, ‘Favorite’ and ‘Idle’
    But am not able to call that service.
  2. Can we have Input select options as radio button or slider instead of a drop-down list?
    Please guide me
    Thanks in advance

Why not?

You should be able to, why aren’t you able to?

Here is my automation code

  • id: ‘1530286583234’
    alias: Test
    trigger:
    • entity_id: input_select.who_cooks
      platform: state
      to: High Speed Mode
      condition: []
      action:
    • data:
      entity_id: fan.xiaomi_air_purifier
      service: fan.set_speed

But am not sure where & how to call the modes ( ‘Auto’, ‘Silent’, ‘Favorite’ and ‘Idle’)

When posting logs or configuration snippets please use code blocks and syntax highlighting.

My automations.yaml

Blockquote

  • id: ‘1530192351578’
    alias: ON Purifier When TV ON ONLY Evening
    trigger:
    • entity_id: switch.tv
      from: ‘off’
      platform: state
      to: ‘on’
      condition:
    • after: ‘18:00:00’
      before: 06:00:00
      condition: time
      action:
    • alias: ‘’
      data:
      entity_id: fan.xiaomi_air_purifier
      service: fan.turn_on
  • id: ‘1530286583234’
    alias: Test
    trigger:
    • entity_id: input_select.who_cooks
      platform: state
      to: High Speed Mode
      condition:
      action:
    • data:
      entity_id: fan.xiaomi_air_purifier
      service: fan.set_speed
      My configuration.yaml

Blockquote
homeassistant:

Name of the location where Home Assistant is running

name: Chaku’s Home Automation

Location required to calculate the time the sun rises and sets

latitude: 13.0833
longitude: 80.2833

Impacts weather/sunrise data (altitude above sea level in meters)

elevation: 9

metric for Metric, imperial for Imperial

unit_system: metric

Pick yours from here: List of tz database time zones - Wikipedia

time_zone: Asia/Kolkata

Customization file

customize: !include customize.yaml

Show links to resources in log and frontend

#introduction:

Enables the frontend

frontend:
mqtt:
broker: core-mosquitto
username: admin
password: admin

switch 01:
platform: mqtt
name: “Hall Light”
command_topic: “cmnd/sonoff00/power”
state_topic: “stat/sonoff00/POWER”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true

switch 02:
platform: mqtt
name: “Walk Way Light”
command_topic: “cmnd/sonoff01/power”
state_topic: “stat/sonoff01/POWER”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true

fan:

Example configuration.yaml entry zhimi.airpurifier.m1

  • platform: xiaomi_miio
    host: 192.168.1.19
    token: 0cbc1f1294290ff7ee51d7667a5a17a9
    name: Xiaomi Air Purifier

panel_iframe:
configurator:
title: Configurator
icon: mdi:wrench
url: http://192.168.1.111:3218

Enables configuration UI

automation: !include automations.yaml
config:

http:

Secrets are defined in the file secrets.yaml

api_password: !secret http_password

Uncomment this if you are using SSL/TLS, running in Docker container, etc.

base_url: example.duckdns.org:8123

Checks for available updates

Note: This component will send some information about your system to

the developers to assist with development of Home Assistant.

For more information, please see:

Explaining the Updater - Home Assistant

updater:

Optional, allows Home Assistant developers to focus on popular components.

include_used_components: true

Discover some devices automatically

discovery:

Allows you to issue voice commands from the frontend in enabled browsers

conversation:

Enables support for tracking state changes over time

history:

View all events in a logbook

logbook:

Enables a map showing the location of tracked devices

map:

Track the sun

sun:

Weather prediction

sensor:

- platform: yr

  • platform: template
    sensors:
    airpurifier_aqi:
    friendly_name: Xiaomi Air Quality Index
    value_template: ‘{{ states.fan.xiaomi_air_purifier.attributes.aqi }}’
    airpurifier_temperature:
    friendly_name: Temperature
    value_template: ‘{{ states.fan.xiaomi_air_purifier.attributes.temperature }}’
    airpurifier_humidity:
    friendly_name: Xiaomi Humidity
    value_template: ‘{{ states.fan.xiaomi_air_purifier.attributes.humidity }}’
    airpurifier_mode:
    friendly_name: Air Purifier Mode
    value_template: ‘{{ states.fan.xiaomi_air_purifier.attributes.mode }}’
    airpurifier_filter_life_remaining:
    friendly_name: Air Purifier Life Remaning
    value_template: ‘{{ states.fan.xiaomi_air_purifier.attributes.filter_life_remaining }}’

Text to speech

tts:

  • platform: google

Cloud

cloud:

#group: !include groups.yaml

Define our dropdown list

input_select:
who_cooks:
name: Air Purifier Mode
options:
- Auto Mode
- Night Mode
- High Speed Mode
initial: Auto Mode
icon: mdi:speedometer

switch 03:
platform: broadlink
host: 192.168.1.2
mac: ‘78:0f:77:00:ac:fa’
timeout: 115
friendly_name: Broadlink Universal Remote
switches:
tv:
friendly_name: “Micromax Tv Power”
command_on:
‘JgBYAAABLpQTExQSEhMTExQSEhMUNhQSEzcSOBM3EzcTNxM3ExMUNhMTEjgUERQSEzcUEhITExMTNxMTEjgSOBITEzcTNxM4EgAFJgABL0kUAAxgAAEuSxQADQU=’
command_off:
‘JgBYAAABL5QUEhQSExMSExMTFBITNxMTEzcTNxM3EzcUNxI4ExITNxMTFDYTExMTEjgUEhITExMTNxMTEzcUNhQSEjgUNhI4EwAFJQABL0oTAAxhAAEwSRQADQU=’

Here’s an example:

Configuration.yaml

fan:
  - platform: xiaomi_miio
    host: 192.168.178.78
    token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    name: xiaomairpurifier

Automation.yaml

- alias: 'Turn off air purifier when door opens between 7am and 5pm'
  trigger:
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d0001f38b1f
      from: 'off'
      to: 'on'
  condition:
    - condition: time
      before: '17:00:00'
      after: '07:00:00'
  action:
    - service: fan.set_speed
      entity_id: fan.xiaomairpurifier
      data:
        speed: 'idle'

Works like a Charm. Thanks a bunch

Few Questions:

  1. Can we have Input select as Radio Buttons ?
    Now it’s by default its Drop down only
  2. I see you have added binary_sensor.door_window_sensor , which I understand as generic 433Mhz Door sensor.
    How did you manage to add that to Home assistant? Any Tutorial link?
    Thanks in advance
  1. looks like a xiaomi sensor to me (from the default name it has been given).

setup an automation using trigger, platform state, input_select
then you can change fan when input_select changes state

xiaomi zigbee door sensor

Thanks a lot