Clean up goalzero (#40817)
* cleanup goalzero code * more cleanup * mroe cleanup * log defined exception to error * return None if not configured * return False if not configured
This commit is contained in:
parent
7554c8d6c5
commit
6627ffff39
6 changed files with 19 additions and 50 deletions
|
@ -30,14 +30,13 @@ class YetiBinarySensor(YetiEntity, BinarySensorEntity):
|
|||
|
||||
def __init__(self, api, coordinator, name, sensor_name, server_unique_id):
|
||||
"""Initialize a Goal Zero Yeti sensor."""
|
||||
super().__init__(api, coordinator, name, sensor_name, server_unique_id)
|
||||
super().__init__(api, coordinator, name, server_unique_id)
|
||||
|
||||
self._condition = sensor_name
|
||||
|
||||
variable_info = BINARY_SENSOR_DICT[sensor_name]
|
||||
self._condition_name = variable_info[0]
|
||||
self._icon = variable_info[2]
|
||||
self.api = api
|
||||
self._device_class = variable_info[1]
|
||||
|
||||
@property
|
||||
|
@ -55,6 +54,7 @@ class YetiBinarySensor(YetiEntity, BinarySensorEntity):
|
|||
"""Return if the service is on."""
|
||||
if self.api.data:
|
||||
return self.api.data[self._condition] == 1
|
||||
return False
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue