commit
c10c71279f
3 changed files with 54 additions and 0 deletions
Binary file not shown.
@ -0,0 +1,43 @@ |
|||||||
|
import json |
||||||
|
import requests |
||||||
|
import base64 |
||||||
|
import time |
||||||
|
import urllib3 |
||||||
|
import logging |
||||||
|
import os |
||||||
|
|
||||||
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) |
||||||
|
logging.basicConfig(level=logging.INFO, filename=os.path.join(os.path.dirname(__file__),'enphase.log'), filemode="a+",format="%(asctime)-15s %(levelname)-8s %(message)s") |
||||||
|
|
||||||
|
user='christophe.scaya@gmail.com' |
||||||
|
password='92@!Z&KYxt8shT' |
||||||
|
envoy_serial='482330092358' |
||||||
|
ip='192.168.0.201' |
||||||
|
ip_esp='192.168.0.115' |
||||||
|
|
||||||
|
"""data = {'user[email]': user, 'user[password]': password} |
||||||
|
response = requests.post('http://enlighten.enphaseenergy.com/login/login.json?',data=data) |
||||||
|
response_data = json.loads(response.text) |
||||||
|
data = {'session_id': response_data['session_id'], 'serial_num': envoy_serial, 'username': user} |
||||||
|
response = requests.post('http://entrez.enphaseenergy.com/tokens', json=data) |
||||||
|
token=response.text""" |
||||||
|
|
||||||
|
token='eyJraWQiOiI3ZDEwMDA1ZC03ODk5LTRkMGQtYmNiNC0yNDRmOThlZTE1NmIiLCJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJhdWQiOiI0ODIzMzAwOTIzNTgiLCJpc3MiOiJFbnRyZXoiLCJlbnBoYXNlVXNlciI6Im93bmVyIiwiZXhwIjoxNzM5MTA4NTIzLCJpYXQiOjE3MDc1NzI1MjMsImp0aSI6IjE5MmI0YjJhLTNjMTktNDc3YS1hZTc5LTdlM2FkZTY4ZWI3MSIsInVzZXJuYW1lIjoiY2hyaXN0b3BoZS5zY2F5YUBnbWFpbC5jb20ifQ.crL1eSrSfZ76AtrQT_vPCukcjA0I9Yyj7HO1bMJSbl6KiAznrETfr85HluwAJrd2KI7mTwNzHZZrVnwPiN4rAA' |
||||||
|
|
||||||
|
headers = {'Accept': 'application/json', |
||||||
|
'Authorization': 'Bearer '+token,} |
||||||
|
|
||||||
|
while True: |
||||||
|
try: |
||||||
|
response = requests.get('http://'+ip+'/ivp/meters/reports/consumption', verify=False, headers=headers) |
||||||
|
json=response.json() |
||||||
|
total = round(json[0]['cumulative']['currW']) |
||||||
|
net = round(json[1]['cumulative']['currW']) |
||||||
|
panneaux = total-net |
||||||
|
#esp_cmd = requests.get('http://'+ip_esp+'/control?cmd=event,setPwr='+str(net)) |
||||||
|
logging.info("Total: "+str(total)+" Panneaux: "+str(panneaux)+" Enedis: "+str(net)) |
||||||
|
print("Total: "+str(total)+" Panneaux: "+str(panneaux)+" Enedis: "+str(net)) |
||||||
|
time.sleep(2) |
||||||
|
except requests.exceptions.RequestException as e: |
||||||
|
logging.error(e) |
||||||
|
time.sleep(30) |
||||||
Loading…
Reference in new issue