8000 Deep sleep does not shut down connection with HA gracefuly · Issue #4794 · esphome/issues · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Deep sleep does not shut down connection with HA gracefuly #4794
Closed
esphome/esphome
#9008
@Jordan-Szwejda

Description

@Jordan-Szwejda

The problem

That's follow up a problem that sensor value of a device which reports voltage every 1h and goes deep sleep is reported as Unavailable in home assistant.
The original thread was created here:
home-assistant/core#98221 (comment)

The node should close correctly API connection to HA. Instead of this what can be observed in logs is:

2023-08-15 02:54:27.493 DEBUG (MainThread) [homeassistant.components.esphome.manager] carvoltage-esp: 192.168.0.208 disconnected (expected=False), running disconnected callbacks.

It is possible that the node enters deep sleep too early and communication with HA is not finished correctly. The node has weak wifi signal but there is not problem neither with transmitting sensor values nor with doing OTA updates so I can assume that connection is reliable enough to perform such a connection closing procedure.

I am attaching logs from HA:

ha-logs.txt

Which version of ESPHome has the issue?

2023.7.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.8.1

What platform are you using?

ESP8266

Board

esp01_1m

Component causing the issue

No response

Example YAML snippet

esphome:
  name: carvoltage-esp
  friendly_name: carvoltage-esp

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "gRoLBS0F6kxfXi6tqO8ye3WUeA+Ny70C6Y35HbyKTi0="

ota:
  password: "e54703412158e61bfff9ced3895c05a6"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  id: wifi_id
  manual_ip:
    static_ip: 192.168.0.208
    gateway: 192.168.0.1
    subnet: 255.255.255.0

deep_sleep:
  id: deep_sleep_id
  sleep_duration: 60s
   
sensor:
  - platform: adc
    id: adc_sensor
    pin: A0
    name: "Car Voltage"
    update_interval: 60000s     
    filters:
     - multiply: 14.02
  - platform: homeassistant
    name: "Deep Sleep Duration"
    id: deep_sleep_time
    entity_id: input_number.carvoltage_deep_sleep_time
    on_value:
      then:
        - logger.log:
            format: "Received deep sleep duration"
        - lambda: 'id(adc_sensor).update();'  
        - if:
            condition: 
              lambda: 'return id(deep_sleep_time).state>0;' 
            then:
              - deep_sleep.enter:
                  id: deep_sleep_id
                  sleep_duration: !lambda |-
                    return id(deep_sleep_time).state * 1000;
  - platform: uptime
    id: uptime_sensor
    name: Uptime Sensor
    internal: True
    on_value:
      then:
        - if:
            condition:            
              lambda: 'return id(uptime_sensor).state>=180 && !id(wifi_id).is_connected();'
            then:
              - deep_sleep.enter:
                  id: deep_sleep_id
                  sleep_duration: 3600s

Anything in the logs that might be useful for us?

2023-08-15 02:54:27.493 DEBUG (MainThread) [homeassistant.components.esphome.manager] carvoltage-esp: 192.168.0.208 disconnected (expected=False), running disconnected callbacks

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0