pschumi / ruuvitag-sensor

Home assistant sensor plugin for home assistant
Apache License 2.0
13 stars 5 forks source link

Getting error when used in Home Assistant docker #5

Open hemantkamalakar opened 5 years ago

hemantkamalakar commented 5 years ago

Getting following error when used inside Home Assistant docker.

2019-08-12T15:55:36.462083159Z /bin/sh: 1: sudo: not found 2019-08-12T15:55:36.474833760Z Exception in thread Thread-3: 2019-08-12T15:55:36.474864364Z Traceback (most recent call last): 2019-08-12T15:55:36.474874008Z File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner 2019-08-12T15:55:36.474881523Z self.run() 2019-08-12T15:55:36.474888803Z File "/config/custom_components/ruuvitag/sensor.py", line 210, in run 2019-08-12T15:55:36.474895667Z items = RuuviTagSensor.get_data_for_sensors(macs) 2019-08-12T15:55:36.474903826Z File "/usr/local/lib/python3.7/site-packages/ruuvitag_sensor/ruuvi.py", line 109, in get_data_for_sensors 2019-08-12T15:55:36.474911288Z for new_data in RuuviTagSensor._get_ruuvitag_datas(macs, search_duratio_sec, bt_device=bt_device): 2019-08-12T15:55:36.474918323Z File "/usr/local/lib/python3.7/site-packages/ruuvitag_sensor/ruuvi.py", line 150, in _get_ruuvitag_datas 2019-08-12T15:55:36.474926008Z for ble_data in data_iter: 2019-08-12T15:55:36.474932178Z File "/usr/local/lib/python3.7/site-packages/ruuvitag_sensor/ble_communication.py", line 116, in get_datas 2019-08-12T15:55:36.474938898Z procs = BleCommunicationNix.start(bt_device) 2019-08-12T15:55:36.474945783Z File "/usr/local/lib/python3.7/site-packages/ruuvitag_sensor/ble_communication.py", line 69, in start 2019-08-12T15:55:36.474952564Z hcitool = subprocess.Popen(['sudo', '-n', 'hcitool', 'lescan', '--duplicates'], stdout=DEVNULL) 2019-08-12T15:55:36.474960069Z File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__ 2019-08-12T15:55:36.474968059Z restore_signals, start_new_session) 2019-08-12T15:55:36.474975337Z File "/usr/local/lib/python3.7/subprocess.py", line 1522, in _execute_child 2019-08-12T15:55:36.474982918Z raise child_exception_type(errno_num, err_msg, err_filename) 2019-08-12T15:55:36.474990605Z FileNotFoundError: [Errno 2] No such file or directory: 'sudo': 'sudo'

hummelriegel commented 5 years ago

I created my own Dockerfile for homeassistant (based on the original one) and added the sudo apk. Looks like this could help you as well.

Dockerfile

FROM homeassistant/raspberrypi3-homeassistant

RUN apk add sudo

RUN pip3 install --no-cache-dir ruuvitag-sensor

You have to build the image then with docker build --tag=homeassistant-custom.

Then add -d for using a Dockerfile with the tag defined during build (e.g. homeassistant-custom) and leave the rest as is (e.g. docker run -d --restart=always homeassistant-custom)

hemantkamalakar commented 5 years ago

Thanks I will try it and let you know.

Teemu commented 4 years ago

If anyone is reading this, custom Dockerfile is not needed anymore. I did have to give extra permissions for unrelated reasons (my Docker container didn't have enough permissions to access Bluetooth):

sudo docker run -d --cap-add=NET_ADMIN --cap-add=NET_RAW --name="home-assistant" -e "TZ=Europe/Helsinki" -v /home/pi/homeassistant:/config --net=host homeassistant/raspberrypi3-homeassistant:stable