Skip to content
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

KeyError: Presence #2

Closed
kcdc80 opened this issue Nov 20, 2017 · 9 comments
Closed

KeyError: Presence #2

kcdc80 opened this issue Nov 20, 2017 · 9 comments
Assignees

Comments

@kcdc80
Copy link

kcdc80 commented Nov 20, 2017

I keep getting this error when trying to setup hue with the custom component

[homeassistant.components.sensor] Error while setting up platform hue
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py”, line 170, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File “/usr/lib/python3.6/asyncio/tasks.py”, line 352, in wait_for
return fut.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/sensor/hue.py”, line 27, in setup_platform
data.update()
File “/usr/lib/python3.6/site-packages/homeassistant/util/init.py”, line 306, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/sensor/hue.py”, line 51, in update
self.data = self.parse_hue_api_response(response.json())
File “/config/deps/lib/python3.6/site-packages/hue_sensors.py”, line 52, in parse_hue_api_response
data_dict[_key] = parse_sml(sensor)
File “/config/deps/lib/python3.6/site-packages/hue_sensors.py”, line 81, in parse_sml
hue_state = response[‘state’][‘presence’]
KeyError: ‘presence’

I hope this is the info you need. If you need something else just let me know.

@kcdc80
Copy link
Author

kcdc80 commented Nov 20, 2017

Also my automations with hue does no longer work after I have added the custom component. Even if I remove the sensor and lines in configuration.yaml and restart my hassio it still does not work, I have no idea why. But if I restore my hassio to a snapshot from before the change the automatons start working again.

@robmarkcole
Copy link
Owner

Need to see what’s returned by the API. Could you post? I’m wondering if there’s just no presence data in your case. Cheers

@kcdc80
Copy link
Author

kcdc80 commented Nov 27, 2017

Sorry - I am not really sure how I can find that information. Can you point me in the right direction? Should be able to figure it out with a little pointer.

@robmarkcole
Copy link
Owner

Sure, in your browser go to http://<bridge ip address>/api/<username>/sensors as per the instructions here, and save the results to a text file.

@kcdc80
Copy link
Author

kcdc80 commented Nov 28, 2017

Ahhh, thats what you mean...Will post it asap.

\kcdc80

@kcdc80
Copy link
Author

kcdc80 commented Nov 29, 2017 via email

@robmarkcole
Copy link
Owner

OK so the issue is that you SML data is not in the format that hue_sensors expects. For example, hue_sensors searches the 'name' field for 'ambient light' to determine the lightlevel, but your API data has the name 'Hue motion sensor Light'. I'm guessing that either you renamed the 'name' or this is the result of a firmware update. Either way hue_sensors should try, except to allow for the case when data is incomplete or in an unknown format, so I will create an issue for that. In the meantime you could try resetting the SML to default settings to return the 'name' field to default.
Cheers

@robmarkcole
Copy link
Owner

Currently for this user the API is returning:

    "name": "Hue motion sensor Light",
    "type": "ZLLLightLevel",

So it is safer to get the sensor type from "type" than "name" as name can be edited by the user but type cannot.

@robmarkcole
Copy link
Owner

This is moved to #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants