Skip to content

Commit

Permalink
next marée
Browse files Browse the repository at this point in the history
next marée + 1
  • Loading branch information
saniho committed Feb 10, 2021
1 parent 0676bfe commit 6e5b9ff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
12 changes: 10 additions & 2 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion custom_components/apiMareeInfo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

DOMAIN = "apiMareeInfo"

__VERSION__ = "1.0.0.3"
__VERSION__ = "1.0.0.4"

__name__ = "apiMareeInfo"
17 changes: 12 additions & 5 deletions custom_components/apiMareeInfo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ def getNomDuPort(self):
def getDateCourante(self):
return self._myMaree.getDateCourante()

def getNextMaree(self):
def getNextMaree(self, indice = 1):
i = 1
maintenant = datetime.now()
prochainemaree = None
for x in self._infoPort.keys():
if ( prochainemaree == None ):
if ( maintenant < self._infoPort[x][ "dateComplete"]):
prochainemaree = self._infoPort[x]
if (indice == i ):
prochainemaree = self._infoPort[x]
else:
i += 1
return prochainemaree

def setup_platform(hass, config, add_entities, discovery_info=None):
Expand Down Expand Up @@ -153,9 +157,12 @@ def _update(self):
self._attributes["coeff_%s_%s" %(jour, nieme)] = "%s" %(info['coeff'])
self._attributes["etat_%s_%s" %(jour, nieme)] = "%s" %(info['etat'])
self._attributes["hauteur_%s_%s" %(jour, nieme)] = "%s" %(info['hauteur'])
self._attributes["next_maree"] = "%s" %self._myPort.getNextMaree()["horaire"]
self._attributes["next_coeff"] = "%s" %self._myPort.getNextMaree()["coeff"]
self._attributes["next_etat"] = "%s" %self._myPort.getNextMaree()["etat"]
# pour avoir les 2 prochaines marées
for x in range(2):
i = x + 1
self._attributes["next_maree_%s"%i] = "%s" %self._myPort.getNextMaree(i)["horaire"]
self._attributes["next_coeff_%s"%i] = "%s" %self._myPort.getNextMaree(i)["coeff"]
self._attributes["next_etat_%s"%i] = "%s" %self._myPort.getNextMaree(i)["etat"]
self._attributes["timeLastCall"] = datetime.now()
self._attributes.update(status_counts)
self._state = self._myPort.getNextMaree()["horaire"]
Expand Down

0 comments on commit 6e5b9ff

Please sign in to comment.