Created
January 16, 2024 20:10
-
-
Save psi-4ward/6725453842114b35fad6138cb6f8dfcd to your computer and use it in GitHub Desktop.
room-sensor esphome v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
devicename: room-sensor | |
esphome: | |
name: $devicename | |
platform: ESP32 | |
board: esp32-c3-devkitm-1 | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Bad-Room-Sensor Fallback Hotspot" | |
password: "s3cr3t" | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
encryption: | |
key: "asdf" | |
ota: | |
i2c: | |
sda: 6 | |
scl: 7 | |
scan: True | |
frequency: 400kHz | |
time: | |
- platform: sntp | |
id: sntp_time | |
sensor: | |
- platform: sht4x | |
temperature: | |
name: "$devicename Temperature" | |
id: sht_temperature | |
accuracy_decimals: 1 | |
filters: | |
offset: -1.3 | |
humidity: | |
name: "$devicename Humidity" | |
id: sht_humidity | |
accuracy_decimals: 0 | |
update_interval: 20s | |
- platform: max44009 | |
address: 0x4A | |
name: "$devicename Luminance" | |
update_interval: 20s | |
accuracy_decimals: 1 | |
- platform: template | |
name: "$devicename Dew Point" | |
id: dew_point | |
unit_of_measurement: °C | |
icon: 'mdi:thermometer-water' | |
accuracy_decimals: 0 | |
lambda: |- | |
return (243.5 * (log(id(sht_humidity).state / 100) + ((17.67 * id(sht_temperature).state) / | |
(243.5 + id(sht_temperature).state))) / (17.67 - log(id(sht_humidity).state / 100) - | |
((17.67 * id(sht_temperature).state) / (243.5 + id(sht_temperature).state)))); | |
binary_sensor: | |
- platform: gpio | |
pin: 3 | |
name: "$devicename Motion" | |
id: pir | |
device_class: motion | |
filters: | |
delayed_off: 60s | |
on_state: | |
then: | |
- lambda: |- | |
if(id(pir).state) { | |
id(ssd1306_display).turn_on(); | |
} else { | |
id(ssd1306_display).turn_off(); | |
} | |
font: | |
- file: "fonts/DejaVuSans.ttf" | |
id: dejavu14 | |
size: 14 | |
glyphs: ":-.%0123456789°C" | |
- file: "fonts/DejaVuSans.ttf" | |
id: dejavu20 | |
size: 20 | |
glyphs: ":-.0123456789°C" | |
- file: 'fonts/materialdesignicons-webfont.ttf' | |
id: icon | |
size: 14 | |
glyphs: | |
- "\U000F058E" # mdi:water-percent | |
- "\U000F0594" # mdi-weather-night | |
- "\U000F058C" # mdi-water | |
display: | |
- platform: ssd1306_i2c | |
id: ssd1306_display | |
model: "SSD1306 128x64" | |
address: 0x3C | |
update_interval: 5s | |
lambda: |- | |
it.strftime(128, 0, id(dejavu14), COLOR_ON, TextAlign::RIGHT, "%H:%M", id(sntp_time).now()); | |
it.printf(64, 22, id(dejavu20), TextAlign::CENTER_HORIZONTAL, "%.1f°C", id(sht_temperature).state); | |
it.printf(0, 50, id(dejavu14), "%.0f%%", id(sht_humidity).state); | |
if(!isnan(id(dew_point).state )) { | |
it.printf(128, 50, id(dejavu14), TextAlign::RIGHT, "%.0f°C", id(dew_point).state); | |
} | |
// it.printf(0, 52, id(icon), "\U000F058C"); | |
// it.printf(0, 16, id(dejavu), "Temp: %.1fC", id(sht_temperature).state); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment