oxan / esphome-stream-server

Stream server (serial-to-wifi bridge) for ESPHome
Other
190 stars 76 forks source link

Sensors show "unknown" until first connection #35

Closed joshuaspence closed 1 year ago

joshuaspence commented 1 year ago

The connected binary sensor and connection count sensor both report a value of Unknown until the first client is connected. I would have expect the binary sensor to report False and the regular sensor to report a count of 0. This seems to happen because StreamServerComponent::publish_sensor is only called from StreamServerComponent::accept and StreamServerComponent::cleanup.

joshuaspence commented 1 year ago

As a workaround:

esphome:
  on_boot:
    priority: 600
    then:
      - lambda: |-
          id(stream_server_connected).publish_state(false);
          id(stream_server_connections).publish_state(0);
oxan commented 1 year ago

Nice catch, thanks!