I spent a few days trying to configure and get my BH1750 light sensor to work via I2C bus on docker-based HassOS system. At the end I got succeded. I will share my step-by-steps here for people who struggles with it. Hope it helps you.
Currently I have HassOS 2.8 and Home assistant 0.87.1 running on my Raspberry Pi 3B.
Prerequisites: You will need an empty USB flash device.
First you need to access to the HassOS base system via SSH (this IS NOT the terminal used in HA web). According these steps here and here:
-
Generate a public and private key via PuTTYgen and save the private key (.ppk). Linux users can use openssl instead of PuTTYGen and skip the second step.
-
Load private_key via PuTTYGen again using “Load” button and copy the WHOLE HASH in the top window and save it in a file called
authorized_keys
. This is important step so the key works on UNIX systems. -
copy
authorized_keys
into root directory of the freshlyFAT/exFAT/NTFS
formatted USB Flash drive. NB! Some topics suggest the USB flash MUST be named CONFIG at formatting. -
Now plug in this Flash drive in your Raspberry USB port
-
in HA web interface open the Hass.io tab → SYSTEM → HARDWARE button - under “disk” you should see your usb flash as
/dev/sda
. If it is so, then press the Import from USB button to import the public key to HassOS. -
from another PC (via PuTTY or linux shell) use the Private key to ssh to port 22222.
For Windows users via PuTTY:
enter your HassIO IP, choose port 22222 and choose the private key (.ppk file) via “connection” → SSH → Auth → “Browse”
for linux users:
ssh -i <path-to-your-saved-privatekey> root@<YourHassioIP> -p 22222
-
You’ll be logged in to the hassio-cli shell. Use
login
command to access to the HassOS file system. -
now as it is suggested in this topic
using your prefered CLI text editor add and save to/mnt/boot/config.txt
the following lines:
dtparam=i2c1=on
dtparam=i2c_arm=on
Alternatively you can add to the directory /etc/modules-load.d/ file named rpi-i2c.conf
with following lines in it:
i2c-dev
i2c-bcm2708
personally I did both.
- restart the device. After restart you still won’t be able to see the /
dev/i2c-1
device or usei2c-tools
, but at this point your sensor should work if it is properly defined in your yaml configuration file.
Good luck!