Add fan per thermostat functionlity.

This commit is contained in:
2021-11-30 17:59:04 -08:00
parent 16231f148d
commit 12724c9695
3 changed files with 268 additions and 149 deletions

View File

@@ -1,37 +1,52 @@
substitutions: substitutions:
duct_fan_pin: GPIO14 duct_fan_pin: GPIO14
duct_fan_id: duct_fan_id duct_fan_spd_name: Prj3 Duct Fan Speed
duct_fan_pwmfreq: 5000Hz duct_fan_spd_target_in_name: Prj3 Duct Fan Target Speed In
duct_fan_spd_id: duct_fan_spd_id duct_fan_spd_target_out_name: Prj3 Duct Fan Target Speed Out
duct_fan_spd_name: pj_3_duct_fan_spd duct_fan_pwmfreq: 5000Hz
# heat_pin: GPIO19 duct_fan_off_spd: "0.0"
# heat_name: "Denon Pwr" duct_fan_lo_spd: "10.0"
duct_fan_hi_spd: "100.0"
prjpwr_pin: GPIO19
prjpwr_name: Prj3 Pwr
dallas_pin: GPIO32 dallas_pin: GPIO32
dallas_1_addr: "0x1F3C01D0756F0928" dallas_in_addr: "0x1F3C01D0756F0928"
dallas_1_name: pj_3_temp_cold dallas_in_name: Prj3 Temp In
dallas_2_addr: "0x873C01D0756D4B28" dallas_prj_addr: "0x873C01D0756D4B28"
dallas_2_name: pj_3_temp_prj_exh dallas_prj_name: Prj3 Temp Prj
dallas_3_addr: "0xA901143295610E28" dallas_out_addr: "0xA901143295610E28"
dallas_3_name: pj_3_temp_box_exh dallas_out_name: Prj3 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: esphome:
name: pj_3 name: prj3
platform: ESP32 platform: ESP32
board: esp32doit-devkit-v1 board: esp32doit-devkit-v1
wifi: wifi:
ssid: "kungle-oss" ssid: "kungle-oss"
password: "hcfU8@gG&8Hm" password: "hcfU8@gG&8Hm"
fast_connect: true fast_connect: true
manual_ip: manual_ip:
static_ip: 192.168.35.192 static_ip: 192.168.35.192
gateway: 192.168.35.1 gateway: 192.168.35.1
subnet: 255.255.255.0 subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails # Enable fallback hotspot (captive portal) in case wifi connection fails
ap: ap:
ssid: "Projector 3 Fallback Hotspot" ssid: "Prj3 Fallback Hotspot"
password: "xfPfYSP3N0C3" password: "xfPfYSP3N0C3"
captive_portal: captive_portal:
@@ -44,63 +59,116 @@ api:
ota: ota:
switch:
- platform: template
name: Thermostat On
id: thermostat_on_id
optimistic: true
output: output:
- platform: ledc - platform: ledc
pin: ${duct_fan_pin} pin: ${duct_fan_pin}
id: ${duct_fan_id} id: duct_fan_output_id
frequency: ${duct_fan_pwmfreq} frequency: ${duct_fan_pwmfreq}
fan: fan:
- platform: speed - platform: speed
id: ${duct_fan_spd_id} id: duct_fan_spd_id
output: ${duct_fan_id} output: duct_fan_output_id
name: ${duct_fan_spd_name} name: ${duct_fan_spd_name}
# speed:
# low: 0.2
# medium: 0.6
# high: 1.0
dallas: dallas:
- pin: - pin:
number: ${dallas_pin} number: ${dallas_pin}
mode: INPUT_PULLUP mode: INPUT_PULLUP
update_interval: 10s update_interval: ${dallas_update_interval}
sensor: sensor:
- platform: dallas - platform: dallas
address: ${dallas_1_addr} address: ${dallas_in_addr}
name: ${dallas_1_name} name: ${dallas_in_name}
id: dallas_in_id
- platform: dallas - platform: dallas
address: ${dallas_2_addr} address: ${dallas_prj_addr}
name: ${dallas_2_name} name: ${dallas_prj_name}
id: dallas_prj_id
- platform: dallas - platform: dallas
address: ${dallas_3_addr} address: ${dallas_out_addr}
name: ${dallas_3_name} name: ${dallas_out_name}
id: dallas_out_id
# # Sense when receiver is turned on number:
# binary_sensor: - platform: template
# - platform: gpio id: duct_fan_spd_target_in
# pin: ${heat_pin} name: ${duct_fan_spd_target_in_name}
# name: ${heat_name} optimistic: true
# device_class: power min_value: ${duct_fan_lo_spd}
# # on_press: max_value: ${duct_fan_hi_spd}
# # then: step: 1
# # - if: - platform: template
# # condition: id: duct_fan_spd_target_out
# # lambda: 'return id(${duct_fan_spd_id}).state == "OFF";' name: ${duct_fan_spd_target_out_name}
# # then: min_value: ${duct_fan_off_spd}
# # - logger.log: "${duct_fan_spd_name} was off. Turning on as ${heat_name} turned on." max_value: ${duct_fan_hi_spd}
# # - fan.turn_on: step: 1
# # id: ${duct_fan_spd_id} set_action:
# # speed: LOW then:
# # else: lambda: |-
# # - logger.log: "${heat_name} turned on, but not turning on ${duct_fan_spd_name} as already on." 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;
# # on_release: # Dual-point thermostat
# # then: climate:
# # - fan.turn_on: - platform: thermostat
# # id: ${duct_fan_spd_id} id: thermostat_out_id
# # speed: LOW name: Prj3 Out
sensor: dallas_prj_id
visual:
min_temperature: 60 °F
max_temperature: 160 °F
temperature_step: 1
default_mode: auto
default_target_temperature_low: 75 °F
default_target_temperature_high: 160 °F
min_cooling_off_time: 60s
min_cooling_run_time: 60s
min_heating_off_time: 60s
min_heating_run_time: 60s
min_idle_time: 60s
heat_action:
- logger.log: "Turning off Prj3 Thermostat"
- switch.turn_off: thermostat_on_id
idle_action:
- logger.log: "Turning on Prj3 Thermostat"
- switch.turn_on: thermostat_on_id
cool_action:
- logger.log: "WARNING: Prj3 Thermostat has hit high temp!"
- switch.turn_on: thermostat_on_id
#TODO - provide some kind of warning / action here
# # - lambda: |- # Sense when projector is turned on
# # if (id(${duct_fan_spd_id}).is_off) { binary_sensor:
- platform: gpio
pin: ${prjpwr_pin}
name: ${prjpwr_name}
device_class: power

