Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit a2b7455

Browse files
committed
Fix max_price related None issues
1 parent eac87e3 commit a2b7455

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

custom_components/ohme/api_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,10 @@ async def async_apply_session_rule(self, max_price=None, target_time=None, targe
200200
"""Apply rule to ongoing charge/stop max charge."""
201201
# Check every property. If we've provided it, use that. If not, use the existing.
202202
if max_price is None:
203-
max_price = self._last_rule['settings'][0]['enabled'] if 'settings' in self._last_rule and len(
204-
self._last_rule['settings']) > 1 else False
203+
if 'settings' in self._last_rule and self._last_rule['settings'] is not None and len(self._last_rule['settings']) > 1:
204+
max_price = self._last_rule['settings'][0]['enabled']
205+
else:
206+
max_price = False
205207

206208
if target_percent is None:
207209
target_percent = self._last_rule['targetPercent'] if 'targetPercent' in self._last_rule else 80

custom_components/ohme/number.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ def icon(self):
252252
def _handle_coordinator_update(self) -> None:
253253
"""Get value from data returned from API by coordinator"""
254254
if self.coordinator.data is not None:
255-
self._state = self.coordinator.data["userSettings"]["chargeSettings"][0]["value"]
255+
try:
256+
self._state = self.coordinator.data["userSettings"]["chargeSettings"][0]["value"]
257+
except:
258+
self._state = None
256259
self.async_write_ha_state()
257260

258261
@property

0 commit comments

Comments
 (0)