init
This commit is contained in:
commit
c70b883817
3 changed files with 166 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Gitignore settings for ESPHome
|
||||||
|
# This is an example and may include too much for your use-case.
|
||||||
|
# You can modify this file to suit your needs.
|
||||||
|
/.esphome/
|
||||||
|
/secrets.yaml
|
23
.zed/tasks.json
Normal file
23
.zed/tasks.json
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// Static tasks configuration.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"label": "esphome run wifi",
|
||||||
|
"command": "podman run --rm -it -v .:/config ghcr.io/esphome/esphome run dewpoint.yaml",
|
||||||
|
"use_new_terminal": false,
|
||||||
|
"allow_concurrent_runs": false,
|
||||||
|
"reveal": "always",
|
||||||
|
"hide": "never",
|
||||||
|
"shell": "system"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "esphome run serial",
|
||||||
|
"command": "podman run --rm -it --device=/dev/ttyUSB0 -v .:/config ghcr.io/esphome/esphome run dewpoint.yaml",
|
||||||
|
"use_new_terminal": false,
|
||||||
|
"allow_concurrent_runs": false,
|
||||||
|
"reveal": "always",
|
||||||
|
"hide": "never",
|
||||||
|
"shell": "system"
|
||||||
|
}
|
||||||
|
]
|
138
dewpoint.yaml
Normal file
138
dewpoint.yaml
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
#<<: !include secrets.yaml
|
||||||
|
esphome:
|
||||||
|
name: dewpointfan
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
board: esp32doit-devkit-v1
|
||||||
|
framework:
|
||||||
|
type: arduino
|
||||||
|
|
||||||
|
# Enable logging
|
||||||
|
logger:
|
||||||
|
|
||||||
|
# Enable Home Assistant API
|
||||||
|
api:
|
||||||
|
password: !secret ota_password
|
||||||
|
|
||||||
|
ota:
|
||||||
|
- platform: esphome
|
||||||
|
password: !secret ota_password
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: !secret wifi_ssid
|
||||||
|
password: !secret wifi_password
|
||||||
|
|
||||||
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||||
|
ap:
|
||||||
|
ssid: "Dewpoint Fan Fallback Hotspot"
|
||||||
|
password: !secret ota_password
|
||||||
|
|
||||||
|
mqtt:
|
||||||
|
id: mqtt_client
|
||||||
|
topic_prefix: dewpoint
|
||||||
|
discovery: false
|
||||||
|
broker: mqtt.fd
|
||||||
|
port: 1883
|
||||||
|
|
||||||
|
i2c:
|
||||||
|
sda: 21
|
||||||
|
scl: 22
|
||||||
|
|
||||||
|
display:
|
||||||
|
- platform: lcd_pcf8574
|
||||||
|
dimensions: 20x4
|
||||||
|
address: 0x27
|
||||||
|
update_interval: 10s
|
||||||
|
lambda: |-
|
||||||
|
it.printf(0, 0, "Fan: %s", id(fan_relay).state ? "ON" : "OFF");
|
||||||
|
it.printf(0, 1, "Temp I/O: %.1f/%.1f", id(inner_temperature).state, id(outer_temperature).state);
|
||||||
|
it.printf(0, 2, "Hum I/O: %.1f/%.1f", id(inner_humidity).state, id(outer_humidity).state);
|
||||||
|
it.printf(0, 3, "Dew I/O: %.1f/%.1f", id(inner_dew_point).state, id(outer_dew_point).state);
|
||||||
|
sensor:
|
||||||
|
- platform: dht
|
||||||
|
pin: 25
|
||||||
|
model: DHT22
|
||||||
|
temperature:
|
||||||
|
name: "Inner Temperature"
|
||||||
|
id: inner_temperature
|
||||||
|
humidity:
|
||||||
|
name: "Inner Humidity"
|
||||||
|
id: inner_humidity
|
||||||
|
update_interval: 10s
|
||||||
|
- platform: dht
|
||||||
|
pin: 26
|
||||||
|
model: DHT22
|
||||||
|
temperature:
|
||||||
|
name: "Outer Temperature"
|
||||||
|
id: outer_temperature
|
||||||
|
humidity:
|
||||||
|
name: "Outer Humidity"
|
||||||
|
id: outer_humidity
|
||||||
|
update_interval: 10s
|
||||||
|
- platform: template
|
||||||
|
name: "Inner Dew Point"
|
||||||
|
lambda: |-
|
||||||
|
float A = 17.27;
|
||||||
|
float B = 237.7;
|
||||||
|
float temp = id(inner_temperature).state;
|
||||||
|
float humidity = id(inner_humidity).state;
|
||||||
|
float alpha = ((A * temp) / (B + temp)) + log(humidity / 100.0);
|
||||||
|
return (B * alpha) / (A - alpha);
|
||||||
|
unit_of_measurement: °C
|
||||||
|
id: inner_dew_point
|
||||||
|
update_interval: 30s
|
||||||
|
- platform: template
|
||||||
|
name: "Outer Dew Point"
|
||||||
|
lambda: |-
|
||||||
|
float A = 17.27;
|
||||||
|
float B = 237.7;
|
||||||
|
float temp = id(outer_temperature).state;
|
||||||
|
float humidity = id(outer_humidity).state;
|
||||||
|
float alpha = ((A * temp) / (B + temp)) + log(humidity / 100.0);
|
||||||
|
return (B * alpha) / (A - alpha);
|
||||||
|
unit_of_measurement: °C
|
||||||
|
id: outer_dew_point
|
||||||
|
update_interval: 30s
|
||||||
|
icon: "mdi:thermometer-water"
|
||||||
|
- platform: template
|
||||||
|
name: "Fan state"
|
||||||
|
lambda: |-
|
||||||
|
uint8_t fan_state = 0;
|
||||||
|
float deltadp = id(inner_dew_point).state - id(outer_dew_point).state;
|
||||||
|
if (deltadp > 6.0) {
|
||||||
|
fan_state = 1;
|
||||||
|
}
|
||||||
|
if (deltadp < 5.0) {
|
||||||
|
fan_state = 0;
|
||||||
|
}
|
||||||
|
if (id(inner_temperature).state < 10.0) {
|
||||||
|
fan_state = 0;
|
||||||
|
}
|
||||||
|
if (id(outer_temperature).state < -10.0) {
|
||||||
|
fan_state = 0;
|
||||||
|
}
|
||||||
|
if (fan_state == 1) {
|
||||||
|
id(fan_relay).turn_on();
|
||||||
|
} else {
|
||||||
|
id(fan_relay).turn_off();
|
||||||
|
}
|
||||||
|
id(mqtt_client).publish_json("sensor/dewpointfan", [=](JsonObject root) {
|
||||||
|
root["inner_temp"] = id(inner_temperature).state;
|
||||||
|
root["inner_humidity"] = id(inner_humidity).state;
|
||||||
|
root["outer_temp"] = id(outer_temperature).state;
|
||||||
|
root["outer_humidity"] = id(outer_humidity).state;
|
||||||
|
root["inner_dewpoint"] = id(inner_dew_point).state;
|
||||||
|
root["outer_dewpoint"] = id(outer_dew_point).state;
|
||||||
|
root["fan_state"] = id(fan_relay).state;
|
||||||
|
});
|
||||||
|
return fan_state;
|
||||||
|
unit_of_measurement: ""
|
||||||
|
update_interval: 30s
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
name: "Relay"
|
||||||
|
id: fan_relay
|
||||||
|
pin: 13
|
||||||
|
|
||||||
|
captive_portal:
|
Loading…
Reference in a new issue