epaper.yaml
· 7.0 KiB · YAML
Raw
esphome:
name: reterminal-e1002
friendly_name: ColorEinkDisplay
on_boot:
- priority: 600
then:
- output.turn_on: bsp_sd_enable
- output.turn_on: bsp_battery_enable
- delay: 200ms
- component.update: battery_voltage
- component.update: battery_level
- priority: -100
then:
- logger.log: "*** Device woke up from deep sleep ***"
- light.turn_on: onboard_led
- delay: 1s
- logger.log: "*** Starting application ***"
esp32:
board: esp32-s3-devkitc-1
framework:
# type: arduino
type: esp-idf
# Enable logging
logger:
hardware_uart: UART0
# Enable Home Assistant API
api:
encryption:
key: "<Your API Key>"
on_client_connected:
- logger.log:
format: "*** Client %s connected to API with IP %s ***"
args: ["client_info.c_str()", "client_address.c_str()"]
ota:
- platform: esphome
password: "<Your OTA PW>"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
min_auth_mode: WPA2
on_connect:
then:
- lambda: |-
id(wifi_status) = 1;
- logger.log: "*** WiFi Connected Successfully! ***"
- delay: 1s
- component.update: dashboard_image
on_disconnect:
then:
- lambda: |-
id(wifi_status) = 0;
- logger.log: "*** WiFi Disconnected ***"
ap:
ssid: "ColoreInkFallbackHotspot"
password: "<Your Fallback Hotspot PW>"
psram:
mode: octal
speed: 80MHz
captive_portal:
globals:
- id: sleep_counter
type: int
restore_value: yes # Use RTC storage to maintain counter during sleep
initial_value: '0'
- id: battery_glyph
type: std::string
restore_value: no
initial_value: "\"\\U000F0079\"" # default full battery
- id: wifi_status
type: int
restore_value: no
initial_value: "0"
- id: recorded_display_refresh
type: int
restore_value: yes
initial_value: '0'
# Deep-sleep, wake by GPIO3
deep_sleep:
id: deep_sleep_1
run_duration: 120s # Device wake up and run 120s. This should not run for 120s because of other code
sleep_duration: 30min # deep sleep for 30m
wakeup_pin: GPIO3 # Green button
wakeup_pin_mode: INVERT_WAKEUP
# SPI bus for display
spi:
clk_pin: GPIO7
mosi_pin: GPIO9
# I2C bus for temperature and humidity sensor
i2c:
scl: GPIO20
sda: GPIO19
http_request:
verify_ssl: false
timeout: 20s
watchdog_timeout: 25s
online_image:
- id: dashboard_image
format: PNG
type: RGB565
buffer_size: 65536
url: http://192.168.1.101:10000/dashboard-robin/display-color?viewport=800x480&lang=en
# update_interval: 20s. # Not needed now
on_download_finished:
- component.update: epaper_display
- delay: 45s # Time to allow display to refresh
- deep_sleep.enter: deep_sleep_1
on_error:
- delay: 30s
- deep_sleep.enter: deep_sleep_1
display:
- platform: epaper_spi
id: epaper_display
model: Seeed-reTerminal-E1002
update_interval: never
lambda: |-
it.image(0, 0, id(dashboard_image));
# Home Assistant time
time:
- platform: homeassistant
id: ha_time
sensor:
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
update_interval: 60s
name: "WiFi Signal dB"
id: wifi_signal_db
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: "WiFi Signal Percent"
id: wifi_signal_percent
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"
- platform: uptime
update_interval: 60s
name: Uptime
- platform: internal_temperature
update_interval: 60s
name: "Internal Temperature"
- platform: template
update_interval: 60s
name: "Display Last Update"
device_class: timestamp
entity_category: "diagnostic"
id: display_last_update
lambda: 'return id(ha_time).now().timestamp;'
- platform: template
name: "Display Refresh Count"
accuracy_decimals: 0
unit_of_measurement: "Refreshes"
state_class: "total_increasing"
entity_category: "diagnostic"
lambda: 'return id(recorded_display_refresh) += 1;'
- platform: sht4x
update_interval: 60s
temperature:
name: "Temperature"
id: temp_sensor
humidity:
name: "Relative Humidity"
id: hum_sensor
- platform: adc
update_interval: 60s
pin: GPIO1
name: "Battery Voltage"
id: battery_voltage
attenuation: 12db
filters:
- multiply: 2.0
- platform: template
update_interval: 60s
name: "Battery Level"
id: battery_level
unit_of_measurement: "%"
icon: "mdi:battery"
device_class: battery
state_class: measurement
lambda: 'return id(battery_voltage).state;'
on_value:
then:
- lambda: |-
int pct = int(x);
if (pct <= 10) id(battery_glyph) = "\U000F007A";
else if (pct <= 20) id(battery_glyph) = "\U000F007B";
else if (pct <= 30) id(battery_glyph) = "\U000F007C";
else if (pct <= 40) id(battery_glyph) = "\U000F007D";
else if (pct <= 50) id(battery_glyph) = "\U000F007E";
else if (pct <= 60) id(battery_glyph) = "\U000F007F";
else if (pct <= 70) id(battery_glyph) = "\U000F0080";
else if (pct <= 80) id(battery_glyph) = "\U000F0081";
else if (pct <= 90) id(battery_glyph) = "\U000F0082";
else id(battery_glyph) = "\U000F0079";
filters:
- calibrate_linear:
- 4.15 -> 100.0
- 3.96 -> 90.0
- 3.91 -> 80.0
- 3.85 -> 70.0
- 3.80 -> 60.0
- 3.75 -> 50.0
- 3.68 -> 40.0
- 3.58 -> 30.0
- 3.49 -> 20.0
- 3.41 -> 10.0
- 3.30 -> 5.0
- 3.27 -> 0.0
- clamp:
min_value: 0
max_value: 100
# Button configuration
binary_sensor:
# - platform: gpio
# pin:
# number: GPIO3 # Green button, commented out because I'm using it for wakeup
# mode: INPUT_PULLUP
# inverted: true
# id: button_1
# name: "Green Button"
# on_press:
# then:
# - logger.log: "*** Green Button (GPIO3) Pressed ***"
- platform: gpio
pin:
number: GPIO4 # Right white button
mode: INPUT_PULLUP
inverted: true
id: button_2
name: "Right Button"
on_press:
then:
- logger.log: "*** Right Button (GPIO4) Pressed ***"
- platform: gpio
pin:
number: GPIO5 # Left white button
mode: INPUT_PULLUP
inverted: true
id: button_3
name: "Left Button"
on_press:
then:
- logger.log: "*** Left Button (GPIO5) Pressed ***"
output:
- platform: gpio
pin: GPIO6
id: bsp_led
inverted: true
- platform: gpio
pin: GPIO16
id: bsp_sd_enable
- platform: gpio
pin: GPIO21
id: bsp_battery_enable
# Onboard LED
light:
- platform: binary
name: "Onboard LED"
output: bsp_led
id: onboard_led
| 1 | esphome: |
| 2 | name: reterminal-e1002 |
| 3 | friendly_name: ColorEinkDisplay |
| 4 | on_boot: |
| 5 | - priority: 600 |
| 6 | then: |
| 7 | - output.turn_on: bsp_sd_enable |
| 8 | - output.turn_on: bsp_battery_enable |
| 9 | - delay: 200ms |
| 10 | - component.update: battery_voltage |
| 11 | - component.update: battery_level |
| 12 | - priority: -100 |
| 13 | then: |
| 14 | - logger.log: "*** Device woke up from deep sleep ***" |
| 15 | - light.turn_on: onboard_led |
| 16 | - delay: 1s |
| 17 | - logger.log: "*** Starting application ***" |
| 18 | |
| 19 | esp32: |
| 20 | board: esp32-s3-devkitc-1 |
| 21 | framework: |
| 22 | # type: arduino |
| 23 | type: esp-idf |
| 24 | |
| 25 | # Enable logging |
| 26 | logger: |
| 27 | hardware_uart: UART0 |
| 28 | |
| 29 | # Enable Home Assistant API |
| 30 | api: |
| 31 | encryption: |
| 32 | key: "<Your API Key>" |
| 33 | on_client_connected: |
| 34 | - logger.log: |
| 35 | format: "*** Client %s connected to API with IP %s ***" |
| 36 | args: ["client_info.c_str()", "client_address.c_str()"] |
| 37 | |
| 38 | ota: |
| 39 | - platform: esphome |
| 40 | password: "<Your OTA PW>" |
| 41 | |
| 42 | wifi: |
| 43 | ssid: !secret wifi_ssid |
| 44 | password: !secret wifi_password |
| 45 | min_auth_mode: WPA2 |
| 46 | on_connect: |
| 47 | then: |
| 48 | - lambda: |- |
| 49 | id(wifi_status) = 1; |
| 50 | - logger.log: "*** WiFi Connected Successfully! ***" |
| 51 | - delay: 1s |
| 52 | - component.update: dashboard_image |
| 53 | on_disconnect: |
| 54 | then: |
| 55 | - lambda: |- |
| 56 | id(wifi_status) = 0; |
| 57 | - logger.log: "*** WiFi Disconnected ***" |
| 58 | ap: |
| 59 | ssid: "ColoreInkFallbackHotspot" |
| 60 | password: "<Your Fallback Hotspot PW>" |
| 61 | |
| 62 | psram: |
| 63 | mode: octal |
| 64 | speed: 80MHz |
| 65 | |
| 66 | |
| 67 | captive_portal: |
| 68 | |
| 69 | globals: |
| 70 | - id: sleep_counter |
| 71 | type: int |
| 72 | restore_value: yes # Use RTC storage to maintain counter during sleep |
| 73 | initial_value: '0' |
| 74 | - id: battery_glyph |
| 75 | type: std::string |
| 76 | restore_value: no |
| 77 | initial_value: "\"\\U000F0079\"" # default full battery |
| 78 | - id: wifi_status |
| 79 | type: int |
| 80 | restore_value: no |
| 81 | initial_value: "0" |
| 82 | - id: recorded_display_refresh |
| 83 | type: int |
| 84 | restore_value: yes |
| 85 | initial_value: '0' |
| 86 | |
| 87 | # Deep-sleep, wake by GPIO3 |
| 88 | deep_sleep: |
| 89 | id: deep_sleep_1 |
| 90 | run_duration: 120s # Device wake up and run 120s. This should not run for 120s because of other code |
| 91 | sleep_duration: 30min # deep sleep for 30m |
| 92 | wakeup_pin: GPIO3 # Green button |
| 93 | wakeup_pin_mode: INVERT_WAKEUP |
| 94 | |
| 95 | # SPI bus for display |
| 96 | spi: |
| 97 | clk_pin: GPIO7 |
| 98 | mosi_pin: GPIO9 |
| 99 | # I2C bus for temperature and humidity sensor |
| 100 | i2c: |
| 101 | scl: GPIO20 |
| 102 | sda: GPIO19 |
| 103 | |
| 104 | http_request: |
| 105 | verify_ssl: false |
| 106 | timeout: 20s |
| 107 | watchdog_timeout: 25s |
| 108 | |
| 109 | online_image: |
| 110 | - id: dashboard_image |
| 111 | format: PNG |
| 112 | type: RGB565 |
| 113 | buffer_size: 65536 |
| 114 | url: http://192.168.1.101:10000/dashboard-robin/display-color?viewport=800x480&lang=en |
| 115 | # update_interval: 20s. # Not needed now |
| 116 | on_download_finished: |
| 117 | - component.update: epaper_display |
| 118 | - delay: 45s # Time to allow display to refresh |
| 119 | - deep_sleep.enter: deep_sleep_1 |
| 120 | on_error: |
| 121 | - delay: 30s |
| 122 | - deep_sleep.enter: deep_sleep_1 |
| 123 | |
| 124 | display: |
| 125 | - platform: epaper_spi |
| 126 | id: epaper_display |
| 127 | model: Seeed-reTerminal-E1002 |
| 128 | update_interval: never |
| 129 | lambda: |- |
| 130 | it.image(0, 0, id(dashboard_image)); |
| 131 | |
| 132 | # Home Assistant time |
| 133 | time: |
| 134 | - platform: homeassistant |
| 135 | id: ha_time |
| 136 | |
| 137 | sensor: |
| 138 | - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB |
| 139 | update_interval: 60s |
| 140 | name: "WiFi Signal dB" |
| 141 | id: wifi_signal_db |
| 142 | entity_category: "diagnostic" |
| 143 | - platform: copy # Reports the WiFi signal strength in % |
| 144 | source_id: wifi_signal_db |
| 145 | name: "WiFi Signal Percent" |
| 146 | id: wifi_signal_percent |
| 147 | filters: |
| 148 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); |
| 149 | unit_of_measurement: "%" |
| 150 | entity_category: "diagnostic" |
| 151 | - platform: uptime |
| 152 | update_interval: 60s |
| 153 | name: Uptime |
| 154 | - platform: internal_temperature |
| 155 | update_interval: 60s |
| 156 | name: "Internal Temperature" |
| 157 | - platform: template |
| 158 | update_interval: 60s |
| 159 | name: "Display Last Update" |
| 160 | device_class: timestamp |
| 161 | entity_category: "diagnostic" |
| 162 | id: display_last_update |
| 163 | lambda: 'return id(ha_time).now().timestamp;' |
| 164 | - platform: template |
| 165 | name: "Display Refresh Count" |
| 166 | accuracy_decimals: 0 |
| 167 | unit_of_measurement: "Refreshes" |
| 168 | state_class: "total_increasing" |
| 169 | entity_category: "diagnostic" |
| 170 | lambda: 'return id(recorded_display_refresh) += 1;' |
| 171 | - platform: sht4x |
| 172 | update_interval: 60s |
| 173 | temperature: |
| 174 | name: "Temperature" |
| 175 | id: temp_sensor |
| 176 | humidity: |
| 177 | name: "Relative Humidity" |
| 178 | id: hum_sensor |
| 179 | - platform: adc |
| 180 | update_interval: 60s |
| 181 | pin: GPIO1 |
| 182 | name: "Battery Voltage" |
| 183 | id: battery_voltage |
| 184 | attenuation: 12db |
| 185 | filters: |
| 186 | - multiply: 2.0 |
| 187 | - platform: template |
| 188 | update_interval: 60s |
| 189 | name: "Battery Level" |
| 190 | id: battery_level |
| 191 | unit_of_measurement: "%" |
| 192 | icon: "mdi:battery" |
| 193 | device_class: battery |
| 194 | state_class: measurement |
| 195 | lambda: 'return id(battery_voltage).state;' |
| 196 | on_value: |
| 197 | then: |
| 198 | - lambda: |- |
| 199 | int pct = int(x); |
| 200 | if (pct <= 10) id(battery_glyph) = "\U000F007A"; |
| 201 | else if (pct <= 20) id(battery_glyph) = "\U000F007B"; |
| 202 | else if (pct <= 30) id(battery_glyph) = "\U000F007C"; |
| 203 | else if (pct <= 40) id(battery_glyph) = "\U000F007D"; |
| 204 | else if (pct <= 50) id(battery_glyph) = "\U000F007E"; |
| 205 | else if (pct <= 60) id(battery_glyph) = "\U000F007F"; |
| 206 | else if (pct <= 70) id(battery_glyph) = "\U000F0080"; |
| 207 | else if (pct <= 80) id(battery_glyph) = "\U000F0081"; |
| 208 | else if (pct <= 90) id(battery_glyph) = "\U000F0082"; |
| 209 | else id(battery_glyph) = "\U000F0079"; |
| 210 | filters: |
| 211 | - calibrate_linear: |
| 212 | - 4.15 -> 100.0 |
| 213 | - 3.96 -> 90.0 |
| 214 | - 3.91 -> 80.0 |
| 215 | - 3.85 -> 70.0 |
| 216 | - 3.80 -> 60.0 |
| 217 | - 3.75 -> 50.0 |
| 218 | - 3.68 -> 40.0 |
| 219 | - 3.58 -> 30.0 |
| 220 | - 3.49 -> 20.0 |
| 221 | - 3.41 -> 10.0 |
| 222 | - 3.30 -> 5.0 |
| 223 | - 3.27 -> 0.0 |
| 224 | - clamp: |
| 225 | min_value: 0 |
| 226 | max_value: 100 |
| 227 | |
| 228 | # Button configuration |
| 229 | binary_sensor: |
| 230 | |
| 231 | # - platform: gpio |
| 232 | # pin: |
| 233 | # number: GPIO3 # Green button, commented out because I'm using it for wakeup |
| 234 | # mode: INPUT_PULLUP |
| 235 | # inverted: true |
| 236 | # id: button_1 |
| 237 | # name: "Green Button" |
| 238 | # on_press: |
| 239 | # then: |
| 240 | # - logger.log: "*** Green Button (GPIO3) Pressed ***" |
| 241 | |
| 242 | - platform: gpio |
| 243 | pin: |
| 244 | number: GPIO4 # Right white button |
| 245 | mode: INPUT_PULLUP |
| 246 | inverted: true |
| 247 | id: button_2 |
| 248 | name: "Right Button" |
| 249 | on_press: |
| 250 | then: |
| 251 | - logger.log: "*** Right Button (GPIO4) Pressed ***" |
| 252 | |
| 253 | - platform: gpio |
| 254 | pin: |
| 255 | number: GPIO5 # Left white button |
| 256 | mode: INPUT_PULLUP |
| 257 | inverted: true |
| 258 | id: button_3 |
| 259 | name: "Left Button" |
| 260 | on_press: |
| 261 | then: |
| 262 | - logger.log: "*** Left Button (GPIO5) Pressed ***" |
| 263 | |
| 264 | output: |
| 265 | - platform: gpio |
| 266 | pin: GPIO6 |
| 267 | id: bsp_led |
| 268 | inverted: true |
| 269 | - platform: gpio |
| 270 | pin: GPIO16 |
| 271 | id: bsp_sd_enable |
| 272 | - platform: gpio |
| 273 | pin: GPIO21 |
| 274 | id: bsp_battery_enable |
| 275 | |
| 276 | # Onboard LED |
| 277 | light: |
| 278 | - platform: binary |
| 279 | name: "Onboard LED" |
| 280 | output: bsp_led |
| 281 | id: onboard_led |