소스 검색

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