Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
c3fe5d4
Adding Support for BME680
Aug 11, 2020
d4e50af
Added Null Values for BME680
Aug 11, 2020
38e489f
Added Sensor Import
Aug 11, 2020
38a7a3f
Fixed indentation
Aug 11, 2020
f39052c
Fixed null pins in pi worker
Aug 11, 2020
db5de91
Fixed error in BME680 sensor
Aug 11, 2020
f173412
Made BME680 values more friendly
Aug 11, 2020
bd30ce3
Cleaned up Float Sensor
Aug 11, 2020
c3efae6
Added Support for Ambient Light Module
Aug 11, 2020
7da24a5
Added catch for bad sensor models
Aug 11, 2020
13b9954
Fixed server being required
Aug 11, 2020
83f3980
Added error catching for Server
Aug 11, 2020
0a9b4b8
Fixed server shutdown
Aug 11, 2020
4be2807
Adding Support for Node Relays
Aug 11, 2020
44ec0c5
Working on node relay support
Aug 11, 2020
79a5b85
Fixing arduino relays
Aug 11, 2020
de85975
Fixes to node relays
Aug 11, 2020
45a1074
Fixes to node relays
Aug 11, 2020
ad82ed0
Pass configs through workers
Aug 11, 2020
18250fb
Fixes to node relays
Aug 11, 2020
ea76367
Update humidity_sensor.py
Aug 11, 2020
ee0c88f
Debugging Node Wifi
Aug 11, 2020
5e7f60c
Working on nodes wifi
Aug 11, 2020
41e4a95
Updates to arduino worker
Aug 11, 2020
a1d5347
Updates to arduino workers
Aug 11, 2020
051490c
Working on nodes
Aug 11, 2020
d250d72
Node bug fixes
Aug 11, 2020
df8563e
Updates to node relay worker
Aug 11, 2020
06a532e
Updates to node workers
Aug 11, 2020
9442913
Updates to sensor worker for nodes
Aug 11, 2020
6e0a266
Node relay worker updates
Aug 11, 2020
cec39ee
Updates to node workers
Aug 11, 2020
a03600f
Fixing node workers
Aug 12, 2020
368b685
Update sensor worker
Aug 12, 2020
36592c6
Debugging on arduino
Aug 12, 2020
93c1244
Cleaning up bugs in node workers
Aug 12, 2020
23506c6
Fixes to arduino sensor worker
Aug 12, 2020
a97e167
Fixing delays for esp32 nodes
Aug 12, 2020
ba61cc5
Debugging arduino worker
Aug 12, 2020
68a5b6b
Debugging sockets on nodes
Aug 12, 2020
9300c32
Pass api connection to sensors
Aug 12, 2020
79cb8a8
Passing api to humidity sensor
Aug 12, 2020
1730ac3
Debugging arduino DHT
Aug 12, 2020
49fd1b0
v0.8.13
Aug 13, 2020
604d6fd
Added I2C Worker
Aug 13, 2020
0f4b0e1
Cleanup old sensors
Aug 13, 2020
8a28672
Update base I2C sensor
Aug 13, 2020
660dac7
Fix for debug on i2c worker
Aug 13, 2020
e27c684
Workers Refactoring
Aug 13, 2020
8ef55ea
Code refactoring
Aug 13, 2020
5216e89
Refactoring arduino worker
Aug 13, 2020
78039a1
v0.8.14
Aug 13, 2020
eab4495
v0.8.14
Aug 14, 2020
a39d2b4
More refactoring
Aug 14, 2020
fb73cda
Remove old LCD worker
Aug 14, 2020
0444e33
Updated base Worker
Aug 14, 2020
13104b5
Refactoring Workers
Aug 14, 2020
660c690
Worker refactoring
Aug 14, 2020
0f7f207
More worker updates
Aug 14, 2020
9e5aac0
Finishing Initial LCD Support
Aug 14, 2020
d1c85e7
Added worker load for LCD
Aug 14, 2020
a45d122
bug fix
Aug 14, 2020
46f6258
Bug fix on import
Aug 14, 2020
3386025
Loop bug fix
Aug 14, 2020
ca9c1c6
Debugging LCD worker
Aug 14, 2020
af8fe1d
Exceptons for LCD worker
Aug 14, 2020
5f5ffcb
Error catches for LCD worker
Aug 14, 2020
f845724
Fixed default types
Aug 14, 2020
df59034
Fixed none type default
Aug 14, 2020
2a0e3d2
Defaults for LCD model
Aug 14, 2020
27faee1
Fixed init of LCD Worker
Aug 14, 2020
79d9885
Fixed init of LCD worker
Aug 14, 2020
cdabebf
Fix address cast
Aug 14, 2020
197e428
Fixes to base Worker Class
Aug 14, 2020
03a9a8e
Fixes to workers
Aug 14, 2020
c082986
Adding PCF model to LCD worker
Aug 14, 2020
ac54091
Bug fix syntax
Aug 14, 2020
b92a22f
Huge refactor to make more uniform
Aug 14, 2020
507c233
Fixed redundant import
Aug 14, 2020
462e35f
LCD message queue and tester
Aug 14, 2020
a017c08
Fixed indentation
Aug 14, 2020
9ebd290
Fixed except clause
Aug 14, 2020
d4a0cff
Updates to LCD worker
Aug 14, 2020
6001882
More refactoring
Aug 14, 2020
5a7718d
Arduino worker fix
Aug 14, 2020
893f843
Too many languages to remember
Aug 14, 2020
2bcf868
Fixes to LCD worker
Aug 14, 2020
01ea03d
Added imports on sensor workers
Aug 14, 2020
6a6bbbf
Updates to lcd worker
Aug 14, 2020
0598eec
Bug fix in LCD worker
Aug 14, 2020
17bad05
Fixing lcd worker
Aug 14, 2020
d8a0956
Fixed LCD worker
Aug 14, 2020
dc022e9
Updates to LCD worker
Aug 15, 2020
c697a37
Logging update
Aug 15, 2020
183230a
v0.9.0
Aug 15, 2020
bb02217
Fixed arg default
Aug 15, 2020
4978177
Better checks for null configs
Aug 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ These are the devices and sensors I tested and used with MudPi successfully. Man
Let me know if you are able to confirm tests on any other devices

## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
This project is licensed under the BSD-4-Clause License - see the [LICENSE.md](LICENSE.md) file for details


<img alt="MudPi Smart Garden" title="MudPi Smart Garden" src="https://mudpi.app/img/mudPI_LOGO_small_flat.png" width="50px">
Expand Down
7 changes: 5 additions & 2 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import subprocess
import sys
sys.path.append('..')
import variables

class Action():

Expand All @@ -15,6 +14,10 @@ def __init__(self, config):
self.key = config.get("key", None).replace(" ", "_").lower() if config.get("key") is not None else self.name.replace(" ", "_").lower()
# Actions will be either objects to publish for events or a command string to execute
self.action = config.get("action")
try:
self.r = config["redis"] if config["redis"] is not None else redis.Redis(host='127.0.0.1', port=6379)
except KeyError:
self.r = redis.Redis(host='127.0.0.1', port=6379)
return

def init_action(self):
Expand All @@ -31,7 +34,7 @@ def trigger(self, value=None):
return

def emitEvent(self):
variables.r.publish(self.topic, json.dumps(self.action))
self.r.publish(self.topic, json.dumps(self.action))
return

def runCommand(self, value=None):
Expand Down
4 changes: 2 additions & 2 deletions controls/arduino/button_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

class ButtonControl(Control):

def __init__(self, pin, name='ButtonControl', key=None, connection=default_connection, analog_pin_mode=False, topic=None):
super().__init__(pin, name=name, key=key, connection=connection, analog_pin_mode=analog_pin_mode)
def __init__(self, pin, name='ButtonControl', key=None, connection=default_connection, analog_pin_mode=False, topic=None, redis_conn=None):
super().__init__(pin, name=name, key=key, connection=connection, analog_pin_mode=analog_pin_mode, redis_conn=redis_conn)
self.topic = topic.replace(" ", "/").lower() if topic is not None else 'mudpi/relay/'
self.state_counter = 3
self.previous_state = 0
Expand Down
9 changes: 6 additions & 3 deletions controls/arduino/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
from nanpy import (ArduinoApi, SerialManager)
import sys
sys.path.append('..')
import variables

default_connection = SerialManager()

# Base sensor class to extend all other arduino sensors from.
class Control():

def __init__(self, pin, name='Control', connection=default_connection, analog_pin_mode=False, key=None):
def __init__(self, pin, name='Control', connection=default_connection, analog_pin_mode=False, key=None, redis_conn=None):
self.pin = pin
self.name = name
self.key = key.replace(" ", "_").lower() if key is not None else self.name.replace(" ", "_").lower()
self.analog_pin_mode = analog_pin_mode
self.connection = connection
self.api = ArduinoApi(connection)
try:
self.r = redis_conn if redis_conn is not None else redis.Redis(host='127.0.0.1', port=6379)
except KeyError:
self.r = redis.Redis(host='127.0.0.1', port=6379)
return

