Explorar o código

Use display-friendly sync mode values (CalDAV, API, Manual)

These values are shown directly to users in HA, so casing matters.
Also fixes sensor.py which was comparing against hardcoded lowercase
literals instead of the constants.

Note: existing config entries storing old lowercase values will need
to be reconfigured.
ZiB hai 4 meses
pai
achega
8824fddaba

+ 3 - 3
custom_components/room_cal_ha/const.py

@@ -19,9 +19,9 @@ CONF_RESERVATION_DEFAULTS = "reservation_defaults"
 CONF_API_TOKEN = "api_token"
 CONF_API_TOKEN = "api_token"
 
 
 # Sync mode values
 # Sync mode values
-SYNC_MODE_CALDAV = "caldav"
-SYNC_MODE_API = "api"
-SYNC_MODE_MANUAL = "manual"
+SYNC_MODE_CALDAV = "CalDAV"
+SYNC_MODE_API = "API"
+SYNC_MODE_MANUAL = "Manual"
 
 
 # iCal event selection and data extraction
 # iCal event selection and data extraction
 RESERVATION_TITLE_PREFIX = "Guest: "
 RESERVATION_TITLE_PREFIX = "Guest: "

+ 2 - 2
custom_components/room_cal_ha/sensor.py

@@ -87,9 +87,9 @@ class SyncSourceSensor(SensorEntity):
   @property
   @property
   def extra_state_attributes(self) -> dict[str, str | None]:
   def extra_state_attributes(self) -> dict[str, str | None]:
     mode = self._entry.options.get(CONF_SYNC_MODE, SYNC_MODE_MANUAL)
     mode = self._entry.options.get(CONF_SYNC_MODE, SYNC_MODE_MANUAL)
-    if mode == "caldav":
+    if mode == SYNC_MODE_CALDAV:
       url = self._entry.options.get(CONF_CALDAV_URL)
       url = self._entry.options.get(CONF_CALDAV_URL)
-    elif mode == "api":
+    elif mode == SYNC_MODE_API:
       url = self._entry.options.get(CONF_API_BASE_URL)
       url = self._entry.options.get(CONF_API_BASE_URL)
     else:
     else:
       url = None
       url = None