[Errno 111] Connection refused

I have successfully set up the ESPHome integration of the ttgo t-camera.

esphome:
  name: ringeapparat
  platform: ESP32
  board: esp-wrover-kit

I get the Successfully connected to 192.168.1.112 message, but even so I still struggle connecting to the Home Assistant API, it seems.

WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 1 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 2 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 4 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
INFO Successfully connected to 192.168.1.112
[12:02:53][D][time:030]: Synchronized time: Mon Sep 16 12:02:53 2019
[12:02:53][C][esp32_camera:043]: ESP32 Camera:
[12:02:53][C][esp32_camera:044]:   Name: Ringeapparat Camera
[12:02:53][C][esp32_camera:045]:   Board Has PSRAM: YES
[12:02:53][C][esp32_camera:047]:   Data Pins: D0:5 D1:14 D2:4 D3:15 D4:18 D5:23 D6:36 D7:39
[12:02:53][C][esp32_camera:048]:   VSYNC Pin: 27
[12:02:53][C][esp32_camera:049]:   HREF Pin: 25
[12:02:53][C][esp32_camera:050]:   Pixel Clock Pin: 19
[12:02:53][C][esp32_camera:051]:   External Clock: Pin:32 Frequency:20000000
[12:02:53][C][esp32_camera:052]:   I2C Pins: SDA:13 SCL:12
[12:02:53][C][esp32_camera:053]:   Reset Pin: -1
[12:02:53][C][esp32_camera:074]:   Resolution: 640x480 (VGA)
[12:02:53][C][esp32_camera:097]:   JPEG Quality: 10
[12:02:53][C][esp32_camera:099]:   Contrast: 0
[12:02:53][C][esp32_camera:100]:   Brightness: 0
[12:02:53][C][esp32_camera:101]:   Saturation: 0
[12:02:53][C][esp32_camera:102]:   Vertical Flip: ON

WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 1 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
INFO Successfully connected to 192.168.1.112

[12:03:02][D][time:030]: Synchronized time: Mon Sep 16 12:03:02 2019
[12:03:03][D][esp32_camera:157]: Got Image: len=26070
[12:03:03][D][binary_sensor:033]: 'Ringeapparat PIR': Sending state ON
[12:03:03][D][binary_sensor:033]: 'Ringeapparat Button': Sending state ON
[12:03:04][D][api:573]: Client 'Home Assistant 0.98.5 (192.168.1.10)' connected successfully!
[12:03:04][D][time:030]: Synchronized time: Mon Sep 16 12:03:04 2019
[12:03:04][D][binary_sensor:033]: 'Ringeapparat Button': Sending state OFF
[12:03:07][D][binary_sensor:033]: 'Ringeapparat PIR': Sending state OFF
[12:03:11][D][sensor:092]: 'Ringeapparat WiFi Signal': Sending state -68.00000 dB with 0 decimals of accuracy
[12:03:13][D][esp32_camera:157]: Got Image: len=24904
WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 1 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 2 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 4 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
INFO Successfully connected to 192.168.1.112
[12:03:30][D][time:030]: Synchronized time: Mon Sep 16 12:03:30 2019
[12:03:33][D][api:573]: Client 'Home Assistant 0.98.5 (192.168.1.10)' connected successfully!
[12:03:33][D][time:030]: Synchronized time: Mon Sep 16 12:03:33 2019
[12:03:38][D][esp32_camera:157]: Got Image: len=26136
WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 1 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 2 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
WARNING Couldn't connect to API (Error connecting to 192.168.1.112: [Errno 111] Connection refused). Trying to reconnect in 4 seconds
INFO Connecting to 192.168.1.112:6053 (192.168.1.112)
INFO Successfully connected to 192.168.1.112

When the button on the ttgo camera is pressed this action is fired. The tts.google_say is working, the message is sendt via notify.notify

