Skip to content

Commit

Permalink
Merge pull request #247 from Snuffy2/Turn-down-more-debug-logging
Browse files Browse the repository at this point in the history
Turn down more debug logging
  • Loading branch information
Snuffy2 authored Oct 10, 2024
2 parents e63bfb8 + d34ebe4 commit 32bc90a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 33 deletions.
18 changes: 9 additions & 9 deletions custom_components/opnsense/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ def _handle_coordinator_update(self) -> None:
self._attr_icon = "mdi:lan-disconnect"

self.async_write_ha_state()
_LOGGER.debug(
f"[OPNsenseScannerEntity handle_coordinator_update] Name: {self.name}, "
f"unique_id: {self.unique_id}, attr_unique_id: {self._attr_unique_id}, "
f"available: {self.available}, is_connected: {self.is_connected}, "
f"hostname: {self.hostname}, ip_address: {self.ip_address}, "
f"last_known_hostname: {self._last_known_hostname}, last_known_ip: {self._last_known_ip}, "
f"last_known_connected_time: {self._last_known_connected_time}, icon: {self.icon}, "
f"extra_state_atrributes: {self.extra_state_attributes}"
)
# _LOGGER.debug(
# f"[OPNsenseScannerEntity handle_coordinator_update] Name: {self.name}, "
# f"unique_id: {self.unique_id}, attr_unique_id: {self._attr_unique_id}, "
# f"available: {self.available}, is_connected: {self.is_connected}, "
# f"hostname: {self.hostname}, ip_address: {self.ip_address}, "
# f"last_known_hostname: {self._last_known_hostname}, last_known_ip: {self._last_known_ip}, "
# f"last_known_connected_time: {self._last_known_connected_time}, icon: {self.icon}, "
# f"extra_state_atrributes: {self.extra_state_attributes}"
# )

@property
def device_info(self) -> DeviceInfo:
Expand Down
8 changes: 4 additions & 4 deletions custom_components/opnsense/pyopnsense/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ async def get_arp_table(self, resolve_hostnames=False) -> Mapping[str, Any]:
return []
# _LOGGER.debug(f"[get_arp_table] arp_table_info: {arp_table_info}")
arp_table: list = arp_table_info.get("rows", [])
_LOGGER.debug(f"[get_arp_table] arp_table: {arp_table}")
# _LOGGER.debug(f"[get_arp_table] arp_table: {arp_table}")
return arp_table

@_log_errors
Expand All @@ -631,7 +631,7 @@ async def get_services(self) -> list:
services: list = response.get("rows", [])
for service in services:
service["status"] = service.get("running", 0) == 1
_LOGGER.debug(f"[get_services] services: {services}")
# _LOGGER.debug(f"[get_services] services: {services}")
return services

@_log_errors
Expand Down Expand Up @@ -713,7 +713,7 @@ async def get_dhcp_leases(self) -> list:
"lease_interfaces": sorted_lease_interfaces,
"leases": sorted_leases,
}
_LOGGER.debug(f"[get_dhcp_leases] dhcp_leases: {dhcp_leases}")
# _LOGGER.debug(f"[get_dhcp_leases] dhcp_leases: {dhcp_leases}")

return dhcp_leases

Expand Down Expand Up @@ -1119,7 +1119,7 @@ async def get_telemetry(self) -> Mapping[str, Any]:
telemetry["openvpn"] = await self._get_telemetry_openvpn()
telemetry["gateways"] = await self._get_telemetry_gateways()
telemetry["temps"] = await self._get_telemetry_temps()
_LOGGER.debug(f"[get_telemetry] telemetry: {telemetry}")
# _LOGGER.debug(f"[get_telemetry] telemetry: {telemetry}")
return telemetry

@_log_errors
Expand Down
16 changes: 5 additions & 11 deletions custom_components/opnsense/services.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from collections.abc import Mapping
import logging
from collections.abc import Mapping

import voluptuous as vol
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers import (
config_validation as cv,
)
from homeassistant.helpers import (
device_registry,
entity_registry,
)
import voluptuous as vol

