Skip to content

Commit 63885b6

Browse files
authored
Merge pull request #415 from jwillemsen/jwi-depwarning
Handle possible missing dictionary item
2 parents 28af511 + 577fe51 commit 63885b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

custom_components/daikin_onecta/select.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_current_option(self):
7979
if self._embedded_id == management_point["embeddedId"]:
8080
management_point_type = management_point["managementPointType"]
8181
if self._management_point_type == management_point_type:
82-
scheduledict = management_point[self._value]
82+
scheduledict = management_point.get(self._value)
8383
if scheduledict is not None:
8484
currentMode = scheduledict["value"]["currentMode"]["value"]
8585
# When there is no schedule enabled we return none
@@ -100,7 +100,7 @@ async def async_select_option(self, option: str) -> None:
100100
if self._embedded_id == management_point["embeddedId"]:
101101
management_point_type = management_point["managementPointType"]
102102
if self._management_point_type == management_point_type:
103-
scheduledict = management_point[self._value]
103+
scheduledict = management_point.get(self._value)
104104
if scheduledict is not None:
105105
currentMode = scheduledict["value"]["currentMode"]["value"]
106106
# Look for a schedule with the user selected readable name, when we find it, we use the schedule id
@@ -138,7 +138,7 @@ def get_options(self):
138138
if self._embedded_id == management_point["embeddedId"]:
139139
management_point_type = management_point["managementPointType"]
140140
if self._management_point_type == management_point_type:
141-
scheduledict = management_point[self._value]
141+
scheduledict = management_point.get(self._value)
142142
if scheduledict is not None:
143143
currentMode = scheduledict["value"]["currentMode"]["value"]
144144
for scheduleName in scheduledict["value"]["modes"][currentMode]["currentSchedule"]["values"]:

0 commit comments

Comments
 (0)