2020-11-04 00:31:46 +00:00
|
|
|
{% for airPurifier in airPurifiers %}
|
|
|
|
# {{ airPurifier.name }}
|
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] mode change'
|
2021-02-20 02:20:06 +00:00
|
|
|
id: {{ airPurifier.componentId }}_mode_change
|
2020-11-04 00:31:46 +00:00
|
|
|
trigger:
|
|
|
|
entity_id: input_select.{{ airPurifier.componentId }}_mode
|
|
|
|
platform: state
|
|
|
|
action:
|
|
|
|
service: fan.set_speed
|
|
|
|
data_template:
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
speed: {{ '\'{{ states.input_select.' + airPurifier.componentId + '_mode.state }}\'' }}
|
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] mode changed'
|
2021-02-20 02:20:06 +00:00
|
|
|
id: {{ airPurifier.componentId }}_mode_changed
|
2020-11-04 00:31:46 +00:00
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
action:
|
|
|
|
service: input_select.select_option
|
|
|
|
entity_id: input_select.{{ airPurifier.componentId }}_mode
|
|
|
|
data_template:
|
|
|
|
option: {{ '\'{{ states.' + airPurifier.entityId + '.attributes.speed }}\'' }}
|
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] favorite level change'
|
2021-02-20 02:20:06 +00:00
|
|
|
id: {{ airPurifier.entityId }}_favorite_level
|
2020-11-04 00:31:46 +00:00
|
|
|
trigger:
|
|
|
|
entity_id: input_number.{{ airPurifier.componentId }}_favorite_level
|
|
|
|
platform: state
|
|
|
|
action:
|
|
|
|
service: xiaomi_miio.fan_set_favorite_level
|
|
|
|
data_template:
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_favorite_level.state | int }}\'' }}
|
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] favorite level changed'
|
2021-02-20 02:20:06 +00:00
|
|
|
id: {{ airPurifier.entityId }}_favorite_level_changed
|
2020-11-04 00:31:46 +00:00
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
action:
|
|
|
|
service: input_number.set_value
|
|
|
|
entity_id: input_number.{{ airPurifier.componentId }}_favorite_level
|
|
|
|
data_template:
|
|
|
|
value: {{ '\'{{ states.' + airPurifier.entityId + '.attributes.favorite_level }}\'' }}
|
2021-02-20 02:20:06 +00:00
|
|
|
{% if airPurifier.supports_fan_level %}
|
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] fan level changed'
|
|
|
|
id: {{ airPurifier.entityId }}_fan_level_changed
|
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
action:
|
|
|
|
service: input_number.set_value
|
|
|
|
entity_id: input_number.{{ airPurifier.componentId }}_fan_level
|
|
|
|
data_template:
|
|
|
|
value: {{ '\'{{ states.' + airPurifier.entityId + '.attributes.fan_level }}\'' }}
|
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] fan level change'
|
|
|
|
id: {{ airPurifier.entityId }}_fan_level_change
|
|
|
|
trigger:
|
|
|
|
entity_id: input_number.{{ airPurifier.componentId }}_fan_level
|
|
|
|
platform: state
|
|
|
|
action:
|
|
|
|
service: xiaomi_miio.fan_set_fan_level
|
|
|
|
data_template:
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_fan_level.state | int }}\'' }}
|
|
|
|
{% endif %}
|
2021-02-22 23:38:55 +00:00
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] increase fan speed'
|
2021-02-20 02:20:06 +00:00
|
|
|
id: {{ airPurifier.entityId }}_fan_speed_increase
|
|
|
|
trigger:
|
|
|
|
- platform: numeric_state
|
|
|
|
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
|
2021-02-22 23:38:55 +00:00
|
|
|
above: '12'
|
2021-02-20 02:20:06 +00:00
|
|
|
action:
|
|
|
|
- service: fan.set_speed
|
|
|
|
data:
|
|
|
|
speed: Favorite
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
2021-02-22 23:38:55 +00:00
|
|
|
- repeat:
|
|
|
|
while:
|
|
|
|
- condition: numeric_state
|
|
|
|
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
|
|
|
|
above: '12'
|
|
|
|
sequence:
|
|
|
|
- service: xiaomi_miio.fan_set_favorite_level
|
|
|
|
data_template:
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
level: {{ '\"{{ state_attr(\'' + airPurifier.entityId + '\', \'favorite_level\') | int + 1 }}\"' }}
|
|
|
|
- service: input_number.set_value
|
|
|
|
entity_id: input_number.{{ airPurifier.componentId }}_favorite_level
|
|
|
|
data_template:
|
|
|
|
value: {{ '\'{{ states.' + airPurifier.entityId + '.attributes.favorite_level }}\'' }}
|
|
|
|
- delay:
|
|
|
|
minutes: 1
|
|
|
|
- alias: '[{{ airPurifier.name }} Air Purifier] decrease fan speed'
|
2021-02-20 02:20:06 +00:00
|
|
|
id: {{ airPurifier.entityId }}_fan_speed_decrease
|
|
|
|
trigger:
|
|
|
|
- platform: numeric_state
|
|
|
|
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
|
|
|
|
below: '10'
|
|
|
|
action:
|
|
|
|
- service: fan.set_speed
|
|
|
|
data:
|
|
|
|
speed: Favorite
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
2021-02-22 23:38:55 +00:00
|
|
|
- repeat:
|
|
|
|
while:
|
|
|
|
- condition: numeric_state
|
|
|
|
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
|
|
|
|
below: '10'
|
|
|
|
sequence:
|
|
|
|
- service: xiaomi_miio.fan_set_favorite_level
|
|
|
|
data_template:
|
|
|
|
entity_id: {{ airPurifier.entityId }}
|
|
|
|
level: {{ '\"{{ state_attr(\'' + airPurifier.entityId + '\', \'favorite_level\') | int - 1 }}\"' }}
|
|
|
|
- service: input_number.set_value
|
|
|
|
entity_id: input_number.{{ airPurifier.componentId }}_favorite_level
|
|
|
|
data_template:
|
|
|
|
value: {{ '\'{{ states.' + airPurifier.entityId + '.attributes.favorite_level }}\'' }}
|
|
|
|
- delay:
|
|
|
|
minutes: 1
|
2020-11-04 00:31:46 +00:00
|
|
|
{% endfor %}
|