Hi,
I didnt find a way to simply display a generated string in homeassistant and in appdaemon frontend.
So I thought pillow with fonts is the solution.
.
Python script test_image.py:
#!/usr/bin/python3
from PIL import Image, ImageDraw, ImageFont
output = 'pillow not working in hass.io'
img = Image.new('RGB', (400, 250), color = (255, 255, 255))
font = ImageFont.truetype("/config/scripts/arial.ttf", 22)
d = ImageDraw.Draw(img)
d.text((18,18), output, font=font, fill=(0,0,0))
img.save('/config/www/test.png')
shell_commands:
testpillow: python3 "/config/scripts/test_image.py"
After calling shellcommand i can use this image in
cameras:
- platform: local_file
name: test_output
file_path: /config/www/test.png
So i can use this ‘camera’ everywhere in groups.yaml and i can use it in appdeamon for displaying infos generated from SQL or a shell command etc.
But …
Traceback (most recent call last):
File "test_image.py", line 7, in <module>
font = ImageFont.truetype("/config/scripts/arial.ttf", 12)
File "/usr/lib/python3.6/site-packages/PIL/ImageFont.py", line 260, in truetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/usr/lib/python3.6/site-packages/PIL/ImageFont.py", line 135, in __init__
if core.HAVE_RAQM:
File "/usr/lib/python3.6/site-packages/PIL/ImageFont.py", line 39, in __getattr__
raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed
apk add py-pillow
fix this error.
So i need to add py-pillow after every update - bad.
Is there another way / bettter way i could achieve this: display infotxt in homeassistant + appdaemon ?