8000 Catch AttributeError on Wink PubNub update by w1ll1am23 · Pull Request #4253 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Catch AttributeError on Wink PubNub update #4253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2016

Conversation

w1ll1am23
Copy link
Contributor
@w1ll1am23 w1ll1am23 commented Nov 6, 2016

Description:
Found the following error today during a state change on a Wink switch (Quirky power strip).

Nov 06 15:34:36 hass hass[10732]: if outlet.get('outlet_id') == str(self.device_id()):
Nov 06 15:34:36 hass hass[10732]: AttributeError: 'str' object has no attribute 'get'

This PR will catch the AttributeError and call the Wink API to fetch the correct state.

Checklist:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass

@mention-bot
Copy link

@w1ll1am23, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @balloob and @jbags81 to be potential reviewers.

@balloob balloob merged commit 0aba227 into home-assistant:dev Nov 7, 2016
@@ -61,7 +61,7 @@ def _pubnub_update(self, message, channel):
json_data = message
self.wink.pubnub_update(json.loads(json_data))
self.update_ha_state()
except (AttributeError, KeyError):
except (AttributeError, KeyError, AttributeError):
Copy link
Member

Choose a reason for hiding this comment

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

This change doesn't make any sense to me. What am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MartinHjelmare wow you're right I was "fixing" it so quick I didn't even notice it was already there. It is really strange though because that is were the error was coming from. Full log below. Shouldn't an exception in a dependency get raised to HA?

Nov 06 15:34:36 hass hass[10732]: File "/home/pi/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.33.0.dev0-py3.4.egg/homeassistant/components/wink.py", line 113, in _pubnub_update
Nov 06 15:34:36 hass hass[10732]: self.wink.pubnub_update(message)
Nov 06 15:34:36 hass hass[10732]: File "/home/pi/.virtualenvs/hass_dev/config/deps/pywink/devices/standard/__init__.py", line 154, in pubnub_update
Nov 06 15:34:36 hass hass[10732]: self._update_state_from_response(json_response)
Nov 06 15:34:36 hass hass[10732]: File "/home/pi/.virtualenvs/hass_dev/config/deps/pywink/devices/standard/__init__.py", line 149, in _update_state_from_response
Nov 06 15:34:36 hass hass[10732]: if outlet.get('outlet_id') == str(self.device_id()):
Nov 06 15:34:36 hass hass[10732]: AttributeError: 'str' object has no attribute 'get'

Copy link
Member

Choose a reason for hiding this comment

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

The stacktrace doesn't match the current code in components.wink.py. Current line 113 is self.update_ha_state(). Stacktrace says self.wink.pubnub_update(message) at line 113.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MartinHjelmare You're right thanks for the help. I was running a different branch without AttributeError being caught and didn't realize it, of course when I made this PR I started the branch from dev which already had the fix. I guess that is what I get for rushing to fix it. 😞

@w1ll1am23 w1ll1am23 deleted the wink_catch_AttributeError branch November 22, 2016 21:12
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0