Removed extra files not related to eagle (sorry Ted) numpy was causing docker builds to take forever, now down to 8 seconds for eagle only stuff
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script configures the eb/ip tables rules to redirect traffic
|
||||
# from the bridge to a different port on the local machine. It gets
|
||||
# run by adding this line to /etc/network/interfaces
|
||||
#
|
||||
# pre-up /home/ted/proj/tHome/bin/acurite-redirect.sh
|
||||
#
|
||||
|
||||
# Redirect traffic on the bridge to port 22041 which must match the port
|
||||
# specified in tHome/conf/acurite.py.
|
||||
PORT=22041
|
||||
|
||||
# Tell the bridge to push the packet to iptables.
|
||||
ebtables -t broute -A BROUTING -p IPv4 --ip-protocol 6 --ip-destination-port 80 -j redirect --redirect-target ACCEPT
|
||||
|
||||
# Redirect the packet to the other port.
|
||||
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port $PORT
|
||||
@@ -1,90 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#===========================================================================
|
||||
#
|
||||
# Eagle posting server
|
||||
#
|
||||
#===========================================================================
|
||||
|
||||
__doc__ = """
|
||||
Starts a small web server to read packets sent from an Acurite Bridgek.
|
||||
|
||||
The Acurite must be redirected to post messages to server instead of
|
||||
it's main server. This assumes the Bridge is connected to a raspberry
|
||||
pi using a USB network adaptor with it's network bridged to the main
|
||||
network. NOTE: The last port number in the iptables command must
|
||||
match the port configured in conf/acurite.py for the acurite web
|
||||
server.
|
||||
|
||||
ebtables -t broute -A BROUTING -p IPv4 --ip-protocol 6 --ip-destination-port 80 -j redirect --redirect-target ACCEPT
|
||||
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 22041
|
||||
|
||||
Scripts uses the tHome.acurite package to decode the bridge posts and
|
||||
converts them to JSON dictionaries which get sent out as MQTT
|
||||
messages.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import bottle as B
|
||||
import sys
|
||||
import json
|
||||
import tHome as T
|
||||
|
||||
#===========================================================================
|
||||
@B.post( '/' )
|
||||
@B.post( '/messages/' )
|
||||
def bridge_post():
|
||||
content = B.request.body.read( B.request.content_length )
|
||||
|
||||
log.info( "Read: %s" % content )
|
||||
|
||||
# Convert the line to messages. Returns a list of tuples of
|
||||
# ( topic, dict ).
|
||||
msgs = T.acurite.cmdLine.process( cfg, content, sensorMap )
|
||||
|
||||
# Send the messages out.
|
||||
for topic, data in msgs:
|
||||
log.info( "Publish: %s: %s" % ( topic, data ) )
|
||||
|
||||
payload = json.dumps( data )
|
||||
client.publish( topic, payload )
|
||||
|
||||
# Standard acurite web site reply - found by watching traffic to
|
||||
# the acurite web site.
|
||||
return { "success" : 1, "checkversion" : "126" }
|
||||
|
||||
#===========================================================================
|
||||
#
|
||||
# Main applications script
|
||||
#
|
||||
#===========================================================================
|
||||
|
||||
p = argparse.ArgumentParser( prog=sys.argv[0],
|
||||
description="T-Home Acurite Server" )
|
||||
p.add_argument( "-c", "--configDir", metavar="configDir",
|
||||
default="/etc/tHome",
|
||||
help="Configuration file directory." )
|
||||
p.add_argument( "-l", "--log", metavar="logFile",
|
||||
default=None, help="Logging file to use. Input 'stdout' "
|
||||
"to log to the screen." )
|
||||
c = p.parse_args( sys.argv[1:] )
|
||||
|
||||
# Parse the eagle config file.
|
||||
cfg = T.acurite.config.parse( c.configDir )
|
||||
log = T.acurite.config.log( cfg, c.log )
|
||||
|
||||
# Create a sensor map from the configuration file.
|
||||
sensorMap = {}
|
||||
for s in cfg.sensors:
|
||||
sensorMap[s.id] = s
|
||||
|
||||
# Create the MQTT client and connect it to the broker.
|
||||
client = T.broker.connect( c.configDir, log )
|
||||
|
||||
# Start the MQTT as a background thread. This way we can run the web
|
||||
# server as the main thread here.
|
||||
client.loop_start()
|
||||
|
||||
log.info( "Starting web server at port %d" % cfg.httpPort )
|
||||
B.run( host='0.0.0.0', port=cfg.httpPort, quiet=True )
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import tHome.sma
|
||||
|
||||
tHome.sma.cmdLine.run( sys.argv )
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#===========================================================================
|
||||
#
|
||||
# Radio thermostats reader
|
||||
#
|
||||
#===========================================================================
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import tHome as T
|
||||
|
||||
#===========================================================================
|
||||
|
||||
#===========================================================================
|
||||
#
|
||||
# Main applications script
|
||||
#
|
||||
#===========================================================================
|
||||
|
||||
p = argparse.ArgumentParser( prog=sys.argv[0],
|
||||
description="T-Home Thermostats" )
|
||||
p.add_argument( "-c", "--configDir", metavar="configDir",
|
||||
default="/etc/tHome",
|
||||
help="Configuration file directory." )
|
||||
p.add_argument( "-l", "--log", metavar="logFile",
|
||||
default=None, help="Logging file to use. Input 'stdout' "
|
||||
"to log to the screen." )
|
||||
c = p.parse_args( sys.argv[1:] )
|
||||
|
||||
# Parse the thermostat config file.
|
||||
cfg = T.thermostat.config.parse( c.configDir )
|
||||
log = T.thermostat.config.log( cfg, c.log )
|
||||
|
||||
# Create the MQTT client and connect it to the broker.
|
||||
client = T.broker.connect( c.configDir, log )
|
||||
|
||||
# Handle set messages being set to the thermostats.
|
||||
def on_message( client, userData, msg ):
|
||||
for t in cfg.thermostats:
|
||||
if mqtt.topic_matches_sub( t.mqttSetTopic, msg.topic ):
|
||||
t.processSet( client, msg )
|
||||
return
|
||||
|
||||
client.on_message = on_message
|
||||
|
||||
# Subscribe to the set messages.
|
||||
for t in cfg.thermostats:
|
||||
print t
|
||||
client.subscribe( t.mqttSetTopic )
|
||||
|
||||
# Start the MQTT as a background thread. This way we can run the web
|
||||
# server as the main thread here.
|
||||
client.loop_start()
|
||||
|
||||
while True:
|
||||
t0 = time.time()
|
||||
for t in cfg.thermostats:
|
||||
try:
|
||||
# Poll the thermostat for status.
|
||||
t.status()
|
||||
|
||||
# Publish any messages.
|
||||
msgs = t.messages()
|
||||
for topic, msg in msgs:
|
||||
payload = json.dumps( msg )
|
||||
client.publish( topic, payload )
|
||||
|
||||
except Exception as e:
|
||||
# This prints a stack trace which is more than we really want.
|
||||
#log.exception( "Error getting thermostat status." )
|
||||
log.error( "Error getting thermostat status: " + str( e ) )
|
||||
|
||||
dt = time.time() - t0
|
||||
delay = max( cfg.pollTime, cfg.pollTime-dt )
|
||||
time.sleep( delay )
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import tHome.weatherUnderground
|
||||
|
||||
tHome.weatherUnderground.cmdLine.run( sys.argv )
|
||||
Reference in New Issue
Block a user