After talking with a few others via discord this has been sorted out. While my case is turning off and on a home scent diffuser triggered by static pressure differential, this same automation can be used for any scenario where an analog input is required to cycle an output on and off. Once I complete the final install I’ll post my hardware design and practical use case. I’m not too happy with the size of tubing on the differential pressure sensor so I’m looking at alternatives.
Functional description:
Examine analog static pressure differential sensor to determine if HVAC is running with a binary sensor object. As configured in included yaml "If differential pressure is greater than HVAC_running_setpoint, then HVAC is running. Using “HVAC running” binary sensor a script is triggered that WHILE TRUE turn relay on for XX Seconds (HA Adjustable via diffuser_on_setpoint) THEN turn relay off for XX Seconds (HA Adjustable via diffuser_off_setpoint)
Setpoints: (Rename as you see fit, located in the NUMBERS section of the yaml)
-
HVAC_running_setpoint: Used as the trigger to start the automation. Adjustable via HA rather than hard coded to make initial setup easier than multiple reflashes of esp32 device.
-
diffuser_on_setpoint: Used as the duration of the ON action trigger. Configured in seconds. Adjustable via HA.
-
diffuser_off_setpoint: Used as the duration of the OFF action trigger. Configured in seconds. Adjustable via HA.
i2c:
sda: GPIO21
scl: GPIO22
scan: true
frequency: 100kHz
number:
- platform: template
id: diffuser_on_setpoint
name: "Diffuser On Setpoint"
optimistic: true
min_value: 0.0
max_value: 300.0
step: 1.0
initial_value: 30.0
restore_value: true
unit_of_measurement: seconds
- platform: template
id: diffuser_off_setpoint
name: "Diffuser Off Setpoint"
optimistic: true
min_value: 0.0
max_value: 300.0
step: 1.0
initial_value: 30.0
restore_value: true
unit_of_measurement: seconds
- platform: template
id: HVAC_running_setpoint
name: "HVAC Running Setpoint"
optimistic: true
min_value: -10.0
max_value: 10.0
step: 0.001
initial_value: 0.015
restore_value: true
unit_of_measurement: hpa
sensor:
- platform: sdp3x
name: "HVAC Pressure"
address: 0x21
id: filter_pressure
measurement_mode: differential_pressure
update_interval: 5s
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
binary_sensor:
- platform: template
name: "HVAC Running"
id: HVAC_running
lambda: return id(filter_pressure).state > id(HVAC_running_setpoint).state;
on_press:
- script.execute: run_diffuser
script:
- id: run_diffuser
mode: single
then:
- while:
condition:
binary_sensor.is_on: HVAC_running
then:
- switch.turn_on: relay
- delay: !lambda return id(diffuser_on_setpoint).state * 1000;
- switch.turn_off: relay
- delay: !lambda return id(diffuser_off_setpoint).state * 1000;
switch:
- platform: gpio
pin: GPIO16
name: relay
id: relay