Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Mar 19, 2023
1 parent 2661738 commit d2cfe13
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions custom_components/peaqev/peaqservice/chargertypes/types/easee.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, hass: HomeAssistant, huboptions: HubOptions, chargertype, aut
)

@property
def max_amps(self): -> int:
def max_amps(self) -> int:
return self.get_allowed_amps()

@property
Expand Down Expand Up @@ -158,19 +158,17 @@ def set_sensors(self):
self.options.ampmeter_is_attribute = False

def get_allowed_amps(self) -> int:
try:
ret = self._hass.states.get(self.entities.maxamps)
if ret is not None:
return int(ret.state)
return 16
except:
_LOGGER.warning("Unable to get max amps for circuit. Setting max amps to 16.")
else:
_LOGGER.warning(f"Unable to get max amps. The sensor {self.entities.maxamps} returned state None. Setting max amps to 16 til I get a proper state.")
return 16

def _validate_sensor(self, sensor: str) -> bool:
ret = self._hass.states.get(sensor)
if ret is None:
return False
if ret.state == "Null":
if ret.state.lower() in ["null", "unavailable"]:
return False
return True

0 comments on commit d2cfe13

Please sign in to comment.