Skip to content

Commit

Permalink
compute hash also on status & region, closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz Kryński committed Jan 14, 2023
1 parent 45ed1a2 commit bc2e53e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/blitzortung/geo_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)

Expand Down

0 comments on commit bc2e53e

Please sign in to comment.