-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from saniho/sensorEcoWatt
Sensor eco watt
- Loading branch information
Showing
13 changed files
with
434 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
try: | ||
from .const import ( # isort:skip | ||
__nameMyEnedis__, | ||
) | ||
|
||
except ImportError: | ||
from const import ( # type: ignore[no-redef] | ||
__nameMyEnedis__, | ||
) | ||
|
||
import logging | ||
|
||
from .myCheckData import myCheckData | ||
from .myDataControl import getInformationDataControl, okDataControl | ||
|
||
log = logging.getLogger(__nameMyEnedis__) | ||
|
||
|
||
class myDataEnedisEcoWatt: | ||
def __init__(self, myCalli, token, version, contrat): | ||
self.myCalli = myCalli | ||
self._value = {} | ||
self._date = None | ||
self._contrat = contrat | ||
self._token, self._version = token, version | ||
self._dateDeb = None | ||
self._dateFin = None | ||
self._callOk = None | ||
self._nbCall = 0 | ||
self._data = None | ||
|
||
def CallgetData(self, dateDeb, dateFin): | ||
val1, val2 = self.myCalli.getDataEcoWatt(dateDeb, dateFin) | ||
return val1, val2 | ||
|
||
def getValue(self): | ||
return self._value | ||
|
||
def getDateFin(self): | ||
return self._dateFin | ||
|
||
def getDateDeb(self): | ||
return self._dateDeb | ||
|
||
def getCallOk(self): | ||
return self._callOk | ||
|
||
def getNbCall(self): | ||
return self._nbCall | ||
|
||
def updateData( | ||
self, | ||
clefFunction, | ||
horairePossible=True, | ||
data=None, | ||
dateDeb=None, | ||
dateFin=None, | ||
withControl=False, | ||
dataControl=None, | ||
): | ||
self._nbCall = 0 | ||
onLance = True | ||
if withControl: | ||
if okDataControl(clefFunction, dataControl, dateDeb, dateFin): | ||
onLance = True | ||
self._callOk = True | ||
else: | ||
if not horairePossible: | ||
onLance = True | ||
dateDeb, dateFin, self._callOk = getInformationDataControl( | ||
dataControl | ||
) | ||
if self._callOk is None: | ||
data = ( | ||
None # si on doit mettre à jour .... sauf si on est pas la | ||
) | ||
else: | ||
self._callOk = None | ||
data = None # si on doit mettre à jour .... sauf si on est pas la | ||
if onLance: | ||
self._dateDeb = dateDeb | ||
self._dateFin = dateFin | ||
log.info(f"--updateData {clefFunction} ( du {dateDeb} au {dateFin} )--") | ||
self._data = data | ||
if self._data is None: | ||
self._data, callDone = self.CallgetData(dateDeb, dateFin) | ||
self._nbCall = 1 | ||
else: | ||
callDone = True | ||
log.info("updateData : data %s", self._data) | ||
if (callDone) and (myCheckData().checkDataEcoWatt(self._data)): | ||
self._value = myCheckData().analyseValueEcoWatt(self._data) | ||
self._callOk = True | ||
else: | ||
self._value = 0 | ||
self._callOk = callDone | ||
log.info(f"with update !! {clefFunction} ( du {dateDeb} au {dateFin} )--") | ||
log.info("updateData : data %s", (self._data)) | ||
else: | ||
log.info(f"noupdate !! {clefFunction} ( du {dateDeb} au {dateFin} )--") | ||
log.info("no updateData : data %s", (self._data)) | ||
return self._data |
Oops, something went wrong.