From bc2e53e8115eede6bef3e63517904a24719302cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Kry=C5=84ski?= Date: Sun, 15 Jan 2023 00:47:31 +0100 Subject: [PATCH] compute hash also on status & region, closes #28 --- custom_components/blitzortung/geo_location.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/blitzortung/geo_location.py b/custom_components/blitzortung/geo_location.py index ee24873..2e46373 100644 --- a/custom_components/blitzortung/geo_location.py +++ b/custom_components/blitzortung/geo_location.py @@ -110,6 +110,8 @@ def lightning_cb(self, lightning): lightning["lon"], "km", lightning["time"], + lightning["status"], + lightning["region"], ) to_delete = self._strikes.insort(event) self._async_add_entities([event]) @@ -135,15 +137,17 @@ def tick(self): class BlitzortungEvent(GeolocationEvent): """Define a lightning strike event.""" - def __init__(self, distance, latitude, longitude, unit, time): + def __init__(self, distance, latitude, longitude, unit, time, status, region): """Initialize entity with data provided.""" self._distance = distance self._latitude = latitude self._longitude = longitude self._time = time + self._status = status + self._region = region self._publication_date = time / 1e9 self._remove_signal_delete = None - self._strike_id = hashlib.sha1(f"{latitude}_{longitude}_{time}".encode()).hexdigest() + self._strike_id = hashlib.sha1(f"{latitude}_{longitude}_{time}_{status}_{region}".encode()).hexdigest() self._unit_of_measurement = unit self.entity_id = "geo_location.lightning_strike_{0}".format(self._strike_id)