Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to work with current API (2.1.9) and OS #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ This is OpenSprinkler pi I2C LCD python script which gets data from OpenSprinkle
Installation instructions
=====

Use apt to install pip, smbus, and i2c tools:

$ sudo apt update
$ sudo apt upgrade -y
$ sudo apt install python-pip python-smbus i2c-tools

Install RPLCD library directly from [PyPI](https://pypi.python.org/pypi/RPLCD/) using pip:

$ sudo pip install RPLCD

Intall smbus and i2c tools:
Install the python netifaces library:

$ sudo apt-get install python-smbus i2c-tools
$ sudo pip install netifaces

Intall ospiLCD script:

Expand Down Expand Up @@ -100,3 +106,6 @@ Green LCD 20x4:

Green LCD 20x4 and ospi with expansion board (E1):
![20x4 lcd exp.](/img/ospilcd7.jpg)

# Helpful References
* Open Sprinkler API Documentation: https://openthings.freshdesk.com/support/solutions/articles/5000716363-os-api-documents
17 changes: 10 additions & 7 deletions ospiLCD.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from time import *
from RPLCD import i2c
from subprocess import check_output
import netifaces

""" ################ Parameters #################### """
osAddress = "127.0.0.1" # OpenSprinkler address (default 127.0.0.1)
Expand All @@ -23,6 +24,7 @@
LCD_cols = 16 # LCD columns (16 or 20)
LCD_rows = 2 # LCD rows (2 or 4)
date_locale = 'en_US.UTF-8' # Set to your Raspberry pi locale eg. 'en_GB.UTF-8' or 'it_IT.UTF-8'
net_iface = 'wlan0' # Set to network interface used for communication (eg. wlan0, eth0)

"""
this example generate md5 pass
Expand All @@ -43,6 +45,7 @@

def get_data(url):
data = urlopen(url).read()
data = data.replace("\"pass\":", "\"password\":") # Replace protected keyword "pass" with acceptable term "password"
variables = json.loads(data, object_hook=lambda d: namedtuple('X', d.keys())(*d.values()))
return variables

Expand Down Expand Up @@ -92,18 +95,18 @@ def get_data(url):
else:
mc = mc+' '

# get sensor status (0 1 2 240)
if ja.options.urs == 1:
# get sensor (0=none, 1=rain, 2=flow, 3=soil, 240=program switch)
if ja.options.sn1t == 1:
if ja.settings.rd == 1 or ja.settings.rs == 1:
mc = mc+'\x03'
else:
mc = mc+' '
elif ja.options.urs == 2:
elif ja.options.sn1t == 2:
mc = mc+'\x06'
elif ja.options.urs == 240:
elif ja.options.sn1t == 240:
mc = mc+'\x07'
else:
mc = mc+' '
mc = mc+' ' # Note, currently no icon for 3=soil. (todo)

# get uSD status
if ja.settings.wto:
Expand All @@ -112,7 +115,7 @@ def get_data(url):
mc = mc+''

# check local network status
net_ip = check_output(['hostname', '-I'])
net_ip = netifaces.ifaddresses(net_iface)[2][0]['addr']
if len(net_ip) > 7:
mc = mc+'\x00'
else:
Expand Down Expand Up @@ -154,7 +157,7 @@ def get_data(url):

#######################################################################################################
# Detect LCD backlight status
if ja.options.lit > 1:
if "lit" in ja.options and ja.options.lit > 1:
backlight = True
else:
backlight = False
Expand Down