-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New approach to debouncing, pylint changes, and a little more documentation.
- Loading branch information
1 parent
0d255d5
commit 0388305
Showing
4 changed files
with
313 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
# Alarm-Thermostat controller | ||
# | ||
# Copyright @ 2019, Wayne Geiser. All Rights Reserved. | ||
# | ||
# Contact the author via email: [email protected] | ||
|
||
This python application sets a Radio Thermostat WiFi thermostat back when pin | ||
#10 on the Raspberry PI goes high and returns it to the currently running | ||
program when the same pin goes low. | ||
|
||
I have this connected to a relay in my alarm system box. When the alarm system | ||
is armed, the relay closes and the Raspberry pi pin goes high. When the alarm | ||
system is disarmed, the relay opens and the Raspberry pi pin goes low. | ||
|
||
One issue that I needed to code around: | ||
|
||
When the alarm is tripped, the relay flashes off and on (the same as the | ||
red light on the alarm keypad). | ||
|
||
Obviously, I didn't want the Raspberry pi to be continually altering the | ||
thermostat settings while this was happening, so you can see in the code where | ||
I simply count trips to the callback routine and then make sure that things | ||
aren't changing before I call the routines to actually do the work. | ||
|
||
You will need to insert your own thermostat name in the TSTAT_IP variable to | ||
customize this to your environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
""" Helper routines I find useful for most of my python code""" | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2018, Wayne Geiser ([email protected]). All Rights Reserved | ||
|
@@ -6,27 +7,37 @@ | |
# | ||
# All functions, variables, etc. should start with "WG" so as not to interfere with other | ||
# packages. | ||
|
||
WGHelper_version = "1.0" | ||
|
||
import datetime | ||
import pprint | ||
|
||
WG_HELPER_VERSION = "2.01" | ||
|
||
############################################################################### | ||
# | ||
# Print out a trace message and flush the buffers. | ||
# | ||
def WGTracePrint(message) : | ||
today = datetime.datetime.now() | ||
outstring = (today.strftime("%x %X") | ||
+ " - " | ||
+ message) | ||
print(outstring, flush=True) | ||
def wg_trace_print(message, trace): | ||
""" Print out a tracing message.""" | ||
if trace: | ||
today = datetime.datetime.now() | ||
outstring = (today.strftime("%x %X") + " - " + message) | ||
print(outstring, flush=True) | ||
|
||
############################################################################### | ||
# | ||
# Print out an error message and flush the buffers. | ||
# | ||
def WGErrorPrint(where, message) : | ||
def wg_error_print(where, message): | ||
"""Print out an error message.""" | ||
outstring = "Error in " + where + "! " + message | ||
WGTracePrint(outstring) | ||
wg_trace_print(outstring, True) | ||
|
||
############################################################################### | ||
# | ||
# Print out a structure if we're tracing | ||
# | ||
def wg_trace_pprint(struct, trace): | ||
"""Nicely print out a structure if we're tracing""" | ||
if trace: | ||
pprt = pprint.PrettyPrinter(indent=4) | ||
pprt.pprint(struct) |
Oops, something went wrong.