Skip to content

Commit

Permalink
Reread registers on every fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
miathedev committed Sep 16, 2023
1 parent b30928a commit ed153ab
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions data_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@

app = Flask(__name__)

global inverter

@app.route('/', methods=['GET'])
def get_values():
args = parse_environment_variables() # Parse environment variables
inverter = solaredge_modbus.Inverter(
host=args["host"],
port=int(args["port"]),
timeout=int(args["timeout"]),
unit=int(args["unit"])
)
global inverter
inverter.read_all()

values = {}
values = inverter.read_all()
Expand Down Expand Up @@ -48,5 +45,13 @@ def parse_environment_variables():
"unit": unit,
}

args = parse_environment_variables() # Parse environment variables
inverter = solaredge_modbus.Inverter(
host=args["host"],
port=int(args["port"]),
timeout=int(args["timeout"]),
unit=int(args["unit"])
)

if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)

0 comments on commit ed153ab

Please sign in to comment.