Garage fridge redesign (#31)

* Temporarily disable the heater

* Shell of new garage fridge component

* Core code should be mostly complete

* Add power monitoring and freezer temp control

* Wrap up core temperature management code

* Add fixed InkBird component

* The new fridge manages temp in the freezer better so we are able to greatly simplify things

* Finish garage fridge

Co-authored-by: Chris Nussbaum <chris.nussbaum@protolabs.com>
This commit is contained in:
Chris Nussbaum 2022-03-29 13:41:35 -05:00 committed by GitHub
parent df2c532d13
commit 3c710571d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 152 additions and 116 deletions

View File

@ -14,6 +14,7 @@ Home Assistant is open source home automation that puts local control and privac
* `components` - Custom components
* `custom` - Other custom code that are not components
* `devices` - Yaml files for my devices
* `images` - Pictures of some of my devices
* `other` - Other misc files
* `packages` - Shared packages used by my devices
* `scripts` - Couple of PowerShell scripts for managing the repo
@ -58,8 +59,9 @@ This is a [NodeMCU](https://www.amazon.com/gp/product/B010N1SPRK/ref=ppx_yo_dt_b
### [Fire Pit and Fountain](./devices/fire_pit_fountain.yaml)
This is a [WEMOS D1 Mini Pro](https://www.amazon.com/gp/product/B07G9HZ5LM/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) that is connected to a couple of [relays](https://www.amazon.com/gp/product/B0057OC6D8/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) and a couple of water proof push buttons [red](https://www.amazon.com/gp/product/B079GNNSRP/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) and [blue](https://www.amazon.com/gp/product/B079GK565N/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1). The multi-click config on the fire pit switch is so that any press will turn it off but to turn it on you have to press it for 3 seconds (to try and prevent kids from turning it on). This is used to control the combination fire pit and fountain in my backyard. I just got this hooked up and is working good other then the fire pit doesn't always come on on the first try (I think I am getting some bounce in the switch but haven't had a chance to troubleshoot further).
### [Garage Fridge](./devices/garage_fridge.yaml)
This is a [NodeMCU](https://www.amazon.com/gp/product/B010N1SPRK/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) that I have installed in the back of my garage fridge and is connected to several [temperature sensors](https://www.amazon.com/gp/product/B012C597T0/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) that monitor the temperature of the compressor, the fridge, and the freezer and a pair of [relays](https://www.amazon.com/gp/product/B0057OC6D8/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) that control a [heat tape](https://www.amazon.com/gp/product/B07HHB1R5S/ref=ox_sc_act_title_1?smid=A1KEJ1ZBUGV6FW&psc=1) wrapped around the compressor and a couple of [heaters](https://www.amazon.com/gp/product/B07GXSDMR2/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) that are inside the fridge. This is to prevent the compressor from getting to cold (when it is cold the oil thickens up which is hard on the compressor), the fridge from dropping below freezing (frozen beer is no fun), and the freezer from getting to warm (when temperatures in the garage are around the desired fridge temperature the freezer tends to get to warm because of lack of cooling demand from the fridge so we warm the fridge up a little to get it to kick in the compressor).
### [Garage Fridge](./devices/garage-fridge.yaml)
This is a [M5Stack ATOM HUB SwitchD](https://shop.m5stack.com/products/atom-hub-switchd-2-relay-kit) mounted in a [box](https://www.amazon.com/gp/product/B07ZBRK5NL) on the side of my garage fridge with a [PZEM-004T](https://www.amazon.com/gp/product/B0855T6VHT). It is paired with 2 [Inkbird IBS-TH1 sensors](https://www.amazon.com/gp/product/B0774BGBHS) for monitoring the temperature in the fridge and freezer sections. One of the relays on the M5Stack ATOM HUB SwitchD is used to control a pair of [heaters](https://www.amazon.com/gp/product/B07GXSDMR2) that are inside the fridge to keep the fridge from dropping below freezing (frozen beer is no fun). I am not entirely happy with the parameters for the [PID controller](https://esphome.io/components/climate/pid.html), I would like it to reach an equlibrium where the heater is on just enough to maintain the temperature at all times but instead it tends to ramp up and down quite a bit. The good news is even with the varying heat output it keeps the temperature pretty close to the desired temp. Using the autotune feature doesn't work because the bluetooth seems to cause periodic reboots which resets the autotune process. Maybe next winter I will try to create a temporary custom autotune that can survive restarts.
<br/><br/><img src="./images/garage-fridge/top_view.jpg" width="600" />
### [Master Bed](./devices/master_bed.yaml)
This is a [NodeMCU](https://www.amazon.com/gp/product/B010N1SPRK/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1) that I have installed under my bed and is connected to a pair of [Force Sensitive Resistors](https://www.kr4.us/force-sensitive-resistor-long.html?gclid=COqn7qrNxdICFVQlgQodeLEMKw) that are placed between the mattress and box spring of my bed, one for my side and one for my wife's side. Because the ESP8266 has only one analog input I had to add some transistors connected to pins D0 and D1 that are used to select which FSR is connected to the A0 analog input. The custom sensors in [bed_sensor.h](./custom/bed_sensor.h) handles switching between the FSR's and reading the values from the FSR's. Generally when the bed is empty the reading is the full 1024 (or at least close to this). If someone is on one side of the bed or the other the reading is typically around 100. However if you lay in the middle of the bed I tend to get readings of around 600-700 on both sides. Thus the 3 different binary sensors (Chris is in Bed, Melissa is in Bed, Someone is in Bed). There is also a Master Bed Count that reports the total number of people in bed, I compare this to a sensor in Home Assistant that tracks the number of "masters" (my wife and me) that are home so that I can activate night mode when everyone is in bed.

128
devices/garage-fridge.yaml Normal file
View File

@ -0,0 +1,128 @@
substitutions:
device_id: garage-fridge
device_name: Garage Fridge
board: m5stack-atom
framework_type: esp-idf
ip_address: !secret garage-fridge-ip
ota_pwd: !secret garage-fridge-ota-pwd
api_pwd: !secret garage-fridge-api-pwd
ap_wifi_pwd: !secret garage-fridge-ap-pwd
packages:
device_base: !include ../packages/esp32_device_base.yaml
logger: !include ../packages/logger/logger_no_serial.yaml
external_components:
- source: github://cbpowell/ESPSense
components: [ espsense ]
climate:
- platform: pid
name: Garage Fridge
id: fridge_heater
entity_category: config
sensor: fridge_temp
default_target_temperature: 34°F
heat_output: fridge_heater_output
visual:
min_temperature: 32°F
max_temperature: 38°F
temperature_step: .1
control_parameters:
kp: 1.0
ki: 0.006
kd: 3
min_integral: 0.0
max_integral: 0.5
esp32_ble_tracker:
scan_parameters:
interval: 16ms
window: 16ms
# espsense:
# plugs:
# - name: ${device_name}
# power_sensor: garage_fridge_power
# current_sensor: garage_fridge_current
# voltage_sensor: garage_fridge_voltage
modbus:
output:
- platform: slow_pwm
pin: 22
id: fridge_heater_output
period: 10s
sensor:
- platform: inkbird_ibsth1_mini
mac_address: "10:08:2C:1F:33:63"
temperature:
id: fridge_temp
name: Garage Fridge Temperature
accuracy_decimals: 2
humidity:
name: Garage Fridge Humidity
battery_level:
name: Garage Fridge Sensor Battery Level
- platform: inkbird_ibsth1_mini
mac_address: "64:69:4E:9D:46:A9"
temperature:
id: freezer_temp
name: Garage Freezer Temperature
accuracy_decimals: 2
humidity:
name: Garage Freezer Humidity
battery_level:
name: Garage Freezer Sensor Battery Level
- platform: pzemac
id: pzem
update_interval: 2s
current:
id: garage_fridge_current
name: ${device_name} Current
voltage:
id: garage_fridge_voltage
name: ${device_name} Voltage
energy:
name: ${device_name}
icon: mdi:flash
power:
id: garage_fridge_power
name: ${device_name} Power
frequency:
name: ${device_name} Power Frequency
power_factor:
name: ${device_name} Power Factor
- platform: pid
name: "Garage Fridge Proportional Term"
type: PROPORTIONAL
entity_category: diagnostic
- platform: pid
name: "Garage Fridge Integral Term"
type: INTEGRAL
entity_category: diagnostic
- platform: pid
name: "Garage Fridge Derivative Term"
type: DERIVATIVE
entity_category: diagnostic
- platform: pid
name: "Garage Fridge Error"
type: ERROR
entity_category: diagnostic
- platform: pid
name: "Garage Fridge PID Result"
type: RESULT
entity_category: diagnostic
- platform: pid
name: "Garage Fridge Heat Output"
type: HEAT
entity_category: diagnostic
uart:
tx_pin: GPIO21
rx_pin: GPIO25
baud_rate: 9600

View File

@ -1,105 +0,0 @@
substitutions:
device_id: garage_fridge
device_name: Garage Fridge
platform: ESP8266
board: nodemcuv2
ip_address: !secret garage-fridge-ip
ota_pwd: !secret garage-fridge-ota-pwd
api_pwd: !secret garage-fridge-api-pwd
ap_wifi_pwd: !secret garage-fridge-ap-pwd
packages:
device_base: !include ../packages/device_base.yaml
binary_sensor:
- platform: template
id: fridge_heater
name: "Garage Fridge Heater"
lambda: return id(fridge_heater_switch).state;
- platform: template
id: compressor_heater
name: "Garage Fridge Compressor Heater"
lambda: return id(compressor_heater_switch).state;
dallas:
- pin: D2
script:
- id: fridge_heater_control
then:
- lambda: |-
if (!id(fridge_heater_switch).state) {
if (id(fridge_temp_avg).state < 33.5) {
id(fridge_heater_switch).turn_on();
} else if (id(freezer_temp).state > 22 && id(fridge_temp).state < 36) {
id(fridge_heater_switch).turn_on();
}
} else if (id(fridge_heater_switch).state) {
if (id(fridge_temp_avg).state > 34 && id(freezer_temp).state < 20) {
id(fridge_heater_switch).turn_off();
}
else if (id(fridge_temp_avg).state > 38) {
id(fridge_heater_switch).turn_off();
}
}
sensor:
- platform: dallas
id: fridge_temp
name: "Garage Fridge Temperature"
unit_of_measurement: "°F"
accuracy_decimals: 1
address: 0x6E01142F5AA82D28
filters:
- lambda: return x * (9.0/5.0) + 32.0;
- platform: dallas
id: freezer_temp
name: "Garage Freezer Temperature"
unit_of_measurement: "°F"
accuracy_decimals: 1
address: 0xEF01142F57328028
filters:
- lambda: return x * (9.0/5.0) + 32.0;
on_value:
then:
- script.execute: fridge_heater_control
- platform: dallas
id: comp_temp
name: "Garage Fridge Compressor Temperature"
unit_of_measurement: "°F"
accuracy_decimals: 1
address: 0x3F02099245F52528
filters:
- lambda: return x * (9.0/5.0) + 32.0;
on_value:
then:
- lambda: |-
if (x < 43 && !id(compressor_heater_switch).state) {
id(compressor_heater_switch).turn_on();
} else if (x > 45 && id(compressor_heater_switch).state) {
id(compressor_heater_switch).turn_off();
}
- platform: template
id: fridge_temp_avg
name: "Garage Fridge Rolling Average Temperature"
unit_of_measurement: "°F"
accuracy_decimals: 1
update_interval: 15s
lambda: return id(fridge_temp).state;
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 1
on_value:
then:
- script.execute: fridge_heater_control
switch:
- platform: gpio
id: fridge_heater_switch
pin: D0
inverted: true
- platform: gpio
id: compressor_heater_switch
pin: D1
inverted: true

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -0,0 +1,4 @@
button:
- platform: restart
id: reboot
name: Restart ${device_name}

View File

@ -4,13 +4,15 @@ substitutions:
wifi_password: !secret wifi-password
ip_subnet: !secret ip-subnet
ip_gateway: !secret ip-gateway
platform: esp8266
esphome:
name: ${device_id}
platform: ${platform}
board: ${board}
build_path: ../build/${device_id}
${platform}:
board: ${board}
packages:
wifi: !include wifi/wifi.yaml
api: !include api/api.yaml
@ -19,7 +21,7 @@ packages:
status_sensor: !include binary_sensor/status.yaml
uptime_sensor: !include sensor/uptime.yaml
wifi_sensor: !include sensor/wifi.yaml
restart_switch: !include switch/restart.yaml
restart_button: !include button/restart.yaml
version_sensor: !include text_sensor/version.yaml
wifi_info_sensor: !include text_sensor/wifi_info.yaml

View File

@ -0,0 +1,10 @@
substitutions:
platform: esp32
framework_type: arduino
esp32:
framework:
type: ${framework_type}
packages:
base: !include device_base.yaml

View File

@ -1,4 +0,0 @@
switch:
- platform: restart
id: reboot
name: Restart ${device_name}

View File

@ -2,7 +2,6 @@ wifi:
ssid: ${wifi_ssid}
password: ${wifi_password}
fast_connect: true
power_save_mode: none
manual_ip:
static_ip: ${ip_address}
subnet: ${ip_subnet}
@ -11,4 +10,4 @@ wifi:
ssid: ${device_id}
password: ${ap_wifi_pwd}
captive_portal:
#captive_portal: