Skip to content

Commit ab86deb

Browse files
authored
Merge pull request #284 from nanomad/develop
#283: Publish HA discovery once per car
2 parents 86613d1 + 26f900d commit ab86deb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

integrations/home_assistant/discovery.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,22 @@ def __init__(self, vehicle_state: VehicleState, vin_info: VinInfo, configuration
9494
self.__vehicle_availability
9595
]
9696
)
97+
self.published = False
9798

9899
def publish_ha_discovery_messages(self):
100+
if self.published:
101+
LOG.debug("Skipping Home Assistant discovery messages as it was already published")
102+
return
103+
99104
if not self.__vehicle_state.is_complete():
100105
LOG.debug("Skipping Home Assistant discovery messages as vehicle state is not yet complete")
101106
return
102107

108+
self.__publish_ha_discovery_messages_real()
109+
self.published = True
110+
111+
def __publish_ha_discovery_messages_real(self):
112+
103113
LOG.debug("Publishing Home Assistant discovery messages")
104114

105115
# Gateway Control

0 commit comments

Comments
 (0)