action:
    - service: sonos.snapshot
    - service: media_player.volume_set
      data:
        entity_id: media_player.kjokken
        volume_level: 0.6
    - service: tts.google_say
      entity_id: media_player.kjokken, media_player.terrasse, media_player.soverom, media_player.lekerom, media_player.bad  
      data:
        message: 'Det ringer på!'
        cache: false   
    - service: notify.notify
      data:
        title: Ringeapparat, hoveddør
        message: Hvem ringer på?
        data:
          attachment:
            content-type: jpeg
          push:
            category: camera
            entity_id: camera.ringeapparat_camera
    - service: sonos.restore

… but there is no photo arriving on my iPhone, only this message inside the pop-up window on the iPhone:

ttgo cam do capture images (see log below), but does not foreward the photo to the notify message.

[12:03:02][D][time:030]: Synchronized time: Mon Sep 16 12:03:02 2019
[12:03:03][D][esp32_camera:157]: Got Image: len=26070
[12:03:03][D][binary_sensor:033]: 'Ringeapparat PIR': Sending state ON
[12:03:03][D][binary_sensor:033]: 'Ringeapparat Button': Sending state ON
[12:03:04][D][api:573]: Client 'Home Assistant 0.98.5 (192.168.1.10)' connected successfully!
[12:03:04][D][time:030]: Synchronized time: Mon Sep 16 12:03:04 2019
[12:03:04][D][binary_sensor:033]: 'Ringeapparat Button': Sending state OFF
[12:03:07][D][binary_sensor:033]: 'Ringeapparat PIR': Sending state OFF
[12:03:11][D][sensor:092]: 'Ringeapparat WiFi Signal': Sending state -68.00000 dB with 0 decimals of accuracy
[12:03:13][D][esp32_camera:157]: Got Image: len=24904

What is going on here?
FYI: This has worked as expected until I moved the cam from my lab (EDIT 9/17: setup to its final setup in the same location, using external power supply) to its final location with external power. This same power supply was used when it worked. :slight_smile:

Any clue is highly appreciated :slight_smile:

Try putting it back in the original setting where it worked to rule out any obvious issues. Sounds like the cameras are unable to grab the images to forward to you. Try grabbing images in a browser to rule out any LAN issues, possible WIFI connection issues with your cameras.

This is the settings that worked. I know it sounds strange, but there has been no changes to the yaml file, and I have tried re-flashing using the same bin and even a freshly build one without any progress.

I am not sure how I can check for image in a browser, though. How can I find the url for that?

The ttgo reports back PIR status, and races on PIR movement, and the button works when pressed, so it is definitely WiFi connected…

This URL gives an 500 http “internal server error”

http://192.168.xxx.nnn:8123/api/camera_proxy/camera.ringeapparat_camera?token=XXYYZZAABBCCDDEEFF

Token replaced

The error found on the iOS device is found in localizable strings in the Home Assistant repository at Github

home-assistant-iOS/HomeAssistant/Resources/en.lproj/Localizable.strings
"extensions.notification_content.error.no_entity_id" = "No entity_id found in payload!"

I have no clue what this means as to what error occurred and how I fix it…

The Safari browser on your Apple device allows you to capture an image. Just try that to see if you can capture an image.

Did you move your experimental setup to a different LAN.

Same LAN. Same IP. I have hard coded til IP in the yaml and via DHCP/mac

Where should this image appear?
Here is the property window for the entity. It never expands to reveal the image (live or still photo).

It should appear on the host, your HA server. Just check the folders to find it. I’m assuming you are using HA in a venv or Hassbian.

hass.io in Docker

Your log reveals api disconnects. Do you have a decent antenna?

Is your cam overheating?

What are your cam settings?

Apologies. Does your camera have any storage medium. If so you’ll find the image there.

I really think the problem lies with authentication between Hass.io and your camera.

I use HA in the venv so maybe someone using hass.io may be able to point you in the right direction.

Reading again, this is certainly to do with your wifi coonectivity, you moved the camera further from your AP right?

The WiFi signal strengt is the best (-68 db)

[12:03:11][D][sensor:092]: 'Ringeapparat WiFi Signal': Sending state -68.00000 dB with 0 decimals of accuracy

I doubt it’s overheating

Here is the configuration

substitutions:
  devicename: ringeapparat
  friendly_name: Ringeapparat
  ip_address: 192.168.1.112
esphome:
  name: $devicename
  platform: ESP32
  board: esp-wrover-kit
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pw
  manual_ip:
    static_ip: $ip_address
    gateway: !secret gateway
    subnet: 255.255.255.0

# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
binary_sensor:
  - platform: gpio
    pin: GPIO33
    name: $friendly_name PIR
    device_class: motion
  - platform: gpio
    pin:
      number: GPIO34  # This is the right side button on the board. 
      mode: INPUT_PULLUP
      inverted: True
    name: $friendly_name Button
#    filters:
#      - delayed_off: 10ms
    
  - platform: status
    name: $friendly_name Status
sensor:
  - platform: wifi_signal
    name: $friendly_name WiFi Signal
    update_interval: 10s
  - platform: uptime
    name: $friendly_name Uptime
esp32_ble_tracker:
esp32_camera:
  name: $friendly_name Camera
  external_clock:
    pin: GPIO32
    frequency: 20MHz
  i2c_pins:
    sda: GPIO13
    scl: GPIO12
  data_pins: [GPIO5, GPIO14, GPIO4, GPIO15, GPIO18, GPIO23, GPIO36, GPIO39]
  vsync_pin: GPIO27
  href_pin: GPIO25
  pixel_clock_pin: GPIO19
  power_down_pin: GPIO26
  resolution: 640x480
  jpeg_quality: 10
  vertical_flip: true      # defaults to true
  horizontal_mirror: true  # defaults to true
i2c:
  sda: GPIO21
  scl: GPIO22
font:
  - file: "arial-narrow.ttf"
    id: tnr1
    size: 20
    glyphs: BÆØÅ brukdnapæøå
  - file: "arial-narrow.ttf"
#  - file: "helveticaneue-light.ttf"
    id: tnr2
    size: 34
time:
  - platform: homeassistant
    id: homeassistant_time
display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    rotation: 180
    address: 0x3C
    lambda: |-
      it.strftime(64, 0, id(tnr1), TextAlign::TOP_CENTER,"Bruk rød knapp", id(homeassistant_time).now());
      it.strftime(64, 64, id(tnr2), TextAlign::BASELINE_CENTER, "%H:%M", id(homeassistant_time).now());

This all happened at the same location. The WiFi signal is good (-68 dB) and it’s been working perfectly at this spot while testing and preparing the device.

Regarding WiFi: since the signal is very good, what else could be causing this?
IP address is now set in the config, as opposed to by dns/Mac.
If, theoretically, the WiFi is the issue, eg. it seems to disconnect?, why is only the image/camera having problems? Pressing the button triggers the doorbell automation as expected.

Last night I ripped the entire ESPHome add-on off my HA installation.
I removed
the esphome entries in Integrations in ha
the esphome folders and files in /.storage.
the /config/esphome folder
uninstalled esphome plug-in
Restarted homeassistant
Installed esphome
Added the yaml and dependent files to /config/esphome
Restarted home Assistant
Added the ttgo device to HA in integration
Restarted ha

Re-flashed the ttgo ATO from within ESPHome

Still camera is missing in Integrations, and it seems to continue disconnecting.

Not what you said in your first post.

True. Apologies. What I meant in the first post was regarding power supply which now is via an external power supply as opposed to via usb from my Mac.

SOLUTION - to connection trouble
Thanks to this article: Simultaneous WiFi and Bluetooth: Paket loss and WiFi disconnects I removed the BLE-integration:

sensor:
  - platform: wifi_signal
    name: $friendly_name WiFi Signal
    update_interval: 10s
  - platform: uptime
    name: $friendly_name Uptime

#esp32_ble_tracker:   # <-----------------REMOVED BLE TRACKER ----------------------

esp32_camera:
  name: $friendly_name Camera
  external_clock:
    pin: GPIO32
    frequency: 20MHz

Disabling BLE was a set-back, as I was planning to use BLE as a detector for known devises, and to unlocking the door, and setting the house in “home mode”.

Anyway; I have yet to address the issue regarding the notify message, which still is missing the photo from the ttgo camera. The iOS popup shows still this error message: