Skip to content

Commit ec81d2b

Browse files
authored
Merge pull request #174 from nickknissen/bug/handle-no-wallet-transactions
fix(sensor): handle empty transactions in native_value property
2 parents dd1803c + a47672c commit ec81d2b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

custom_components/monta/sensor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,11 @@ def __init__(
342342
@property
343343
def native_value(self) -> StateType:
344344
"""Return the state."""
345+
transactions = self.coordinator.data.get(ATTR_TRANSACTIONS, [])
346+
if not transactions:
347+
return None
345348
return self.entity_description.value_fn(
346-
self.coordinator.data[ATTR_TRANSACTIONS][0]["state"]
349+
transactions[0]["state"]
347350
)
348351

349352
@property

0 commit comments

Comments
 (0)