Home Assistant release with the issue:
99.2
Operating environment (Hass.io/Docker/Windows/etc.):
HASSIO running on linux mini pc
Integration:
https://www.home-assistant.io/integrations/stream
Description of problem:
when calling the camera.record service I get the following error:
Call-service API error. Error Message: Stream already recording to /config/www/xxx.mp4
Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
- platform: ffmpeg
name: woonkamer
input: -rtsp_transport tcp -i rtsp://192.168.0.51:8554/unicast
Additional information:
2019-10-04 00:34:49 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140371347870992] Stream already recording to /config/www/xxxxx.mp4!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1234, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1259, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 373, in _handle_service_platform_call
await func(entity, data)
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 712, in async_handle_record_service
DOMAIN_STREAM, SERVICE_RECORD, data, blocking=True, context=call.context
File "/usr/src/homeassistant/homeassistant/core.py", line 1234, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1259, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 130, in async_record
await async_handle_record_service(hass, call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 232, in async_handle_record_service
raise HomeAssistantError(f"Stream already recording to {recorder.video_path}!")
homeassistant.exceptions.HomeAssistantError: Stream already recording to /config/www/xxxxx.mp4!
Hey there @hunterjm, mind taking a look at this issue as its been labeled with a integration (stream) you are listed as a codeowner for? Thanks!
I have the same issue on 0.99.3. Nevertheless it is the first time I use the record service
I get the error the second time I use the record service. As you can see it is starting but never stops
{
"entity_id": "camera.dafang",
"filename": "www/records/lr_{{ payload }}.mp4",
"duration": 5
}
payload is a variable from nodered which creates the datetime in format: YYYYMMDD-HHMMSS
2019-10-05 00:15:59 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.dafang to X.X.X.Y (auth: True)
2019-10-05 00:16:09 INFO (MainThread) [homeassistant.components.stream] Started stream: http://X.X.X.X:8554/unicast.m3u8
2019-10-05 00:16:09 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.dafang to X.X.X.Y (auth: True)
2019-10-05 00:16:17 INFO (MainThread) [homeassistant.components.stream] Stopped stream: http://X.X.X.X:8554/unicast.m3u8
2019-10-05 00:16:19 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.dafang to X.X.X.Y (auth: True)
2019-10-05 00:16:29 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.dafang to X.X.X.Y (auth: True)
2019-10-05 00:16:36 INFO (MainThread) [homeassistant.components.stream] Started stream: http://X.X.X.X:8554/unicast.m3u8
2019-10-05 00:16:39 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.dafang to X.X.X.Y (auth: True)
2019-10-05 00:16:49 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.dafang to X.X.X.Y (auth: True)
2019-10-05 00:16:59 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.dafang to X.X.X.Y (auth: True)
Same issue on yi dome 1080p, wich flashed to stream support(rtsp). Hassio 0.101.3.
I have the same issue as well. I'm using frigate ( https://github.com/blakeblackshear/frigate ) as a trigger to record a stream when a person is detected. However, it's getting stuck with the very same error:
Mon Jan 06 2020 17:36:00 GMT+0100 (Central European Standard Time)
Error while executing automation automation.nagrywaj_osoby_z_kamery_podjazd_przod. Unknown error for call_service at pos 1:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 443, in action
await script_obj.async_run(variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 190, in async_run
await self._handle_action(action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 273, in _handle_action
await self._actions[_determine_action(action)](action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 355, in _async_call_service
context=context,
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 97, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 205, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 336, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 360, in _handle_service_platform_call
await func(entity, data)
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 712, in async_handle_record_service
DOMAIN_STREAM, SERVICE_RECORD, data, blocking=True, context=call.context
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 111, in async_record
await async_handle_record_service(hass, call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 216, in async_handle_record_service
raise HomeAssistantError(f"Stream already recording to {recorder.video_path}!")
homeassistant.exceptions.HomeAssistantError: Stream already recording to /config/recording/20200106-173549_czlowiek_podjazd_przod.mp4!
Is this perhaps a race condition somewhere?
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
This issue is not fixed yet
At this moment the problems remains..
Are we certain the automation isn’t being triggered twice?
I have the same issue. I use an automation that worked a couple of days until yesterday...
- alias: motion detection oprit
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_buiten_motion
to: 'on'
condition: []
action:
- service: camera.record
data_template:
entity_id: camera.oprit
filename: 'www/video/oprit_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4'
lookback: 10
2020-05-14 09:35:34 ERROR (MainThread) [homeassistant.components.automation] motion detection oprit: Error executing script. Unexpected error for call_service at pos 1: Stream already recording to www/video/oprit_20200514-092129.mp4!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 153, in _async_step
self, f"_async_{cv.determine_script_action(self._action)}_step"
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 623, in _async_call_service_step
*self._prep_call_service_step(), blocking=True, context=self._context
File "/usr/src/homeassistant/homeassistant/core.py", line 1247, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1282, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
self._platforms.values(), func, call, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 453, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 596, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 484, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 717, in async_handle_record_service
DOMAIN_STREAM, SERVICE_RECORD, data, blocking=True, context=call.context
File "/usr/src/homeassistant/homeassistant/core.py", line 1247, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1282, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 110, in async_record
await async_handle_record_service(hass, call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 216, in async_handle_record_service
raise HomeAssistantError(f"Stream already recording to {recorder.video_path}!")
homeassistant.exceptions.HomeAssistantError: Stream already recording to www/video/oprit_20200514-092129.mp4!
I noticed that it sometimes works and sometimes not... bit strange. Today a couple of files are saved, and also the file as mentioned in the log, but that file now contains a stream at time 09:36h iso 09:21h.
This is a known limitation of the record service. There can only be one recording at a time. If it is already recording to a different file, you can not record a second time until the first is complete. Double check your record duration in the configuration?
In my case this is the default 30 seconds. However, the error message for a file with a specific time stamp in some cases comes back an hour long...
Btw, it starts with:
2020-05-14 15:17:49 ERROR (stream_worker) [homeassistant.components.stream.worker] Error demuxing stream: No dts in packet
self._check_response_for_errors(response_text)
File "/usr/local/lib/python3.7/site-packages/pylast/__init__.py", line 970, in _check_response_for_errors
raise WSError(self.network, status, details)
pylast.WSError: Operation failed - Most likely the backend service failed. Please try again.
2020-05-14 15:19:08 ERROR (stream_worker) [homeassistant.components.stream.worker] Error demuxing stream: No dts in packet
2020-05-14 15:19:27 ERROR (MainThread) [homeassistant.components.automation] motion detection oprit: Error executing script. Unexpected error for call_service at pos 1: Stream already recording to www/video/oprit_20200514-151857.mp4!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 153, in _async_step
self, f"_async_{cv.determine_script_action(self._action)}_step"
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 623, in _async_call_service_step
*self._prep_call_service_step(), blocking=True, context=self._context
File "/usr/src/homeassistant/homeassistant/core.py", line 1247, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1282, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
self._platforms.values(), func, call, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 453, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 596, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 484, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 717, in async_handle_record_service
DOMAIN_STREAM, SERVICE_RECORD, data, blocking=True, context=call.context
File "/usr/src/homeassistant/homeassistant/core.py", line 1247, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1282, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 110, in async_record
await async_handle_record_service(hass, call)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 216, in async_handle_record_service
raise HomeAssistantError(f"Stream already recording to {recorder.video_path}!")
homeassistant.exceptions.HomeAssistantError: Stream already recording to www/video/oprit_20200514-151857.mp4!
Hello.
I tested hundred times and I don’t know why but from time to time this not work.
I know that only one record at the same time is needed, my config is always recording only one time and with record of 8’ maximum. I reset Hassio I reset computer I reset everything.. and always the same msg.
I had similar issue with Stream service, maybe somebody will find it useful. I found out, that you need at least 5 seconds before you can call camera.record service again. In my case, I have PIR sensor triggering camera.record service with a duration of 20 seconds. If another movement was triggered between 20 up to 25th second, there was an error with "Camera stream already recording". I simply extended PIR trigger time above 25 seconds and now it seems to be ok.
Would prefer to have a camera.record_stop and camera.record_start service. In that way you get more control. The default 30 sec recording can still be applicable but can be overruled by a camera.record_stop service... I also face the issue that although I programmed a duration and lookback period that the record doesn't finish and blocks any new records until I turn off and on the automation
same issue with dafang with hack
Out of curiosity, did any of you have a RuntimeError: dictionary changed size during iteration error message from in your logs? It could cause this, as the worker thread will stop without closing the stream outputs. If that's the case, #38766 may fix the issue.
I can confirm that the issue remains, at least in my case, in current version.
I have an automation that records 15 seconds. Since yesterday I have the error Call-service API error. Error Message: Stream already recording to /config/www/images/security/casa/video/casa_video_20200916_145343.mp4!
So the message is several hours old. There is no such file in the folder, so it seems the recording has failed and it thinks it is recording.
This is not the first time I have this error. The only way to make it work again is to reboot the system.
Looking at the logs, I think I have found the "uncaught" error:
2020-09-16 16:48:04 ERROR (stream_worker) [root] Uncaught thread exception
Traceback (most recent call last):
File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 49, in stream_worker
container = av.open(stream.source, options=stream.options)
File "av/container/core.pyx", line 354, in av.container.core.open
File "av/container/core.pyx", line 225, in av.container.core.Container.__cinit__
File "av/container/core.pyx", line 257, in av.container.core.Container.err_check
File "av/error.pyx", line 336, in av.error.err_check
av.error.InvalidDataError: [Errno 1094995529] Invalid data found when processing input: 'rtsp://XXXXX:[email protected]/ch0_0.h264'
It seems that after this error I have the other, but I'm not too sure. Maybe this error is not being caught and "stop" the recording?
Most helpful comment
I can confirm that the issue remains, at least in my case, in current version.
I have an automation that records 15 seconds. Since yesterday I have the error
Call-service API error. Error Message: Stream already recording to /config/www/images/security/casa/video/casa_video_20200916_145343.mp4!So the message is several hours old. There is no such file in the folder, so it seems the recording has failed and it thinks it is recording.
This is not the first time I have this error. The only way to make it work again is to reboot the system.