diff --git a/install.sh b/install.sh index ecf17cda8..7de2c3455 100755 --- a/install.sh +++ b/install.sh @@ -144,6 +144,7 @@ if [ -f /etc/modules ]; then fi fi + # Make sure pigpiod is started at boot, and that user PI can restart it with sudo command echo "${SCRIPT_USER} ALL=(ALL) NOPASSWD: /usr/sbin/service pigpiod restart" > /etc/sudoers.d/terrariumpi # https://github.com/UedaTakeyuki/mh-z19/blob/master/pypi/mh_z19/__init__.py#L18 diff --git a/terrariumNotification.py b/terrariumNotification.py index 0adb8204b..93b4a5dcf 100644 --- a/terrariumNotification.py +++ b/terrariumNotification.py @@ -421,6 +421,11 @@ def stop(self): if self.telegram is not None: self.telegram.stop() + for messagetype in self.__notification_leds: + if self.__notification_leds[messagetype]['pin'] is not None: + GPIO.cleanup(self.__notification_leds[messagetype]['pin']) + self.__notification_leds[messagetype]['pin'] = None + def set_profile_image(self,imagefile): self.__profile_image = imagefile if self.__profile_image is None: diff --git a/terrariumSensor.py b/terrariumSensor.py index 34fb216c8..ee58b45a1 100644 --- a/terrariumSensor.py +++ b/terrariumSensor.py @@ -4,7 +4,8 @@ import os.path import re -import mh_z19 +import subprocess +import json from glob import iglob from time import time from pyownet import protocol @@ -350,7 +351,6 @@ def scan_sensors(callback = None): os.path.basename(address), callback_indicator = callback) - class terrariumOWFSSensor(terrariumSensorSource): TYPE = 'owfs' VALID_SENSOR_TYPES = ['temperature','humidity'] @@ -425,7 +425,10 @@ def set_address(self,address): def load_data(self): data = None if self.get_address() is not None: - data = mh_z19.read() + try: + data = json.loads(subprocess.check_output(['sudo', 'python', '-m', 'mh_z19']).decode('utf-8').replace("'",'"')) + except Exception as ex: + print(ex) if data is None: return None