Skip to content

Commit

Permalink
Attempted to handle disabling some features from the get go.
Browse files Browse the repository at this point in the history
Unfortunately, it will actually disable stuff I DON'T want disabled.
  • Loading branch information
corporategoth committed May 17, 2023
1 parent cca1043 commit b122692
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions custom_components/powerpetdoor/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"class": NumberDeviceClass.VOLTAGE,
"category": EntityCategory.CONFIG,
"unit_of_measurement": UnitOfElectricPotential.VOLT,
"disabled": True,
},
"sleep_sensor_trigger_voltage": {
"field": FIELD_SLEEP_SENSOR_TRIGGER_VOLTAGE,
Expand All @@ -68,6 +69,7 @@
"class": NumberDeviceClass.VOLTAGE,
"category": EntityCategory.CONFIG,
"unit_of_measurement": UnitOfElectricPotential.VOLT,
"disabled": True,
},
}

Expand Down Expand Up @@ -99,6 +101,8 @@ def __init__(self,
self._attr_native_step = number["step"]
if "unit" in number:
self._attr_native_unit_of_measurement = number["unit"]
if "disabled" in number:
self._attr_entity_registry_visible_default = not number["disabled"]
if "multiplier" in number:
self.multiplier = number["multiplier"]
self._attr_device_info = device
Expand Down
4 changes: 4 additions & 0 deletions custom_components/powerpetdoor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@
"icon": "mdi:reload",
"class": "total_increasing",
"category": EntityCategory.DIAGNOSTIC,
"disabled": True,
},
"auto_retracts": {
"field": FIELD_TOTAL_AUTO_RETRACTS,
"icon": "mdi:alert",
"class": "total_increasing",
"category": EntityCategory.DIAGNOSTIC,
"disabled": True,
},
}

Expand Down Expand Up @@ -319,6 +321,8 @@ def __init__(self,
self._attr_entity_category = sensor["category"]
if "class" in sensor:
self._attr_state_class = sensor["class"]
if "disabled" in sensor:
self._attr_entity_registry_visible_default = not sensor["disabled"]
self._attr_device_info = device
self._attr_unique_id = f"{client.host}:{client.port}-{sensor['field']}"

Expand Down
18 changes: 15 additions & 3 deletions custom_components/powerpetdoor/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
"disable": CMD_DISABLE_OUTSIDE_SENSOR_SAFETY_LOCK,
"icon_on": "mdi:weather-sunny-alert",
"icon_off": "mdi:shield-sun-outline",
"category": EntityCategory.CONFIG
"category": EntityCategory.CONFIG,
"disabled": True,
},
"cmd_lockout": {
"field": FIELD_CMD_LOCKOUT,
Expand All @@ -103,7 +104,8 @@
"disable": CMD_DISABLE_CMD_LOCKOUT,
"icon_on": "mdi:window-shutter-open",
"icon_off": "mdi:window-shutter",
"category": EntityCategory.CONFIG
"category": EntityCategory.CONFIG,
"disabled": True,
},
"autoretract": {
"field": FIELD_AUTORETRACT,
Expand All @@ -112,7 +114,8 @@
"disable": CMD_DISABLE_AUTORETRACT,
"icon_on": "mdi:window-shutter-alert",
"icon_off": "mdi:window-shutter-settings",
"category": EntityCategory.CONFIG
"category": EntityCategory.CONFIG,
"disabled": True,
},
"power": {
"field": FIELD_POWER,
Expand All @@ -129,26 +132,31 @@
"field": FIELD_SENSOR_ON_INDOOR_NOTIFICATIONS,
"icon_on": "mdi:motion-sensor",
"icon_off": "mdi:motion-sensor-off",
"disabled": True,
},
"inside_off": {
"field": FIELD_SENSOR_OFF_INDOOR_NOTIFICATIONS,
"icon_on": "mdi:motion-sensor",
"icon_off": "mdi:motion-sensor-off",
"disabled": True,
},
"outside_on": {
"field": FIELD_SENSOR_ON_OUTDOOR_NOTIFICATIONS,
"icon_on": "mdi:motion-sensor",
"icon_off": "mdi:motion-sensor-off",
"disabled": True,
},
"outside_off": {
"field": FIELD_SENSOR_OFF_OUTDOOR_NOTIFICATIONS,
"icon_on": "mdi:motion-sensor",
"icon_off": "mdi:motion-sensor-off",
"disabled": True,
},
"low_battery": {
"field": FIELD_LOW_BATTERY_NOTIFICATIONS,
"icon_on": "mdi:battery-alert-variant-outline",
"icon_off": "mdi:battery-remove-outline",
"disabled": True,
},
}

Expand All @@ -170,6 +178,8 @@ def __init__(self,
self._attr_name = name
if "category" in switch:
self._attr_entity_category = switch["category"]
if "disabled" in switch:
self._attr_entity_registry_visible_default = not switch["disabled"]
self._attr_device_info = device
self._attr_unique_id = f"{client.host}:{client.port}-{switch['field']}"

Expand Down Expand Up @@ -244,6 +254,8 @@ def __init__(self,
self.switch = switch

self._attr_name = name
if "disabled" in switch:
self._attr_entity_registry_visible_default = not switch["disabled"]
self._attr_device_info = device
self._attr_unique_id = f"{client.host}:{client.port}-{switch['field']}"

Expand Down

0 comments on commit b122692

Please sign in to comment.