def cmd_daily(sma, args): if len(args) != 1: print("Command usage: daily") sys.exit(1) timestamp, daily = sma.daily_yield() print("%s: Daily generation %d Wh" % (format_time(timestamp), daily))
def historic_daily(config, args): db = config.database() if args.fromdate is None: print("No date specified", file=sys.stderr) sys.exit(1) fromdate = dateutil.parser.parse(args.fromdate) todate = dateutil.parser.parse(args.todate) fromtime = int(fromdate.timestamp()) totime = int(todate.timestamp()) for system in config.systems(): print("%s:" % system.name) for inv in system.inverters(): print("\t%s:" % inv.name) # web_pdb.set_trace() try: sma = inv.connect_and_logon() # dtime, daily = sma.historic_daily() # print("\t\tDaily generation at %s:\t%d Wh" # % (smadata2.datetimeutil.format_time(dtime), daily)) hlist = sma.historic_daily(fromtime, totime) for timestamp, val in hlist: print("[%d] %s: Total generation %d Wh" % (timestamp, format_time(timestamp), val)) # ttime, total = sma.total_yield() # print("\t\tTotal generation at %s:\t%d Wh" # % (smadata2.datetimeutil.format_time(ttime), total)) except Exception as e: print("ERROR contacting inverter: %s" % e, file=sys.stderr)
def cmd_total(sma, args): if len(args) != 1: print("Command usage: total") sys.exit(1) timestamp, total = sma.total_yield() print("%s: Total generation to-date %d Wh" % (format_time(timestamp), total))
def cmd_historic_daily(sma, args): fromtime = ptime("2013-01-01") totime = int(time.time()) # Now if len(args) > 1: fromtime = ptime(args[1]) if len(args) > 2: totime = ptime(args[2]) if len(args) > 3: print("Command usage: historic [start-date [end-date]]") sys.exit(1) hlist = sma.historic_daily(fromtime, totime) for timestamp, val in hlist: print("[%d] %s: Total generation %d Wh" % (timestamp, format_time(timestamp), val))
def cmd_historic(sma, args): """ # Command: Historic data (5 minute intervals) called from download_inverter which specifies "historic" as the data_fn :param sma: Connection class :param args: command line args, including [start-date [end-date]] fromtime, totime :return: """ fromtime = ptime("2013-01-01") totime = int(time.time()) # Now if len(args) > 1: fromtime = ptime(args[1]) if len(args) > 2: totime = ptime(args[2]) if len(args) > 3: print("Command usage: historic [start-date [end-date]]") sys.exit(1) hlist = sma.historic(fromtime, totime) for timestamp, val in hlist: print("[%d] %s: Total generation %d Wh" % (timestamp, format_time(timestamp), val))