Using SenseHAT with Hass.io

Hey guys. Hopefully I’m posting this in the correct category.

The issue I’m writing about is enabling the SenseHAT platform on Hassio. I’m trying to get the SenseHAT sensors running on a fresh 0.85.1 install of Home Assistant on top of the recommended Hassio image.

The problem is that this platform only seems to be compatible with Home Assistant installations running on top of Hassbian or the All-in-one installer, both of which seem to be deprecated now. As you can see on the configuration page: https://www.home-assistant.io/components/sensor.sensehat/, some additional python dependencies need to be installed in order for the platform to function.

By default, it will just complain of missing the RTIMU library when Home Assistant is booting up:

sensehat: Error on device update!

2:37 PM components/sensor/sensehat.py (ERROR)

Error while setting up platform sensehat

2:37 PM components/light/sensehat.py (ERROR)

The stacktrace itself is pretty self explanatory:

ModuleNotFoundError: No module named 'RTIMU'

As far as I’ve understood from the Github issues of others that have faced this before me, getting this to work on Hassio will require a RTIMU add-on.

I’d be glad to volunteer a RTIMU add-on for Hassio, I’ve got the time to dedicate into getting this running if this is the case. Any pointers on getting the ball rolling on this? I’ve been using Home Assistant for a while now, but this would be my first add-on I’d be working on.

Thanks!

1 Like

Following up on this. I was able to get SenseHAT working by using a Hassbian based installation. I did end up having to tweak the official instructions a bit, however this route works I guess. I’d love if we could get it running under Hass.io as well.

Hello,
Following up too, I’d be glad to see my Sense hat working on hass.io !

I wonder if adding these dependencies to the REQUIREMENTS array in https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/sensor/sensehat.py and the running it as a custom Hassio component would work (Editing Component Files in Hassio).

I’ll try to test this out when I have a bit of time, but it might take a while until I get there (currently running on Hassbian).

Anyone had any progress with this? Im looking at making the sense hat working with hass.io as well.

So what did you have to tweak exactly to make the Sense HAT work on Hassbian? I’m going to do this myself soon.

@koan sadly it’s been almost 6 months so the details are a bit hazy. Nothing out of the ordinary, as far as I remember I just followed the causes of any remaining stack traces when booting up home assistant and had to install some additional packages aside from the ones listed in the instructions. If you run into any issues when doing the setup, perhaps circle back here and we can try to solve them together. I should regain access to the Pi running that specific Hassbian setup in a few days.

Thanks for the offer! As soon as the Sense HAT arrives, I’m going to try it, and I’ll let you know how far I come by following the instructions and some common sense :slight_smile:

Hi, I’ve installed HassIO using this method, on top or Raspbian:
https://github.com/home-assistant/hassio-installer

Then I tried to follow the documentation at the bottom of that page where applicable:
https://www.home-assistant.io/components/sensehat/

I only ran that command and did not touch any environment variable:

pip3 install sense-hat rtimulib

But I don’t seem to be able to get the SenseHat to work.
Any help would be very greatly appreciated!

So, the installation instructions for the Sense HAT component in Home Assistant didn’t work for me, but after some tweaking I finally found a solution that works for me, on the latest Hassbian image (image_2019-05-14-Hassbian.zip):

First, run sudo raspi-config and choose the option 5 Interfacing Options , P5 I2C and then enable I2C by choosing Yes. Close the program with Finish .

Then install RTIMULib and some dependencies:

sudo apt update
sudo apt install libjpeg-dev libatlas-base-dev python3-rtimulib

Link the installed RTIMULib to the Python virtual environment of Home Assistant:

sudo ln -s /usr/lib/python3/dist-packages/RTIMU.cpython-37m-arm-linux-gnueabihf.so /srv/homeassistant/lib/python3.7/site-packages/

Then activate the virtual environment and install the Sense HAT library:

sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install sense-hat

Contrary to the installation instructions of the Sense HAT component in Home Assistant, I didn’t need to add the user homeassistant to the groups input, i2c and video, as they already were in the groups.

Now open the configuration file of Home Assistant:

nano /home/homeassistant/.homeassistant/configuration.yaml

And add the following lines:

light:
  - platform: sensehat

sensor:
  - platform: sensehat
    display_options:
      - temperature
      - humidity
      - pressure

Now restart Home Assistant, and the Sense HAT sensors and light should be visible in Home Assistant. In my case I also had to remove the directory with the Sense HAT’s configuration files:

rm -rf /home/homeassistant/.config/sense_hat/

And then restart Home Assistant. Only then the light worked.

1 Like

That’s exactly in line with what I saw a few months ago. Thanks for posting this here! I should have thought of capturing the commands for those extra libraries. Have fun tinkering! :slight_smile:

Has anybody successfully installed a Sense Hat on their HassOS (complete Hass.io image for Raspberry Pi)? I tried to install it, but can’t get it to work.

It seems that the python package sense-hat should be installed automatically, but does the system have RTIMU installed?

I haven’t tried again. Gave up, and also upgraded to a Pi 4 that has a fan where the SenseHAT would sit otherwise…

I followed
https://www.pcactive.nl/workshops/4105-workshop-home-assistant-op-een-raspberry-pi-met-sense-hat
which is pretty much what koan did.
I wonder whether in yaml other functions can be used for instance to light on a single LED in an action upon a trigger…
Can anyone provide examples?

That’s no coincidence because I’m the author of that PC-Active article :wink:

I don’t believe this functionality exists in the Sense HAT integration. At least it wasn’t when I tried it for that article.

Yes, I just found out that you are indeed the author of the article I followed.
Unfortunately I cannot google any example that use other features of the Sense Hat in Home Assistant. While functions such as set_pixel() are contained in the sense-hat library that is loaded for homeassistant@hassbian.
Any idea who could be knowledgeable enough to shed light on this issue?

If you’re looking at the code of the Sense HAT integration in Home Assistant, you see that it only uses the clear() method of the Sense HAT library to set the entire LED matrix to a single color. You would need indeed the set_pixel() method to set pixel colors individually, but that functionality of the library just isn’t exposed in the integration. It would be a nice project for someone who wants this functionality to add this to the Sense HAT integration :slight_smile:

1 Like

Hi guys, I finally managed to install Sense HAT on HassOS! I have documented it in this PR https://github.com/home-assistant/home-assistant.io/pull/15503
Let me know if you like this! I make use of Custom deps deployment and it works :slight_smile: