From b74feed77175fdeed3a485c1732e7b6502697103 Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Sun, 17 Sep 2023 18:04:35 +0200 Subject: [PATCH] Handle calibration times --- bot.py | 29 ++++++++++++++++++++--------- commands.txt | 12 ++++++------ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/bot.py b/bot.py index 9207d26..4d00b41 100644 --- a/bot.py +++ b/bot.py @@ -214,22 +214,33 @@ class Bot: ) return self.tapo.setPreset(presets[self.profile_name]) - self.tapo.setPrivacyMode(privacy_mode) - await self.bot.send_message( + message = await self.bot.send_message( chat_id=msg.chat_id, - text=f"Repositioned to profile '{self.profile_name}'", + text=f"Repositioning to profile '{self.profile_name}'...", + ) + await asyncio.sleep(5) + self.tapo.setPrivacyMode(privacy_mode) + await self.bot.edit_message_text( + chat_id=msg.chat_id, + message_id=message.message_id, + text=f"Repositioning complete", ) case "/calibrate": privacy_mode = self.tapo.getPrivacyMode() + self.tapo.setPrivacyMode(False) + await asyncio.sleep(0.3) self.tapo.calibrateMotor() - presets = self._get_presets() - if self.profile_name in presets: - self.tapo.setPreset(presets[self.profile_name]) - self.tapo.setPrivacyMode(privacy_mode) - await self.bot.send_message( + message = await self.bot.send_message( chat_id=msg.chat_id, - text=f"Calibrated and repositioned to profile '{self.profile_name}'", + text=f"Calibrating, this will take ~25s...", ) + await asyncio.sleep(26) + await self.bot.edit_message_text( + chat_id=msg.chat_id, + message_id=message.message_id, + text=f"Calibration complete", + ) + self.tapo.setPrivacyMode(privacy_mode) case "/light_on": await self._send_item_command("ON") await self.bot.send_message( diff --git a/commands.txt b/commands.txt index 72baa4a..96353d0 100644 --- a/commands.txt +++ b/commands.txt @@ -1,10 +1,10 @@ photo - Take a photo of the grocery list board -calibrate - Calibrate the camera motor and re-aim -reposition - Re-aim the camera -light_on - Turn on the light -light_off - Turn off the light -light_status - Check the status of the light photo_unprocessed - Take a photo of the grocery list board without processing +calibrate - Calibrate the camera motor +reposition - Re-aim the camera privacy_on - Turn on privacy mode privacy_off - Turn off privacy mode -privacy_status - Check the status of privacy mode \ No newline at end of file +privacy_status - Check the status of privacy mode +light_on - Turn on the light +light_off - Turn off the light +light_status - Check the status of the light \ No newline at end of file