Repository: mampfes/hacs_waste_collection_schedule

Issue:
Unique ID for entity/entities
Frankly, this is a minor / cosmetic structural issue, but its nice to have regarding the 2022.4 update, because it enables unique entites to be hidden (instead of on/off) - and it would be nice to have this on top of this already fantastic extension. 

**Context:** Setting up hacs_waste_collection_schedule creates an Entry in the default Dashboard (former Lovelace) called Calendar/Kalender with a single entry, in my case "AWB Köln". It shows only the on/off status. Its not showing the different countdowns till the pick-up dates for each type of trash.

**Expected Behaviour:** Upon Clicking the entry "AWB Köln" and further clicking "settings", I would be able to switch the entry to "hidden", thus making it invisible to default Dashboards.

**Current Behaviour:** Clicking "settings" reveals that the entity has no unique id and can't be set to hidden. 

**Tested solutions:** Manually adding a  "unique_id" the entry via configuration.yaml - throws an error and does not work. Either 
      unique_id: awbkoelnsource
      unique_id: calendar.awbkoelnsource
did not work.

Attached: Screenshots (in german) for explanation:
1:  Shown entry in dashboard (former lovelace)
2: Error when trying to access the entrys settings
3: Snippet of the configuration.yaml and the tried postiton for a unique_id

![Bildschirmfoto 2022-04-05 um 13 24 27](https://user-images.githubusercontent.com/2975047/161744234-55a693d5-5f58-4a48-9160-affd4f13823a.png)
![Bildschirmfoto 2022-04-05 um 13 24 37](https://user-images.githubusercontent.com/2975047/161744239-9ed44cb3-b997-4335-96db-9d15a7708568.png)
![Bildschirmfoto 2022-04-05 um 13 27 43](https://user-images.githubusercontent.com/2975047/161744245-9b9d3f3a-0f75-45ba-9caf-aac33681ef93.png)
 


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/calendar.py b/custom_components/waste_collection_schedule/calendar.py
--- a/custom_components/waste_collection_schedule/calendar.py
+++ b/custom_components/waste_collection_schedule/calendar.py
@@ -30,6 +30,7 @@ class WasteCollectionCalendar(CalendarEventDevice):
     def __init__(self, api, scraper):
         self._api = api
         self._scraper = scraper
+        self._attr_unique_id = scraper.unique_id + "_calendar"
 
     @property
     def name(self):
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py b/custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py
@@ -75,6 +75,7 @@ def __init__(
         description: str,
         url: Optional[str],
         calendar_title: Optional[str],
+        unique_id: str,
     ):
         self._source = source
         self._customize = customize
@@ -82,6 +83,7 @@ def __init__(
         self._description = description
         self._url = url
         self._calendar_title = calendar_title
+        self._unique_id = unique_id
         self._refreshtime = None
         self._entries: List[Collection] = []
 
@@ -109,6 +111,10 @@ def url(self):
     def calendar_title(self):
         return self._calendar_title or self._title
 
+    @property
+    def unique_id(self):
+        return self._unique_id
+
     def fetch(self):
         """Fetch data from source."""
         try:
@@ -238,6 +244,11 @@ def create(
             description=source_module.DESCRIPTION,  # type: ignore[attr-defined]
             url=source_module.URL,  # type: ignore[attr-defined]
             calendar_title=calendar_title,
+            unique_id=calc_unique_scraper_id(source_name, source_args),
         )
 
         return g
+
+
+def calc_unique_scraper_id(source_name, source_args):
+    return source_name + str(sorted(source_args.items()))


Test patch: