Skip to content

Commit

Permalink
Expose all possible options
Browse files Browse the repository at this point in the history
This will make it easier to know all existing values
  • Loading branch information
kamaradclimber committed Jun 9, 2024
1 parent 1187c6c commit 89f3880
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions custom_components/rte_ecowatt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ def __init__(self, coordinator: EcoWattAPICoordinator, hass: HomeAssistant):
self.hass = hass
self._attr_name = "Ecowatt downgraded level"
self._events = []
self.options = {
0: "Situation normale - Electricité faible émission de CO2",
1: "Situation normale",
2: "Risques de coupures d'électricité",
3: "Coupures d'électricité programmées",
}

@property
def event(self) -> Optional[CalendarEvent]:
Expand Down Expand Up @@ -372,12 +378,7 @@ def _merge_events(self, events: list[CalendarEvent]) -> list[CalendarEvent]:
def _level2string(self, level):
if self.state == STATE_ON and level == 3:
return "Coupure d'électricité en cours"
return {
0: "Situation normale - Electricité faible émission de CO2",
1: "Situation normale",
2: "Risques de coupures d'électricité",
3: "Coupures d'électricité programmées",
}[level]
return self.options[level]

@property
def device_info(self):
Expand All @@ -398,6 +399,13 @@ def __init__(
self._state = None
self.shift = shift
self.happening_now = False
self.options = {
0: "Situation normale - Electricité faible émission de CO2",
1: "Situation normale",
2: "Risques de coupures d'électricité",
3: "Coupures d'électricité programmées",
}
self._attr_extra_state_attributes["options"] = list(self.options.values()) + ["Coupure d'électricité en cours"]

def _timezone(self):
timezone = self.hass.config.as_dict()["time_zone"]
Expand Down Expand Up @@ -425,12 +433,7 @@ def _level2string(self, level) -> Optional[str]:
return "Coupure d'électricité en cours"
if level is None:
return None
return {
0: "Situation normale - Electricité faible émission de CO2",
1: "Situation normale",
2: "Risques de coupures d'électricité",
3: "Coupures d'électricité programmées",
}[level]
return self.options[level]

def _level2icon(self, level) -> Optional[str]:
return {
Expand Down

0 comments on commit 89f3880

Please sign in to comment.