Hello,
in the documentation it says, that if you want to add python packages, you can do this by creating a docker file, in which you specify the additional packages you need. My HABApp installation is not running in a docker, so I´m wondering how I can/should install python packages needed by my rules.
My current working solution is (example for package googlemaps):
seven@openhab:~ $ cd /usr/share/habapp/
seven@openhab:/usr/share/habapp $ source bin/activate
(habapp) seven@openhab:/usr/share/habapp $ sudo ./bin/python -m pip install googlemaps
(habapp) seven@openhab:/usr/share/habapp $ deactivate
(not sure about the sudo, could be better to use the openhab user or owner of the habapp folder)
This seems to be working. How are you installing additional python packages?
For completeness or if someone wants to do something similar
import logging
import HABApp
from HABApp.openhab.items import NumberItem
import googlemaps
class Traffic(HABApp.Rule):
def __init__(self):
super().__init__()
self.log = logging.getLogger('HABApp.Rules')
self.gmaps = googlemaps.Client(key='mykey')
self.run.soon(self.get_duration_from_home_to_work)
self.run.every_hour(self.get_duration_from_home_to_work)
def get_duration_from_home_to_work(self):
result = self.gmaps.distance_matrix('aaa', 'bbb', departure_time='now', mode='driving')
if result['rows'][0]['elements'][0]['status'] == 'OK':
time_in_secs = int(result['rows'][0]['elements'][0]['duration_in_traffic']['value'])
time_in_mins = int(round(time_in_secs / 60, 0))
self.log.info(f"Driving duration to work: {time_in_mins} min")
NumberItem.get_item('traffic_duration_to_work').oh_post_update(time_in_mins)
Traffic()