Send Prowl when go back to bleu
This commit is contained in:
@ -4,10 +4,11 @@ import urllib3
|
|||||||
import json
|
import json
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import time
|
import time
|
||||||
|
import pyprowl
|
||||||
#import syslog
|
#import syslog
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
from secret import ecodevice,gx,gxsn,chgbleu,chgblanc,chgrouge,minbleu,minblanc,minrouge
|
from secret import ecodevice,gx,gxsn,chgbleu,chgblanc,chgrouge,minbleu,minblanc,minrouge,prowlkey
|
||||||
|
|
||||||
# Lancer ceci du 01 Oct au 31 mai
|
# Lancer ceci du 01 Oct au 31 mai
|
||||||
# une fois avant 22h / une fois apres 22h
|
# une fois avant 22h / une fois apres 22h
|
||||||
@ -17,6 +18,12 @@ from secret import ecodevice,gx,gxsn,chgbleu,chgblanc,chgrouge,minbleu,minblanc,
|
|||||||
ESSwBL = 1 # ESS "Optimized with BatteryLife)
|
ESSwBL = 1 # ESS "Optimized with BatteryLife)
|
||||||
ESSwoBL = 10 # ESS "Optimized without BatteryLife)
|
ESSwoBL = 10 # ESS "Optimized without BatteryLife)
|
||||||
|
|
||||||
|
p = pyprowl.Prowl(prowlkey)
|
||||||
|
|
||||||
|
def sendprowl(foo):
|
||||||
|
p.notify(event='EDF TEMPO', description='Attention EDF Tarif: '+foo,
|
||||||
|
priority=0, appName='EDF TEMPO')
|
||||||
|
|
||||||
# Log !
|
# Log !
|
||||||
def loggerinfo(foo):
|
def loggerinfo(foo):
|
||||||
#syslog.syslog(syslog.LOG_INFO,foo)
|
#syslog.syslog(syslog.LOG_INFO,foo)
|
||||||
@ -101,6 +108,13 @@ def setESSstate(state):
|
|||||||
else:
|
else:
|
||||||
loggerinfo(" -> not published")
|
loggerinfo(" -> not published")
|
||||||
|
|
||||||
|
# Setup Prowl
|
||||||
|
try:
|
||||||
|
p.verify_key()
|
||||||
|
except Exception as e:
|
||||||
|
print("Error verifying Prowl API key: {}".format(e))
|
||||||
|
exit()
|
||||||
|
|
||||||
# Setup EcoDevice
|
# Setup EcoDevice
|
||||||
http = urllib3.PoolManager()
|
http = urllib3.PoolManager()
|
||||||
resp = http.request("GET", "http://"+ecodevice+"/api/xdevices.json?cmd=10")
|
resp = http.request("GET", "http://"+ecodevice+"/api/xdevices.json?cmd=10")
|
||||||
@ -187,11 +201,13 @@ if today == tomorrow:
|
|||||||
elif today == 0: # Bleu
|
elif today == 0: # Bleu
|
||||||
if tomorrow == 1: # Blanc
|
if tomorrow == 1: # Blanc
|
||||||
if daynight == 1:
|
if daynight == 1:
|
||||||
|
sendprowl('BLANC')
|
||||||
loggerinfo ("Charge 90%")
|
loggerinfo ("Charge 90%")
|
||||||
setChargeSetpoint(chgblanc)
|
setChargeSetpoint(chgblanc)
|
||||||
elif tomorrow == 2: # Rouge
|
elif tomorrow == 2: # Rouge
|
||||||
if daynight == 1:
|
if daynight == 1:
|
||||||
loggerinfo ("Charge 95%")
|
loggerinfo ("Charge 95%")
|
||||||
|
sendprowl('ROUGE')
|
||||||
setChargeSetpoint(chgrouge)
|
setChargeSetpoint(chgrouge)
|
||||||
else:
|
else:
|
||||||
loggerinfo ("SocMin 25%")
|
loggerinfo ("SocMin 25%")
|
||||||
@ -203,11 +219,13 @@ elif today == 1: # Blanc
|
|||||||
if daynight == 1:
|
if daynight == 1:
|
||||||
loggerinfo ("Charge 80%")
|
loggerinfo ("Charge 80%")
|
||||||
setChargeSetpoint(chgbleu)
|
setChargeSetpoint(chgbleu)
|
||||||
|
sendprowl('BLEU')
|
||||||
else:
|
else:
|
||||||
loggerinfo ("SocMin 30%")
|
loggerinfo ("SocMin 30%")
|
||||||
setMinSocSetpoint(minbleu)
|
setMinSocSetpoint(minbleu)
|
||||||
elif tomorrow == 2: # Rouge
|
elif tomorrow == 2: # Rouge
|
||||||
if daynight == 1:
|
if daynight == 1:
|
||||||
|
sendprowl('ROUGE')
|
||||||
loggerinfo ("Charge 95%")
|
loggerinfo ("Charge 95%")
|
||||||
setChargeSetpoint(chgrouge)
|
setChargeSetpoint(chgrouge)
|
||||||
else:
|
else:
|
||||||
@ -220,6 +238,7 @@ elif today == 2: # Rouge
|
|||||||
if daynight == 1:
|
if daynight == 1:
|
||||||
loggerinfo ("Charge 80%")
|
loggerinfo ("Charge 80%")
|
||||||
setChargeSetpoint(chgbleu)
|
setChargeSetpoint(chgbleu)
|
||||||
|
sendprowl('BLEU')
|
||||||
else:
|
else:
|
||||||
loggerinfo ("SocMin 30%")
|
loggerinfo ("SocMin 30%")
|
||||||
setChargeSetpoint(chgbleu)
|
setChargeSetpoint(chgbleu)
|
||||||
@ -227,6 +246,7 @@ elif today == 2: # Rouge
|
|||||||
setESSstate(ESSwBL)
|
setESSstate(ESSwBL)
|
||||||
elif tomorrow == 1: # Blanc
|
elif tomorrow == 1: # Blanc
|
||||||
if daynight == 1:
|
if daynight == 1:
|
||||||
|
sendprowl('BLANC')
|
||||||
loggerinfo ("Charge 90%")
|
loggerinfo ("Charge 90%")
|
||||||
setChargeSetpoint(chgblanc)
|
setChargeSetpoint(chgblanc)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user