-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Catch AttributeError on Wink PubNub update #4253
Conversation
@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. |
@@ -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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 😞
Description:
Found the following error today during a state change on a Wink switch (Quirky power strip).
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:
tox
run successfully. Your PR cannot be merged unless tests pass