change ip_address to host parameter

This commit is contained in:
suaveolent 2023-12-19 12:15:08 +01:00
parent 092420bbdb
commit 477cf993db

View File

@ -4,22 +4,26 @@ import time
def main():
parser = argparse.ArgumentParser(description="Hoymiles HMS Monitoring")
parser.add_argument("ip_address", type=str, help="IP address or hostname of the inverter")
parser.add_argument("--host", type=str, required=True, help="IP address or hostname of the inverter")
parser.add_argument("command", type=str, choices=['get-real-data-new', 'get-real-data-hms', 'get-real-data', 'get-config', 'network-info', 'app-information-data', 'app-get-hist-power'], help="Command to execute")
args = parser.parse_args()
inverter = Inverter(args.ip_address)
inverter = Inverter(args.host)
# Execute the specified command
response = getattr(inverter, args.command.replace('-', '_'), lambda: None)()
if response:
print(f"{args.command.capitalize()} Response: {response}")
else:
print(f"Unable to retrieve {args.command.replace('_', ' ')}")
try:
while True:
# Execute the specified command
response = getattr(inverter, args.command, lambda: None)()
if response:
print(f"{args.command.capitalize()} Response: {response}")
else:
print(f"Unable to retrieve {args.command.replace('_', ' ')}")
# Sleep for a while before the next update
time.sleep(60)
# Sleep for a while before the next update
time.sleep(60)
except KeyboardInterrupt:
print("Exiting.")
if __name__ == "__main__":
main()