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 }}
level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_fan_level.state | int }}\'' }}
{% endif %}
- alias: '[{{ airPurifier.name }} Purifier] increase fan speed'
- alias: '[{{ airPurifier.name }} Air Purifier] increase fan speed'
id: {{ airPurifier.entityId }}_fan_speed_increase
trigger:
- platform: numeric_state
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
above: '15'
for: 1m
above: '12'
action:
- service: fan.set_speed
data:
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
data_template:
entity_id: {{ airPurifier.entityId }}
level: {{ '\'{{ states.input_number.' + airPurifier.componentId + '_favorite_level.state | int + 1 }}\'' }}
- alias: '[{{ airPurifier.name }} Purifier] decrease fan speed'
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'
id: {{ airPurifier.entityId }}_fan_speed_decrease
trigger:
- platform: numeric_state
entity_id: sensor.{{ airPurifier.componentId }}_air_quality_pm25
below: '10'
for: 1m
action:
- service: fan.set_speed
data:
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
data_template:
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 %}

View File

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