home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.15k stars 29.83k forks source link

ESP32 camera not working after update to 2021.7.0 #52718

Closed pmannk closed 3 years ago

pmannk commented 3 years ago

The problem

After updating to core-2021.7.0 my ESP32 camera feed stopped displaying in my lovelace view. Looking into the HA logbook, I found the camera entity was continually toggling between available and unavailable. This ESP32 camera module is running firmware compiled with ESPHome (1.19.4).

The ESP32 board in question also has a a few sensors connected to its GPIO pins as well as some very generic ESPHome sensors (uptime, wifi signal, reboot switch, etc).

I notice that every time HA tries to poll the ESP32 for an image, the HA API disconnects from the device (which causes all the other sensors/switches/entities associated with the ESP32 to briefly toggle offline too).

If I remove the esp32_camera component from the firmware, the HA API remains connected and the entity state of my sensors/switches remains online as expected.

Rolling back to HA 2021.6.6 fixes the issue - the camera feed works and the HA API remains connected with no problem.

What is version of Home Assistant Core has the issue?

core-2021.7.0

What was the last working version of Home Assistant Core?

core-2021.6.6

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ESPHome

Link to integration documentation on our website

https://www.home-assistant.io/integrations/esphome/

Example YAML snippet

Example config components from ESPHome - these are the sensors, camera, etc
sensor:
  - platform: wifi_signal
    name: ${devname} WiFi Signal
    id: ${devname}_wifi_signal
    update_interval: 60s

  - platform: uptime
    name: ${devname} Uptime
    id: ${devname}_uptime

esp32_camera:
  external_clock:
    pin: GPIO0
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22
  power_down_pin: GPIO32
  max_framerate: 1 fps
  resolution: SXGA
  jpeg_quality: 20
  contrast: 2
  saturation: 2
  name: ${devname} camera
  id: ${devname}_camera

switch:
  - platform: restart
    name: ${devname} Restart
    id: ${devname}_restart

Anything in the logs that might be useful for us?

Every 10 seconds when HA polls the ESP32 for an image, the ESP32 logs the following:
[14:26:05][D][esp32_camera:156]: Got Image: len=38209
[14:26:05][D][api:067]: Disconnecting Home Assistant 2021.7.0 (192.168.6.8)
[14:26:06][D][api.connection:630]: Client 'Home Assistant 2021.7.0 (192.168.6.8)' connected successfully!
[14:26:06][D][time:040]: Synchronized time: Thu Jul  8 14:26:06 2021

... and any entities associated with the ESP32 toggle offline in the logbook:
espcam_1 Restart turned off
2:26:06 PM - 17 minutes ago
espcam_1 Restart became unavailable

Additional information

probot-home-assistant[bot] commented 3 years ago

esphome documentation esphome source (message by IssueLinks)

probot-home-assistant[bot] commented 3 years ago

Hey there @ottowinter, @jesserockz, mind taking a look at this issue as its been labeled with an integration (esphome) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

pacomm commented 3 years ago

I have de same problem

MattWestb commented 3 years ago

Same here the cam is broken in 2021.7 on the HA side not in ESPHome.

2021-07-08 12:08:48 INFO (MainThread) [homeassistant.components.esphome] Successfully connected to 192.168.2.80
2021-07-08 12:08:58 INFO (MainThread) [aioesphomeapi.connection] 192.168.2.80: Unexpected error while reading incoming messages: 'CameraImageResponse' object has no attribute 'image'
2021-07-08 12:08:58 INFO (MainThread) [homeassistant.components.esphome] Disconnected from ESPHome API for 192.168.2.80

Its looks ESPHome is trying sending one images but HA cant handling it and ESPHome is disconnecting for API.

The device is flagged offline but is responding to commands like toggling the flashlight without problems so its only that HA is refusing receiving the images from our cams.

jesserockz commented 3 years ago

Might be related to https://github.com/esphome/aioesphomeapi/pull/36

MattWestb commented 3 years ago

So all users need recompiling there firmware for there cams and applying the patch for HA for making it working ??

jesserockz commented 3 years ago

So all users need recompiling there firmware for there cams and applying the patch for HA for making it working ??

No, only updating to HA 2021.7.1 when it is released and it should work again.

MattWestb commented 3 years ago

OK I was patching HA core with #52738 but i was thinking the https://github.com/esphome/aioesphomeapi/pull/62 is not in HA its in ESPHome so i was not patching it and the cam is not loading at all in HA.

