Browse Source

Add info logging throughout check-in/check-out action sequence

ZiB 4 months ago
parent
commit
3a80d909c5
1 changed files with 16 additions and 7 deletions
  1. 16 7
      custom_components/room_cal_ha/coordinator.py

+ 16 - 7
custom_components/room_cal_ha/coordinator.py

@@ -205,37 +205,47 @@ class RoomCalCoordinator(DataUpdateCoordinator[CoordinatorData]):
       await self._room_state_switch.async_turn_off()
 
   async def _async_run_check_in_actions(self, res: ReservationData) -> None:
-    """Run WiFi + Z-Wave updates and guest mode activation. No-op when mode_sync is off."""
+    """Run WiFi + lock updates and guest mode activation. No-op when mode_sync is off."""
     if not self._is_mode_sync_on():
       return
+    _LOGGER.info("Check-in: guest=%s", res.guest_name)
     if self._is_use_unifi_on() and isinstance(res.wifi_ssid, str):
       from .wifi import async_set_ssid_enabled, async_set_wifi_key
       try:
+        _LOGGER.info("WiFi on: enabling SSID '%s'", res.wifi_ssid)
         await async_set_ssid_enabled(self.hass, res.wifi_ssid, True)
+        _LOGGER.info("WiFi on: SSID '%s' enabled", res.wifi_ssid)
       except Exception as err:
         _LOGGER.warning("Failed to enable SSID '%s': %s", res.wifi_ssid, err)
       if isinstance(res.wifi_key, str):
         try:
+          _LOGGER.info("WiFi on: setting key for SSID '%s'", res.wifi_ssid)
           await async_set_wifi_key(self.hass, res.wifi_ssid, res.wifi_key)
+          _LOGGER.info("WiFi on: key set for SSID '%s'", res.wifi_ssid)
         except Exception as err:
           _LOGGER.warning("Failed to set WiFi key: %s", err)
     if self._is_use_zwave_on() and isinstance(res.door_code, str):
       await self._async_push_lock_codes(res.door_code)
     await self._async_set_room_state(True)
+    _LOGGER.info("Check-in complete: guest=%s", res.guest_name)
 
   async def _async_run_check_out_actions(self, res: ReservationData) -> None:
-    """Run WiFi SSID disable, Z-Wave code clear, and guest mode deactivation. No-op when mode_sync is off."""
+    """Run WiFi SSID disable, lock slot disable, and guest mode deactivation. No-op when mode_sync is off."""
     if not self._is_mode_sync_on():
       return
+    _LOGGER.info("Check-out: guest=%s", res.guest_name)
     if self._is_use_unifi_on() and isinstance(res.wifi_ssid, str):
       from .wifi import async_set_ssid_enabled
       try:
+        _LOGGER.info("WiFi off: disabling SSID '%s'", res.wifi_ssid)
         await async_set_ssid_enabled(self.hass, res.wifi_ssid, False)
+        _LOGGER.info("WiFi off: SSID '%s' disabled", res.wifi_ssid)
       except Exception as err:
         _LOGGER.warning("Failed to disable SSID '%s': %s", res.wifi_ssid, err)
     if self._is_use_zwave_on():
       await self._async_clear_lock_codes()
     await self._async_set_room_state(False)
+    _LOGGER.info("Check-out complete: guest=%s", res.guest_name)
 
   def _zlock_entity_ids(self) -> list[str]:
     """Return all lock entity IDs from the configured zlock_slots entries."""
@@ -249,42 +259,41 @@ class RoomCalCoordinator(DataUpdateCoordinator[CoordinatorData]):
   async def _async_push_lock_codes(self, code: str) -> None:
     slot = self.entry.options.get(CONF_ZWAVE_SLOT)
     lock_entity_ids = self._zlock_entity_ids()
-    _LOGGER.debug("push_lock_codes: slot=%s locks=%s", slot, lock_entity_ids)
+    _LOGGER.info("Lock enable: slot=%s locks=%s", slot, lock_entity_ids)
     if not lock_entity_ids or slot is None:
       return
     slot = int(slot)
     for entity_id in lock_entity_ids:
       try:
-        _LOGGER.debug("zlock set_code: %s slot %s", entity_id, slot)
         await self.hass.services.async_call(
           "zlock_slots", "set_code",
           {"lock_entity_id": entity_id, "slot": slot, "code": code},
           blocking=True,
         )
-        _LOGGER.debug("zlock set_slot_enabled True: %s slot %s", entity_id, slot)
         await self.hass.services.async_call(
           "zlock_slots", "set_slot_enabled",
           {"lock_entity_id": entity_id, "slot": slot, "enabled": True},
           blocking=True,
         )
+        _LOGGER.info("Lock enabled: %s slot %s", entity_id, slot)
       except Exception as err:
         _LOGGER.warning("Failed to set lock code on '%s': %s", entity_id, err)
 
   async def _async_clear_lock_codes(self) -> None:
     slot = self.entry.options.get(CONF_ZWAVE_SLOT)
     lock_entity_ids = self._zlock_entity_ids()
-    _LOGGER.debug("clear_lock_codes: slot=%s locks=%s", slot, lock_entity_ids)
+    _LOGGER.info("Lock disable: slot=%s locks=%s", slot, lock_entity_ids)
     if not lock_entity_ids or slot is None:
       return
     slot = int(slot)
     for entity_id in lock_entity_ids:
       try:
-        _LOGGER.debug("zlock set_slot_enabled False: %s slot %s", entity_id, slot)
         await self.hass.services.async_call(
           "zlock_slots", "set_slot_enabled",
           {"lock_entity_id": entity_id, "slot": slot, "enabled": False},
           blocking=True,
         )
+        _LOGGER.info("Lock disabled: %s slot %s", entity_id, slot)
       except Exception as err:
         _LOGGER.warning("Failed to disable lock slot on '%s': %s", entity_id, err)