Polar plot of the Sun, Moon, a few planets, and the solstices

How to install package skyfield
Lot of errors in log

Command errored out with exit status 1:
   command: /usr/local/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xklbyva4/sgp4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xklbyva4/sgp4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-70be8njf
       cwd: /tmp/pip-install-xklbyva4/sgp4/
  Complete output (25 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-armv7l-3.7
  creating build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/__init__.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/propagation.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/tests.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/functions.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/ext.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/wrapper.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/model.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/earth_gravity.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/api.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/io.py -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/SGP4-VER.TLE -> build/lib.linux-armv7l-3.7/sgp4
  copying sgp4/tcppver.out -> build/lib.linux-armv7l-3.7/sgp4
  running build_ext
  building 'sgp4.vallado_cpp' extension
  creating build/temp.linux-armv7l-3.7
  creating build/temp.linux-armv7l-3.7/extension
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.7m -c extension/SGP4.cpp -o build/temp.linux-armv7l-3.7/extension/SGP4.o
  unable to execute 'gcc': No such file or directory
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for sgp4
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xklbyva4/sgp4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xklbyva4/sgp4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-srcc9zzo/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/sgp4
         cwd: /tmp/pip-install-xklbyva4/sgp4/
    Complete output (25 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-3.7
    creating build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/__init__.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/propagation.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/tests.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/functions.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/ext.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/wrapper.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/model.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/earth_gravity.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/api.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/io.py -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/SGP4-VER.TLE -> build/lib.linux-armv7l-3.7/sgp4
    copying sgp4/tcppver.out -> build/lib.linux-armv7l-3.7/sgp4
    running build_ext
    building 'sgp4.vallado_cpp' extension
    creating build/temp.linux-armv7l-3.7
    creating build/temp.linux-armv7l-3.7/extension
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.7m -c extension/SGP4.cpp -o build/temp.linux-armv7l-3.7/extension/SGP4.o
    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xklbyva4/sgp4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xklbyva4/sgp4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-srcc9zzo/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/sgp4 Check the logs for full command output.
2020-04-08 12:57:25 ERROR (MainThread) [homeassistant.config] Platform error: camera - Requirements for ha_skyfield not found: ['skyfield==1.15']

In the optional configuration section listed here there are various options that you can put riht under platform: ha_skyfield in the config entry. So like:

camera:
    platform: ha_skyfield
    show_constellations: true
1 Like

Looks like the gcc compiler is missing. Maybe try installing the build-essential package with something like the following will fix?

sudo apt-get install build-essential

Stays the same problem

Should this work with hassio?

No.

I spent a lockdown day on this today.

I got to the point where it was nearly running, then completely borked my docker container and had to remove it and start again - which of course completely reverted to the starting point. A brief outline of arriving at that point:

  • I am running HA core on docker with the following
docker run --restart unless-stopped  --init -d --name="home-assistant" -e "TZ=Pacific/Auckland" -v /home/homeassistant/.homeassistant:/config --net=host homeassistant/home-assistant:0.107.7
  • the essential problem is that the wheel files for matplotlib, cycler and kiwisaver on pypi do not seem to be compatible with the home assistant docker images. FAIL.
  • pip therefore tries to compile the necessary packages, but gcc is not present in the home assistant docker image, FAIL sigh
  • OK, well you can try to install stuff into the container - this will break when you next update home-assistant, but it should be reproducible and scriptable to instal into the next container, so letā€™s see.
  • Research reveals alpinelinux (which the docker images are based on) has packages for py3-cycler, py3-matplotlib and py3-kiwisaver. Excellent.
  • But hold on they are not in a repository that the container automatically has access to. sigh
  • Research the inner workings of the apk command and decide that this might work (obviously this is inside the container, reached by docker exec -it home-assistant /bin/bash)
bash-5.0# apk add s3-matplotlib s3-kiwisolver s3-solver --update-cache --allow-untrusted --repository  http://dl-cdn.alpinelinux.org/alpine/edge/community/
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  s3-kiwisolver (missing):
    required by: world[s3-kiwisolver]
  s3-matplotlib (missing):
    required by: world[s3-matplotlib]
  s3-solver (missing):
    required by: world[s3-solver]
  • sigh no luck
  • OK letā€™s download the packages and try again
bash-5.0# wget http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/py3-matplotlib-3.2.1-r0.apk
bash-5.0# wget http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/py3-cycler-0.10.0-r6.apk
bash-5.0# wget http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/py3-kiwisolver-1.2.0-r0.apk
bash-5.0# apk add --allow-untrusted py3-cycler-0.10.0-r6.apk py3-kiwisolver-1.2.0-r0.apk py3-matplotlib-3.2.1-r0.apk
(1/23) Installing python3 (3.8.2-r0)
(2/23) Installing py3-six (1.13.0-r0)
(3/23) Installing py3-cycler (0.10.0-r6)
(4/23) Installing py3-setuptools (42.0.2-r0)
(5/23) Installing py3-kiwisolver (1.2.0-r0)
(6/23) Installing libquadmath (9.2.0-r4)
(7/23) Installing libgfortran (9.2.0-r4)
(8/23) Installing blas (3.9.0-r1)
(9/23) Installing lapack (3.9.0-r1)
(10/23) Installing openblas (0.3.7-r2)
(11/23) Installing py3-numpy (1.17.4-r1)
(12/23) Installing py3-dateutil (2.8.1-r0)
(13/23) Installing py3-parsing (2.4.5-r1)
(14/23) Installing py3-tz (2019.3-r2)
(15/23) Installing libxrender (0.9.10-r3)
(16/23) Installing pixman (0.38.4-r0)
(17/23) Installing cairo (1.16.0-r2)
(18/23) Installing py3-cairo (1.18.2-r0)
(19/23) Installing tcl (8.6.9-r0)
(20/23) Installing libxft (2.3.3-r0)
(21/23) Installing tk (8.6.10-r0)
(22/23) Installing python3-tkinter (3.8.0-r0)
(23/23) Installing py3-matplotlib (3.2.1-r0)
Executing busybox-1.31.1-r9.trigger
OK: 332 MiB in 176 packages
  • OK, that is looking positive, but the trouble is that matplotlib is only working with python3.8 and yet home-assistant docker image has python 3.7. sigh
  • OK letā€™s make the python binary link point to python 3.8 hint donā€™t, at that point home-assistant stops working and you have to delete the container and start it again and it comes back in a virgin state
  • At this point realise that I need to understand more about python versioning.
1 Like

Had to suspend it as this was too heavy on my tiny RPI3+ install RAM resources :slight_smile:
Nothing catastrophyic but still made me check status daily :frowning:
But it worked OK and was nice to haveā€¦
Maybe time to move on to another HW as demands rise and wishes/ideas too.
Thnx to developer, still watching Your progress.
Best, JR

1 Like

@partofthething Is matplotlib v3.1.2 really required?
Iā€™ve tried to install without the version-requirement, the latest version, v3.3.1, installed just fine on my HA Core system (hassio). So did the latest versions of skyfield and numpy.

Unfortunately, with the latest matplotlib version there is an error when I try to check out the camera-picture:

Log Details (ERROR)
Logger: aiohttp.server
Source: custom_components/ha_skyfield/bodies.py:184
First occurred: 2:34:02 PM (1 occurrences)
Last logged: 2:34:02 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 499, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 534, in handle
    return await camera.handle_async_mjpeg_stream(request)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 399, in handle_async_mjpeg_stream
    return await self.handle_async_still_stream(request, self.frame_interval)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 389, in handle_async_still_stream
    return await async_get_still_stream(
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 205, in async_get_still_stream
    img_bytes = await image_cb()
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 385, in async_camera_image
    return await self.hass.async_add_executor_job(self.camera_image)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/ha_skyfield/camera.py", line 137, in camera_image
    self.sky.plot_sky(buf)
  File "/config/custom_components/ha_skyfield/bodies.py", line 184, in plot_sky
    ax.set_thetagrids(
  File "/usr/local/lib/python3.8/site-packages/matplotlib/projections/polar.py", line 1346, in set_thetagrids
    self.set_xticklabels(labels)
  File "/usr/local/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 63, in wrapper
    return get_method(self)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 451, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/matplotlib/axis.py", line 1793, in _set_ticklabels
    return self.set_ticklabels(labels, minor=minor, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/matplotlib/axis.py", line 1714, in set_ticklabels
    raise ValueError(
ValueError: The number of FixedLocator locations (9), usually from a call to set_ticks, does not match the number of ticklabels (8).
1 Like

Update: Iā€™ve changed line 185 in bodies.py to:

np.linspace(0, 360.0, 9), ["N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"]

Adding a 2nd ā€œNā€ to make it 9 instead of 8 directions, matching the 9 in np.linspace.

And then, after restarting HA, it works!

Pull-request created:

2 Likes

Update 3:

After the change shown in the above post itā€™s fully working:

2 Likes

Beautiful! Thanks for the fixes. I merged the PR.

Iā€™m assuming you donā€™t mean hassio/ha supervised? Core isnā€™t hassio/supervised. This still wonā€™t work on supervised right?

Thanks for your great work!

Works perfect on my system.
NUC+proxmox+hassOS


arch	x86_64
chassis	vm
dev	false
docker	true
docker_version	19.03.11
hassio	true
host_os	HassOS 4.12
installation_type	Home Assistant OS
os_name	Linux
os_version	5.4.56
python_version	3.8.3
supervisor	235
timezone	Europe/Berlin
version	0.114.3
virtualenv	false

1 Like

How did you do this?

Download the prerequisites: pip3 install skyfield matplotlib numpy

Download the recent ha_skyfield folder (updated one hour ago) from GitHub and copy to custom_components folder
Add camera to configuration file.
And add entity to lovelace.
Thatā€™s it.

2 Likes

Just doing that nowā€¦ I had tried previously and it didnā€™t work because those requirements were not met and couldnā€™t be installed. Awesome if this works now.

1 Like

This is great!
@tom_l did you see this?

Is this how I should configure it?

# Skyfield Custom Component https://github.com/partofthething/ha_skyfield
camera:
  - platform: ha_skyfield
    show_time: true
    show_constellations: true
    show_legend: true

seem to be getting these fairly regularly
image
and the plot disappearsā€¦

ok Iā€™m going to remove thisā€¦ my HA keeps restartingā€¦

That doesnā€™t sound good.