Skip to content

Commit

Permalink
Add sensor and disable it
Browse files Browse the repository at this point in the history
Add sensor and disable it if luxtronik visibility is 0
  • Loading branch information
BenPru authored Jan 25, 2023
1 parent e65ebc4 commit 05b5f16
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/luxtronik/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,9 @@ def __init__(
self._attr_extra_state_attributes = { ATTR_EXTRA_STATE_ATTRIBUTE_LUXTRONIK_KEY: sensor_key }
self._extra_attributes = extra_attributes

def disable_by_default(self):
self._attr_entity_registry_enabled_default = False

@property
def icon(self): # -> str | None:
"""Return the icon to be used for this entity."""
Expand Down Expand Up @@ -1186,8 +1189,9 @@ def _schedule_immediate_update(self):
self.async_schedule_update_ha_state(True)

def add_sensor_if_active(luxtronik, entities, check_key: str, sensor: LuxtronikSensor):
if luxtronik.get_value(check_key) > 0:
entities += [sensor]
if luxtronik.get_value(check_key) <= 0:
sensor.disable_by_default()
entities += [sensor]

def add_sensor_if_min_minor_version(luxtronik, entities, min_minor: int, sensor: LuxtronikSensor):
if luxtronik.firmware_version_minor >= min_minor:
Expand Down

0 comments on commit 05b5f16

Please sign in to comment.