Skip to content

Commit

Permalink
Merge pull request #216 from Snuffy2/Remove-unused-get_interfaces
Browse files Browse the repository at this point in the history
Remove unused get_interfaces
  • Loading branch information
alexdelprete authored Sep 27, 2024
2 parents 745ea74 + 773aaa8 commit c75bc74
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
5 changes: 0 additions & 5 deletions custom_components/opnsense/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ async def _get_host_firmware_version(self) -> None | str:
async def _get_config(self):
return await self._client.get_config()

@_log_timing
async def _get_interfaces(self):
return await self._client.get_interfaces()

@_log_timing
async def _get_services(self):
return await self._client.get_services()
Expand Down Expand Up @@ -137,7 +133,6 @@ async def _async_update_data(self):
self._state["firmware_update_info"] = await self._get_firmware_update_info()
self._state["telemetry"] = await self._get_telemetry()
self._state["config"] = await self._get_config()
self._state["interfaces"] = await self._get_interfaces()
self._state["services"] = await self._get_services()
self._state["carp_interfaces"] = await self._get_carp_interfaces()
self._state["carp_status"] = await self._get_carp_status()
Expand Down
22 changes: 0 additions & 22 deletions custom_components/opnsense/pyopnsense/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,28 +463,6 @@ async def get_config(self) -> Mapping[str, Any]:
return {}
return response.get("data", {})

@_log_errors
async def get_interfaces(self) -> Mapping[str, Any]:
return await self._get_config_section("interfaces")

@_log_errors
async def get_interface(self, interface) -> Mapping[str, Any]:
interfaces: Mapping[str, Any] = await self.get_interfaces()
return interfaces.get(interface, {})

@_log_errors
async def get_interface_by_description(self, interface):
interfaces: Mapping[str, Any] = await self.get_interfaces()
for i, i_interface in enumerate(interfaces.keys()):
if "descr" not in interfaces[i_interface]:
continue

if interfaces[i_interface]["descr"] is None:
continue

if interfaces[i_interface]["descr"] == interface:
return interfaces[i_interface]

@_log_errors
async def enable_filter_rule_by_created_time(self, created_time) -> None:
config = await self.get_config()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/opnsense/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def process_entities_callback(hass, config_entry):
coordinator,
SensorEntityDescription(
key=f"telemetry.interface.{interface_name}.{prop_name}",
name=f"Interface {interface_name} {prop_name}",
name=f"Interface {interface.get('name', interface_name)} {prop_name}",
native_unit_of_measurement=native_unit_of_measurement,
icon=icon,
state_class=state_class,
Expand Down

0 comments on commit c75bc74

Please sign in to comment.