fuatakgun / eufy_security

Home Assistant integration to manage Eufy Security devices as cameras, home base stations, doorbells, motion and contact sensors.
932 stars 79 forks source link

Camera feed not detected after setup. #10

Closed apokha1 closed 3 years ago

apokha1 commented 3 years ago

I am working with a wired doorbell, T8200. After the installation, three new entities were added, person detector sensor, battery & wifi ssid power. The battery entity was unavailable, as it makes sens with the wired doorbell, there is no battery. wifi ssid sensor was unavailable too. And I had no luck getting the stream from the doorbell camera.

image

Some log lines:

2021-07-18 12:16:49 ERROR (MainThread) [custom_components.eufy_security] eufy_security - Exception in websocket - process_messages : 'battery' - traceback: Traceback (most recent call last): File "/config/custom_components/eufy_security/websocket.py", line 55, in process_messages await self.on_message(msg) File "/config/custom_components/eufy_security/websocket.py", line 66, in on_message await self.message_callback(message) File "/config/custom_components/eufy_security/coordinator.py", line 165, in on_message self.async_set_updated_data(self.data) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 287, in async_set_updated_data update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 453, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 425, in _stringify_state state = self.state File "/config/custom_components/eufy_security/sensor.py", line 86, in state return self.entity[self.key] KeyError: 'battery'

2021-07-18 12:12:43 ERROR (MainThread) [homeassistant.components.camera] Error while setting up eufy_security platform for camera Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/eufy_security/camera.py", line 34, in async_setup_entry _LOGGER.debug(f"{DOMAIN} - camera setup entries - {entities}") File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 803, in __repr__ return f"<Entity {self.name}: {self.state}>" File "/config/custom_components/eufy_security/camera.py", line 74, in state self.is_streaming = self.entity["rtspStream"] KeyError: 'rtspStream'

fuatakgun commented 3 years ago

yes, i am working on it, let's follow from here, i will publish an update tonight in EU time :) https://github.com/fuatakgun/eufy_security/issues/6

fuatakgun commented 3 years ago

ops, let's reopen it to track battery and WIFI sensors

apokha1 commented 3 years ago

Sure thing. Thank you, will keep an eye on this issue.

dsjackson commented 3 years ago

Just installed it today with the custom integration. Two cameras were detected and one doorbell. All of them have various sensors, etc. None of them show as having an entity ID as camera.XXX

BTW...excellent progress! Happy that I don't need to install a Docker.

rpitera commented 3 years ago

Same here; was happy to see that my 2k Floodlight cam was detected along with my cams, but no camera entities for any of them.

Still though; following the directions given, the install went great and the progress is amazing. Thanks for the work! Hoping this will replace ioBroker for my setup!

apokha1 commented 3 years ago

I tried installing everything fresh again after your recent commit and followed the instruction there. The problem with the camera not being detected is still there along with wifi_rssi sensor being unavailable and the doorbell_battery sensor unavailable as well. (I have a wired version - T8200) The only sensor that seems to populate after the installation of the integration is the Person Detection Sensor.

Here are my log files.

2021-07-22 08:33:00 ERROR (MainThread) [homeassistant.components.camera] Error while setting up eufy_security platform for camera
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/eufy_security/camera.py", line 76, in async_setup_entry
_LOGGER.debug(f"{DOMAIN} - camera setup entries - {entities}")
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 803, in __repr__
return f"<Entity {self.name}: {self.state}>"
File "/config/custom_components/eufy_security/camera.py", line 124, in state
self.entity["rtspStream"] == True
KeyError: 'rtspStream'

2021-07-22 08:33:00 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform eufy_security
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 666, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 453, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 425, in _stringify_state
state = self.state
File "/config/custom_components/eufy_security/sensor.py", line 86, in state
return self.entity[self.key]
KeyError: 'battery'

