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
Changes from 1 commit
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
Next Next commit
Fixes to work with current API and OS
Open Sprinkler API has changed, causing errors in opsiLCD.py. Updated
to work with v.2.1.9.

Also, fixed the network IP detection. Previous method of "hostname -I"
returned all addresses, including IPv6, with no guaranteed order. Now
uses the netifaces library and a defined variable for specifying which
interface will be used (wlan, eth0, etc.) The downside is that it
requires installation of netifaces. The upside is that it should be
a bit more future-proof. Here's hoping.
sirkus7 committed Sep 16, 2020
commit 0c73d1c6b01915d4edfaf6aa8bbab433d7ce4aaf
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@ Install RPLCD library directly from [PyPI](https://pypi.python.org/pypi/RPLCD/)

$ sudo pip install RPLCD

Install the python netifaces library:
$ sudo pip install netifaces

Intall smbus and i2c tools:

$ sudo apt-get install python-smbus i2c-tools
@@ -100,3 +103,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/folders/5000147084
16 changes: 9 additions & 7 deletions ospiLCD.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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)
@@ -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
@@ -92,18 +94,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:
@@ -112,7 +114,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:
@@ -154,7 +156,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