224 lines
6.4 KiB
YAML
224 lines
6.4 KiB
YAML
substitutions:
|
|
device_name: rack-2
|
|
dn: rack_2
|
|
sn: R2
|
|
friendly_name: Rack 2
|
|
df_attic_pin: GPIO13
|
|
df_attic_name: ${friendly_name} Attic Duct Fan Spd
|
|
df_attic_vent_spd_name: ${sn} DF Vent Spd
|
|
df_attic_tgt_spd_out_name: ${sn} DF Tgt Spd Out
|
|
df_attic_pwmfreq: 5000Hz
|
|
df_attic_off_spd: "0.0"
|
|
df_attic_lo_spd: "1.0"
|
|
df_attic_init_spd: "60.0"
|
|
df_attic_hi_spd: "100.0"
|
|
df_attic_tach_pin: GPIO12
|
|
df_attic_tach_id: df_attic_tach_id
|
|
df_attic_tach_name: ${friendly_name} Attic Duct Fan Tach
|
|
# wall_fan_pwr_pin: GPIO21
|
|
# wall_fan_pwr_name: ${friendly_name} Wall Fan Power
|
|
# wall_fan_spd_pin: GPIO22
|
|
# wall_fan_spd_pwmfreq: 25000Hz
|
|
# wall_fan_spd_name: ${friendly_name} Wall Fan Speed
|
|
# wall_fan_tach_pin: GPIO23
|
|
# wall_fan_tach_id: wall_fan_tach_id
|
|
# wall_fan_tach_name: ${friendly_name} Wall Fan Tach
|
|
dallas_pin: GPIO32
|
|
dallas_in_addr: "0x1D02131D6063AA28"
|
|
dallas_in_name: ${friendly_name} Temp In
|
|
dallas_out_addr: "0x1D01143296570128"
|
|
dallas_out_name: ${friendly_name} Temp Out
|
|
dallas_update_interval: 30s
|
|
|
|
globals:
|
|
- id: df_attic_off_spd_id
|
|
type: float
|
|
initial_value: ${df_attic_off_spd}
|
|
- id: df_attic_lo_spd_id
|
|
type: float
|
|
initial_value: ${df_attic_lo_spd}
|
|
- id: df_attic_hi_spd_id
|
|
type: float
|
|
initial_value: ${df_attic_hi_spd}
|
|
|
|
<<: !include .common.yaml
|
|
<<: !include .wifi-oss.yaml
|
|
|
|
esphome:
|
|
name: ${dn}
|
|
platform: ESP32
|
|
board: esp32doit-devkit-v1
|
|
on_boot:
|
|
- priority: 200.0
|
|
then:
|
|
- output.set_level:
|
|
id: df_attic_output_id
|
|
level: ${df_attic_init_spd}%
|
|
|
|
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
|
|
pin: ${df_attic_pin}
|
|
id: df_attic_output_id
|
|
channel: 0
|
|
frequency: ${df_attic_pwmfreq}
|
|
# - platform: ledc
|
|
# pin: ${wall_fan_spd_pin}
|
|
# id: wall_fan_spd_id
|
|
# channel: 2
|
|
# frequency: ${wall_fan_spd_pwmfreq}
|
|
|
|
fan:
|
|
- platform: speed
|
|
id: df_attic_spd_id
|
|
output: df_attic_output_id
|
|
name: ${df_attic_name}
|
|
# - platform: speed
|
|
# output: wall_fan_spd_id
|
|
# name: ${wall_fan_spd_name}
|
|
|
|
dallas:
|
|
- pin:
|
|
number: ${dallas_pin}
|
|
mode: INPUT_PULLUP
|
|
update_interval: ${dallas_update_interval}
|
|
|
|
sensor:
|
|
- platform: pulse_counter
|
|
pin:
|
|
number: ${df_attic_tach_pin}
|
|
mode: INPUT_PULLUP
|
|
unit_of_measurement: 'RPM'
|
|
name: ${df_attic_tach_name}
|
|
update_interval: 10s
|
|
filters:
|
|
- multiply: 0.5
|
|
# - platform: pulse_counter
|
|
# pin:
|
|
# number: ${wall_fan_tach_pin}
|
|
# mode: INPUT_PULLUP
|
|
# unit_of_measurement: 'RPM'
|
|
# name: ${wall_fan_tach_name}
|
|
# update_interval: 10s
|
|
# filters:
|
|
# - multiply: 0.5
|
|
- platform: dallas
|
|
address: ${dallas_in_addr}
|
|
name: ${dallas_in_name}
|
|
- platform: dallas
|
|
address: ${dallas_out_addr}
|
|
name: ${dallas_out_name}
|
|
id: dallas_out_id
|
|
|
|
binary_sensor:
|
|
- platform: homeassistant
|
|
name: "Ventilate House"
|
|
entity_id: binary_sensor.ventilate_house
|
|
id: ventilate_house
|
|
|
|
number:
|
|
- platform: template
|
|
id: df_attic_vent_spd_id
|
|
name: ${df_attic_vent_spd_name}
|
|
optimistic: true
|
|
min_value: ${df_attic_lo_spd}
|
|
max_value: ${df_attic_hi_spd}
|
|
step: 10
|
|
initial_value: ${df_attic_init_spd}
|
|
- platform: template
|
|
id: df_attic_tgt_spd_out
|
|
name: ${df_attic_tgt_spd_out_name}
|
|
min_value: ${df_attic_off_spd}
|
|
max_value: ${df_attic_hi_spd}
|
|
step: 1
|
|
set_action:
|
|
then:
|
|
lambda: |-
|
|
float lo_temp;
|
|
float hi_temp;
|
|
float curtemp;
|
|
float off_spd;
|
|
float lo_spd;
|
|
float vent_spd;
|
|
float hi_spd;
|
|
float newspd;
|
|
lo_temp = id(thermostat_out_id).target_temperature_low;
|
|
hi_temp = id(thermostat_out_id).target_temperature_high;
|
|
curtemp = id(dallas_out_id).state;
|
|
off_spd = id(df_attic_off_spd_id);
|
|
lo_spd = id(df_attic_lo_spd_id);
|
|
vent_spd = id(df_attic_vent_spd_id).state;
|
|
hi_spd = id(df_attic_hi_spd_id);
|
|
ESP_LOGD("fan_speed", "DEBUG Ventilate House: %d", id(ventilate_house).state);
|
|
ESP_LOGD("fan_speed", "DEBUG Current Temp: %f", curtemp);
|
|
ESP_LOGD("fan_speed", "DEBUG Thermostat State: %d", id(thermostat_on_id).state);
|
|
if ((id(ventilate_house).state == false) &&
|
|
((curtemp < lo_temp) || (id(thermostat_on_id).state == false))) {
|
|
ESP_LOGD("fan_speed", "DEBUG turning off");
|
|
auto call = id(df_attic_spd_id).turn_off();
|
|
call.perform();
|
|
return off_spd;
|
|
}
|
|
if (curtemp > hi_temp) {
|
|
ESP_LOGD("fan_speed", "DEBUG curtemp > hi_temp");
|
|
newspd = hi_spd;
|
|
} else {
|
|
// Set newspd to same linear proportion of spd range as current temp is of temp range
|
|
newspd = lo_spd + ((hi_spd - lo_spd) * (curtemp - lo_temp) / (hi_temp - lo_temp));
|
|
ESP_LOGD("fan_speed", "DEBUG New Speed set: %f", newspd);
|
|
}
|
|
if ((id(ventilate_house).state == true) && (newspd < vent_spd)) {
|
|
newspd = vent_spd;
|
|
ESP_LOGD("fan_speed", "DEBUG New Speed changed to Vent Speed: %f", newspd);
|
|
}
|
|
if (newspd < lo_spd) {
|
|
ESP_LOGD("fan_speed", "DEBUG New Speed under lo_spd, turning off");
|
|
auto call = id(df_attic_spd_id).turn_off();
|
|
call.perform();
|
|
return off_spd;
|
|
}
|
|
ESP_LOGD("fan_speed", "DEBUG Setting fan to newspd: %f", newspd);
|
|
auto call = id(df_attic_spd_id).turn_on();
|
|
call.set_speed(newspd);
|
|
call.perform();
|
|
return newspd;
|
|
|
|
# Dual-point thermostat
|
|
climate:
|
|
- platform: thermostat
|
|
id: thermostat_out_id
|
|
name: ${friendly_name} Out
|
|
sensor: dallas_out_id
|
|
visual:
|
|
min_temperature: 60 °F
|
|
max_temperature: 100 °F
|
|
temperature_step: 1
|
|
default_preset: Default
|
|
preset:
|
|
- name: Default
|
|
default_target_temperature_low: 75 °F
|
|
default_target_temperature_high: 100 °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 ${friendly_name} Thermostat"
|
|
- switch.turn_off: thermostat_on_id
|
|
idle_action:
|
|
- logger.log: "Turning on ${friendly_name} Thermostat"
|
|
- switch.turn_on: thermostat_on_id
|
|
cool_action:
|
|
- logger.log: "WARNING: ${friendly_name} Thermostat has hit high temp!"
|
|
- switch.turn_on: thermostat_on_id
|
|
#TODO - provide some kind of warning / action here
|