Skip to content
Snippets Groups Projects
Verified Commit 64c9d588 authored by David Hoese's avatar David Hoese
Browse files

Add incomplete wunderground logic to influxdb script

parent 4c7954b3
No related branches found
No related tags found
No related merge requests found
...@@ -73,6 +73,12 @@ def main(): ...@@ -73,6 +73,12 @@ def main():
help='each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG') help='each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG')
parser.add_argument('--sleep-interval', type=float, parser.add_argument('--sleep-interval', type=float,
help="Seconds to wait between submitting each record") help="Seconds to wait between submitting each record")
# parser.add_argument('--weather-underground', action='store_true',
# help="Send new records to wunderground.com")
# parser.add_argument('--wu-id', default='KWIMADIS52',
# help='Weather underground station ID')
# parser.add_argument('--wu-password-file', default='/home/metobs/wunderground_password.txt',
# help='File containing the password for the weather underground upload')
parser.add_argument('src', help='Level 0 raw data file') parser.add_argument('src', help='Level 0 raw data file')
args = parser.parse_args() args = parser.parse_args()
...@@ -84,6 +90,10 @@ def main(): ...@@ -84,6 +90,10 @@ def main():
station_tags = STATIONS[args.station] station_tags = STATIONS[args.station]
symbols = SYMBOL_CONVERSIONS symbols = SYMBOL_CONVERSIONS
# wu_pw = None
# if args.weather_underground:
# wu_pw = open(args.wu_password_file, 'r').read().strip()
if args.ldmp: if args.ldmp:
from aosstower.level_00.parser import ldmp_generator from aosstower.level_00.parser import ldmp_generator
record_gen = ldmp_generator(args.src, args.tables) record_gen = ldmp_generator(args.src, args.tables)
...@@ -102,6 +112,14 @@ def main(): ...@@ -102,6 +112,14 @@ def main():
'http://{host}:{port:d}/write?db={dbname}'.format(host=args.host, port=args.port, dbname=args.dbname), 'http://{host}:{port:d}/write?db={dbname}'.format(host=args.host, port=args.port, dbname=args.dbname),
data='\n'.join(lines)) data='\n'.join(lines))
resp.raise_for_status() resp.raise_for_status()
if wu_pw and args.ldmp:
stamp = record['timestamp'].isoformat('+')
record_parameters = "dateutc={stamp}6&winddir={winddir:d}&windspeedmph={windspeed:0.1f}&windgustmph={gust}&humidity=64&tempf=70.5&baromin=29.742&dewptf=57.9&solarradiation=0.5&rainin=0.00&dailyrainin=0.00".format(
stamp=stamp,
winddir=int(record['wind_dir']),
)
resp = requests.post('http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID={wu_id}&PASSWORD={wu_pw}&action=updateraw&dateutc=2017-04-16+01:54:46&winddir=198&windspeedmph=14.7&windgustmph=21.7&humidity=64&tempf=70.5&baromin=29.742&dewptf=57.9&solarradiation=0.5&rainin=0.00&dailyrainin=0.00&softwaretype=SSEC-RIG')
if args.sleep_interval: if args.sleep_interval:
time.sleep(args.sleep_interval) time.sleep(args.sleep_interval)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment