Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Sensor Default Tweaks #273

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Additional Sensor Default Tweaks
  • Loading branch information
Snuffy2 committed Oct 20, 2024
commit 60837cc6ab0a9436053d5d4541c8856ec5b36873
10 changes: 5 additions & 5 deletions custom_components/opnsense/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
device_class=None,
icon="mdi:table-network",
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=True,
entity_registry_enabled_default=False,
# entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
# mbuf
Expand Down Expand Up @@ -122,7 +122,7 @@
device_class=None,
icon=ICON_MEMORY,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=True,
entity_registry_enabled_default=False,
# entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
# memory with state_class due to being less static
Expand All @@ -147,7 +147,7 @@
icon=ICON_MEMORY,
state_class=None,
suggested_display_precision=1,
suggested_unit_of_measurement=UnitOfInformation.MEGABYTES,
suggested_unit_of_measurement=UnitOfInformation.GIGABYTES,
entity_registry_enabled_default=False,
# entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
Expand All @@ -159,7 +159,7 @@
icon=ICON_MEMORY,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
suggested_unit_of_measurement=UnitOfInformation.MEGABYTES,
suggested_unit_of_measurement=UnitOfInformation.GIGABYTES,
entity_registry_enabled_default=False,
# entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
Expand All @@ -183,7 +183,7 @@
device_class=None,
icon=ICON_MEMORY,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=True,
entity_registry_enabled_default=False,
# entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
"telemetry.memory.used_percent": SensorEntityDescription(
Expand Down
8 changes: 4 additions & 4 deletions custom_components/opnsense/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ async def _compile_interface_sensors(
"status",
"inbytes_kilobytes_per_second",
"outbytes_kilobytes_per_second",
"inpkts_packets_per_second",
"outpkts_packets_per_second",
]:
enabled_default = True

Expand All @@ -192,7 +190,7 @@ async def _compile_interface_sensors(
device_class = SensorDeviceClass.DATA_SIZE
state_class = SensorStateClass.TOTAL_INCREASING
suggested_display_precision = 1
suggested_unit_of_measurement = UnitOfInformation.MEGABYTES
suggested_unit_of_measurement = UnitOfInformation.GIGABYTES
if "pkts" in prop_name:
native_unit_of_measurement = DATA_PACKETS
state_class = SensorStateClass.TOTAL_INCREASING
Expand Down Expand Up @@ -244,6 +242,7 @@ async def _compile_gateway_sensors(
native_unit_of_measurement = None
device_class = None
state_class = SensorStateClass.MEASUREMENT
enabled_default = False
icon = "mdi:router-network"

if prop_name == "loss":
Expand All @@ -256,6 +255,7 @@ async def _compile_gateway_sensors(
if prop_name == "status":
icon = "mdi:check-network"
state_class = None
enabled_default = True

entity = OPNsenseGatewaySensor(
config_entry=config_entry,
Expand All @@ -267,7 +267,7 @@ async def _compile_gateway_sensors(
device_class=device_class,
icon=icon,
state_class=state_class,
entity_registry_enabled_default=True,
entity_registry_enabled_default=enabled_default,
# entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
)
Expand Down
Loading