Hey guys,
I’m pretty new and actually have no clue what I’m doing here. Sound like a good start at least to me.
So I found a automation Script here and “edited” it to my liking (and use).
It looks like that now:
- alias: Set state for air purifier mode input
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: sensor.xiaomi_miio_device
action:
- service: input_select.select_option
data_template:
entity_id: input_select.xiaomi_miio_device
option: '{{ states.fan.xiaomi_miio_device.attributes.mode }}'
- alias: Set state for air purifier favorite level input
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: sensor.xiaomi_miio_device
action:
- service: input_number.set_value
data_template:
entity_id: input_number.xiaomi_miio_device
value: '{{ states.fan.xiaomi_miio_device.favorite_level | int }}'
################################################################################
# Inputs
################################################################################
- alias: Air purifier Mode
trigger:
platform: state
entity_id: input_select.xiaomi_miio_device
action:
- service: fan.set_speed
data_template:
entity_id: fan.xiaomi_miio_device
speed: '{{ states.input_select.xiaomi_miio_device.state }}'
- alias: Air purifier User Mode
trigger:
platform: state
entity_id: input_number.xiaomi_miio_device
action:
- service: fan.xiaomi_miio_device_set_favorite_level
data_template:
entity_id: fan.xiaomi_miio_device
level: '{{ states.input_number.xiaomi_miio_device.state | int }}'
################################################################################
# Automatic control
################################################################################
- alias: Air purifier ausschalten
trigger:
platform: numeric_state
entity_id: fan.xiaomi_miio_device
value_template: "{{ states.fan.xiaomi_miio_device.attributes.aqi | int }}"
below: 20
for: '00:03:00'
condition:
- condition: state
entity_id: 'fan.xiaomi_miio_device'
state: 'on'
action:
- service: fan.turn_off
entity_id: fan.xiaomi_miio_device
- alias: Air purifier Nacht
trigger:
platform: numeric_state
entity_id: fan.xiaomi_miio_device
value_template: "{{ states.fan.xiaomi_miio_device.attributes.aqi | int }}"
above: 100
for: '00:03:00'
condition:
- condition: state
entity_id: 'fan.xiaomi_miio_device'
state: 'on'
action:
- service: fan.turn_on
entity_id: fan.xiaomi_miio_device
- service: fan.speed
entity_id: fan.xiaomi_miio_device
data:
speed: favorite
- alias: Air purifier User
trigger:
platform: numeric_state
entity_id: fan.xiaomi_miio_device
value_template: "{{ states.fan.xiaomi_miio_device.attributes.aqi | int }}"
above: 20
for: '00:03:00'
condition:
- condition: state
entity_id: 'fan.xiaomi_miio_device'
state: 'off'
action:
- service: fan.turn_on
entity_id: fan.xiaomi_miio_device
- service: fan.speed
entity_id: fan.xiaomi_miio_device
data:
speed: silent
#- alias: Set favorite fan speed for air purifier
# trigger:
# platform: time_pattern
# minutes: '/5'
# condition:
# - condition: state
# entity_id: 'fan.xiaomi_miio_device'
# state: 'on'
# action:
# - service: fan.set_speed
# entity_id: fan.xiaomi_miio_device
# data:
# speed: favorite
# - service: fan.xiaomi_miio_device_set_favorite_level
# data_template:
# entity_id: fan.xiaomi_miio_device
# level: >
# {% if states.fan.xiaomi_miio_device.attributes.aqi | int > 30 %}
# 15
# {% elif states.fan.xiaomi_miio_device.attributes.aqi | int > 25 %}
# 10
# {% elif states.fan.xiaomi_miio_device.attributes.aqi | int > 20 %}
# 5
# {% elif states.fan.xiaomi_miio_device.attributes.aqi | int > 15 %}
# 3
# {% elif states.fan.xiaomi_miio_device.attributes.aqi | int > 10 %}
# 1
# {% else %}
# 0
# {% endif %}
# - service: input_select.select_option
# data_template:
# entity_id: input_select.xiaomi_miio_device_mode_airpurifier
# option: '{{ states.fan.xiaomi_miio_device.attributes.mode }}'
# - service: input_number.set_value
# data_template:
# entity_id: input_number.xiaomi_miio_device_favorite_level_airpurifier
# value: '{{ states.fan.xiaomi_miio_device.attributes.favorite_level }}'
But I get this error on startup (altough it looks like it is working anyway):
2019-05-27 18:52:47 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.set_state_for_air_purifier_mode_input. Service not found for call_service at pos 1: (ServiceNotFound(...), 'Service input_select.select_option not found')
I just wanna make sure I actually understand kinda what the definitions there are since I will need some more Automations… So is there anything wrong in my part?