From 26f900d14085850378040ebf3d1303cc26135656 Mon Sep 17 00:00:00 2001 From: Giovanni Condello Date: Sun, 15 Dec 2024 22:04:27 +0100 Subject: [PATCH] #283: Publish HA discovery once per car --- integrations/home_assistant/discovery.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/integrations/home_assistant/discovery.py b/integrations/home_assistant/discovery.py index 8ba28c3..17be8cb 100644 --- a/integrations/home_assistant/discovery.py +++ b/integrations/home_assistant/discovery.py @@ -94,12 +94,22 @@ def __init__(self, vehicle_state: VehicleState, vin_info: VinInfo, configuration self.__vehicle_availability ] ) + self.published = False def publish_ha_discovery_messages(self): + if self.published: + LOG.debug("Skipping Home Assistant discovery messages as it was already published") + return + if not self.__vehicle_state.is_complete(): LOG.debug("Skipping Home Assistant discovery messages as vehicle state is not yet complete") return + self.__publish_ha_discovery_messages_real() + self.published = True + + def __publish_ha_discovery_messages_real(self): + LOG.debug("Publishing Home Assistant discovery messages") # Gateway Control