Reviewers needed: Environment Canada component with weather, sensor, and camera (radar) platforms

got this:

pi@raspberrypi:~ $ sudo apt-get install libopenjp2-7
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libopenjp2-7 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libopenjp2-7' has no installation candidate

Update: after doing a sudo apt-get update, I was able to install the lib
However I always do an apt-get update before each HA update, so I don’t know what was the issue here

new error:

2019-06-28 13:38:46 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform environment_canada
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/__init__.py", line 40, in <module>
    from . import multiarray
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/overrides.py", line 6, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/environment_canada/sensor.py", line 91, in setup_platform
    from env_canada import ECData
  File "/srv/homeassistant/lib/python3.7/site-packages/env_canada/__init__.py", line 1, in <module>
    from .env_canada import *
  File "/srv/homeassistant/lib/python3.7/site-packages/env_canada/env_canada.py", line 9, in <module>
    import imageio
  File "/srv/homeassistant/lib/python3.7/site-packages/imageio/__init__.py", line 22, in <module>
    from .core import FormatManager, RETURN_BYTES
  File "/srv/homeassistant/lib/python3.7/site-packages/imageio/core/__init__.py", line 10, in <module>
    from .util import Image, Array, Dict, asarray, image_as_uint, urlopen
  File "/srv/homeassistant/lib/python3.7/site-packages/imageio/core/util.py", line 27, in <module>
    import numpy as np
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/__init__.py", line 71, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
  your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
  1. Check that you are using the Python you expect (you're using /srv/homeassistant/bin/python3.7),
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy versions you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

     Note: this error has many possible causes, so please don't comment on
     an existing issue about this - open a new one instead.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

But:

(homeassistant) homeassistant@raspberrypi:/home/pi $ pip3 install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: numpy in /srv/homeassistant/lib/python3.7/site-packages (1.16.4)

Thanks, I’m digging into this:

  • I’ve split up the env_canada classes and their dependencies, so the sensor won’t depend on image processing.
  • I’ve tested the new build of the env_canada library in an Ubuntu container and it worked.
  • What OS are you guys seeing the problems on?

Thanks for your help on this.

I’m running Hassbian.

I tried sideloading env_canada using pip in my venv, but it didn’t change anything. Platform is still not recognized.

I can do some tests if you want me to.

It looks like Hassbian is based on Debian Buster, so I spun up a container based on debian:buster and it seemed work. Here’s what I did:

Docker:

docker run -dit debian:buster --name debian
docker attach debian

Debian:

apt update
apt upgrade -y
apt install python3 python3-pip
pip3 install ipython env_canada
ipython

iPython:

In [9]: from env_canada import ECData, ECRadar

In [10]: data = ECData(station_id='ON/s0000430')

In [11]: print(data.conditions['condition'])
Mostly Cloudy

In [12]: radar = ECRadar(station_id='XFT')

In [13]: print(radar.get_loop()[:50])
b'GIF89aD\x02\xe0\x01\x87\x00\x00\xfe\xfe\xfe\xff\xff3\xf5\xec\xef\xf1\xdc\xdb\xff\xcc\x00\x99\xcc\xff\xed\xca\xc8\xee\xc0\xbb\xec\xb7\xb3\xe9\xac\xa9\xea\xa0\x9c\xff\x99\x00\x98'

I’m not sure if that helps, but at the same time I’m not sure how to replicate the error.

According to How do I fix the Pollen platform after upgrading to .82?, this error was solved previously by running:

apt install libatlas3-base

Ok, here’s what I did so far:

Sideloaded env-canada using pip in venv
upgraded env-canada to latest version (0.0.13) in venv (didn’t seem to have updated the HA package though)
–> ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory
sudo apt-get install libopenjp2-7
–> ImportError: libtiff.so.5: cannot open shared object file: No such file or directory
sudo apt-get install libtiff5
–> ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory
sudo apt-get install libatlas3-base
–> ImportError: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27’ not found (required by /srv/homeassistant/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-arm-linux-gnueabihf.so)
sudo apt-get install libc6
–> libc6 is already the newest version (2.24-11+deb9u4).

ldd --version
–> ldd (Debian GLIBC 2.24-11+deb9u4) 2.24

So now, i’m kinda stuck as 2.24 seems the latest version for Hassbian, but numpy wants 2.27…

I’ll try to override the HA env_canada with a custom_component to see if I can get it to work.

Still getting the “platform not found” when trying to add the weather platform, but I also tried with another weather platform (met) and I get the same error… So maybe this platform has a bigger problem than just the environment_canada thing…

Still stuck on the sensor error… I’m now using env_canada 0.0.13 code, but still no bueno.

GLIBC 2.24 is the latest stable release for debian/raspbian/hassbian. 2.27 is unstable.

This doesn’t look to good for us Hassbian users…

Thanks, this helps a lot. I’ll see if I can rework the dependencies so that it’ll run properly on Debian Stretch. Edit: I tried it with a Debian Stretch container and it worked…

I’ve only been working on the env_canada library for now; I’ll rework the components once I get the library fixed.

Which glibc version was in your container? And what python version were you running?
A container or full fledged OS should be the same in theory.

glibc = 2.24
python = 3.5.3

I’m trying to see if I can spin up a container based on Hassbian now.

I’m running python 3.7.3 and from what I found online, this could be the problem…

I just upgraded to python 3.7 due to the obsolecense of 3.5 in august… I’d be curious to see if you get the same results with python 3.7.3

Congratulation Michael for the release in v0.95! It works very well for me, very good work
thank you

1 Like

Had the same issue. Fixed by using “’” in station parameter, e.g. station: ‘ON/s0000430’`

I had to install libatlas-base-dev to get numpy to install properly, to get rid of the “platform not found” message

Fixed by using the following line to avoid installing the pre-compiled version:

pip install numpy==1.16.4 --force-reinstall --ignore-installed --no-binary :all:

Working well for me in hassio 95.4. Really happy about this component. I’ve parsed through the thread and saw that there was quite a bit of work put into the warning,statements, and ending statements, etc portion and how people used it in cards and how the work was incorporated into the component. Maybe when the installation hubub dies down somebody could throw me a bone on some automation ideas for bad weather. I was hoping to get bad weather announced with google tts. This might actually score some “significant other” acceptance points for my technology hobby

Thanks, I’m glad you’re finding it useful!

As luck would have it, I’ve been playing around with sending alerts to TTS this afternoon, and so far this script is working well:

  weather_alert_tts:
    alias: Weather Alert TTS
    sequence:
      - service: tts.amazon_polly_say
        data_template:
          message: '{{ states("sensor.warnings") }} in effect. {{ state_attr("sensor.warnings", "alert detail") }}'

I’m thinking about increasing the update frequency to every minute (maybe I should make this configurable…), and then having an automation trigger this kind of script if the alert sensors change. It’s a work in progress.

1 Like

Running
pip install numpy==1.16.4 --force-reinstall --ignore-installed --no-binary :all:
as @jmll suggested fixed the Numpy error with the sensor, as well as the “platform not found” error.

But as of now, I’m not getting any readings for temperature and condition. I’m getting the weather forecast and wind speed though.

EDIT: Problem has to do with my closest station… I tried with another one and everythoing works

Problem replicated manually:

>>> from env_canada import ECData, ECRadar
>>> data = ECData(station_id='ON/s0000430')
>>> print(data.conditions['condition'])
Mainly Sunny
>>> print(data.conditions['temperature'])
20.9
>>> data = ECData(station_id='QC/s0000416')
>>> print(data.conditions['temperature'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'temperature'
>>> data = ECData(station_id='QC/s0000620')
>>> print(data.conditions['temperature'])
20.2