Closed wchorski closed 2 years ago
Looks like the Python update that HA 2022.2 brings with it, did change or even break something regarding the Image decoding. The code that breaks, tries to add color palettes to each frame, if it somehow is missing. Maybe in the older version it just ignored that, because the GIF is not palettized. I'm not sure.
I just added a check for the supported modes before that line, to make sure it does not throw an error based on that. On my HA, which is still at 2021.12.10, it still works after the change and the GIFs look correct. Obviously it needs to be tested on the newer version, which I will probably do in the next days, after I updated my HA. If you happen to test that earlier, let me know if it fixes the problem and if the GIFs you use, still work correctly.
Had to update earlier than expected, because Supervisor just updated Python automatically. Good thing is, I could test it myself and after the update it still could send GIFs to my Pixoo. Therefore, "works on my machine". Will wait a bit for your confirmation or new error, depending on what happens on your side.
sorry for the wait. I upgraded from HA (2021.12.10) to (2022.2.9). I'm using the manual Supervisor install on a Rasbperry Pi 4. I had everything working on the 2021 version and when I went to the 2022 and continued to get the same error
[2965997312] illegal image mode Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 190, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 282, in service_handler await script_entity.async_turn_on( File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 386, in async_turn_on await coro File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 412, in _async_run return await self.script.async_run(script_vars, context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1253, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 354, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 372, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 575, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 222, in _async_notify_message_service await self.async_send_message(*kwargs) File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 198, in async_send_message await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(self.args, **self.kwargs) File "/config/custom_components/notify/notify.py", line 119, in send_message self._device.show_image(image_path) File "/config/custom_components/notify/devices/pixoo.py", line 309, in show_image frames = self.process_image(file) File "/config/custom_components/notify/devices/pixoo.py", line 176, in process_image img.putpalette(palette) File "/usr/local/lib/python3.9/site-packages/PIL/Image.py", line 1747, in putpalette raise ValueError("illegal image mode") ValueError: illegal image mode
I'll paste the script I use too
configuration.yaml snip
script: !include scripts.yaml
script:
pixoo_mrsaturn:
alias: pixoo mr saturn
sequence:
- service: script.pixoo_night_light
- service: notify.pixoo
data:
message: mr saturn
data:
mode: image
file: mrsaturn.gif
You'll also see i call - service: script.pixoo_night_light
. This is a work around to get any .gifs to display as the device won't 'wake up' unless i call a solid color command first. Do you have to do this as well?
I also included an external script file, I do get warnings about having 2 script, but would continue to have the same problems if i dumped all scripts into the external file.
Is there a manual install of some python library I add to my build? Or some config workaround I can add in my .yaml file?
That's strange, because I looked into the code and the only possibilities that this errors happens are prevented by the if-statement I added directly before. You are sure, that you updated the custom component manually?
To be sure this error does not break/cancel the script, I added a simple try-catch. This definitly will prevent that error, but the result that will be displayed on your Pixoo might be a bit different and it will generate a log warning. If your GIF is displayed fine, you can ignore the warning that will be in the logs. If your GIF is not displayed or displayed incomplete, you might consider trying another GIF or re-saving the GIF. This can be done by opening your GIF with for example GIMP (or an image editor of your choice that supports GIFs) and exporting it as GIF again (make sure to check the animation checkbox when using GIMP).
🙏 Everything is back to normal.
I still have to trigger a mode: light
before i display any gif, but the work around is very simple.
Yeah I know, certain things will not work, if the previous mode does not fit. Most noticable with turning the display off and then trying anything other than mode:light.
In my setup I worked around that by not turning the display off, but rather setting the light:mode into full black. That way I can just send anything (GIFs, scoreboard, visualizer) into it and it gets displayed without the need to send mode:light before.
When calling
mode: 'image'
I'm met with the error "Call-service error. illegal image mode". I rolled back my HA and got images to work again. Thinking this was just a syntax error in my current build.I'm still scratching my head. have you tested
mode: 'image'
with HA 2022.2.3?i'm not sure what the last line is telling me. ``` /usr/local/lib/python3.9/site-packages/PIL/Image.py", line 1747, in putpalette raise ValueError("illegal image mode")