i'm a bloddy starter at programming python and don't know, what i'm doing wrong. Im reading trough the documantaions from PiCamera and Schedule, but a combinded command is not working.
So i want to do this with schedule:
schedule.every().day.at("17:20:30").do(Foto).until("17:21:30")
which is working, when the job is: print.("bla")
and i want to this with PiCamera:
camera = PiCamera()
camera.start_preview()
sleep(2)
for filename in camera.capture_continuous('img{counter:03d}.jpg'):
print('Captured %s' % filename)
sleep(300) # wait 5 minutes
which is also working, in its own script. (copied by documentation)
But when i put them together:
from picamera import PiCamera
from time import sleep
import schedule
def Foto():
camera = PiCamera()
camera.start_preview()
sleep(2)
for filename in camera.capture_continuous('img{counter:03d}.jpg'):
print('Captured %s' % filename)
sleep(5) # wait 5 Sek
schedule.every().day.at("17:20:00").do(Foto).until("17:21:00")
while True:
schedule.run_pending()
time.sleep(1)
I get an error:
Traceback (moste recent call last):
File "usr/lib/python3.9/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "home/pi/Dokumente/Schedule.py", line 9
camera = PiCamera()
^
IndentationError: expected an indented block
i also tried to put camera = PiCamera()
before import schedule
which resulted in this error:
Traceback (most recent call last):
File "/usr/lib/python3.9/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "/home/pi/Dokumente/Schedule.py", line 11
camera.start_preview()
^
IndentationError: expected an indented block
I hope you can help me :)
Ps. Here are the two docs:
https://schedule.readthedocs.io/en/stable/examples.html#run-a-job-until-a-certain-time
https://picamera.readthedocs.io/en/release-1.13/recipes1.html#capturing-timelapse-sequences
The code of the function Foto is not indented.
def Foto():
camera = PiCamera()
camera.start_preview()
sleep(2)
for filename in camera.capture_continuous('img{counter:03d}.jpg'):
print('Captured %s' % filename)
sleep(5) # wait 5 Sek