svenakela / ha

Code related to Home Assistant
MIT License
8 stars 1 forks source link

Not sure I got i all correct or if I missed a step. #4

Closed b00lt closed 9 months ago

b00lt commented 9 months ago

Running HA and have installed appdaemon with the three dependencies: python_packages:

Have a HUB and a few displays. Have configured the ipadress to the hub.

have edited the apps.yaml have edited the epaper_small_display.py to reflect my AP ip, MAC and my nordpool conf

In the appdaemon the app is saying idle...

No updates on the display...

Error message / log: 2024-02-20 20:00:30.056285 WARNING epaper_small_chart: ------------------------------------------------------------ 2024-02-20 20:06:14.057073 INFO AppDaemon: Client disconnection from Admin Client 2024-02-20 20:06:14.060308 INFO AppDaemon: Client disconnected unexpectedly from Admin Client 2024-02-20 20:06:19.067186 INFO AppDaemon: Previous message repeated 2050 times 2024-02-20 20:06:19.067920 INFO AppDaemon: Client disconnected unexpectedly from Admin Client 2024-02-20 20:07:12.963395 INFO AppDaemon: Previous message repeated 952 times 2024-02-20 20:07:12.964939 INFO AppDaemon: New client Admin Client connected 2024-02-20 20:41:19.401959 INFO AppDaemon: Client disconnection from Admin Client 2024-02-20 20:41:19.403902 INFO AppDaemon: Client disconnected unexpectedly from Admin Client 2024-02-20 20:41:24.410389 INFO AppDaemon: Previous message repeated 1955 times 2024-02-20 20:41:24.411287 INFO AppDaemon: Client disconnected unexpectedly from Admin Client 2024-02-20 20:45:58.034765 INFO AppDaemon: Previous message repeated 787 times 2024-02-20 20:45:58.035775 INFO AppDaemon: New client Admin Client connected 2024-02-20 21:00:30.022179 INFO epaper_small_chart: Values in array: 24. Values: [0.613, 0.548, 0.506, 0.524, 0.516, 0.516, 0.516, 0.532, 0.547, 0.599, 0.749, 0.776, 0.788, 0.779, 0.776, 0.726, 0.701, 0.724, 0.71, 0.741, 0.782, 0.769, 0.739, 0.646] 2024-02-20 21:00:30.026040 WARNING epaper_small_chart: ------------------------------------------------------------ 2024-02-20 21:00:30.026651 WARNING epaper_small_chart: Unexpected error in worker for App epaper_small_chart: 2024-02-20 21:00:30.027526 WARNING epaper_small_chart: Worker Ags: {'id': 'a0cb90ebdff74e95bd28e87b6fea1696', 'name': 'epaper_small_chart', 'objectid': 'e3269a7215d2464a888091abfaa85367', 'type': 'scheduler', 'function': <bound method SmallDisplayChart.callback of <epaper_small_display.SmallDisplayChart object at 0x7fdc28f8e250>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 3600, '__thread_id': 'thread-0'}} 2024-02-20 21:00:30.032010 WARNING epaper_small_chart: ------------------------------------------------------------ 2024-02-20 21:00:30.035903 WARNING epaper_small_chart: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"])) File "/config/apps/epaper_small_display.py", line 26, in callback self.generate_chart(None, None, kwargs) File "/config/apps/epaper_small_display.py", line 66, in generate_chart FONT_BIG = ImageFont.truetype('/config/apps/Bungee-Regular.ttf', size=24) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/PIL/ImageFont.py", line 819, in truetype return freetype(font) ^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/PIL/ImageFont.py", line 816, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/PIL/ImageFont.py", line 245, in __init__ self.font = core.getfont( ^^^^^^^^^^^^^ OSError: unknown file format

svenakela commented 9 months ago

Your script can't find the Bungee-Regular.ttf font file, either being misplaced or not added to your environment.

b00lt commented 9 months ago

Hi, I have placed it in the default apps folder, the same as the JSON file....I believe that is correct?

image

I also tried to change the path since it does not match with the logical name in the code, but with the same issue.

image
svenakela commented 9 months ago

Yes I believe so, and I think you also have to restart the App Daemon add-on. The files are added into the docker environment during startup if I remember correctly.

b00lt commented 9 months ago

Hi again, thanks for sticking around in the thread! ;)

I have tried both paths and the AppDaemon has been restarted. (even whole Home Assistant that is running this AppDaemon as an addon).

Not sure what I can try next...

still getting the errors: image

svenakela commented 9 months ago

The only issues I know that could make this is either a faulty/missing file or some old versions of Pillow. What version of Appdaemon are you running?

I do have Pillow as an added dependency if I check the Appdaemon Configuration tab in HA.

Here are some examples of the same error https://github.com/python-pillow/Pillow/issues/6554 https://stackoverflow.com/questions/66997352/pil-oserror-unknown-file-format https://stackoverflow.com/questions/64556714/why-am-i-getting-oserror-unknown-file-format-when-opening-a-ttf-with-pil-i

b00lt commented 9 months ago

I got 0.16.4

I can see that the dependencies are downloaded and initiated during the start of appdaemon.

image
svenakela commented 9 months ago

How did you add the font file to your environment? Did you curl or wget it to your HA? Can you do cat Bungee-Regular.ttf and check your output?

If you get anything readable, like Json content, it's not a font file. A font file should return total gibberish.

wget https://github.com/svenakela/ha/raw/main/addon_configs/appdaemon/apps/Bungee-Regular.ttf should give you a proper font file.

b00lt commented 9 months ago

that did it, it was the fonts that was not downloaded properly. thanks!

TheQue42 commented 8 months ago

Since I ran into this issue as well, running in Ha Container, and setting up AppDaemon in another container, the issue for me was that the documentation for AppDaemon refers to the default installation path as /conf/, not /config.

I personally I would mind a APPS_PATH variable at the top of the .py script, that highlights that the location of apps/ might differ depending on your installation. And then use something like:

FONT_BIG = ImageFont.truetype(APPS_PATH + 'Bungee-Regular.ttf', size=24)

Additionally, in an even more helpful world, I wouldn't have minded a helper-link that tells me how I can add the dependency of the Pillow package to app daemon. Personally, I created a packages/requirements.txt file in the /conf directory, but they might even be better ways.

Now I just have to figure out why my screen is almost all black instead of the nice line-graph :-/