From 18ce40b6bb5306a996a40954b8d915c5075d4e5c Mon Sep 17 00:00:00 2001 From: Teemu R Date: Wed, 17 May 2023 20:08:05 +0200 Subject: [PATCH] Add inactivity setting for the motion module (#453) * Add inactivity setting for the motion module * Fix set_cold_time payload Co-authored-by: Matt Whitlock * Add mention about "smart control" --------- Co-authored-by: Matt Whitlock --- kasa/modules/motion.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kasa/modules/motion.py b/kasa/modules/motion.py index 45e272be..71d1a617 100644 --- a/kasa/modules/motion.py +++ b/kasa/modules/motion.py @@ -59,3 +59,16 @@ class Motion(Module): ) return await self.call("set_trigger_sens", payload) + + @property + def inactivity_timeout(self) -> int: + """Return inactivity timeout in milliseconds.""" + return self.data["cold_time"] + + async def set_inactivity_timeout(self, timeout: int): + """Set inactivity timeout in milliseconds. + + Note, that you need to delete the default "Smart Control" rule in the app + to avoid reverting this back to 60 seconds after a period of time. + """ + return await self.call("set_cold_time", {"cold_time": timeout})