Skip to content

Commit 1ddf19d

Browse files
committed
catch None old_state
1 parent 54b1e89 commit 1ddf19d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

custom_components/pyscript/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async def state_changed(event):
232232

233233
for attribute in event.data["new_state"].attributes:
234234
new_val = event.data["new_state"].attributes[attribute]
235-
if "old_state" in event.data and attribute in event.data["old_state"].attributes:
235+
if "old_state" in event.data and event.data['old_state'] is not None and attribute in event.data["old_state"].attributes:
236236
old_val = event.data["old_state"].attributes[attribute]
237237
else:
238238
old_val = None

0 commit comments

Comments
 (0)