Hi,
I have a problem with my api connection to HA resetting about every second (or even faster). I am trying to run a ePaper display with a 18650 battery with deep sleep and wake-up every 10 minutes. Right now the battery holds for about one week, but I suppose this could be much longer when the api doesnt disconnect and reconnect so many times during the time the ESP32 is awake.
[D][sensor:127]: 'Battery voltage': Sending state 3.23015 V with 2 decimals of accuracy
[D][api:102]: Accepted ::FFFF:192.168.0.3
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:07
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api:102]: Accepted ::FFFF:192.168.0.3
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:07
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api:102]: Accepted ::FFFF:192.168.0.3
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:08
[D][api:102]: Accepted ::FFFF:192.168.0.3
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:08
[D][api:102]: Accepted ::FFFF:192.168.0.3
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:09
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api:102]: Accepted ::FFFF:192.168.0.3
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:10
[D][api:102]: Accepted ::FFFF:192.168.0.3
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:10
[W][api.connection:083]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection closed
[D][api:102]: Accepted ::FFFF:192.168.0.3
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:11
[D][homeassistant.sensor:024]: 'sensor.serverraum_temperatur': Got state 26.60
[D][sensor:127]: 'server_temperature': Sending state 26.60000 with 1 decimals of accuracy
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api:102]: Accepted ::FFFF:192.168.0.3
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:11
[D][api:102]: Accepted ::FFFF:192.168.0.3
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:12
[D][api:102]: Accepted ::FFFF:192.168.0.3
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:13
[D][api:102]: Accepted ::FFFF:192.168.0.3
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][homeassistant.sensor:024]: 'sensor.serverraum_temperatur': Got state 26.50
[D][sensor:127]: 'server_temperature': Sending state 26.50000 with 1 decimals of accuracy
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:13
[W][api.connection:081]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connection reset
[D][api:102]: Accepted ::FFFF:192.168.0.3
[D][api.connection:918]: Home Assistant 2023.2.3 (::FFFF:192.168.0.3): Connected successfully
[D][time:045]: Synchronized time: 2023-02-28 10:19:14
Here is my code:
esphome:
name: mxr-epaper-3big
on_boot:
priority: -100
then:
- delay: 15s
- component.update: my_display
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "mwv5iF21Bqk741qVbHCorE+Jt6rvRP5r7A0n9ylQKMI="
ota:
password: "27ccb311048adf6cf621ee0a40534a68"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
time:
- platform: homeassistant
id: esptime
on_time:
#Deep sleep at 8pm and wake up at 7am.
- hours: 20
then:
- delay: 1s
#Rest up
- deep_sleep.enter:
id: deep_sleep_control
until: "08:00:00"
time_id: esptime
deep_sleep:
id: deep_sleep_control
run_duration: 30s
sleep_duration: 10min
sensor:
- platform: homeassistant
id: gasverbrauch_tn_12_cost
entity_id: sensor.gast_strom_gesamt_utility
internal: true
- platform: adc
pin: 34
id: battery
name: "Battery voltage"
update_interval: 15s
filters:
- multiply: 3.85
- platform: homeassistant
id: outside_temperature
entity_id: sensor.mxr_temperature
internal: true
- platform: homeassistant
id: office_temperature
entity_id: sensor.durchschnittstemperatur_office
internal: true
- platform: homeassistant
id: server_temperature
entity_id: sensor.serverraum_temperatur
internal: true
- platform: homeassistant
id: detections_today
entity_id: sensor.eye_detections_today
internal: true
text_sensor:
- platform: homeassistant
id: counter
entity_id: counter.unangenehme_uberraschungen
internal: true
- platform: homeassistant
id: next_geburtstag
entity_id: calendar.geburtstage_mxr
attribute: message
internal: true
- platform: homeassistant
id: next_geburtstag_date
entity_id: sensor.birthday_cal_friendly
internal: true
- platform: homeassistant
id: epaper_text
entity_id: input_text.epaper_text
internal: true
font:
- file: 'fonts/materialdesignicons-webfont.ttf'
id: icon_font
size: 48
glyphs:
- "\U000F081A" # mdi-door
- file: 'fonts/Roboto-Regular.ttf'
id: roboto_80
size: 72
glyphs:
['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³', 'Ü', '€']
- file: 'fonts/Roboto-Regular.ttf'
id: roboto_40
size: 40
glyphs:
['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³', 'Ü']
- file: 'fonts/Roboto-Regular.ttf'
id: roboto_18
size: 20
glyphs:
['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³', 'Ü']
- file: 'fonts/Roboto-Regular.ttf'
id: roboto_200
size: 200
glyphs:
['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³', 'Ü', '€']
spi:
clk_pin: 14
mosi_pin: 27
display:
- platform: waveshare_epaper
id: my_display
cs_pin: 26
dc_pin: 32
update_interval: never
busy_pin: 35
reset_pin: 25
reset_duration: 2ms
model: 7.50inV2alt
rotation: 90
lambda: |-
it.strftime(475, 795, id(roboto_18), TextAlign::BOTTOM_RIGHT, "%x, %H:%M", id(esptime).now());
it.printf(475, 775, id(roboto_18), TextAlign::BOTTOM_RIGHT , "%.1f V", id(battery).state);
it.printf(10, 10, id(roboto_80), TextAlign::TOP_LEFT , "%.1f°C", id(outside_temperature).state);
it.print(10, 90, id(roboto_18), TextAlign::TOP_LEFT, "Aussentemperatur");
it.printf(470, 10, id(roboto_80), TextAlign::TOP_RIGHT , "%.1f°C", id(office_temperature).state);
it.print(470, 90, id(roboto_18), TextAlign::TOP_RIGHT, "Durschnittstemperatur Office");
it.line(10, 130, 470, 130);
it.printf(10, 140, id(roboto_80), TextAlign::TOP_LEFT , "%.1f°C", id(server_temperature).state);
it.print(10, 220, id(roboto_18), TextAlign::TOP_LEFT, "Serverraum Temperatur");
it.printf(470, 140, id(roboto_80), TextAlign::TOP_RIGHT , "%.1f €", id(gasverbrauch_tn_12_cost).state);
it.print(470, 220, id(roboto_18), TextAlign::TOP_RIGHT, "Strom- und Gaskosten");
it.line(10, 260, 470, 260);
it.printf(10, 270, id(roboto_80), TextAlign::TOP_LEFT, "%s",id(next_geburtstag).state.c_str());
it.printf(10, 355, id(roboto_18), TextAlign::TOP_LEFT, "Nächster Geburtstag am %s",id(next_geburtstag_date).state.c_str());
it.line(10, 395, 470, 395);
it.printf(10, 405, id(roboto_18), TextAlign::TOP_LEFT, "%s",id(epaper_text).state.c_str());
it.line(10, 590, 470, 590);
std::string val = to_string(id(counter).state);
it.printf(5, 795, id(roboto_200), TextAlign::BOTTOM_LEFT, "%s",id(counter).state.c_str());
it.print(5, 775, id(roboto_18), TextAlign::BOTTOM_LEFT, "Unangenehme");
it.print(5, 795, id(roboto_18), TextAlign::BOTTOM_LEFT, "Überraschungen");
it.printf(260, 600, id(roboto_40), TextAlign::TOP_LEFT , "%.0f", id(detections_today).state);
it.printf(220, 602, id(icon_font), TextAlign::TOP_LEFT, "\U000F081A");