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