diff --git a/custom_components/opnsense/device_tracker.py b/custom_components/opnsense/device_tracker.py index 9fc7242..1b58e00 100644 --- a/custom_components/opnsense/device_tracker.py +++ b/custom_components/opnsense/device_tracker.py @@ -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: diff --git a/custom_components/opnsense/pyopnsense/__init__.py b/custom_components/opnsense/pyopnsense/__init__.py index 3fa31ca..3ec7bed 100644 --- a/custom_components/opnsense/pyopnsense/__init__.py +++ b/custom_components/opnsense/pyopnsense/__init__.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/custom_components/opnsense/services.py b/custom_components/opnsense/services.py index 6f525cd..75c4be5 100644 --- a/custom_components/opnsense/services.py +++ b/custom_components/opnsense/services.py @@ -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, @@ -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 [] @@ -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: @@ -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')}" @@ -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( @@ -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( @@ -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: @@ -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() @@ -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() @@ -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')}" diff --git a/custom_components/opnsense/switch.py b/custom_components/opnsense/switch.py index 86b90ea..c9b14d6 100644 --- a/custom_components/opnsense/switch.py +++ b/custom_components/opnsense/switch.py @@ -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(".") @@ -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] @@ -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]