The script return battery voltage and battery capacity in json format and work great if i run in a ssh console, but fail to run under docker because the module smbus is missing under homeassistant docker.
I also create a test script that return the json structure with some fixed values without retrieve data from I2C to test the sensors in the configuration.yaml and it works great.
Then my issue is only related to smbus. How I can add the python3 module smbus under homeassistant docker?
The module might not be enough, because the smbus might simply not be available at all in a virtual enviroment, like docker.
You should maybe set HA up to make the SSH connection to the host and then run it like your test.
Aside what @WallyR wrote (I have no clue if smbus will work or not)… when you add it into the container, it will be gone with the next upgrade.
However, I chose to do so as the other option was not working out fine for my package.
So, I went into the container to do a "pip install [package]’ … which I now do about once a month (I donot upgrade to each release)
Another option, this may work sometimes, is to put the package in the same set of folders as the py you run and do a import from there. I got this working once in a while from my config/python_scripts
I’m only sorry that the add-on cant start in home assistant supervised, I suppose because on debiab O.S. a ssh service is already running. But in the post is reported that the add-on is required to configure docker to allow calling ssh service. I shall left it stopped but configured with protected mode disabled.
HAOS systems also often have two ssh services running since you can enable host ssh. Doesn’t cause an issue.
But host ssh runs on port 22222 when you enable that for HAOS instead of the usual port 22. Are you trying to use port 22 for both services? If so then that won’t work, one of them has to use a different port.
My homeassistant is the supervised installation running on debian system.
I figured out that the “raspbian 64bit edition lite” is simply a debian 64bit as reported in etc/os-release:
By this, the O.S. already offers a standard ssh service on port 22. If the add-on try to add another ssh on the same port, the operation cannot be done. For my use, that’s not a problem since I already had a ssh service, manually configured to accept only ssh keyfile connections on standard 22 port. In this way, if the guide is true, the add-on is used only to enable the homeassistant docker container to allow ssh connection without restrictions. To start the add-ons at all I need to change the port used by the addon.
Debian Linux Debian 11 aka Bullseye (no derivatives)
So if you’re running on Raspbian then that probably explains why some things aren’t working as expected. You are likely to run into a number of strange issues on an unsupported OS.