Where in HA Core is the file that need the https://github.com/esphome/aioesphomeapi/pull/62 patch ?

jesserockz commented 3 years ago

If you also patched the manifest.json file then HA should install the newer version to match the changes.

MattWestb commented 3 years ago

Then better waiting for the dot 1 release then its in my production system ;-))

gonzotek commented 3 years ago

I've upgraded to 2021.7.1, verified my venv install has the new 5.0.0 version of aioesphome and I'm still not getting my camera in Home Assistant (just a broken image icon). I turned the Home Assistant logging all the way to debug for homeassistant.components.esphome, but nothing esphome-related is showing up since the 2021.7.1 update. The other entities tied to the device (a restart switch and the on-board led light) aren't going unavailable every few seconds like they were, but still no image :-(. I'm at work and can not access the esphome logging until I get home later today to see if there is anything telling from that end.

DavyRoswinkel commented 3 years ago

Updated to 2021.7.1 Still no camera image here. No errors in the log, just a blank image where the camera picture normally is.

MattWestb commented 3 years ago

The cam is sending images but HA is lagging it complete off line. ESPHome log:

[18:46:25][D][sensor:117]: 'Sun Azimuth': Sending state 283.09189 ° with 1 decimals of accuracy
[18:46:32][D][esp32_camera:156]: Got Image: len=32452
[18:46:42][D][esp32_camera:156]: Got Image: len=32008
[18:46:52][D][esp32_camera:156]: Got Image: len=32411
[18:47:02][D][esp32_camera:156]: Got Image: len=32494
[18:47:07][D][sensor:117]: 'Sun Elevation': Sending state 18.49035 ° with 1 decimals of accuracy
[18:47:12][D][esp32_camera:156]: Got Image: len=33068

HA card:

Device info
Espressif ESP32 Dev Module
by espressif
Firmware: 1.19.0 (Jun 17 2021, 13:03:44)
Entities
ESPHome Cam Unavailable
ESPHome Cam Flach light
ESPHome Cam Restart
ESPHome Cam Status Unavailable
Sun Azimuth Unavailable
Sun Elevation Unavailable

And 2 errors in HA log:

ogger: homeassistant
Source: components/esphome/__init__.py:223
First occurred: 18:41:50 (7 occurrences)
Last logged: 18:41:50

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/__init__.py", line 223, in send_home_assistant_state_event
    and event.data["old_state"].state
AttributeError: 'NoneType' object has no attribute 'state'

2

Logger: homeassistant
Source: components/esphome/entry_data.py:144
First occurred: 18:41:50 (1 occurrences)
Last logged: 18:41:50

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/__init__.py", line 282, in complete_setup
    infos, services = await entry_data.async_load_from_store()
  File "/usr/src/homeassistant/homeassistant/components/esphome/entry_data.py", line 144, in async_load_from_store
    self.device_info = DeviceInfo.from_dict(restored.pop("device_info"))
KeyError: 'device_info'
MattWestb commented 3 years ago

Deleting the device and restarting HA and re-adding it and its connecting OK but no video displayed. ESPHCamA

And some errors in HA log after the restart:

Logger: homeassistant
Source: components/esphome/__init__.py:223
First occurred: 18:58:52 (7 occurrences)
Last logged: 18:58:52

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/__init__.py", line 223, in send_home_assistant_state_event
    and event.data["old_state"].state
AttributeError: 'NoneType' object has no attribute 'state'

Logger: root
Source: /usr/src/homeassistant/homeassistant/bootstrap.py:312
First occurred: 18:58:44 (1 occurrences)
Last logged: 18:58:44

Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiocoap/transports/tinydtls.py", line 254, in _event
    self._connecting.set_result(True)
asyncio.exceptions.InvalidStateError: invalid state
MattWestb commented 3 years ago

The open the "camera window" (only possible from the device card) ESPHCamB ESPHome cam is starting sending images with fast rate but HA is not using them so somthing more is broken.

