From 623fb5294e8a861cffe58f349128274e41a7976f Mon Sep 17 00:00:00 2001 From: Alexander Terry Date: Sat, 8 Jun 2024 15:38:37 -0800 Subject: [PATCH] cache stupid --- alexBot/cogs/smartHome.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/alexBot/cogs/smartHome.py b/alexBot/cogs/smartHome.py index 6230f63..1eb84e5 100644 --- a/alexBot/cogs/smartHome.py +++ b/alexBot/cogs/smartHome.py @@ -271,8 +271,9 @@ async def on_presence_update(self, before: discord.Member, after: discord.Member if before.status != after.status: mqtt: HomeAssistantIntigreation = self.bot.get_cog("HomeAssistantIntigreation") # type: ignore blob = {"status": after.status.value, "mobile": after.is_on_mobile()} - self.status_cache[after.id] = blob - if self.status_cache[before.id] != blob: + + if self.status_cache.get(after.id) != blob: + self.status_cache[after.id] = blob await mqtt.mqttPublish(f"discord/{after.id}/status", json.dumps(blob))