Add fan per thermostat functionlity.
This commit is contained in:
115
rack_2.yaml
115
rack_2.yaml
@@ -1,8 +1,13 @@
|
||||
substitutions:
|
||||
duct_fan_pin: GPIO13
|
||||
duct_fan_name: Rack 2 Duct Fan Speed
|
||||
duct_fan_spd_target_in_name: Rack 2 Duct Fan Target Speed In
|
||||
duct_fan_spd_target_out_name: Rack 2 Duct Fan Target Speed Out
|
||||
# duct_fan_channel: "0"
|
||||
duct_fan_pwmfreq: 5000Hz
|
||||
duct_fan_off_spd: "0.0"
|
||||
duct_fan_lo_spd: "10.0"
|
||||
duct_fan_hi_spd: "100.0"
|
||||
wall_fan_pwr_pin: GPIO21
|
||||
wall_fan_pwr_name: Rack 2 Wall Fan Power
|
||||
wall_fan_spd_pin: GPIO22
|
||||
@@ -14,9 +19,21 @@ substitutions:
|
||||
wall_fan_tach_name: Rack 2 Wall Fan Tach
|
||||
dallas_pin: GPIO32
|
||||
dallas_in_addr: "0x1D02131D6063AA28"
|
||||
dallas_in_name: Rack 3 Temp In
|
||||
dallas_in_name: Rack 2 Temp In
|
||||
dallas_out_addr: "0x1D01143296570128"
|
||||
dallas_out_name: Rack 3 Temp Out
|
||||
dallas_out_name: Rack 2 Temp Out
|
||||
dallas_update_interval: 30s
|
||||
|
||||
globals:
|
||||
- id: duct_fan_off_spd
|
||||
type: float
|
||||
initial_value: ${duct_fan_off_spd}
|
||||
- id: duct_fan_lo_spd
|
||||
type: float
|
||||
initial_value: ${duct_fan_lo_spd}
|
||||
- id: duct_fan_hi_spd
|
||||
type: float
|
||||
initial_value: ${duct_fan_hi_spd}
|
||||
|
||||
esphome:
|
||||
name: rack_2
|
||||
@@ -39,10 +56,23 @@ wifi:
|
||||
|
||||
captive_portal:
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
|
||||
ota:
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
pin: ${wall_fan_pwr_pin}
|
||||
name: ${wall_fan_pwr_name}
|
||||
- platform: template
|
||||
name: Thermostat On
|
||||
id: thermostat_on_id
|
||||
optimistic: true
|
||||
|
||||
output:
|
||||
- platform: ledc
|
||||
@@ -69,7 +99,7 @@ dallas:
|
||||
- pin:
|
||||
number: ${dallas_pin}
|
||||
mode: INPUT_PULLUP
|
||||
update_interval: 10s
|
||||
update_interval: ${dallas_update_interval}
|
||||
|
||||
sensor:
|
||||
- platform: pulse_counter
|
||||
@@ -88,49 +118,51 @@ sensor:
|
||||
address: ${dallas_out_addr}
|
||||
name: ${dallas_out_name}
|
||||
id: dallas_out_id
|
||||
on_value:
|
||||
then:
|
||||
number.set:
|
||||
id: duct_fan_speed_target_out
|
||||
value: !lambda |-
|
||||
float lo;
|
||||
float hi;
|
||||
lo = id(thermostat_rack2_out).target_temperature_low;
|
||||
hi = id(thermostat_rack2_out).target_temperature_high;
|
||||
if (x < lo) {
|
||||
return 0.0;
|
||||
}
|
||||
if (x > hi) {
|
||||
return 100.0;
|
||||
}
|
||||
return 100 * (x - lo) / (hi - lo);
|
||||
|
||||
number:
|
||||
- platform: template
|
||||
id: duct_fan_speed_target_in
|
||||
name: Duct Fan Speed Target In
|
||||
id: duct_fan_spd_target_in
|
||||
name: ${duct_fan_spd_target_in_name}
|
||||
optimistic: true
|
||||
min_value: 0
|
||||
max_value: 100
|
||||
min_value: ${duct_fan_lo_spd}
|
||||
max_value: ${duct_fan_hi_spd}
|
||||
step: 1
|
||||
- platform: template
|
||||
id: duct_fan_speed_target_out
|
||||
name: Duct Fan Speed Target Out
|
||||
optimistic: true
|
||||
min_value: 0
|
||||
max_value: 100
|
||||
id: duct_fan_spd_target_out
|
||||
name: ${duct_fan_spd_target_out_name}
|
||||
min_value: ${duct_fan_off_spd}
|
||||
max_value: ${duct_fan_hi_spd}
|
||||
step: 1
|
||||
on_value_range:
|
||||
above: 25.0
|
||||
set_action:
|
||||
then:
|
||||
fan.turn_on:
|
||||
id: duct_fan_spd_id
|
||||
speed: !lambda |-
|
||||
return x;
|
||||
lambda: |-
|
||||
float lo;
|
||||
float hi;
|
||||
float curtemp;
|
||||
float newspd;
|
||||
lo = id(thermostat_out_id).target_temperature_low;
|
||||
hi = id(thermostat_out_id).target_temperature_high;
|
||||
curtemp = id(dallas_out_id).state;
|
||||
if ((curtemp < lo) || (id(thermostat_on_id).state == false)) {
|
||||
auto call = id(duct_fan_spd_id).turn_off();
|
||||
call.perform();
|
||||
return id(duct_fan_off_spd);
|
||||
}
|
||||
if (curtemp > hi) {
|
||||
newspd = id(duct_fan_hi_spd);
|
||||
} else {
|
||||
// Set newspd to same linear proportion of spd range as current temp is of temp range
|
||||
newspd = id(duct_fan_lo_spd) + (id(duct_fan_hi_spd) * (curtemp - lo) / (hi - lo));
|
||||
}
|
||||
auto call = id(duct_fan_spd_id).turn_on();
|
||||
call.set_speed(newspd);
|
||||
call.perform();
|
||||
return newspd;
|
||||
|
||||
# Dual-point thermostat
|
||||
climate:
|
||||
- platform: thermostat
|
||||
id: thermostat_rack2_out
|
||||
id: thermostat_out_id
|
||||
name: Rack2 Out
|
||||
sensor: dallas_out_id
|
||||
visual:
|
||||
@@ -147,19 +179,12 @@ climate:
|
||||
min_idle_time: 60s
|
||||
heat_action:
|
||||
- logger.log: "Turning off Rack2 Thermostat"
|
||||
- fan.turn_off:
|
||||
id: duct_fan_spd_id
|
||||
- switch.turn_off: thermostat_on_id
|
||||
idle_action:
|
||||
- logger.log: "Turning on Rack2 Thermostat"
|
||||
- switch.turn_on: thermostat_on_id
|
||||
cool_action:
|
||||
- logger.log: "WARNING: Rack2 Thermostat has hit high temp!"
|
||||
- switch.turn_on: thermostat_on_id
|
||||
#TODO - provide some kind of warning / action here
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
|
||||
ota:
|
||||
|
||||
Reference in New Issue
Block a user