瀏覽代碼

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 4 月之前
父節點
當前提交
8824fddaba
共有 2 個文件被更改,包括 5 次插入 和 5 次删除
  1. 3 3
      custom_components/room_cal_ha/const.py
  2. 2 2
      custom_components/room_cal_ha/sensor.py

+ 3 - 3
custom_components/room_cal_ha/const.py

@@ -19,9 +19,9 @@ CONF_RESERVATION_DEFAULTS = "reservation_defaults"
 CONF_API_TOKEN = "api_token"
 
 # 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
 RESERVATION_TITLE_PREFIX = "Guest: "

+ 2 - 2
custom_components/room_cal_ha/sensor.py

@@ -87,9 +87,9 @@ class SyncSourceSensor(SensorEntity):
   @property
   def extra_state_attributes(self) -> dict[str, str | None]:
     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)
-    elif mode == "api":
+    elif mode == SYNC_MODE_API:
       url = self._entry.options.get(CONF_API_BASE_URL)
     else:
       url = None