2021-07-22 08:33:00 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up eufy_security platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 258, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 666, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 453, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 425, in _stringify_state
state = self.state
File "/config/custom_components/eufy_security/sensor.py", line 86, in state
return self.entity[self.key]
KeyError: 'battery'
2021-07-22 08:33:01 ERROR (MainThread) [custom_components.eufy_security] eufy_security - Exception - process_messages : 'battery' - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/websocket.py", line 65, in process_messages
await self.on_message(msg)
File "/config/custom_components/eufy_security/websocket.py", line 81, in on_message
await self.message_callback(message)
File "/config/custom_components/eufy_security/coordinator.py", line 170, in on_message
self.async_set_updated_data(self.data)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 287, in async_set_updated_data
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 453, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 425, in _stringify_state
state = self.state
File "/config/custom_components/eufy_security/sensor.py", line 86, in state
return self.entity[self.key]
KeyError: 'battery'

2021-07-22 08:33:01 ERROR (MainThread) [homeassistant.components.binary_sensor] eufy_security: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 432, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 601, in async_device_update
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 336, in async_update
await self.coordinator.async_request_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 141, in async_request_refresh
await self._debounced_refresh.async_call()
File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 78, in async_call
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_refresh
await self._async_refresh(log_failures=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 453, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 425, in _stringify_state
state = self.state
File "/config/custom_components/eufy_security/sensor.py", line 86, in state
return self.entity[self.key]
KeyError: 'battery'
jbrukardt commented 3 years ago

Adding some log data to this. Eufy 2k indoor cameras

Logger: homeassistant.components.stream.worker
Source: components/stream/worker.py:215
Integration: Stream (documentation, issues)
First occurred: 3:55:58 PM (42 occurrences)
Last logged: 4:05:54 PM

Error opening stream None

No stream under any circumstances, including when start stream service command is issued.

fuatakgun commented 3 years ago

Adding some log data to this. Eufy 2k indoor cameras

Logger: homeassistant.components.stream.worker
Source: components/stream/worker.py:215
Integration: Stream (documentation, issues)
First occurred: 3:55:58 PM (42 occurrences)
Last logged: 4:05:54 PM

Error opening stream None

No stream under any circumstances, including when start stream service command is issued.

can you confirm that you have enabled rtsp stream from camera? i believe supports rtsp.

jbrukardt commented 3 years ago

Adding some log data to this. Eufy 2k indoor cameras

Logger: homeassistant.components.stream.worker
Source: components/stream/worker.py:215
Integration: Stream (documentation, issues)
First occurred: 3:55:58 PM (42 occurrences)
Last logged: 4:05:54 PM

Error opening stream None

No stream under any circumstances, including when start stream service command is issued.

can you confirm that you have enabled rtsp stream from camera? i believe supports rtsp.

Confirmed

Setting screenshot: https://i.imgur.com/j51XPp4.png

fuatakgun commented 3 years ago

After you call camera.turn_on or start_livestream, can you also check the logs of Add On which is used mainly communication with devices.

if you can enable excessive logging for the integration and share the logs, i could have a deep dive investigation.

logger:
  default: warning
  logs:
    custom_components.eufy_security: debug
    haffmpeg.core: debug
    ffmpeg: debug
dsjackson commented 3 years ago

See attached logs logs.txt

fuatakgun commented 3 years ago

See attached logs logs.txt

Can you confirm you have the latest codebase?

dsjackson commented 3 years ago

Installed everything 21 July...certainly can update to make sure code is current.

jbrukardt commented 3 years ago

Latest codebase here (f948623) please see attached log.

Issued the service call to start streams on all devices at 2021-07-23 10:38:26. Something very obviously changed when that was issued as the logging blew up (truncated the log slightly after that for size), but still no livestream.

log: home-assistant.txt

Installed everything 21 July...certainly can update to make sure code is current.

ancient history by fuat's coding speed :D i think theres been three revs since then.

apokha1 commented 3 years ago

Finally, with the latest update, I was able to get the camera entity along with Motion Sensor, Person Detector Sensor, Ringing Sensor. But, the camera entity fails to start the live stream. I do get a still image when there is an event, but unable to start the live feed.

There seem to be tons of eufy_security strings in the log file.

image

File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
BrokenPipeError: [Errno 32] Broken pipe
2021-07-23 11:50:43 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:43 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:43 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:43 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream eufy_security-T8200N001939068F.m3u8
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:44 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (Thread-22) [pychromecast.socket_client] [Play Area speaker(192.168.11.25):8009] Failed to connect to service ServiceInfo(type='mdns', data='Google-Home-Mini-53650d3cd8b0a82b5c01e1e7b6d47b9b._googlecast._tcp.local.'), retrying in 5.0s
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:45 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:46 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:47 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:47 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:47 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:47 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:47 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:47 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file
2021-07-23 11:50:47 ERROR (MainThread) [custom_components.eufy_security] eufy_security Exception in video : I/O operation on closed file - traceback: Traceback (most recent call last):
File "/config/custom_components/eufy_security/camera.py", line 240, in process_frames
self.ffmpeg.process.stdin.write(frame_bytes)
ValueError: I/O operation on closed file

The log goes on and on with similar data, I am assuming whenever I am trying to start the stream, this is happening.

Please let me know if I am doing anything wrong, or if I need to do anything on my end to help identify and solve the bug if it is one.

dsjackson commented 3 years ago

Will confirm...latest update shows cameras (and static images). Live stream fails. All-in-all, excellent progress!

rpitera commented 3 years ago

Seconded @dsjackson findings - same here. Also same on progress - getting from no cameras to semi working was fast!

fuatakgun commented 3 years ago

Please confirm you have enabled ffmpeg in your setup.

rpitera commented 3 years ago

Install: Home Assistant OS 6.1 / core-2021.7.4 / supervisor-2021.06.8 Running on Virtualbox on a dedicated Win10 Pro workstation. I could provide access to the server via SplashTop if it would help or provide a login to the HA instance.

System Health

version core-2021.7.4
installation_type Home Assistant OS
dev false
hassio true
docker true
virtualenv false
python_version 3.9.5
os_name Linux
os_version 5.10.45
arch x86_64
timezone America/New_York
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 5000 Installed Version | 1.13.2 Stage | running Available Repositories | 856 Installed Repositories | 63
AccuWeather can_reach_server | ok -- | -- remaining_requests | 42
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | August 16, 2021, 8:00 PM relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 6.1 -- | -- update_channel | stable supervisor_version | supervisor-2021.06.8 docker_version | 20.10.6 disk_total | 30.8 GB disk_used | 17.7 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (9.1.3), ADB - Android Debug Bridge (0.8.0), ESPHome (1.20.0), Visual Studio Code (3.6.0), Let's Encrypt (4.11.0), Node-RED (9.2.1), Home Assistant Google Drive Backup (0.104.3), MariaDB (2.4.0), Check Home Assistant configuration (3.8.0), Glances (0.12.3), Bitwarden (Vaultwarden) (0.12.0), Portainer (1.5.1), Tautulli (2.3.0), phpMyAdmin (0.4.3), php-nginx Docker Image (latest), rest980 Docker Image (20200205), ioBroker (0.8.0), eufy_security_addon (latest)
Lovelace dashboards | 2 -- | -- resources | 48 views | 28 mode | storage

I'm using FFMPEG with other cameras (Like Wyze RTSP streams) and they are currently working so I believe I have FFMPEG installed and running correctly.

ffmpeg:

is confirmed in my configuration.yaml. Also RTSP is set on all of my compatible eufycams; it has been for months as I was testing out the other options (Fuzzy's custom component, MQTT, ioBroker, etc.). The account I'm using for your component/add on pair are not is use anywhere else. That's about all I can think of off the top of my head.

rpitera commented 3 years ago

Also was wondering about this - In the dev service screen, the start/top llivestream service shows targets (devices/entities) as shown here:

stream

but the start/stop RTSP services doesn't show any options for selecting a target at all:

rtsp

Is this as expected or does this indicate an issue on my end?

jbrukardt commented 3 years ago

Please confirm you have enabled ffmpeg in your setup.

  • FFMPEG is a required integration to make this thing working, double check your configuration.yaml file if it is enabled. More information: https://www.home-assistant.io/integrations/ffmpeg/
  • give me more information about your home assistant setup (os, installation method), as live stream functionality is creating a file on main directory of home assistant, it might be related to your setup.
  • as a last resort, i am ready to spare time to connect your local add on if you can expose your IP address temporarily to me, so we can nail down the issue faster.

1) Confirmed that ffmpeg is enabled in my configuration.yaml, and installed on my base system.

2) Home assistant supervised install on debian 10.

