Skip to content

Commit

Permalink
Fix python version and added temperature readout. #247
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Mar 4, 2019
1 parent aecdf59 commit 08cc703
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions terrariumSensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import subprocess
import json
import sys
from glob import iglob
from time import time
from pyownet import protocol
Expand Down Expand Up @@ -416,7 +417,7 @@ def scan_sensors(callback=None):

class terrariumMHZ19Sensor(terrariumSensorSource):
TYPE = 'mh-z19'
VALID_SENSOR_TYPES = ['co2']
VALID_SENSOR_TYPES = ['co2','temperature']

def set_address(self,address):
# Address is not needed according to source....
Expand All @@ -426,16 +427,18 @@ def load_data(self):
data = None
if self.get_address() is not None:
try:
data = json.loads(subprocess.check_output(['sudo', 'python', '-m', 'mh_z19']).decode('utf-8').replace("'",'"'))
data = json.loads(subprocess.check_output(['sudo', 'python' + ('3' if sys.version_info.major == 3 else '2'), '-m', 'mh_z19','--all']).decode('utf-8').replace("'",'"'))
except Exception as ex:
print(ex)

if data is None:
return None
else:
data = data['co2']
del(data['SS'])
del(data['UhUl'])
del(data['TT'])

return { self.get_sensor_type() : data}
return data

from terrariumAnalogSensor import terrariumSKUSEN0161Sensor
from terrariumBluetoothSensor import terrariumMiFloraSensor
Expand Down

0 comments on commit 08cc703

Please sign in to comment.