Prevent invalid context from crashing (#21231)

* Prevent invalid context from crashing

* Lint
This commit is contained in:
Paulus Schoutsen
2019-02-19 23:02:56 -08:00
committed by Pascal Vizeli
parent 27d598fff8
commit cf3a8b60ff
2 changed files with 64 additions and 46 deletions

View File

@@ -744,7 +744,10 @@ class State:
context = json_dict.get('context')
if context:
context = Context(**context)
context = Context(
id=context.get('id'),
user_id=context.get('user_id'),
)
return cls(json_dict['entity_id'], json_dict['state'],
json_dict.get('attributes'), last_changed, last_updated,