diff --git a/aosstower/level_00/influxdb.py b/aosstower/level_00/influxdb.py index 865b047305a5a0085381509d984f7ffd7f10eeb6..5fb0a908b3c5838a0de030dfdd7e4ca946b50cd6 100644 --- a/aosstower/level_00/influxdb.py +++ b/aosstower/level_00/influxdb.py @@ -73,6 +73,12 @@ def main(): help='each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG') parser.add_argument('--sleep-interval', type=float, 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') args = parser.parse_args() @@ -84,6 +90,10 @@ def main(): station_tags = STATIONS[args.station] symbols = SYMBOL_CONVERSIONS + # wu_pw = None + # if args.weather_underground: + # wu_pw = open(args.wu_password_file, 'r').read().strip() + if args.ldmp: from aosstower.level_00.parser import ldmp_generator record_gen = ldmp_generator(args.src, args.tables) @@ -102,6 +112,14 @@ def main(): 'http://{host}:{port:d}/write?db={dbname}'.format(host=args.host, port=args.port, dbname=args.dbname), data='\n'.join(lines)) 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: time.sleep(args.sleep_interval)