2023-11-17 12:20:23 +00:00
import argparse
2023-12-19 08:28:47 +00:00
from hoymiles_wifi . inverter import Inverter
2023-11-17 11:10:33 +00:00
import time
def main ( ) :
2023-11-17 12:20:23 +00:00
parser = argparse . ArgumentParser ( description = " Hoymiles HMS Monitoring " )
parser . add_argument ( " ip_address " , type = str , help = " IP address or hostname of the inverter " )
2023-12-19 11:08:05 +00:00
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 " )
2023-11-17 12:20:23 +00:00
args = parser . parse_args ( )
2023-12-19 08:28:47 +00:00
inverter = Inverter ( args . ip_address )
2023-11-17 11:10:33 +00:00
2023-12-19 11:08:05 +00:00
# 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 ( ' _ ' , ' ' ) } " )
2023-12-19 07:41:57 +00:00
2023-12-19 11:08:05 +00:00
# Sleep for a while before the next update
time . sleep ( 60 )
2023-11-17 11:10:33 +00:00
if __name__ == " __main__ " :
2023-11-17 11:45:17 +00:00
main ( )