Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions homeassistant/components/mysensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ def mysensors_callback(msg):
_LOGGER.debug(
"Node update: node %s child %s", msg.node_id, msg.child_id)

child = msg.gateway.sensors[msg.node_id].children.get(msg.child_id)
if child is None:
try:
child = msg.gateway.sensors[msg.node_id].children[msg.child_id]
except KeyError:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

child can also be None and that will not check anymore.

Copy link
Copy Markdown
Member Author

@MartinHjelmare MartinHjelmare May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, child can not be None. The child id can be missing, but if it's not missing, the child instance is never None.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I see you replace .get()

_LOGGER.debug("Not a child update for node %s", msg.node_id)
return

Expand Down