Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE: Unable to prepare setup for platform mail_and_packages.sensor: Platform not found #63

Closed
ttaidapos opened this issue Mar 15, 2020 · 29 comments
Labels
external This issue is a result of external issues workaround-available Work around is available for this issue

Comments

@ttaidapos
Copy link

ttaidapos commented Mar 15, 2020

Describe the bug
Manual install will not create sensors :(. No sensors are getting created for any of the carriers.

Environment (please complete the following information):

  • OS: Rasbpian
  • Type of device: RPI4
  • Home Assistant version: 106.6
  • Hassio/Docker/Core: Virtual
  • Python Version: 3.7.3

Logs
Mar 14 22:44:52 hass hass[790]: 2020-03-14 22:44:52 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform mail_and_packages.sensor: Platform not found (
Mar 14 22:44:52 hass hass[790]: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Mar 14 22:44:52 hass hass[790]: Importing the numpy c-extensions failed.
Mar 14 22:44:52 hass hass[790]: - Try uninstalling and reinstalling numpy.
Mar 14 22:44:52 hass hass[790]: - If you have already done that, then:
Mar 14 22:44:52 hass hass[790]: 1. Check that you expected to use Python3.7 from "/srv/homeassistant/bin/python3",
Mar 14 22:44:52 hass hass[790]: and that you have no directories in your PATH or PYTHONPATH that can
Mar 14 22:44:52 hass hass[790]: interfere with the Python and numpy version "1.18.1" you're trying to use.
Mar 14 22:44:52 hass hass[790]: 2. If (1) looks fine, you can open a new issue at
Mar 14 22:44:52 hass hass[790]: https://github.com/numpy/numpy/issues. Please include details on:
Mar 14 22:44:52 hass hass[790]: - how you installed Python
Mar 14 22:44:52 hass hass[790]: - how you installed numpy
Mar 14 22:44:52 hass hass[790]: - your operating system
Mar 14 22:44:52 hass hass[790]: - whether or not you have multiple versions of Python installed
Mar 14 22:44:52 hass hass[790]: - if you built from source, your compiler versions and ideally a build log
Mar 14 22:44:52 hass hass[790]: - If you're working with a numpy git repository, try git clean -xdf
Mar 14 22:44:52 hass hass[790]: (removes all files not under version control) and rebuild numpy.
Mar 14 22:44:52 hass hass[790]: Note: this error has many possible causes, so please don't comment on
Mar 14 22:44:52 hass hass[790]: an existing issue about this - open a new one instead.
Mar 14 22:44:52 hass hass[790]: Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory
Mar 14 22:44:52 hass hass[790]: ).

Screenshots
none

Additional context
Followed the readme to the 't' using the manual installation. Below is the component directory and permissions.

pi@hass:/home/homeassistant/.homeassistant/custom_components/mail_and_packages $ ls -lha
total 60K
drwxr-xr-x 3 root root 4.0K Mar 14 22:06 .
drwxr-xr-x 4 root root 4.0K Mar 14 12:20 ..
-rw-r--r-- 1 root root 4.3K Mar 3 21:34 config_flow.py
-rw-r--r-- 1 root root 1.2K Mar 3 21:34 const.py
-rw-r--r-- 1 root root 1.6K Mar 3 21:34 init.py
-rw-r--r-- 1 root root 274 Mar 3 21:34 manifest.json
-rw-r--r-- 1 root root 28K Mar 3 21:34 sensor.py
drwxr-xr-x 2 root root 4.0K Mar 3 21:34 .translations

@moralmunky
Copy link
Owner

Are you running home assistant as root or as hass?
You activated it through the integration menu?

@moralmunky
Copy link
Owner

It appears that there is an issue on your system preventing python packages being installed. This person had a similar issue and it appeared to be related with how they installed python 3.7.

numpy/numpy#14553

@ttaidapos
Copy link
Author

Are you running home assistant as root or as hass?

hass aka (homeassistant)

You activated it through the integration menu?

Correct

It appears that there is an issue on your system preventing python packages being installed. This person had a similar issue and it appeared to be related with how they installed python 3.7.

numpy/numpy#14553

This is a vanilla buster lite installation following instructions from hass website.

@moralmunky
Copy link
Owner

I see that the permission on your file are owned by root and are group root. Are the other files for the configuration also owned by root?

@moralmunky
Copy link
Owner

moralmunky commented Mar 15, 2020

I followed the instruction for rasp pi 3 from this page. Used Samba to copy the files over manually, added my details to the integration with the exception of changing the path to the home folder since it is different in this system installation.

/config/www/mail_and_packages/

All sensors are showing. See if the path corrects your issue. Or if you used different installation instruction please post the link to the page.

@firstof9
Copy link
Collaborator

firstof9 commented Mar 15, 2020

numpy isn't a requirement in 0.1.2 so use that version, which is the version on the master branch.

@ttaidapos
Copy link
Author

I see that the permission on your file are owned by root and are group root. Are the other files for the configuration also owned by root?

Yes they are below are the two other directories.

pi@hass:/home/homeassistant/.homeassistant/custom_components/mail_and_packages $ cd .translations/
pi@hass:/home/homeassistant/.homeassistant/custom_components/mail_and_packages/.translations $ ls -lha
total 12K
drwxr-xr-x 2 root root 4.0K Mar 3 21:34 .
drwxr-xr-x 3 root root 4.0K Mar 14 22:06 ..
-rw-r--r-- 1 root root 1.0K Mar 3 21:34 en.json

and images folder...
pi@hass:/home/homeassistant/.homeassistant/www/mail_and_packages $ ls -lha
total 96K
drwxr-xr-x 2 pi homeassistant 4.0K Mar 14 12:32 .
drwxr-xr-x 5 pi homeassistant 4.0K Mar 14 12:31 ..
-rw-r--r-- 1 pi homeassistant 44K Mar 3 20:34 image-no-mailpieces700.jpg
-rw-r--r-- 1 pi homeassistant 41K Mar 3 20:34 mail_none.gif

By comparison, here's another custom component I'm using and the permissions.
pi@hass:/home/homeassistant/.homeassistant/custom_components/nws_alerts $ ls -lha
total 16K
drwxr-xr-x 2 root root 4.0K Feb 23 11:17 .
drwxr-xr-x 4 root root 4.0K Mar 14 12:20 ..
-rw-r--r-- 1 root root 0 May 8 2019 init.py
-rw-r--r-- 1 root root 5.9K May 9 2019 sensor.py

I followed the instruction for rasp pi 3 from this page. Used Samba to copy the files over manually, added my details to the integration with the exception of changing the path to the home folder since it is different in this system installation.

/config/www/mail_and_packages/

All sensors are showing. See if the path corrects your issue. Or if you used different installation instruction please post the link to the page.

The guide you used is for hass.io it looks like. Here are the instructions I use:
https://www.home-assistant.io/docs/installation/raspberry-pi/

numpy isn't a requirement in 0.1.2 so use that version, which is the version on the master branch.

I'll give this a try.

@firstof9
Copy link
Collaborator

This is why the recommended way is to use HACS to install. The files being owned by root should be fine since there's read access.

@ttaidapos
Copy link
Author

numpy isn't a requirement in 0.1.2 so use that version, which is the version on the master branch.

Removed integration, deleted files, installed 1.2 and rebooted. Added integration, rebooted again and i still get the exact same issues as OP including numpy.

This is the zip i used for .1.2
https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/releases/tag/0.1.2

I did try hacs but ran into some goofy issues hence the manual route.

@firstof9
Copy link
Collaborator

Double checked imageio uses numpy, try giving this command a go: sudo apt-get install libatlas-base-dev

@moralmunky
Copy link
Owner

I flashed raspberry lite and used the instructions you provided to install manually within a venv.

I also received this error. It occurs right after saving the integration settings. It appears to be an issue specific to raspberry pi. @firstof9 taking the current version from the repository produces this, there might be a dependency on numpy that hasn't been completely removed?

Based on recommendation from other forums installing
sudo apt-get install libatlas-base-dev

This fixes the initial error but other errors are produced on this platform, line 868.

UnboundLocalError: local variable 'fp' referenced before assignment

I've run out of time to go deeper, but still platform specific. I run hass in the same manner but on Ubunutu without this issue.

@firstof9
Copy link
Collaborator

UnboundLocalError: local variable 'fp' referenced before assignment

This sounds like the try/catch had an error. When you have time can you check the log for a CRITICAL error?

@firstof9 firstof9 added external This issue is a result of external issues investigating Investigating the issue labels Mar 16, 2020
@firstof9 firstof9 added workaround-available Work around is available for this issue and removed investigating Investigating the issue labels Mar 23, 2020
@firstof9
Copy link
Collaborator

The fix for numpy related errors: sudo apt-get install libatlas-base-dev

@ttaidapos
Copy link
Author

The fix for numpy related errors: sudo apt-get install libatlas-base-dev

Do you still get error messages "UnboundLocalError: local variable 'fp' referenced before assignment" as @moralmunky mentioned?

@firstof9
Copy link
Collaborator

I never got an error regarding 'fp' have you @ttaidapos ?

@ttaidapos
Copy link
Author

The said error mentioned above I did not get. I was able to configure once and that was initially. After everything looked good, i removed the integration and re-added (reboots in between) so I can change the folder to look into in GMail since I was not able to find any file to edit my initial configuration.

Every since, I'm not able to get it working again even with using the default "inbox" folder. Below is what i'm seeing. During the integration add, all i'm getting is "unknown error" in red letters.

P.S I'm on hass 107.5

`Log Details (ERROR)
Logger: aiohttp.server
Source: custom_components/mail_and_packages/config_flow.py:106
First occurred: 8:54:11 PM (3 occurrences)
Last logged: 8:54:51 PM

Error handling request
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 72, in ban_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 127, in auth_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 123, in handle
result = await result
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/config/config_entries.py", line 163, in post
return await super().post(request, flow_id)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/data_validator.py", line 50, in wrapper
result = await method(view, request, *args, **kwargs)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/data_entry_flow.py", line 92, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 130, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/home/homeassistant/.homeassistant/custom_components/mail_and_packages/config_flow.py", line 42, in async_step_user
user_input[CONF_USERNAME], user_input[CONF_PASSWORD])
File "/home/homeassistant/.homeassistant/custom_components/mail_and_packages/config_flow.py", line 106, in _test_login
account = imaplib.IMAP4_SSL(host, port)
File "/usr/lib/python3.7/imaplib.py", line 1288, in init
IMAP4.init(self, host, port)
File "/usr/lib/python3.7/imaplib.py", line 198, in init
self.open(host, port)
File "/usr/lib/python3.7/imaplib.py", line 1301, in open
IMAP4.open(self, host, port)
File "/usr/lib/python3.7/imaplib.py", line 299, in open
self.sock = self._create_socket()
File "/usr/lib/python3.7/imaplib.py", line 1291, in _create_socket
sock = IMAP4._create_socket(self)
File "/usr/lib/python3.7/imaplib.py", line 289, in _create_socket
return socket.create_connection((host, self.port))
File "/usr/lib/python3.7/socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known`

@firstof9
Copy link
Collaborator

socket.gaierror: [Errno -2] Name or service not known`

This error means the hostname isn't correct.

Check what you are putting in the host, if it's Gmail make sure you are putting imap.gmail.com not imap.google.com I've made that mistake once or twice myself.

@ttaidapos
Copy link
Author

socket.gaierror: [Errno -2] Name or service not known`

This error means the hostname isn't correct.

Check what you are putting in the host, if it's Gmail make sure you are putting imap.gmail.com not imap.google.com I've made that mistake once or twice myself.

You're absolutely right, so sorry for this novice error. This is what happens when you try to plow through troubleshooting. Couldn't find this anywhere else, can you use other labels (folders) in GMail besides "inbox". I've having a hell of a time getting it to work.

@firstof9
Copy link
Collaborator

Step 2 has a drop down to select your labels. It pulls your folders list from the server itself now, for Gmail labels act as folders.

@ttaidapos
Copy link
Author

ttaidapos commented Mar 24, 2020

Step 2 has a drop down to select your labels. It pulls your folders list from the server itself now, for Gmail labels act as folders.

Not sure I understand. I created a gmail label named "Mail and Packages". Inputting that in the configuration screen doesn't seem to work.

Never mind, wrapped it in quotes and that did the trick. Thank you everyone!

@moralmunky
Copy link
Owner

Sounds like you are on an older version. The folder option was changed to a drop down menu that provides a list of the folders found in your mailbox.

@moralmunky
Copy link
Owner

Also, was your issue running on the pi fixed by using another version of the integration or by installing the suggested package?

@ttaidapos
Copy link
Author

Also, was your issue running on the pi fixed by using another version of the integration or by installing the suggested package?

Installing suggested package.

@firstof9
Copy link
Collaborator

Sounds like you are on an older version. The folder option was changed to a drop down menu that provides a list of the folders found in your mailbox.

To be fair, the 0.1.3 releases are marked as betas. I think once the Yahoo mail thing is sorted it should be good enough for everyone.

@ttaidapos
Copy link
Author

ttaidapos commented Mar 24, 2020

Sounds like you are on an older version. The folder option was changed to a drop down menu that provides a list of the folders found in your mailbox.

To be fair, the 0.1.3 releases are marked as betas. I think once the Yahoo mail thing is sorted it should be good enough for everyone.

Explains why i was going crazy lol I installed the latest greatest twice and didn't see it lol On another note, is it me or "packages in transit" total does not equal UPS+FEDEX+USPS packages in transit?
Untitled

@firstof9
Copy link
Collaborator

That if i recall is fixed in the beta

@ttaidapos
Copy link
Author

That if i recall is fixed in the beta

Cool thanks! Also, seems like USPS Mail is counting not only mail but packages as well, unless that's intended?

@moralmunky
Copy link
Owner

The USPS Mail sensor should only be counting the number of mail pieces from the informed delivery email, no packages. Can you show what you are seeing?

@ttaidapos
Copy link
Author

The USPS Mail sensor should only be counting the number of mail pieces from the informed delivery email, no packages. Can you show what you are seeing?

Confirmed this was a goof on the USPS side. Ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external This issue is a result of external issues workaround-available Work around is available for this issue
Projects
None yet
Development

No branches or pull requests

3 participants