Compare commits
5 Commits
work
...
a235bc46ba
Author | SHA1 | Date | |
---|---|---|---|
a235bc46ba | |||
db460df4a9 | |||
3f47a4640d | |||
e45ca1b2d3 | |||
1402c07e70 |
11
Dockerfile
11
Dockerfile
@@ -1,8 +1,11 @@
|
|||||||
FROM debian:trixie-slim
|
FROM debian:bullseye-slim
|
||||||
#
|
#
|
||||||
|
RUN apt update && apt install python3 python3-pip -y
|
||||||
|
COPY enphase.py /usr/local/bin/
|
||||||
COPY requirements.txt /
|
COPY requirements.txt /
|
||||||
COPY init.sh /
|
COPY init.sh /
|
||||||
RUN apt update && apt install python3 python3-pip -y && pip3 install -r /requirements.txt --break-system-packages && apt clean
|
RUN chmod +x /init.sh
|
||||||
COPY enphase.py /usr/local/bin/
|
RUN chmod +x /usr/local/bin/enphase.py
|
||||||
RUN chmod +x /init.sh && chmod +x /usr/local/bin/enphase.py
|
RUN pip3 install -r /requirements.txt
|
||||||
|
RUN apt clean
|
||||||
CMD ["/init.sh"]
|
CMD ["/init.sh"]
|
36
enphase.py
36
enphase.py
@@ -171,42 +171,18 @@ while True:
|
|||||||
session.headers.update({"Authorization":"Bearer "+enphasetoken})
|
session.headers.update({"Authorization":"Bearer "+enphasetoken})
|
||||||
details = enphaseurl + "/production.json?details=1"
|
details = enphaseurl + "/production.json?details=1"
|
||||||
inverteruri= enphaseurl + "/api/v1/production/inverters"
|
inverteruri= enphaseurl + "/api/v1/production/inverters"
|
||||||
mainresponse = session.get(details,verify=False)
|
mainresponse = session.get(details,verify=False).json()
|
||||||
if mainresponse.status_code == 401:
|
inverterresponse = session.get(inverteruri,verify=False).json()
|
||||||
print("Authentication Error, please renew enphase token at https://entrez.enphaseenergy.com/entrez_tokens")
|
#print(json.dumps(mainresponse,indent=1))
|
||||||
quit()
|
for inverterdata in inverterresponse:
|
||||||
print("Status code:", mainresponse.status_code)
|
|
||||||
print("Headers:", mainresponse.headers)
|
|
||||||
print("Raw text:", mainresponse.text[:500])
|
|
||||||
try:
|
|
||||||
mainresponseresult = mainresponse.json()
|
|
||||||
print("Parsed JSON:\n", json.dumps(mainresponseresult, indent=2))
|
|
||||||
except Exception as e:
|
|
||||||
print("Failed to parse JSON:", e)
|
|
||||||
quit()
|
|
||||||
|
|
||||||
inverterresponse = session.get(inverteruri,verify=False)
|
|
||||||
if inverterresponse.status_code == 401:
|
|
||||||
print("Authentication Error, please renew enphase token at https://entrez.enphaseenergy.com/entrez_tokens")
|
|
||||||
quit()
|
|
||||||
print("Status code:", inverterresponse.status_code)
|
|
||||||
print("Headers:", inverterresponse.headers)
|
|
||||||
print("Raw text:", inverterresponse.text[:500])
|
|
||||||
try:
|
|
||||||
inverterresponseresult = inverterresponse.json()
|
|
||||||
print("Parsed JSON:\n", json.dumps(inverterresponseresult, indent=2))
|
|
||||||
except Exception as e:
|
|
||||||
print("Failed to parse JSON:", e)
|
|
||||||
quit()
|
|
||||||
for inverterdata in inverterresponseresult:
|
|
||||||
myinverter = inverter(inverterdata['serialNumber'],inverterdata['lastReportDate'],inverterdata['devType'],inverterdata['lastReportWatts'],inverterdata['maxReportWatts'])
|
myinverter = inverter(inverterdata['serialNumber'],inverterdata['lastReportDate'],inverterdata['devType'],inverterdata['lastReportWatts'],inverterdata['maxReportWatts'])
|
||||||
inverterlist.append(myinverter)
|
inverterlist.append(myinverter)
|
||||||
#print(json.dumps(response.json(),indent=1))
|
#print(json.dumps(response.json(),indent=1))
|
||||||
#for myinverter in inverterlist:
|
#for myinverter in inverterlist:
|
||||||
#pass
|
#pass
|
||||||
# myinverter.print()
|
# myinverter.print()
|
||||||
#print(json.dumps(mainresponse,indent=1))
|
print(json.dumps(mainresponse,indent=1))
|
||||||
maindata = ElectricalData(mainresponseresult)
|
maindata = ElectricalData(mainresponse)
|
||||||
influxsession = requests.Session()
|
influxsession = requests.Session()
|
||||||
influxsession.verify = False
|
influxsession.verify = False
|
||||||
influxsession.auth = (infdbuser, infdbpass)
|
influxsession.auth = (infdbuser, infdbpass)
|
||||||
|
Reference in New Issue
Block a user