From faeb98c8e9b642901c4929b18ab77d20a14e508e Mon Sep 17 00:00:00 2001 From: Bram van Dartel Date: Tue, 2 Nov 2021 17:05:02 +0100 Subject: [PATCH] Update sensor_custom.py --- custom_components/afvalwijzer/sensor_custom.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/custom_components/afvalwijzer/sensor_custom.py b/custom_components/afvalwijzer/sensor_custom.py index e5904e1..181e919 100755 --- a/custom_components/afvalwijzer/sensor_custom.py +++ b/custom_components/afvalwijzer/sensor_custom.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import hashlib from datetime import datetime from homeassistant.helpers.entity import Entity @@ -10,6 +11,10 @@ ATTR_YEAR_MONTH_DAY_DATE, CONF_DEFAULT_LABEL, CONF_ID, + CONF_INCLUDE_DATE_TODAY, + CONF_POSTAL_CODE, + CONF_STREET_NUMBER, + CONF_SUFFIX, MIN_TIME_BETWEEN_UPDATES, PARALLEL_UPDATES, SENSOR_ICON, @@ -36,11 +41,20 @@ def __init__(self, hass, waste_type, fetch_afvalwijzer_data, config): self._state = self.config.get(CONF_DEFAULT_LABEL) self._icon = SENSOR_ICON self._year_month_day_date = None + self._unique_id = hashlib.sha1( + f"{self.waste_type}{self.config.get(CONF_ID)}{self.config.get(CONF_POSTAL_CODE)}{self.config.get(CONF_STREET_NUMBER)}{self.config.get(CONF_SUFFIX,'')}".encode( + "utf-8" + ) + ).hexdigest() @property def name(self): return self._name + @property + def unique_id(self): + return self._unique_id + @property def icon(self): return self._icon