Hi community,
I’ve just gotten started with esphome, and it’s fantastic. I’m looking at putting together a replacement for my window AC control interface. The hardware is pretty simple: three relays (one for compressor, one for fan on/off, one for fan speed high/low), and last summer I managed to get it working with tasmota, but it was pretty basic and simple. To be clear: this is not a window AC with an IR remote, I’ve completely gutted the control system.
I’m planning on integrating an i2c oled display, HTU21D temperature/humidity sensor, and some tactile switches as a physical interface on the window unit itself, and ideally it would integrate seamlessly with the Home Assistant MQTT generic thermostat component.
I’ve had some trouble finding resources that will help me learn about the lambda functions and how to integrate things. The cookbook has been immeasurably helpful, but I’ve hit a wall.
I’m looking for help figuring out a few things that have so far got me stumped:
- how to set up the fan so it’s linked to one of the relays (e.g. when the fan is on, the relay is on) but that the speed is linked to a separate relay pin
- ensuring that if/when compressor is turned on, the fan will run, and when the compressor shuts off, the fan will run for two minutes then shut itself off
- setting a minimum run time of two minutes for the compressor (to prevent damage from power cycling too quickly)
- using icons on the OLED to show state (e.g. fan off/running, ac mode cool or off)
Here’s what I’ve got so far:
esphome:
name: airconditioner1
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret ssid
password: !secret wifi_password
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
mqtt:
broker: 192.168.1.13
username: !secret mqtt-user
password: !secret mqtt-pass
discovery: true
status_led:
pin:
number: D4
inverted: true
time:
- platform: homeassistant
id: time
switch:
- platform: gpio
name: "Compressor"
id: compressor
pin: D6
inverted: true
icon: "mdi:snowflake"
- platform: gpio
name: "Fan"
id: fan_output
pin: D5
inverted: true
icon: "mdi:fan"
- platform: gpio
name: "Fan Speed"
id: fan_speed
pin: D7
inverted: true
icon: "mdi:weather-windy"
sensor:
- platform: htu21d
temperature:
name: "Temperature"
id: temp
humidity:
name: "Humidity"
id: hum
update_interval: 60s
# text_sensor:
# - name: "Mode"
# id: mode
# - name: "State"
# id: state
# internal: true
font:
- file: 'slkscr.ttf'
id: font1
size: 8
- file: 'bebas.ttf'
id: font2
size: 36
- file: 'arial_narrow_7.ttf'
id: font3
size: 14
i2c:
sda: D1
scl: D2
scan: False
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
reset_pin: D0
address: 0x3C
lambda: |-
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Air Conditioner");
// Print time in HH:MM format
it.strftime(0, 60, id(font2), TextAlign::BASELINE_LEFT, "%H:%M", id(time).now());
// Print inside temperature (from homeassistant sensor)
if (id(temp).has_state()) {
it.printf(127, 23, id(font3), TextAlign::TOP_RIGHT , "%.1f°", id(temp).state);
}
// Print outside temperature (from homeassistant sensor)
if (id(hum).has_state()) {
it.printf(127, 60, id(font3), TextAlign::BASELINE_RIGHT , "%.0f%%", id(hum).state);
}