Skip to content

Commit a73b136

Browse files
committed
default less important entities by default
1 parent 15aa265 commit a73b136

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

custom_components/openwrt/api/ssh.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ async def get_services(self) -> list[ServiceInfo]:
829829

830830
return services
831831

832-
833832
async def reboot(self) -> bool:
834833
"""Reboot the device."""
835834
try:

custom_components/openwrt/api/ubus.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ async def manage_service(self, name: str, action: str) -> bool:
15111511
# 1. Try standard ubus rc.init (best practice)
15121512
await self._call("rc", "init", {"name": name, "action": action})
15131513
return True
1514-
except (UbusPermissionError, UbusError):
1514+
except UbusPermissionError, UbusError:
15151515
try:
15161516
# 2. Try ubus file.exec (direct init script call)
15171517
await self._call(
@@ -1950,7 +1950,6 @@ async def get_adblock_status(self) -> AdBlockStatus:
19501950
pass
19511951
return status
19521952

1953-
19541953
async def set_adblock_enabled(self, enabled: bool) -> bool:
19551954
"""Enable/disable adblock service."""
19561955
val = "1" if enabled else "0"

custom_components/openwrt/binary_sensor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ async def async_setup_entry(
7171
translation_key="mwan_online",
7272
translation_placeholders={"interface": mwan.interface_name},
7373
device_class=BinarySensorDeviceClass.CONNECTIVITY,
74+
entity_category=EntityCategory.DIAGNOSTIC,
75+
entity_registry_enabled_default=False,
7476
is_on_fn=lambda data, n=mwan.interface_name: any(
7577
m.status == "online"
7678
for m in data.mwan_status

custom_components/openwrt/sensor.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def _get_system_sensors() -> tuple[OpenWrtSensorDescription, ...]:
462462
native_unit_of_measurement=PERCENTAGE,
463463
state_class=SensorStateClass.MEASUREMENT,
464464
entity_category=EntityCategory.DIAGNOSTIC,
465+
entity_registry_enabled_default=False,
465466
value_fn=lambda data: (
466467
round(
467468
data.system_resources.filesystem_used
@@ -527,6 +528,7 @@ def _get_system_sensors() -> tuple[OpenWrtSensorDescription, ...]:
527528
name="Neighbor Devices",
528529
translation_key="neighbor_devices",
529530
state_class=SensorStateClass.MEASUREMENT,
531+
entity_registry_enabled_default=False,
530532
value_fn=lambda data: len(data.ip_neighbors),
531533
attrs_fn=lambda data: {
532534
"reachable": sum(
@@ -571,13 +573,15 @@ def _get_qmodem_sensors() -> tuple[OpenWrtSensorDescription, ...]:
571573
name="Modem Manufacturer",
572574
translation_key="qmodem_manufacturer",
573575
entity_category=EntityCategory.DIAGNOSTIC,
576+
entity_registry_enabled_default=False,
574577
value_fn=lambda data: data.qmodem_info.manufacturer,
575578
),
576579
OpenWrtSensorDescription(
577580
key="qmodem_revision",
578581
name="Modem Revision",
579582
translation_key="qmodem_revision",
580583
entity_category=EntityCategory.DIAGNOSTIC,
584+
entity_registry_enabled_default=False,
581585
value_fn=lambda data: data.qmodem_info.revision,
582586
),
583587
OpenWrtSensorDescription(
@@ -802,6 +806,7 @@ async def async_setup_entry(
802806
device_class=SensorDeviceClass.DATA_SIZE,
803807
state_class=SensorStateClass.MEASUREMENT,
804808
entity_category=EntityCategory.DIAGNOSTIC,
809+
entity_registry_enabled_default=False,
805810
value_fn=lambda usage: usage.total,
806811
),
807812
OpenWrtStorageSensorDescription(
@@ -811,6 +816,7 @@ async def async_setup_entry(
811816
device_class=SensorDeviceClass.DATA_SIZE,
812817
state_class=SensorStateClass.MEASUREMENT,
813818
entity_category=EntityCategory.DIAGNOSTIC,
819+
entity_registry_enabled_default=False,
814820
value_fn=lambda usage: usage.used,
815821
),
816822
OpenWrtStorageSensorDescription(
@@ -820,6 +826,7 @@ async def async_setup_entry(
820826
device_class=SensorDeviceClass.DATA_SIZE,
821827
state_class=SensorStateClass.MEASUREMENT,
822828
entity_category=EntityCategory.DIAGNOSTIC,
829+
entity_registry_enabled_default=False,
823830
value_fn=lambda usage: usage.free,
824831
),
825832
OpenWrtStorageSensorDescription(
@@ -828,6 +835,7 @@ async def async_setup_entry(
828835
native_unit_of_measurement=PERCENTAGE,
829836
state_class=SensorStateClass.MEASUREMENT,
830837
entity_category=EntityCategory.DIAGNOSTIC,
838+
entity_registry_enabled_default=False,
831839
value_fn=lambda usage: usage.percent,
832840
),
833841
]
@@ -1367,6 +1375,7 @@ def _create_sqm_sensors(
13671375
translation_key="sqm_interface",
13681376
name=f"SQM {name} Interface",
13691377
entity_category=EntityCategory.DIAGNOSTIC,
1378+
entity_registry_enabled_default=False,
13701379
value_fn=lambda data, sid=section_id: next(
13711380
(s.interface for s in data.sqm if s.section_id == sid), None
13721381
),
@@ -1384,6 +1393,7 @@ def _create_sqm_sensors(
13841393
translation_key="sqm_qdisc",
13851394
name=f"SQM {name} Qdisc",
13861395
entity_category=EntityCategory.DIAGNOSTIC,
1396+
entity_registry_enabled_default=False,
13871397
value_fn=lambda data, sid=section_id: next(
13881398
(s.qdisc for s in data.sqm if s.section_id == sid), None
13891399
),
@@ -1401,6 +1411,7 @@ def _create_sqm_sensors(
14011411
translation_key="sqm_script",
14021412
name=f"SQM {name} Script",
14031413
entity_category=EntityCategory.DIAGNOSTIC,
1414+
entity_registry_enabled_default=False,
14041415
value_fn=lambda data, sid=section_id: next(
14051416
(s.script for s in data.sqm if s.section_id == sid), None
14061417
),

0 commit comments

Comments
 (0)