Skip to content

Fix key error upon missing node#14460

Merged
pvizeli merged 1 commit into
home-assistant:devfrom
MartinHjelmare:fix-mysensors-key-error
May 14, 2018
Merged

Fix key error upon missing node#14460
pvizeli merged 1 commit into
home-assistant:devfrom
MartinHjelmare:fix-mysensors-key-error

Conversation

@MartinHjelmare
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare commented May 14, 2018

Description:

  • This is needed after gateway ready message generates an update while persistence is off, or while the gateway node hasn't been presented yet.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

* This is needed after gateway ready message generates an update while
  persistence is off, or while the gateway node hasn't been presented
  yet.
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()

@pvizeli pvizeli merged commit 7562b41 into home-assistant:dev May 14, 2018
@MartinHjelmare MartinHjelmare deleted the fix-mysensors-key-error branch May 16, 2018 11:20
@balloob balloob mentioned this pull request May 28, 2018
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
* This is needed after gateway ready message generates an update while
  persistence is off, or while the gateway node hasn't been presented
  yet.
@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants