Ability to turn on and off cameras without HA restart

At the moment there is no any way to turn on / off cameras correctly. For example, in case the cameras are used as security system when there is nobody in the house but they should be turned off when somebody at home, the only way is to turn them on and off by power switch. In this case there are two issues:

  1. HA continuously generates error in log when camera power is off:
2021-04-19 19:08:29 ERROR (stream_worker) [libav.tcp] Connection to tcp://192.168.0.100:5000?timeout=5000000 failed: Host is unreachable
  1. It takes a lot of time for HA to see the camera again when its power is on. Moreover, lovelace often should be refreshed in web browser for it. Or the next error continuously appears in HA log even if lovelace shows the camera view correctly (!!):
2021-04-19 19:08:29 ERROR (stream_worker) [homeassistant.components.stream.worker] Error opening stream rtsp://admin:[email protected]:5000/h264Preview

Thus, it would be great to add native mechanism how to turn on and turn off cameras via HA.

While this might not be what you are looking for, but if you have a separate security system that records video streams it might be of interes for you.

Shinobi has REST API so you can set/unset from HA automations the recording mode of the different cameras that are added to Shinobi.

Those “host is unreachable” errors are the worst. Yes, I know it’s unreachable, because I turned the camera off.

Edit: I was able to eliminate those error messages by disabling “Preload stream.”