I have a blueprint that is switching on/off a entity(FAN) based on two humidity sensors data.
I have some situations were I need to block this condition to happen, and I added an input that can be a switch or a input_boolean. What I am trying to do is if any of the entities or input bools are True or On, I want to leave the FAN switch on and not allow the humidity difference to turn it off. It seemed to work with one entity but not with multiple: true. any ideas?
blueprint:
name: Humidity Difference
description: Turn a fan on and off based on the difference between a humidity sensor and a baseline
domain: automation
input:
humidity_sensor:
name: Humidity Sensor
description: A sensor that measures the humidity of the area
selector:
entity:
domain:
- sensor
multiple: false
reference_humidity:
name: Reference Humidity
description: A percentage point value that indicates the baseline humidity if there is no reference sensor available
default: 60
reference_humidity_sensor:
name: Reference Humidity Sensor
description: A sensor that indicates the baseline humidity of the location
selector:
entity:
domain:
- sensor
multiple: false
default: []
fan_switch:
name: Fan Switch
description: A switch that turns the fan on and off
selector:
entity:
domain:
- switch
multiple: false
blocking_entities:
name: Blocking entities
description: Switches or booleans that block the fan from turning off (optional)
selector:
entity:
domain:
- switch
- input_boolean
multiple: true
default: []
rising_threshold:
name: Rising Threshold
description: How many percentage points above the reference humidity the sensor can rise before the fan is turned on
selector:
number:
min: 0.0
max: 100.0
step: 1.0
mode: slider
default: 8
falling_threshold:
name: Falling Threshold
description: How many percentage points above the reference humidity the sensor must fall to before the fan is turned off
selector:
number:
min: 0.0
max: 100.0
step: 1.0
mode: slider
default: 3
trigger:
- entity_id: !input humidity_sensor
platform: state
- entity_id: !input reference_humidity_sensor
platform: state
condition: []
action:
- service: switch.turn_{{ mode }}
entity_id: !input fan_switch
variables:
reference_humidity: !input reference_humidity
humidity_sensor: !input humidity_sensor
reference_humidity_sensor: !input reference_humidity_sensor
fan_switch: !input fan_switch
blocking_entities: !input blocking_entities
blocking_entities_state: >
{% set result = False %}
{% for switch in blocking_entities %}
{% if states(switch) == 'on' %}
{% set result = True %}
{% break %}
{% endif %}
{% endfor %}
{{ result }}
switch_state: '{{ states(fan_switch) }}'
rising_threshold: !input rising_threshold
falling_threshold: !input falling_threshold
difference: '{{ states(humidity_sensor)|float - (states(reference_humidity_sensor)|float or reference_humidity|float) }}'
mode: >
{% if blocking_entities_state %}
on
{% elif switch_state == 'off' and difference|float > rising_threshold|float %}
on
{% elif switch_state == 'on' and difference|float < falling_threshold|float %}
off
{% else %}
on
{% endif %}
mode: single