from .const import (
DOMAIN,
Expand Down Expand Up @@ -38,7 +40,7 @@ async def _get_clients(
first_entry_id = next(iter(hass.data[DOMAIN]))
if len(hass.data[DOMAIN]) == 1:
if OPNSENSE_CLIENT in hass.data[DOMAIN][first_entry_id]:
_LOGGER.debug(f"[get_clients] Only 1 entry. entry_id: {first_entry_id}")
# _LOGGER.debug(f"[get_clients] Only 1 entry. entry_id: {first_entry_id}")
return [hass.data[DOMAIN][first_entry_id][OPNSENSE_CLIENT]]
return []

Expand Down Expand Up @@ -68,7 +70,6 @@ async def _get_clients(
clients: list = []
# _LOGGER.debug(f"[get_clients] entry_ids: {entry_ids}")
for entry_id, entry in hass.data[DOMAIN].items():
# _LOGGER.debug(f"[get_clients] entry_id: {entry_id}")
if (
len(entry_ids) == 0 or entry_id in entry_ids
) and OPNSENSE_CLIENT in entry:
Expand All @@ -80,7 +81,6 @@ async def service_close_notice(call: ServiceCall) -> None:
clients: list = await _get_clients(
call.data.get("device_id", []), call.data.get("entity_id", [])
)
# _LOGGER.debug(f"[service_close_notice] clients: {clients}")
for client in clients:
_LOGGER.debug(
f"[service_close_notice] Calling stop_service for {call.data.get('id')}"
Expand All @@ -91,7 +91,6 @@ async def service_start_service(call: ServiceCall) -> None:
clients: list = await _get_clients(
call.data.get("device_id", []), call.data.get("entity_id", [])
)
# _LOGGER.debug(f"[service_start_service] clients: {clients}")
success = None
for client in clients:
_LOGGER.debug(
Expand All @@ -111,7 +110,6 @@ async def service_stop_service(call: ServiceCall) -> None:
clients: list = await _get_clients(
call.data.get("device_id", []), call.data.get("entity_id", [])
)
# _LOGGER.debug(f"[service_stop_service] clients: {clients}")
success = None
for client in clients:
_LOGGER.debug(
Expand All @@ -131,7 +129,6 @@ async def service_restart_service(call: ServiceCall) -> None:
clients: list = await _get_clients(
call.data.get("device_id", []), call.data.get("entity_id", [])
)
# _LOGGER.debug(f"[service_restart_service] clients: {clients}")
success = None
if call.data.get("only_if_running"):
for client in clients:
Expand Down Expand Up @@ -168,7 +165,6 @@ async def service_system_halt(call: ServiceCall) -> None:
clients: list = await _get_clients(
call.data.get("device_id", []), call.data.get("entity_id", [])
)
# _LOGGER.debug(f"[service_system_halt] clients: {clients}")
for client in clients:
_LOGGER.debug("[service_system_halt] Calling System Halt")
await client.system_halt()
Expand All @@ -177,7 +173,6 @@ async def service_system_reboot(call: ServiceCall) -> None:
clients: list = await _get_clients(
call.data.get("device_id", []), call.data.get("entity_id", [])
)
# _LOGGER.debug(f"[service_system_reboot] clients: {clients}")
for client in clients:
_LOGGER.debug("[service_system_reboot] Calling System Reboot")
await client.system_reboot()
Expand All @@ -186,7 +181,6 @@ async def service_send_wol(call: ServiceCall) -> None:
clients: list = await _get_clients(
call.data.get("device_id", []), call.data.get("entity_id", [])
)
# _LOGGER.debug(f"[service_send_wol] clients: {clients}")
for client in clients:
_LOGGER.debug(
f"[service_send_wol] Calling WOL. interface: {call.data.get('interface')}, mac: {call.data.get('mac')}"
Expand Down
12 changes: 3 additions & 9 deletions custom_components/opnsense/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ def __init__(
)
self._tracker: str = self._opnsense_get_tracker()
self._rule: Mapping[str, Any] | None = None
_LOGGER.debug(
f"[OPNsenseFilterSwitch init] Name: {self.name}, tracker: {self._tracker}"
)
# _LOGGER.debug(f"[OPNsenseFilterSwitch init] Name: {self.name}, tracker: {self._tracker}")

def _opnsense_get_tracker(self) -> str:
parts = self.entity_description.key.split(".")
Expand Down Expand Up @@ -356,9 +354,7 @@ def __init__(
self._rule_type: str = self._opnsense_get_rule_type()
self._tracker: str = self._opnsense_get_tracker()
self._rule: Mapping[str, Any] | None = None
_LOGGER.debug(
f"[OPNsenseNatSwitch init] Name: {self.name}, tracker: {self._tracker}, rule_type: {self._rule_type}"
)
# _LOGGER.debug(f"[OPNsenseNatSwitch init] Name: {self.name}, tracker: {self._tracker}, rule_type: {self._rule_type}")

def _opnsense_get_rule_type(self) -> str:
return self.entity_description.key.split(".")[0]
Expand Down Expand Up @@ -444,9 +440,7 @@ def __init__(
)
self._service: Mapping[str, Any] | None = None
self._prop_name: str = self._opnsense_get_property_name()
_LOGGER.debug(
f"[OPNsenseServiceSwitch init] Name: {self.name}, prop_name: {self._prop_name}"
)
# _LOGGER.debug(f"[OPNsenseServiceSwitch init] Name: {self.name}, prop_name: {self._prop_name}")

def _opnsense_get_property_name(self) -> str:
return self.entity_description.key.split(".")[2]
Expand Down

0 comments on commit 32bc90a

Please sign in to comment.