Error executing script. Unexpected error for call_service at pos 1: Stream already recording to …
That is the error message I am getting. Let me share the background so hopefully I can get some help.
I have an automation set up to call a script when ever the front gate sensor is triggered. The condition of the automation is that the scrip called is “off”, to try and make sure I didn’t call the script again while still running (Think this condition is actually not necessary).
The script records about 10 seconds of footage, saves the file with the same name (each time script runs it overwrites the previous video), and then sends the video out via Telegram. This works great most of the time.
I usually find out there is an issue, when I receive the same video twice. Lets say gate gets triggered at 2pm. I get the correct video. Then at 3pm gate gets triggered again, but I receive the same video I got at 2pm. I don’t get any more videos after that.
I then log in to home assistant, and if I try to manually run the script I get the Error executing script. Unexpected error for call_service at pos 1: Stream already recording to …
I tried to look at logs to figure out what is triggering the issue, but I can’t make much sense. In my example, it would seem that when the automation ran at 3pm, it started recording but it never stopped. The script then ends up sending the previous video, then the future script calls don’t run because they get the camara still in use error.
I couldn’t figure out how to stop recording. The only solution I found was to reboot the camera. For testing purposes I’ve put the cameras power supply behind a relay I can control via home assistant. When I notice the script stopped working I just turn off the relay for 5 seconds, then turn it back on.
I just read https://www.home-assistant.io/integrations/camera/ this time actually going all the way to the bottom. I will try the turn off service turn on service option next time it does it, to see if that is a way I can reset the cameras without having to power down the cameras physically. (Ok, so the way they had written it confused me, but basically the instructions suggest we use camera.turn_off service, which I had tried before and doesn’t work for me)
What I need help with is REAL solutions.
The ideal solution would be to find out what is making the camera ignore the duration setting and stay on recording status. Then fix the issue at its root. A camera.stop_record service would do the trick as well, but seems not at option yet. This brings me to plan B.
Is there a way I can run triggers based on camera.record status? I am thinking maybe an automation that would turn off then on camera service if a camera is recording for more than 1 minute. All my scrips call for camera record durations of under 20 seconds, so a camera record over 1 minute would mean camera is not working properly.
If camera record duration is not a variable we can track, how about the camera.record status? If camara.record is “on” for any camera, and all scripts are “off”, again it would mean the camera is not working properly and I could run a script to reset it.
Or finally, if we can’t get anything from camera.record to track, how about event errors that are logged? Is there a way to run a trigger when “Error executing script. Unexpected error for call_service at pos 1: Stream already recording to …”. The idea would be to create a script to reset the camera after that error pops up.
Thanks in advance for any and all help!