def init_control(self):
Expand Down Expand Up @@ -46,4 +49,4 @@ def emitEvent(self, data):
}
}
print(message["data"])
variables.r.publish('controls', json.dumps(message))
self.r.publish('controls', json.dumps(message))
4 changes: 2 additions & 2 deletions controls/arduino/potentiometer_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

class PotentiometerControl(Control):

def __init__(self, pin, name='PotentiometerControl', key=None, connection=default_connection, analog_pin_mode=True, topic=None, reading_buffer=3):
super().__init__(pin, name=name, key=key, connection=connection, analog_pin_mode=analog_pin_mode)
def __init__(self, pin, name='PotentiometerControl', key=None, connection=default_connection, analog_pin_mode=True, topic=None, reading_buffer=3, redis_conn=None):
super().__init__(pin, name=name, key=key, connection=connection, analog_pin_mode=analog_pin_mode, redis_conn=redis_conn)
self.previous_state = 0
# Reading buffer helps prevent multiple events when values are floating between small amounts
self.reading_buffer = reading_buffer
Expand Down
4 changes: 2 additions & 2 deletions controls/arduino/switch_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

class SwitchControl(Control):

def __init__(self, pin, name='SwitchControl', key=None, connection=default_connection, analog_pin_mode=False, topic=None):
super().__init__(pin, name=name, key=key, connection=connection, analog_pin_mode=analog_pin_mode)
def __init__(self, pin, name='SwitchControl', key=None, connection=default_connection, analog_pin_mode=False, topic=None, redis_conn=None):
super().__init__(pin, name=name, key=key, connection=connection, analog_pin_mode=analog_pin_mode, redis_conn=redis_conn)
self.topic = topic.replace(" ", "/").lower() if topic is not None else 'mudpi/relay/'
self.state_counter = 3
self.previous_state = 0
Expand Down
4 changes: 2 additions & 2 deletions controls/pi/button_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

class ButtonControl(Control):

def __init__(self, pin, name='ButtonControl', key=None, resistor=None, edge_detection=None, debounce=None, topic=None):
super().__init__(pin, name=name, key=key, resistor=resistor, edge_detection=edge_detection, debounce=debounce)
def __init__(self, pin, name='ButtonControl', key=None, resistor=None, edge_detection=None, debounce=None, topic=None, redis_conn=None):
super().__init__(pin, name=name, key=key, resistor=resistor, edge_detection=edge_detection, debounce=debounce, redis_conn=redis_conn)
self.topic = topic.replace(" ", "/").lower() if topic is not None else 'mudpi/relay/'
return

Expand Down
9 changes: 6 additions & 3 deletions controls/pi/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
import RPi.GPIO as GPIO
import sys
sys.path.append('..')
import variables

# Base sensor class to extend all other arduino sensors from.
class Control():

def __init__(self, pin, name='Control',key=None, resistor=None, edge_detection=None, debounce=None):
def __init__(self, pin, name='Control',key=None, resistor=None, edge_detection=None, debounce=None, redis_conn=None):
self.pin = pin
self.name = name
self.key = key.replace(" ", "_").lower() if key is not None else self.name.replace(" ", "_").lower()
self.gpio = GPIO
self.debounce = debounce if debounce is not None else None
try:
self.r = redis_conn if redis_conn is not None else redis.Redis(host='127.0.0.1', port=6379)
except KeyError:
self.r = redis.Redis(host='127.0.0.1', port=6379)

if resistor is not None:
if resistor == "up" or resistor == GPIO.PUD_UP:
Expand Down Expand Up @@ -67,4 +70,4 @@ def emitEvent(self, data):
}
}
print(message["data"])
variables.r.publish('controls', json.dumps(message))
self.r.publish('controls', json.dumps(message))
4 changes: 2 additions & 2 deletions controls/pi/switch_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

class SwitchControl(Control):

def __init__(self, pin, name='SwitchControl', key=None, resistor=None, edge_detection=None, debounce=None, topic=None):
super().__init__(pin, name=name, key=key, resistor=resistor, edge_detection=edge_detection, debounce=debounce)
def __init__(self, pin, name='SwitchControl', key=None, resistor=None, edge_detection=None, debounce=None, topic=None, redis_conn=None):
super().__init__(pin, name=name, key=key, resistor=resistor, edge_detection=edge_detection, debounce=debounce, redis_conn=redis_conn)
self.topic = topic.replace(" ", "/").lower() if topic is not None else 'mudpi/relay/'
# Keep counter 1 above delay to avoid event on boot
self.state_counter = 3
Expand Down
Loading