Turn off sensor/camera with automation

I’d like to be able to turn off polling of an entity (either a REST sensor, or a Camera component) based on triggers in a automation.

Here’s a use case: I have a webcam which doesn’t support IR and produces black images at night, so I’d prefer not polling it after sunset. Similarly, I’d like to be able to “turn off” some sensors when some conditions are met.

Is there any way to do this? I haven’t found any way yet…

I’d like to do the same thing… did you find a way?

No, but the workaround I used calls a shell script to turn off the process which reads from the camera (mjpeg_streamer). It’s not ideal and not universal.
In a different setup I have the TV screen recorded as a camera. In this case I didn’t want to poll it while the tv is off. In this case I had to edit the camera’s api so that it returns a fake image while the tv is off…
I’m still looking for a better way.