View File

@@ -1,8 +1,13 @@
substitutions: substitutions:
duct_fan_pin: GPIO13 duct_fan_pin: GPIO13
duct_fan_name: Rack 2 Duct Fan Speed 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_channel: "0"
duct_fan_pwmfreq: 5000Hz 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_pin: GPIO21
wall_fan_pwr_name: Rack 2 Wall Fan Power wall_fan_pwr_name: Rack 2 Wall Fan Power
wall_fan_spd_pin: GPIO22 wall_fan_spd_pin: GPIO22
@@ -14,9 +19,21 @@ substitutions:
wall_fan_tach_name: Rack 2 Wall Fan Tach wall_fan_tach_name: Rack 2 Wall Fan Tach
dallas_pin: GPIO32 dallas_pin: GPIO32
dallas_in_addr: "0x1D02131D6063AA28" dallas_in_addr: "0x1D02131D6063AA28"
dallas_in_name: Rack 3 Temp In dallas_in_name: Rack 2 Temp In
dallas_out_addr: "0x1D01143296570128" 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: esphome:
name: rack_2 name: rack_2
@@ -39,10 +56,23 @@ wifi:
captive_portal: captive_portal:
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
ota:
switch: switch:
- platform: gpio - platform: gpio
pin: ${wall_fan_pwr_pin} pin: ${wall_fan_pwr_pin}
name: ${wall_fan_pwr_name} name: ${wall_fan_pwr_name}
- platform: template
name: Thermostat On
id: thermostat_on_id
optimistic: true
output: output:
- platform: ledc - platform: ledc
@@ -69,7 +99,7 @@ dallas:
- pin: - pin:
number: ${dallas_pin} number: ${dallas_pin}
mode: INPUT_PULLUP mode: INPUT_PULLUP
update_interval: 10s update_interval: ${dallas_update_interval}
sensor: sensor:
- platform: pulse_counter - platform: pulse_counter
@@ -88,49 +118,51 @@ sensor:
address: ${dallas_out_addr} address: ${dallas_out_addr}
name: ${dallas_out_name} name: ${dallas_out_name}
id: dallas_out_id 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: number:
- platform: template - platform: template
id: duct_fan_speed_target_in id: duct_fan_spd_target_in
name: Duct Fan Speed Target In name: ${duct_fan_spd_target_in_name}
optimistic: true optimistic: true
min_value: 0 min_value: ${duct_fan_lo_spd}
max_value: 100 max_value: ${duct_fan_hi_spd}
step: 1 step: 1
- platform: template - platform: template
id: duct_fan_speed_target_out id: duct_fan_spd_target_out
name: Duct Fan Speed Target Out name: ${duct_fan_spd_target_out_name}
optimistic: true min_value: ${duct_fan_off_spd}
min_value: 0 max_value: ${duct_fan_hi_spd}
max_value: 100
step: 1 step: 1
on_value_range: set_action:
above: 25.0
then: then:
fan.turn_on: lambda: |-
id: duct_fan_spd_id float lo;
speed: !lambda |- float hi;
return x; 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 # Dual-point thermostat
climate: climate:
- platform: thermostat - platform: thermostat
id: thermostat_rack2_out id: thermostat_out_id
name: Rack2 Out name: Rack2 Out
sensor: dallas_out_id sensor: dallas_out_id
visual: visual:
@@ -147,19 +179,12 @@ climate:
min_idle_time: 60s min_idle_time: 60s
heat_action: heat_action:
- logger.log: "Turning off Rack2 Thermostat" - logger.log: "Turning off Rack2 Thermostat"
- fan.turn_off: - switch.turn_off: thermostat_on_id
id: duct_fan_spd_id
idle_action: idle_action:
- logger.log: "Turning on Rack2 Thermostat" - logger.log: "Turning on Rack2 Thermostat"
- switch.turn_on: thermostat_on_id
cool_action: cool_action:
- logger.log: "WARNING: Rack2 Thermostat has hit high temp!" - logger.log: "WARNING: Rack2 Thermostat has hit high temp!"
- switch.turn_on: thermostat_on_id
#TODO - provide some kind of warning / action here #TODO - provide some kind of warning / action here
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
ota:

View File

@@ -1,7 +1,12 @@
substitutions: substitutions:
duct_fan_pin: GPIO13 duct_fan_pin: GPIO13
duct_fan_name: Rack 3 Duct Fan Speed
duct_fan_spd_target_in_name: Rack 3 Duct Fan Target Speed In
duct_fan_spd_target_out_name: Rack 3 Duct Fan Target Speed Out
duct_fan_pwmfreq: 5000Hz duct_fan_pwmfreq: 5000Hz
duct_fan_spd_name: rack_3_duct_fan_spd duct_fan_off_spd: "0.0"
duct_fan_lo_spd: "10.0"
duct_fan_hi_spd: "100.0"
amppwr_pin: GPIO19 amppwr_pin: GPIO19
amppwr_name: "Denon Pwr" amppwr_name: "Denon Pwr"
dallas_pin: GPIO32 dallas_pin: GPIO32
@@ -9,6 +14,18 @@ substitutions:
dallas_in_name: Rack 3 Temp In dallas_in_name: Rack 3 Temp In
dallas_out_addr: "0xB801143296ED7B28" dallas_out_addr: "0xB801143296ED7B28"
dallas_out_name: Rack 3 Temp Out dallas_out_name: Rack 3 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: esphome:
name: rack_3 name: rack_3
@@ -31,6 +48,20 @@ wifi:
captive_portal: captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
switch:
- platform: template
name: Thermostat On
id: thermostat_on_id
optimistic: true
output: output:
- platform: ledc - platform: ledc
pin: ${duct_fan_pin} pin: ${duct_fan_pin}
@@ -41,13 +72,13 @@ fan:
- platform: speed - platform: speed
id: duct_fan_spd_id id: duct_fan_spd_id
output: duct_fan_output_id output: duct_fan_output_id
name: ${duct_fan_spd_name} name: ${duct_fan_name}
dallas: dallas:
- pin: - pin:
number: ${dallas_pin} number: ${dallas_pin}
mode: INPUT_PULLUP mode: INPUT_PULLUP
update_interval: 10s update_interval: ${dallas_update_interval}
sensor: sensor:
- platform: dallas - platform: dallas
@@ -57,49 +88,51 @@ sensor:
address: ${dallas_out_addr} address: ${dallas_out_addr}
name: ${dallas_out_name} name: ${dallas_out_name}
id: dallas_out_id id: dallas_out_id
on_value:
then:
number.set:
id: fan_speed_target_out
value: !lambda |-
float lo;
float hi;
lo = id(thermostat_rack3_out).target_temperature_low;
hi = id(thermostat_rack3_out).target_temperature_high;
if (x < lo) {
return 0.0;
}
if (x > hi) {
return 100.0;
}
return 100 * (x - lo) / (hi - lo);
number: number:
- platform: template - platform: template
id: fan_speed_target_in id: duct_fan_spd_target_in_id
name: Fan Speed Target In name: ${duct_fan_spd_target_in_name}
optimistic: true optimistic: true
min_value: 0 min_value: ${duct_fan_lo_spd}
max_value: 100 max_value: ${duct_fan_hi_spd}
step: 1 step: 1
- platform: template - platform: template
id: fan_speed_target_out id: duct_fan_spd_target_out_id
name: Fan Speed Target Out name: ${duct_fan_spd_target_out_name}
optimistic: true min_value: ${duct_fan_lo_spd}
min_value: 0 max_value: ${duct_fan_hi_spd}
max_value: 100
step: 1 step: 1
on_value_range: set_action:
above: 25.0
then: then:
fan.turn_on: lambda: |-
id: duct_fan_spd_id float lo;
speed: !lambda |- float hi;
return x; 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 # Dual-point thermostat
climate: climate:
- platform: thermostat - platform: thermostat
id: thermostat_rack3_out id: thermostat_out_id
name: Rack3 Out name: Rack3 Out
sensor: dallas_out_id sensor: dallas_out_id
visual: visual:
@@ -116,12 +149,13 @@ climate:
min_idle_time: 60s min_idle_time: 60s
heat_action: heat_action:
- logger.log: "Turning off Rack3 Thermostat" - logger.log: "Turning off Rack3 Thermostat"
- fan.turn_off: - switch.turn_off: thermostat_on_id
id: duct_fan_spd_id
idle_action: idle_action:
- logger.log: "Turning on Rack3 Thermostat" - logger.log: "Turning on Rack3 Thermostat"
- switch.turn_on: thermostat_on_id
cool_action: cool_action:
- logger.log: "WARNING: Rack3 Thermostat has hit high temp!" - logger.log: "WARNING: Rack3 Thermostat has hit high temp!"
- switch.turn_on: thermostat_on_id
#TODO - provide some kind of warning / action here #TODO - provide some kind of warning / action here
# Sense when receiver is turned on # Sense when receiver is turned on
@@ -130,11 +164,3 @@ binary_sensor:
pin: ${amppwr_pin} pin: ${amppwr_pin}
name: ${amppwr_name} name: ${amppwr_name}
device_class: power device_class: power
# Enable logging
logger:
# Enable Home Assistant API
api:
ota: