On Mon, 28 Jun 2021 at 08:23, Ernest Jillson <
etji...@gmail.com> wrote:
>
> Anyone know of any skins that can produce a static image with most parameters in either text or dial format? The web pages are great, but I'd love to find something that creates an image with T, MaxT, MinT, Wind, Precip (at the least) and ftp it to a friend's web site.
>
> Thanks in advance,
IThe box my webcam (actually a pi + pi camera) is on a different box
to my weewx host, I found the easiest way was to save the weather
conditions I was interested in via mqttwarn[1] which dumps it down to
a local file (since 'loop' outputs may not align with the timings when
I need to grab an image.
The image is grabbed every 5 mins:
pi@stupify:~ $ crontab -l | grep cam
*/5 5-20 * * * /home/pi/llamacam.py
pi@stupify:~ $ cat /home/pi/llamacam.py
#!/usr/bin/python3
import io
import picamera
from PIL import Image
from PIL import ImageFont,ImageDraw
import time
import os
temperaturefile = '/var/www/html/weewx/test.txt'
image_out = '/var/www/html/webcam/latest.jpg'
text_overlay = '{}'.format(time.strftime('%a %Y-%m-%d %H:%M %Z'))
#print(os.path.getmtime(temperaturefile),time.time(),(time.time() -
os.path.getmtime(temperaturefile)))
if (time.time() - os.path.getmtime(temperaturefile)<= 300):
with open(temperaturefile, "r") as f:
temperature = float(f.read())
text_overlay += ', Outside Temp: {:.1f}°C'.format(temperature)
else:
text_overlay += ' (No temperature reading available)'
# Create the in-memory stream
stream = io.BytesIO()
with picamera.PiCamera() as camera:
camera.led = False
camera.resolution = (1920,1080)
camera.start_preview()
time.sleep(2)
camera.capture(stream, format='jpeg')
# "Rewind" the stream to the beginning so we can read its content
stream.seek(0)
image = Image.open(stream)
# add logo to bottom rightt
overlay = Image.open("lw_logo.png");
image.paste(overlay, (1400,750 ), overlay)
# add text too
font = ImageFont.truetype("Miriam.ttf", 36)
draw = ImageDraw.Draw(image)
draw.text((50, 1020), text_overlay, font=font, fill='rgb(0, 168, 162)')
image.save(image_out)
And that dumps out the following image
[1]
https://github.com/jpmens/mqttwarn