From 1be8ae7d4b07293ae6e3581c26b71202ec90d9f9 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 30 Mar 2020 12:24:18 -0500 Subject: [PATCH] v0.8.7 Bug Fixes to Configs --- package.json | 2 +- workers/adc_worker.py | 2 +- workers/arduino_control_worker.py | 2 +- workers/arduino_sensor_worker.py | 2 +- workers/camera_worker.py | 12 ++++++------ workers/pi_control_worker.py | 2 +- workers/pi_sensor_worker.py | 2 +- workers/pump_worker.py | 1 + workers/relay_worker.py | 1 + workers/sensor_worker.py | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 3038afd..556afd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mudpi-core", - "version": "0.8.6", + "version": "0.8.7", "description": "Configurable automated smart garden for raspberry pi", "bugs": "https://github.com/mudpi/mudpi-core/issues", "contributors": [ diff --git a/workers/adc_worker.py b/workers/adc_worker.py index 2c9a7a1..58aaa51 100644 --- a/workers/adc_worker.py +++ b/workers/adc_worker.py @@ -72,7 +72,7 @@ def init_sensors(self): 'type').capitalize() + 'Sensor' # analog_pin_mode = False if sensor.get('is_digital', False) else True imported_sensor = self.dynamic_sensor_import(sensor_type) - new_sensor = imported_sensor(sensor.get('pin'), + new_sensor = imported_sensor(int(sensor.get('pin')), name=sensor.get('name', sensor.get('type')), key=sensor.get('key', None), mcp=self.mcp) diff --git a/workers/arduino_control_worker.py b/workers/arduino_control_worker.py index fa9e6fa..4b39ebd 100644 --- a/workers/arduino_control_worker.py +++ b/workers/arduino_control_worker.py @@ -57,7 +57,7 @@ def init_controls(self): # Define default kwargs for all control types, conditionally include optional variables below if they exist control_kwargs = { 'name' : control.get('name', control.get('type')), - 'pin' : control.get('pin'), + 'pin' : int(control.get('pin')), 'connection': self.connection, 'key' : control.get('key', None), 'analog_pin_mode': analog_pin_mode, diff --git a/workers/arduino_sensor_worker.py b/workers/arduino_sensor_worker.py index 4752adb..bb5a7bf 100644 --- a/workers/arduino_sensor_worker.py +++ b/workers/arduino_sensor_worker.py @@ -58,7 +58,7 @@ def init_sensors(self, connection=None): # Define default kwargs for all sensor types, conditionally include optional variables below if they exist sensor_kwargs = { 'name' : sensor.get('name', sensor.get('type')), - 'pin' : sensor.get('pin'), + 'pin' : int(sensor.get('pin')), 'connection': self.connection, 'key' : sensor.get('key', None) } diff --git a/workers/camera_worker.py b/workers/camera_worker.py index 36ecb2f..7ce2b06 100644 --- a/workers/camera_worker.py +++ b/workers/camera_worker.py @@ -24,15 +24,15 @@ def __init__(self, config, main_thread_running, system_ready, camera_available): self.camera_available = camera_available #Dynamic Properties based on config - self.path = self.config['path'].replace(" ", "-") if self.config['path'] is not None else 'mudpi/img/' + self.path = self.config['path'].replace(" ", "-") if self.config['path'] is not None else '/etc/mudpi/img/' self.topic = self.config['topic'].replace(" ", "/").lower() if self.config['topic'] is not None else 'mudpi/camera/' if self.config['resolution'] is not None: - self.resolutionX = self.config['resolution'].get('x', 1920) - self.resolutionY = self.config['resolution'].get('y', 1080) + self.resolutionX = int(self.config['resolution'].get('x', 1920)) + self.resolutionY = int(self.config['resolution'].get('y', 1080)) if self.config['delay'] is not None: - self.hours = self.config['delay'].get('hours', 0) - self.minutes = self.config['delay'].get('minutes', 0) - self.seconds = self.config['delay'].get('seconds', 0) + self.hours = int(self.config['delay'].get('hours', 0)) + self.minutes = int(self.config['delay'].get('minutes', 0)) + self.seconds = int(self.config['delay'].get('seconds', 0)) self.init() return diff --git a/workers/pi_control_worker.py b/workers/pi_control_worker.py index ddd45c9..95bc185 100644 --- a/workers/pi_control_worker.py +++ b/workers/pi_control_worker.py @@ -47,7 +47,7 @@ def init_controls(self): # Define default kwargs for all control types, conditionally include optional variables below if they exist control_kwargs = { 'name' : control.get('name', control.get('type')), - 'pin' : control.get('pin'), + 'pin' : int(control.get('pin')), 'key' : control.get('key', None), 'topic': control.get('topic', None), 'resistor': control.get('resistor', None), diff --git a/workers/pi_sensor_worker.py b/workers/pi_sensor_worker.py index f4fa47e..b12ac5c 100644 --- a/workers/pi_sensor_worker.py +++ b/workers/pi_sensor_worker.py @@ -47,7 +47,7 @@ def init_sensors(self): # Define default kwargs for all sensor types, conditionally include optional variables below if they exist sensor_kwargs = { 'name' : sensor.get('name', sensor.get('type')), - 'pin' : sensor.get('pin'), + 'pin' : int(sensor.get('pin')), 'key' : sensor.get('key', None) } diff --git a/workers/pump_worker.py b/workers/pump_worker.py index 27e8639..d4bcaa0 100644 --- a/workers/pump_worker.py +++ b/workers/pump_worker.py @@ -16,6 +16,7 @@ class PumpWorker(): def __init__(self, config, main_thread_running, system_ready, pump_ready, pump_should_be_running): #self.config = {**config, **self.config} self.config = config + self.config['pin'] = int(self.config['pin']) #parse possbile strings to avoid errors self.main_thread_running = main_thread_running self.system_ready = system_ready self.pump_ready = pump_ready diff --git a/workers/relay_worker.py b/workers/relay_worker.py index 8e58164..c70f28f 100644 --- a/workers/relay_worker.py +++ b/workers/relay_worker.py @@ -18,6 +18,7 @@ class RelayWorker(): def __init__(self, config, main_thread_running, system_ready, relay_available, relay_active): #self.config = {**config, **self.config} self.config = config + self.config['pin'] = int(self.config['pin']) #parse possbile strings to avoid errors #Events self.main_thread_running = main_thread_running diff --git a/workers/sensor_worker.py b/workers/sensor_worker.py index dac8668..0580479 100644 --- a/workers/sensor_worker.py +++ b/workers/sensor_worker.py @@ -80,7 +80,7 @@ def init_sensors(self): # Define default kwargs for all sensor types, conditionally include optional variables below if they exist sensor_kwargs = { 'name' : sensor.get('name', sensor.get('type')), - 'pin' : sensor.get('pin'), + 'pin' : int(sensor.get('pin')), 'connection': self.connection, 'key' : sensor.get('key', None) }