[D][sensor:117]: 'Sun Azimuth': Sending state 287.24930 ° with 1 decimals of accuracy
[D][esp32_camera:156]: Got Image: len=19455
[D][esp32_camera:156]: Got Image: len=21192
[D][esp32_camera:156]: Got Image: len=21037
[D][esp32_camera:156]: Got Image: len=19995
[D][sensor:117]: 'Sun Elevation': Sending state 14.63072 ° with 1 decimals of accuracy
[D][esp32_camera:156]: Got Image: len=20132
[D][esp32_camera:156]: Got Image: len=20211
[D][esp32_camera:156]: Got Image: len=20368
[D][esp32_camera:156]: Got Image: len=20399
[D][esp32_camera:156]: Got Image: len=20116
[D][esp32_camera:156]: Got Image: len=20188
[D][esp32_camera:156]: Got Image: len=20186
[D][esp32_camera:156]: Got Image: len=20166
[D][esp32_camera:156]: Got Image: len=20185
[D][esp32_camera:156]: Got Image: len=20190
[D][esp32_camera:156]: Got Image: len=20236
[D][esp32_camera:156]: Got Image: len=20363
[D][esp32_camera:156]: Got Image: len=20129
[D][esp32_camera:156]: Got Image: len=20145
[D][esp32_camera:156]: Got Image: len=20141
[D][esp32_camera:156]: Got Image: len=20141
[D][esp32_camera:156]: Got Image: len=20185
[D][esp32_camera:156]: Got Image: len=20109

The first part (4 images) is idle and and then its "live streaming" in very short interval.

freitas666 commented 3 years ago

The open the "camera window" ESPHCamB ESPHome cam is starting sending images with fast rate but HA is not using them so somthing more is broken.

[D][sensor:117]: 'Sun Azimuth': Sending state 287.24930 ° with 1 decimals of accuracy�
[D][esp32_camera:156]: Got Image: len=19455�
[D][esp32_camera:156]: Got Image: len=21192�
[D][esp32_camera:156]: Got Image: len=21037�
[D][esp32_camera:156]: Got Image: len=19995�
[D][sensor:117]: 'Sun Elevation': Sending state 14.63072 ° with 1 decimals of accuracy�
[D][esp32_camera:156]: Got Image: len=20132�
[D][esp32_camera:156]: Got Image: len=20211�
[D][esp32_camera:156]: Got Image: len=20368�
[D][esp32_camera:156]: Got Image: len=20399�
[D][esp32_camera:156]: Got Image: len=20116�
[D][esp32_camera:156]: Got Image: len=20188�
[D][esp32_camera:156]: Got Image: len=20186�
[D][esp32_camera:156]: Got Image: len=20166�
[D][esp32_camera:156]: Got Image: len=20185�
[D][esp32_camera:156]: Got Image: len=20190�
[D][esp32_camera:156]: Got Image: len=20236�
[D][esp32_camera:156]: Got Image: len=20363�
[D][esp32_camera:156]: Got Image: len=20129�
[D][esp32_camera:156]: Got Image: len=20145�
[D][esp32_camera:156]: Got Image: len=20141�
[D][esp32_camera:156]: Got Image: len=20141�
[D][esp32_camera:156]: Got Image: len=20185�
[D][esp32_camera:156]: Got Image: len=20109�

The first part (4 images) is idle and and then its "live streaming" in very short interval.

Yeah bro.. i have the same problem here...

Hope they fix as soon possible!

pacomm commented 3 years ago

Yes, still broken...

MattWestb commented 3 years ago

Now the video is broken but the API is working OK after the first fix that was doing the module rebooting then was not able having communication with the module.

freitas666 commented 3 years ago

Now the video is broken but the API is working OK after the first fix that was doing the module rebooting then was not able having communication with the module.

Yes.. yesterday had a bug about connect and disconnect all time.. Today was fix. But not show image on Home Assistant :-/

Strangehadron commented 3 years ago

Same for me since the update. I've not change anything and it was working on 2021.6 The cam itself work, but no video at all.

jlt24 commented 3 years ago

Same issue here. Just updated to 2021.7.1. No longer getting connection / re-connection issues but still no video.

Kaibob2 commented 3 years ago

Same here. No video for the esp32cam. HA 2021.7.1 ESPHOME 1.19.4 Debian Buster / NUC Docker

dUaL13 commented 3 years ago

Hello,

Same issue with HA 2021.7.1 with ESPHome 1.19.4 on a Raspberry Pi 4.

freitas666 commented 3 years ago

Remember NEVER MORE update HA for a new release!!!! The way is wait till 4 releases after....

