Update bathroom-fan.yaml

Update: 
 - Faster response to changes from HASS
 - Faster response to PIR detection
 - Few temperature updates sent to HASS
 - Better clamping and control of fan-speed
This commit is contained in:
nc
2025-10-28 19:35:56 +01:00
parent bc61ef6c01
commit 593b6dee25

View File

@@ -151,6 +151,8 @@ sensor:
temperature: temperature:
name: "Temperature" # We only use Temp for information. SHT3x uses it for Relative Humidity name: "Temperature" # We only use Temp for information. SHT3x uses it for Relative Humidity
id: temp id: temp
filters:
- delta: 0.6 # Don't react to every small change
humidity: humidity:
name: "Humidity" name: "Humidity"
id: humid id: humid
@@ -159,7 +161,7 @@ sensor:
min_value: 0.1 min_value: 0.1
max_value: 99.9 max_value: 99.9
ignore_out_of_range: true ignore_out_of_range: true
- delta: 2.0 # Don't react to every small change - delta: 1.0 # Don't react to every small change
on_value: on_value:
then: then:
- script.execute: update_fan - script.execute: update_fan
@@ -185,9 +187,9 @@ script:
// = ((100-25) / (80 - $C$5)) * B8 + (100 - (((100-25) / (80 - $C$5))*80)) // = ((100-25) / (80 - $C$5)) * B8 + (100 - (((100-25) / (80 - $C$5))*80))
float speed = (75/(80-cutoff)) * humidity + (100-((75/ (80-cutoff))*80)); float speed = (75/(80-cutoff)) * humidity + (100-((75/ (80-cutoff))*80));
// Clamp between 25 and 100 // Clamp between 20% and 100% duty-cycle
if( humidity <= cutoff ) if( humidity <= cutoff )
speed = 25; speed = 20;
if( humidity >= 80) if( humidity >= 80)
speed = 100; speed = 100;
@@ -196,7 +198,8 @@ script:
speed = speed / 2; speed = speed / 2;
// Turn the fan on and set the speed, or turn off // Turn the fan on and set the speed, or turn off
if( humidity >= cutoff ) // Test for both cutoff, and minimum speed.
if( humidity >= cutoff && speed >= 10)
{ {
auto call = id(Extractor).turn_on(); auto call = id(Extractor).turn_on();
call.set_speed(speed); call.set_speed(speed);
@@ -223,6 +226,9 @@ switch:
# - switch.turn_on: switch2 # - switch.turn_on: switch2
# turn_off_action: # turn_off_action:
# - switch.turn_on: switch1 # - switch.turn_on: switch1
on_state:
then:
- script.execute: update_fan # Update fan to reflect quiet-mode state
number: number:
- platform: template # Control in Home Assistant to set point where fan should turn off - platform: template # Control in Home Assistant to set point where fan should turn off
@@ -237,3 +243,6 @@ number:
step: 1 step: 1
initial_value: 35 # 35% rel humidity is slightly high as low cutoff initial_value: 35 # 35% rel humidity is slightly high as low cutoff
restore_value: True restore_value: True
on_value:
then:
- script.execute: update_fan # Update fan to reflect new cut-off and range