MatthewFlamm / nwsradar

Home assistant custom camera platform for NWS radar loops
MIT License
20 stars 2 forks source link

only logs errors, does not show up in states #1

Closed jgdigitaljedi closed 5 years ago

jgdigitaljedi commented 5 years ago

I installed this from HACS and verified that the files were indeed downloaded and placed in custom_components. I cannot get this to show up in my states at all and I have even stripped down my config to the minimum to try and figure out what is going on. I don't really do python so I'm at a loss.

Here is my config: `#NWS radar camera:

Here are the errors I'm seeing in my log. 2019-09-06 14:05:24 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform nwsradar Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/lib/python3.7/asyncio/tasks.py", line 416, in wait_for return fut.result() File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/nwsradar/camera.py", line 41, in setup_platform add_entities([NWSRadarCam(name, radartype.upper(), station.upper(), frames, style)]) File "/home/homeassistant/.homeassistant/custom_components/nwsradar/camera.py", line 49, in __init__ from nws_radar import Nws_Radar, Nws_Radar_Lite File "/srv/homeassistant/lib/python3.7/site-packages/nws_radar/__init__.py", line 2, in <module> from nws_radar.nws_radar import Nws_Radar File "/srv/homeassistant/lib/python3.7/site-packages/nws_radar/nws_radar.py", line 6, in <module> from PIL import Image File "/srv/homeassistant/lib/python3.7/site-packages/PIL/Image.py", line 95, in <module> from . import _imaging as core ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory

MatthewFlamm commented 5 years ago

ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory

Thanks for the report. This is a lack of the jpeg library requirement that cannot be installed automatically, i.e. the user has to install it using sudo apt-get install libjpeg-dev or similar package for your OS. This is already in the README.md, but maybe not prominently enough.

How are you using HA? Hass.io, in a virtual environment, etc.? and what OS are you using? What version of the nwsradar are you using in HACS?

I was hoping that by not using a jpeg file at all in the newest version that it would be fixed, so if you are using v0.3.0, then this is not true. It looks like the Image class in the Pillow library imports the jpeg dependency immediately. So we are stuck with it unless I can completely remove it from this section of the code.

PS you need to use triple back quotes to make your yaml formatted correctly on multiple lines.

jgdigitaljedi commented 5 years ago

Thanks for the response (and the triple quote tip). I installed that dependency and rebooted (just to be safe but probably not necessary). I'll try reinstalling and hope that does it.

I'm using a Hassbian image I downloaded last week (new setup). HA version is 0.98.1 and I installed using HACS so I got version 0.3.0.

MatthewFlamm commented 5 years ago

Hope it works for you! I updated the README.md and info.md that gets rendered in HACS to make this dependency more prominently displayed. It was kind of just stuck in the middle and could have been easily missed.

jgdigitaljedi commented 5 years ago

Well, I removed and reinstalled the dependency and unfortunately I get the same error. Not sure what to do from here. Thanks for being so quick on this!

MatthewFlamm commented 5 years ago

Hmmmm...

I found this, maybe you need a different library.

https://stackoverflow.com/questions/48012582/pillow-libopenjp2-so-7-cannot-open-shared-object-file-no-such-file-or-directo

jgdigitaljedi commented 5 years ago

So I tried the following:

sudo apt-get install libjpeg8-dev
sudo apt-get install libopenjp2-7
sudo apt-get install libopenjp2-7-dev

With the same result.

jgdigitaljedi commented 5 years ago

Nope, different ImportError at the bottom:

ImportError: libtiff.so.5: cannot open shared object file: No such file or directory
jgdigitaljedi commented 5 years ago

Got it working!

I had to then run:

sudo apt-get install libtiff5
jgdigitaljedi commented 5 years ago

Thanks for all the support. Not sure which of the jpeg deps did the trick (I'm thinking it was either the one you suggested or the -dev variant), but with that package and libtiff it works. Maybe this can help someone in the future?

As an additional side-note, I think Hassbian is basically is stripped down version of Raspbian that only has what HASS needs and no extras. That said, it makes sense that I was missing those dependencies.

MatthewFlamm commented 5 years ago

Huzzah!

Unfortunately, we don't really know specifically which packages you needed (certainly one of the jpeg ones and the libtiff one). I will add libtiff5 to the README as well.

There is a Pillow library installable via apt-get which would pull all of its needed requirements, but this introduces other problems like if other packages use it in HA with different version requirements, so I would like to avoid it.

MatthewFlamm commented 5 years ago

Thanks again for following up on the fixes and additional missing libraries. I linked to this issue in the README.md so others can see the other libjpeg libraries if needed. I'm going to close this since it sounds like it is fixed on your end.