Skip to content

Commit

Permalink
More entities default disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
superrob committed Dec 28, 2024
1 parent ecde27e commit 3b8d57f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
20 changes: 10 additions & 10 deletions custom_components/genvex_connect/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.BYPASS_OPENOFFSET))
# Air supply level sliders
if genvexNabto.providesValue(GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL1):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL1, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL1, defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL2):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL2, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL2, defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL3):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL3, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL3, defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL4):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL4, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.SUPPLY_AIR_LEVEL4, defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL1):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL1, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL1, defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL2):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL2, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL2, defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL3):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL3, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL3, defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL4):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL4, enabledDefault=False))
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.EXTRACT_AIR_LEVEL4, defaultEnabled=False))
# Boost time
if genvexNabto.providesValue(GenvexNabtoSetpointKey.BOOST_TIME):
new_entities.append(GenvexConnectNumber(genvexNabto, GenvexNabtoSetpointKey.BOOST_TIME))
Expand All @@ -58,15 +58,15 @@ async def async_setup_entry(hass, config_entry, async_add_entities):


class GenvexConnectNumber(GenvexConnectEntityBase, NumberEntity):
def __init__(self, genvexNabto, valueKey, enabledDefault=True):
def __init__(self, genvexNabto, valueKey, defaultEnabled=True):
super().__init__(genvexNabto, valueKey, valueKey)
self._valueKey = valueKey
self._attr_device_class = NumberDeviceClass.TEMPERATURE
self._attr_native_min_value = genvexNabto.getSetpointMinValue(valueKey)
self._attr_native_max_value = genvexNabto.getSetpointMaxValue(valueKey)
self._attr_native_step = genvexNabto.getSetpointStep(valueKey)
self._attr_entity_category = EntityCategory.CONFIG
self._attr_entity_registry_enabled_default = enabledDefault
self._attr_entity_registry_enabled_default = defaultEnabled

async def async_set_native_value(self, value: float) -> None:
"""Update the current value."""
Expand Down
18 changes: 13 additions & 5 deletions custom_components/genvex_connect/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
if genvexNabto.providesValue(GenvexNabtoDatapointKey.DUTYCYCLE_EXTRACT):
new_entities.append(GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.DUTYCYCLE_EXTRACT, unitOfMeasurement="%"))
if genvexNabto.providesValue(GenvexNabtoDatapointKey.PREHEAT_PWM):
new_entities.append(GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.PREHEAT_PWM, unitOfMeasurement="%", enabledDefault=False))
new_entities.append(
GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.PREHEAT_PWM, unitOfMeasurement="%", defaultEnabled=False)
)
if genvexNabto.providesValue(GenvexNabtoDatapointKey.REHEAT_PWM):
new_entities.append(GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.REHEAT_PWM, unitOfMeasurement="%", enabledDefault=False))
new_entities.append(
GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.REHEAT_PWM, unitOfMeasurement="%", defaultEnabled=False)
)
if genvexNabto.providesValue(GenvexNabtoDatapointKey.RPM_SUPPLY):
new_entities.append(
GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.RPM_SUPPLY, unitOfMeasurement="rpm", displayPrecision=0)
Expand All @@ -132,7 +136,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
)
if genvexNabto.providesValue(GenvexNabtoDatapointKey.ROTOR_SPEED):
new_entities.append(
GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.ROTOR_SPEED, unitOfMeasurement="rpm", displayPrecision=0, enabledDefault=False)
GenvexConnectSensorGeneric(
genvexNabto, GenvexNabtoDatapointKey.ROTOR_SPEED, unitOfMeasurement="rpm", displayPrecision=0, defaultEnabled=False
)
)
if genvexNabto.providesValue(GenvexNabtoDatapointKey.FAN_LEVEL_SUPPLY):
new_entities.append(GenvexConnectSensorGeneric(genvexNabto, GenvexNabtoDatapointKey.FAN_LEVEL_SUPPLY))
Expand Down Expand Up @@ -219,7 +225,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):


class GenvexConnectSensorGeneric(GenvexConnectEntityBase, SensorEntity):
def __init__(self, genvexNabto, valueKey, deviceClass=None, stateClass=None, unitOfMeasurement=None, displayPrecision=None, enabledDefault=True):
def __init__(
self, genvexNabto, valueKey, deviceClass=None, stateClass=None, unitOfMeasurement=None, displayPrecision=None, defaultEnabled=True
):
super().__init__(genvexNabto, valueKey, valueKey)
self._valueKey = valueKey
self._attr_state_class = SensorStateClass.MEASUREMENT
Expand All @@ -229,7 +237,7 @@ def __init__(self, genvexNabto, valueKey, deviceClass=None, stateClass=None, uni
self._attr_native_unit_of_measurement = unitOfMeasurement
if displayPrecision:
self._attr_suggested_display_precision = displayPrecision
self._attr_entity_registry_enabled_default = enabledDefault
self._attr_entity_registry_enabled_default = defaultEnabled

def update(self) -> None:
"""Fetch new state data for the sensor."""
Expand Down
7 changes: 4 additions & 3 deletions custom_components/genvex_connect/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):

new_entities = []
if genvexNabto.providesValue(GenvexNabtoSetpointKey.REHEATING):
new_entities.append(GenvexConnectSwitch(genvexNabto, GenvexNabtoSetpointKey.REHEATING, "mdi:heating-coil"))
new_entities.append(GenvexConnectSwitch(genvexNabto, GenvexNabtoSetpointKey.REHEATING, "mdi:heating-coil", defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.PREHEATING):
new_entities.append(GenvexConnectSwitch(genvexNabto, GenvexNabtoSetpointKey.PREHEATING, "mdi:heating-coil"))
new_entities.append(GenvexConnectSwitch(genvexNabto, GenvexNabtoSetpointKey.PREHEATING, "mdi:heating-coil", defaultEnabled=False))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.COOLING_ENABLE):
new_entities.append(GenvexConnectSwitch(genvexNabto, GenvexNabtoSetpointKey.COOLING_ENABLE, "mdi:coolant-temperature"))
if genvexNabto.providesValue(GenvexNabtoSetpointKey.HUMIDITY_CONTROL):
Expand All @@ -27,11 +27,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities):


class GenvexConnectSwitch(GenvexConnectEntityBase, SwitchEntity):
def __init__(self, genvexNabto, valueKey, icon):
def __init__(self, genvexNabto, valueKey, icon, defaultEnabled=True):
super().__init__(genvexNabto, valueKey, valueKey)
self._valueKey = valueKey
self._attr_device_class = SwitchDeviceClass.SWITCH
self._icon = icon
self._attr_entity_registry_enabled_default = defaultEnabled

@property
def icon(self):
Expand Down

0 comments on commit 3b8d57f

Please sign in to comment.