I had an automation using an Aqara temperature and humidity sensor that was based on advice here and was working fine and I tried switching to a Xiaomi BLE sensor and it isn’t working, probably because of an error on my part.
Before:
- id: '1613789175774'
alias: Turn Master Bath Fan Off When Humidity Becomes Low
description: Turn fan off when bathroom humidity lowers to within 20% of the h
humidity
trigger:
- platform: numeric_state
entity_id: sensor.aqara_th_mb_humidity
value_template: '{{state.state|float - 20}}'
below: sensor.bedrooms_hallway_humidity
condition: []
action:
- type: turn_off
device_id: 0019e6842bfcb803464247eb3ffb6792
entity_id: switch.treatlife6
domain: switch
mode: single
where the entity sensor.aqara_th_mb_humidity had the following attributes:
state_class: measurement
battery: 99
humidity: 51.71
linkquality: 29
pressure: 1005.1
temperature: 21.32
voltage: 2975
unit_of_measurement: '%'
device_class: humidity
friendly_name: Aqara TH MB humidity
After:
The BLE sensor entity sensor.trial_A4C138BEFF87_humidity has the attributes
Humidity: 50
GPIO_PA5: 'OFF'
Triggered_by_Humidity: 'OFF'
Triggered_by_Temperature: 'ON'
Time: '2022-03-17T16:47:27'
Temperature: 21.6
GPIO_PA6: 'ON'
DewPoint: 10.4117
MAC: A4C138BEFF87
Flag: 5
Model: ATCpvvx
Battery_Voltage: 2.973
Alias: trial_A4C138BEFF87
Count: 197
RSSI: -80
Battery: 90
unit_of_measurement: '%'
device_class: humidity
friendly_name: trial_A4C138BEFF87 Humidity
But a simple text substitution in the automation as below did not achieve the desired result
- id: '1613789175774'
alias: Turn Master Bath Fan Off When Humidity Becomes Low
description: Turn fan off when bathroom humidity lowers to within 20% of the h
humidity
trigger:
- platform: numeric_state
entity_id: sensor.trial_atcbeff87_humidity
value_template: '{{state.state|float - 20}}'
below: sensor.bedrooms_hallway_humidity
condition: []
action:
- type: turn_off
device_id: 0019e6842bfcb803464247eb3ffb6792
entity_id: switch.treatlife6
domain: switch
mode: single
Finally, the entity sensor.bedrooms_hallway_humidity has the attributes
state_class: measurement
unit_of_measurement: '%'
device_class: humidity
friendly_name: Bedrooms Hallway Humidity
Since no errors were thrown up, I’m at a loss for figuring out what I did wrong that is causing the fan to not turn off when humidity goes down
Thanks