3) If it helps you troubleshoot for everyone, im glad to create a user for you, but you definitely should not feel obligated to offer me personalized tech support

jbrukardt commented 3 years ago

Install: Home Assistant OS 6.1 / core-2021.7.4 / supervisor-2021.06.8 Running on Virtualbox on a dedicated Win10 Pro workstation. I could provide access to the server via SplashTop if it would help or provide a login to the HA instance.

System Health

version core-2021.7.4 installation_type Home Assistant OS dev false hassio true docker true virtualenv false python_version 3.9.5 os_name Linux os_version 5.10.45 arch x86_64 timezone America/New_York Home Assistant Community Store AccuWeather Home Assistant Cloud Home Assistant Supervisor Lovelace I'm using FFMPEG with other cameras (Like Wyze RTSP streams) and they are currently working so I believe I have FFMPEG installed and running correctly.

ffmpeg:

is confirmed in my configuration.yaml. Also RTSP is set on all of my compatible eufycams; it has been for months as I was testing out the other options (Fuzzy's custom component, MQTT, ioBroker, etc.). The account I'm using for your component/add on pair are not is use anywhere else. That's about all I can think of off the top of my head.

I have had similar issues on all those other implementations to the issues im having here, did you get streams working on any of them? The only one i got to work was the webRTC of the actual RSTP stream the cam is spitting out, but CPU usage was way too high even on my i5 NUC to maintain it.

rpitera commented 3 years ago

I have had similar issues on all those other implementations to the issues im having here, did you get streams working on any of them?

It's been a while, but I remember getting a couple of cams to work with those components, not 100% reliably but enough times to know that it worked.

apokha1 commented 3 years ago

I am assuming it is related to the file created in the main directory of the Home Assistant Install. I have re-installed the latest version, most of the prior error logs have vanished, but the stream does not seem to work.

My installation is docker HA installed on the dedicated Ubuntu LTS 20.04 Desktop. ffmpeg: is enabled in my configuration.yaml file.

Here is the server info:

System Health

version core-2021.7.4
installation_type Home Assistant Container
dev false
hassio false
docker true
virtualenv false
python_version 3.9.5
os_name Linux
os_version 5.8.0-63-generic
arch x86_64
timezone America/Chicago
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4876 Installed Version | 1.13.2 Stage | running Available Repositories | 850 Installed Repositories | 7
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Lovelace dashboards | 4 -- | -- resources | 1 views | 33 mode | storage

The only errors I see on the log file are

2021-07-24 09:48:39 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream None
2021-07-24 09:48:49 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream None
2021-07-24 09:49:09 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream None
2021-07-24 09:49:39 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream None
2021-07-24 09:50:19 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream None
2021-07-24 09:51:09 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream None
fabianluque commented 3 years ago

I’ve got the stream to work. Something is wrong when the integration starts with my 2K indoor camera with RTSP enabled.

In order for the stream to work I have to call the Camera Turn Off service followed by the Camera Turn On service. After that, stream starts working properly.

I’ve had a few instances where the stream will stop working due to “demuxing errors” and wasn’t able to recover by itself forcing me to redo the above steps.

rpitera commented 3 years ago

I can confirm the same as @fabianluque on my system. (Brilliant find BTW! Thanks!!) Turned off then on and the stream came up right away. Tested with two of my cams, both worked the same.

jbrukardt commented 3 years ago

I’ve got the stream to work. Something is wrong when the integration starts with my 2K indoor camera with RTSP enabled.

In order for the stream to work I have to call the Camera Turn Off service followed by the Camera Turn On service. After that, stream starts working properly.

I’ve had a few instances where the stream will stop working due to “demuxing errors” and wasn’t able to recover by itself forcing me to redo the above steps.

Confirmed behavior, calling camera_turnon and off on the camera indicated makes the stream work

jbrukardt commented 3 years ago

So everyone is aware, the turn-off turn-on method is subject to the three minute stream limit, after which you have to execute the function again. This is an underlying limitation with eufy, and bropat has looked at it before as have fuzzy and a few of the others.

rpitera commented 3 years ago

And to elaborate on @jbrukardt's comment, this limitation is how eufy can make their battery life claims as keeping the devices streaming would kill them in short order. I can't fault them much for this as they last longer than my Arlo or Ring battery devices.

Seems like a trivial thing to script and attach to a button or make part of a tap action though. (That's what I did back when I was using Fuzzy's implementation.)

dpomnean commented 3 years ago

@jbrukardt I can also confirm on my 2k wireless doorbell that the live feed seems to break after about the 3 minute mark. Restarting the services live feed will allow me to view it again.

fuatakgun commented 3 years ago

to recap;

I prefer not to do anything inside Home Assistant and request to fix this on WS layer, what do you think?

dpomnean commented 3 years ago

@fuatakgun All bullet points seem accurate. I am not sure if that is possible on the WS layer as I dont fully understand it but it is worth opening a discussion.

fabianluque commented 3 years ago

For RTSP cameras I guess the 3 minute limit doesn't count. I have been running the stream for days now without stopping.

@fuatakgun Camera turn off/on is a step we have to do with RTSP cameras? Shouldn't they start by themselves by default at least be configurable?

fuatakgun commented 3 years ago

I have created this: https://github.com/bropat/eufy-security-client/issues/30

It is better to fix this from source.

fuatakgun commented 3 years ago

For RTSP cameras I guess the 3 minute limit doesn't count. I have been running the stream for days now without stopping.

@fuatakgun Camera turn off/on is a step we have to do with RTSP cameras? Shouldn't they start by themselves by default at least be configurable?

is it battery powered or mains? I have battery powered 2C cameras and they support RTSP and it goes around 3 minutes.

fabianluque commented 3 years ago

@fuatakgun It’s not battery powered, but USB. Issue is it won’t work from the start until I call manually camera off/on service.

fuatakgun commented 3 years ago

You are right, when initializing at first run, i am not checking if it is already live streaming. This is solvable.

jbrukardt commented 3 years ago

to recap;

  • we are able to start and stop the livestream for the first time without any issues
  • if live stream continues more than 3 minutes, it is closed on eufy side but we don't receive the update - action item: at least, we can update the state on our end
  • to restart live stream after 3 minutes timespan, you need to stop and start the stream.

I prefer not to do anything inside Home Assistant and request to fix this on WS layer, what do you think?

Concur that this is a WS layer issue. Disagree with item 1 though "we are able to start and stop the livestream for the first time without any issues". It doesnt work the first time for me on 2k, has to stop and start to get it working at all.

jbrukardt commented 3 years ago

to recap;

  • we are able to start and stop the livestream for the first time without any issues
  • if live stream continues more than 3 minutes, it is closed on eufy side but we don't receive the update - action item: at least, we can update the state on our end
  • to restart live stream after 3 minutes timespan, you need to stop and start the stream.

I prefer not to do anything inside Home Assistant and request to fix this on WS layer, what do you think?

I am not versed in what the services actually do... but the service that works is "Camera: Turn off" and "Camera: Turn on", not "Eufy Security: Start Live Stream". Start live stream doesnt solve the problem, and seems to contribute to lockup.

fuatakgun commented 3 years ago

let's put a timeline here:

fuatakgun commented 3 years ago

to recap;

  • we are able to start and stop the livestream for the first time without any issues
  • if live stream continues more than 3 minutes, it is closed on eufy side but we don't receive the update - action item: at least, we can update the state on our end
  • to restart live stream after 3 minutes timespan, you need to stop and start the stream.

I prefer not to do anything inside Home Assistant and request to fix this on WS layer, what do you think?

I am not versed in what the services actually do... but the service that works is "Camera: Turn off" and "Camera: Turn on", not "Eufy Security: Start Live Stream". Start live stream doesnt solve the problem, and seems to contribute to lockup.

camera.turn_on: checks if RTSP attribute exists in camera attributes, if yes, calls start_rtsp if not calls start_livestream camera.turn_off: same logic to turn off.

jbrukardt commented 3 years ago

to recap;

  • we are able to start and stop the livestream for the first time without any issues
  • if live stream continues more than 3 minutes, it is closed on eufy side but we don't receive the update - action item: at least, we can update the state on our end
  • to restart live stream after 3 minutes timespan, you need to stop and start the stream.

I prefer not to do anything inside Home Assistant and request to fix this on WS layer, what do you think?

I am not versed in what the services actually do... but the service that works is "Camera: Turn off" and "Camera: Turn on", not "Eufy Security: Start Live Stream". Start live stream doesnt solve the problem, and seems to contribute to lockup.

camera.turn_on: checks if RTSP attribute exists in camera attributes, if yes, calls start_rtsp if not calls start_livestream camera.turn_off: same logic to turn off.

ohhh, thats strange. I stream everything to BlueIRIS all the time, so i know RSTP is actually working. Ill have to ensure flipping it on and off doesnt break the Blueiris side of things.

fuatakgun commented 3 years ago

Yes, double check it and let me know the outcome.

jbrukardt commented 3 years ago

flipping it does cause a break in the rstp stream, buts its a 1/2 second or so blip and the stream picks right back up. Its fine.

Just wonder why the WS library doesnt detect the stream is already live, but thats a bropat question.

fuatakgun commented 3 years ago

Actually, if you are using rtsp, it should work fine and remember the state. I had issues for p2p cases, i will double check and let you know for 2c cameras.

On Mon, Jul 26, 2021, 19:44 jbrukardt @.***> wrote:

flipping it does cause a break in the rstp stream, buts its a 1/2 second or so blip and the stream picks right back up. Its fine.

Just wonder why the WS library doesnt detect the stream is already live, but thats a bropat question.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fuatakgun/eufy_security/issues/10#issuecomment-886900660, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUSN7U7K26XTKC2NA4DL63TZWNIVANCNFSM5ASKXPHQ .

jbrukardt commented 3 years ago

ok, im glad to run any test needed for usb-powered indoor 2k's as well, but I can verify that they all have an active rstp stream already. I think most folks (bropat included) have 2c's and design towards those, so there is some odd behavior on indoor 2ks.

fabianluque commented 3 years ago

ok, im glad to run any test needed for usb-powered indoor 2k's as well, but I can verify that they all have an active rstp stream already. I think most folks (bropat included) have 2c's and design towards those, so there is some odd behavior on indoor 2ks.

+1

I can also test using my 2K indoor cameras.

jbrukardt commented 3 years ago

sent you a message on home assistant forums with a test account tied to one of my 2k cams in a place I dont care about, you can use it for testing in whatever manner you like.

fuatakgun commented 3 years ago

I have updated repository with some fixes, now, it should understand that stream is active when it started running and attach to it. please get latest codebase and let us know

apokha1 commented 3 years ago

The stream doesn't seem to work for my 2K Wired Doorbell. I have got the following new set of errors in the logs.

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/eufy_security/camera.py:241
Integration: Eufy Security (documentation, issues)
First occurred: 4:41:55 PM (1 occurrences)
Last logged: 4:41:55 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 263, in preload_stream
    stream = await camera.create_stream()
  File "/config/custom_components/eufy_security/camera.py", line 241, in create_stream
    self.hass, stream_source, options=self.stream_options
UnboundLocalError: local variable 'stream_source' referenced before assignment
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/eufy_security/camera.py:241
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 4:49:37 PM (1 occurrences)
Last logged: 4:49:37 PM

[139838889703264] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 25, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 605, in ws_camera_stream
    url = await _async_stream_endpoint_url(hass, camera, fmt=msg["format"])
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 743, in _async_stream_endpoint_url
    stream = await camera.create_stream()
  File "/config/custom_components/eufy_security/camera.py", line 241, in create_stream
    self.hass, stream_source, options=self.stream_options
UnboundLocalError: local variable 'stream_source' referenced before assignment