Now all my esp32 cam projects is stopped....and not depends on me to fix :(

jlt24 commented 3 years ago

Remember NEVER MORE update HA for a new release!!!! The way is wait till 4 releases after....

Now all my esp32 cam projects is stopped....and not depends on me to fix :(

Rollback?

freitas666 commented 3 years ago

I always do backup and take a snapshot on my vmware before update but this time... i didnt...

Enviado do meu iPhone

Em 8 de jul. de 2021, à(s) 23:34, jlt24 @.***> escreveu:



Remember NEVER MORE update HA for a new release!!!! The way is wait till 4 releases after....

Now all my esp32 cam projects is stopped....and not depends on me to fix :(

Rollback?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/52718#issuecomment-876868223, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAQ7DLQULTCMXV2OBREKHG3TWZN4JANCNFSM5AAIAMFA.

nickrout commented 3 years ago

You can still rollback.

ha core update --version 2021.6.6
freitas666 commented 3 years ago

In this case not i will lose others updates?

Enviado do meu iPhone

Em 8 de jul. de 2021, à(s) 23:43, nickrout @.***> escreveu:



You can still rollback.

ha core update --version 2017.6.6

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/52718#issuecomment-876870803, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAQ7DLX6QUH6URWCFRCBS6TTWZO4JANCNFSM5AAIAMFA.

nickrout commented 3 years ago

You will revert to 2021.6.6 (sorry I made e typo above, I had 2017, fixed it now)

freitas666 commented 3 years ago

Just core will be revert?

Enviado do meu iPhone

Em 8 de jul. de 2021, à(s) 23:48, nickrout @.***> escreveu:



You will revert to 2021.6.6 (sorry I made e typo above, I had 2017, fixed it now)

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/52718#issuecomment-876872448, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAQ7DLUMU5DB4ZZFUG656QTTWZPRNANCNFSM5AAIAMFA.

jesserockz commented 3 years ago

Deleting the device and restarting HA and re-adding it and its connecting OK but no video displayed.

And some errors in HA log after the restart:

Logger: homeassistant
Source: components/esphome/__init__.py:223
First occurred: 18:58:52 (7 occurrences)
Last logged: 18:58:52

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/__init__.py", line 223, in send_home_assistant_state_event
    and event.data["old_state"].state
AttributeError: 'NoneType' object has no attribute 'state'

Logger: root
Source: /usr/src/homeassistant/homeassistant/bootstrap.py:312
First occurred: 18:58:44 (1 occurrences)
Last logged: 18:58:44

Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiocoap/transports/tinydtls.py", line 254, in _event
    self._connecting.set_result(True)
asyncio.exceptions.InvalidStateError: invalid state

@MattWestb This stacktrace looks unrelated to the esp32 camera, could you please open a new issue for it though as I think I know what is causing it. (To do with using sensor -> platform: homeassistant in the yaml)

nickrout commented 3 years ago

Just core will be revert?

If you run the command I gave then the core will revert. Were you expecting something else from ha core update?

pmannk commented 3 years ago

I updated to 2021.7.1 this evening and I'm seeing the same behaviour as @MattWestb The API no longer disconnects, and image requests are made every ~10 seconds as expected, however no image is rendered in the lovelace card:

[20:47:32][D][api.connection:630]: Client 'Home Assistant 2021.7.1 (192.168.6.8)' connected successfully! [20:47:32][D][time:040]: Synchronized time: Fri Jul 9 20:47:32 2021 [20:47:39][D][esp32_camera:156]: Got Image: len=36493 [20:47:49][D][esp32_camera:156]: Got Image: len=34560 [20:47:59][D][esp32_camera:156]: Got Image: len=34129 [20:48:10][D][esp32_camera:156]: Got Image: len=34363 [20:48:20][D][esp32_camera:156]: Got Image: len=34229 ....

If I open the camera to watch the stream I see the image requests increase to 1/second as expected, however nothing ever renders [20:49:49][D][esp32_camera:156]: Got Image: len=34146 [20:49:50][D][esp32_camera:156]: Got Image: len=34194 [20:49:51][D][esp32_camera:156]: Got Image: len=34161 [20:49:52][D][esp32_camera:156]: Got Image: len=34560 [20:49:53][D][esp32_camera:156]: Got Image: len=34938 ....

Edit - nevermind, I just saw the other pull request that a fix is in the pipeline

52783

Nathareth commented 3 years ago

I am using 6 ESP32 CAMs. Unfortunately, after updating to the latest version, all cameras stopped working for me.

Berkeborn commented 3 years ago

Same here. My esp32 cam’s stopped feeding img to lovelace after update to 2021.7.1.

pmannk commented 3 years ago

Confirming this issue is resolved after updating to 2021.7.2

Kaibob2 commented 3 years ago

Confirming this issue is resolved after updating to 2021.7.2

Same here. Good job. All cams are working again.