Home Assistant Git Exporter

This commit is contained in:
root
2024-08-26 13:38:09 +02:00
parent 80fc630f5e
commit fc0376e38e
2010 changed files with 11414 additions and 16153 deletions

View File

@@ -371,26 +371,46 @@ class UsageRestrictionEntity(CoordinatorEntity, SensorEntity):
def compute_native_value(self) -> Optional[str]:
"""This method extract the most relevant restriction level to display as aggregate"""
def any_restriction_match(matcher):
r = re.compile(matcher, re.IGNORECASE)
for restriction in self._restrictions:
if r.search(restriction):
return True
return False
if len(self._restrictions) == 0:
return "Aucune restriction"
if "Interdiction sur plage horaire" in self._restrictions:
if any_restriction_match("interdiction sur plage horaire"):
return "Interdiction sur plage horaire"
if "Interdiction sauf exception" in self._restrictions:
if any_restriction_match("interdi.*sauf"):
return "Interdiction sauf exception"
if "Interdit sauf pour les usages commerciaux après accord du service de police de leau." in self._restrictions:
if any_restriction_match("à lexception"):
return "Interdiction sauf exception"
if "Interdiction" in self._restrictions:
if any_restriction_match("à lexclusion"):
return "Interdiction sauf exception"
if any_restriction_match("Interdit.*dès lors"):
return "Interdiction sauf exception"
if any_restriction_match("Interdiction"):
return "Interdiction"
if "Interdiction." in self._restrictions:
if any_restriction_match("interdit"):
return "Interdiction"
if "Réduction de prélèvement" in self._restrictions:
if any_restriction_match("interdiction"):
return "Interdiction"
if any_restriction_match("limitation au strict nécessaire"):
return "Interdiction sauf strict nécessaire"
if any_restriction_match("Réduction de prélèvement"):
return "Réduction de prélèvement"
if "Consulter larrêté" in self._restrictions:
if any_restriction_match("Consulter larrêté"):
return "Erreur: consulter l'arreté"
if "Se référer à l'arrêté de restriction en cours de validité." in self._restrictions:
if any_restriction_match("Se référer à l'arrêté de restriction en cours de validité."):
return "Erreur: consulter l'arreté"
if "Pas de restriction sauf arrêté spécifique." in self._restrictions:
if any_restriction_match("Pas de restriction sauf arrêté spécifique."):
return "Autorisé sauf exception"
if any_restriction_match("Sensibiliser"):
return "Sensibilisation"
if any_restriction_match("Sensibilisation"):
return "Sensibilisation"
if len(self._restrictions) == 1:
return self._restrictions[0]
_LOGGER.warn(f"Restrictions are hard to interpret: {self._restrictions}")