1
0

Add automations for air purifiers

This commit is contained in:
pgrondek 2021-02-23 00:38:55 +01:00
parent 0b8d095327
commit 58a499a263
2 changed files with 36 additions and 14 deletions

View File

@ -62,36 +62,58 @@
entity_id: {{ airPurifier.entityId }} entity_id: {{ airPurifier.entityId }}
level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_fan_level.state | int }}\'' }} level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_fan_level.state | int }}\'' }}
{% endif %} {% endif %}
- alias: '[{{ airPurifier.name }} Purifier] increase fan speed' - alias: '[{{ airPurifier.name }} Air Purifier] increase fan speed'
id: {{ airPurifier.entityId }}_fan_speed_increase id: {{ airPurifier.entityId }}_fan_speed_increase
trigger: trigger:
- platform: numeric_state - platform: numeric_state
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25 entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
above: '15' above: '12'
for: 1m
action: action:
- service: fan.set_speed - service: fan.set_speed
data: data:
speed: Favorite speed: Favorite
entity_id: fan.{{ airPurifier.componentId }} entity_id: {{ airPurifier.entityId }}
- repeat:
while:
- condition: numeric_state
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
above: '12'
sequence:
- service: xiaomi_miio.fan_set_favorite_level - service: xiaomi_miio.fan_set_favorite_level
data_template: data_template:
entity_id: {{ airPurifier.entityId }} entity_id: {{ airPurifier.entityId }}
level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_favorite_level.state | int + 1 }}\'' }} level: {{ '\"{{ state_attr(\'' + airPurifier.entityId + '\', \'favorite_level\') | int + 1 }}\"' }}
- alias: '[{{ airPurifier.name }} Purifier] decrease fan speed' - 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'
id: {{ airPurifier.entityId }}_fan_speed_decrease id: {{ airPurifier.entityId }}_fan_speed_decrease
trigger: trigger:
- platform: numeric_state - platform: numeric_state
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25 entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
below: '10' below: '10'
for: 1m
action: action:
- service: fan.set_speed - service: fan.set_speed
data: data:
speed: Favorite speed: Favorite
entity_id: fan.{{ airPurifier.componentId }} entity_id: {{ airPurifier.entityId }}
- repeat:
while:
- condition: numeric_state
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
below: '10'
sequence:
- service: xiaomi_miio.fan_set_favorite_level - service: xiaomi_miio.fan_set_favorite_level
data_template: data_template:
entity_id: {{ airPurifier.entityId }} entity_id: {{ airPurifier.entityId }}
level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_favorite_level.state | int - 1 }}\'' }} 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
{% endfor %} {% endfor %}

View File

@ -17,7 +17,7 @@ lights:
name: Couch lamp name: Couch lamp
airPurifiers: airPurifiers:
- entityId: fan.xiaomi_miio_device - entityId: fan.xiaomi_miio_device
componentId: xiaomi_miio_device componentId: xiaomi_airpurifier
name: Living Room name: Living Room
ip: 192.168.60.6 ip: 192.168.60.6
token: 66e56ff414f359b371b2d0b86e3d37d4 token: 66e56ff414f359b371b2d0b86e3d37d4