Hue motion sensors + remotes: custom component

You’re absolutely right @jimbob1001. Using your example made it work instantly :slight_smile:

Thanks…

1 Like

Tried out your approach today and you’re right it works without defining a to: in the trigger. Simplifies things to not have to use the template sensor, thanks!

I made an issue on github. If you need anything more from me I would be glad to help out.

\kcdc80

Hi I can 't see any new issues, should be on https://github.com/robmarkcole/Hue-sensors-HASS/issues
Cheers

For the life of me I couldn’t figure out why this wasn’t working for me. Finally found the problem. I’m using a Hue Tap, and the underlying hue-sensors library has a bug where it sets the wrong model ID for that accessory. Because of the bug, Hue-sensors-HASS never sets attributes when the sensor is updated.

I’ve sent a pull request on Hue-sensors: https://github.com/robmarkcole/Hue-sensors/pull/3

Once I work around that bug locally everything works great. Thanks for the custom component, @robmarkcole!

1 Like

Ahhh, I made it here…

Can I move it or should I create a new (a copy)?

\kcdc80

Probably a really stupid question but can I use this somehow on Hass-io?

You should be able to use this. The custom_components folder needs to be created in your configuration folder.

Hello, I added this custom component in Hassio thanks for creating it! I see sensor.door_motion_sensor in states which reports light level, temperature etc in the attributes column. How do I break this out to separate sensors i.e. sensor.door_temperature, sensor.door_light_level as per your example on Github?

Many thanks
Justin

Thanks @zarthan, eventually got round to doing this and all switches, dimmers and sensors turned up. Installing and reading on Hass.io it leads you to believe that you can’t install any addons unless they are part of the hass.io store or through an addon repository. If you have Samba installed this really was as easy as copying the custom_config directory over and adding the components to the respective yamls. Too easy!

great work @robmarkcole loving it!

Hi all, I addressed multiple issues in the latest release of the custom component. Please note the changes are actually to the hue-sensors requirement which is bumped from v1.1 to v1.2. Let me know of any more issues.
Cheers!

1 Like

Have updated the README to show usage of a template sensor. Cheers

1 Like

Thank you :slight_smile:

Just tried @robmarkcole 's component. Works great here :slight_smile: thanks!

Even though it’s working I am now seeing the following logged in my logs. Not sure if its related

2017-12-09 14:37:13 ERROR (MainThread) [aiohttp.access] Error in logging
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/api.py", line 125, in get
    payload = yield from to_write.get()
  File "/usr/lib/python3.6/asyncio/queues.py", line 167, in get
    yield from getter
  File "/usr/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 236, in result
    raise CancelledError
concurrent.futures._base.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aiohttp/helpers.py", line 554, in __get__
    return inst._cache[self.name]
KeyError: 'remote'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aiohttp/helpers.py", line 521, in log
    for key, value in fmt_info:
  File "/usr/lib/python3.6/site-packages/aiohttp/helpers.py", line 513, in <genexpr>
    for key, method in self._methods)
  File "/usr/lib/python3.6/site-packages/aiohttp/helpers.py", line 473, in _format_a
    ip = request.remote
  File "/usr/lib/python3.6/site-packages/aiohttp/helpers.py", line 556, in __get__
    val = self.wrapped(inst)
  File "/usr/lib/python3.6/site-packages/aiohttp/web_request.py", line 319, in remote
    peername = transport.get_extra_info('peername')
  File "/usr/lib/python3.6/asyncio/sslproto.py", line 306, in get_extra_info
    return self._ssl_protocol._get_extra_info(name, default)
  File "/usr/lib/python3.6/asyncio/sslproto.py", line 547, in _get_extra_info
    return self._transport.get_extra_info(name, default)
AttributeError: 'NoneType' object has no attribute 'get_extra_info'

Yeah that’s not related

I’m having trouble getting this working.
Here are my logs:

2017-12-10 10:24:34 ERROR (MainThread) [homeassistant.setup] Error during setup of component hue
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 193, in _async_setup_component
component.setup, hass, processed_config)
AttributeError: module ‘custom_components.hue’ has no attribute ‘setup’
2017-12-10 10:24:35 ERROR (MainThread) [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 166, in _async_setup_platform
None, platform.setup_platform, self.hass, platform_config,
AttributeError: module ‘custom_components.sensor.hue’ has no attribute ‘setup_platform’
2017-12-10 10:25:31 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform hue
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py”, line 171, 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 “/usr/lib/python3.6/site-packages/homeassistant/components/light/hue.py”, line 143, in setup_platform
allow_in_emulated_hue, allow_hue_groups)
File “/usr/lib/python3.6/site-packages/homeassistant/components/light/hue.py”, line 267, in setup_bridge
update_lights()
File “/usr/lib/python3.6/site-packages/homeassistant/util/init.py”, line 306, in wrapper
result = method(*args, **kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/util/init.py”, line 306, in wrapper
result = method(*args, **kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/light/hue.py”, line 185, in update_lights
api = bridge.get_api()
File “/usr/lib/python3.6/site-packages/phue.py”, line 838, in get_api
return self.request(‘GET’, ‘/api/’ + self.username)
TypeError: must be str, not NoneType

And my configuration.yaml

homeassistant:
  name: Home
  latitude: !secret home_latitude
  longitude: !secret home_longitude
  elevation: !secret home_elevation
  unit_system: metric
  time_zone: !secret time_zone

logger:
  default: warn
config:
ios: !include ios.yaml
updater:
map:
discovery:
logbook:
sun:
recorder:
  purge_interval: 2
  purge_keep_days : 4
history: !include history.yaml
http:
  api_password: !secret api_password
hue:
sensor:
  - platform: hue

Have you got a phue.conf file in your config folder as created by the hue lights component?

1 Like

Yes I have got that file in my config folder.
Here are its contents:

{“192.168.1.8”: {“username”: “xxxx”}}

Now, I am also getting this error:

2017-12-10 10:42:56 ERROR (MainThread) [homeassistant.components.sensor] Error on device update!
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py”, line 217, in async_add_entity
yield from entity.async_device_update(warning=False)
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 306, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.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 102, in update
self._hue_id][‘lux’]
KeyError: ‘lux’

Please could you create an issue in this repo and post your anonymised return from the hue API. Cheers. https://github.com/robmarkcole/Hue-sensors/issues/2

1 Like