I have:
- A running instance of Home Assistant with HassIO, on a Raspberry PI.
- A Python code that does what I need on my Ubuntu desktop, and needs Selenium to fetch some data.
Now I want to fetch this data and display it as a graph in Home Assistant. The question is: how to use Selenium on HassIO, Selenium being a dependency of a custom sensor?
By Selenium I mean any “browser + webdriver” combo that works. I’ve tried with chrome/chromium, but firefox or phantomjs (actually, deprecated) would be fine, too.
Here’s what I’ve tried:
- The most straightforward way would be just to install
chromium
andchromium-chromedriver
packages from the Alpine Linux repository using the APK package manager. I enabled community repository in APK and tried to install e.g. chromium withapk add chromium
, but I get this:
WARNING: Ignoring APKINDEX.0a96cc2d.tar.gz: No such file or directory
WARNING: This apk-tools is OLD! Some packages might not function properly.
ERROR: unsatisfiable constraints:
chromium (missing):
required by: world[chromium]
- I thought of creating a Home Assistant add-on, using Docker. Then I could install Selenium dependencies there. However, I’ve tried to do it, but given that I’m a novice in terms of Docker, I faced a similar problem like described above (probably the root cause is the same). Theoretically I could expose a server with a REST API, and I could tell HASS to fetch the value from this local server. But I want to avoid going this direction for now, it in favor of creating a custom Python sensor class, because I believe it should be possible and is much simpler. The main question here is whether add-ons allow exposing some Python classes, without running a server and exposing APIs?
What is the recommended way to go here?