Hue motion sensors + remotes: custom component

Temperature is an attribute, so use a Template sensor. Cheers

Thanks @robmarkcole :slight_smile:

Think I need a little more help with that feature of using templates and their advantages though. Do you have a guide for that also?

This is a great component, utilizing the extra options that one already have.

1 Like

I’m on holiday without access to my config but recommend modifying the example in the docs

I can’t figure this out. Added your example into my sensors.yaml file like this:

# Hue sensors
  - platform: template
      bryggers_temperature:
        friendly_name: Bryggers Temperatur
        value_template:  '{{states.sensor.bryggers_motion_sensor.attributes.temperature}}'
        unit_of_measurement: "°C"

Get error like this:

2017-11-19 10:38:59 ERROR (SyncWorker_0) [homeassistant.util.yaml] mapping values are not allowed here
  in "/config/sensor.yaml", line 68, column 27
2017-11-19 10:38:59 ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: mapping values are not allowed here
  in "/config/sensor.yaml", line 68, column 27

Yes I have created a sensor.yaml file and included in my configuration.yaml. Everything else works.

It does try it out. If you do not define a “to:” in the trigger and instead put the button press in the condition it fires on each press.

@snjoetw In reply to your earlier question “now that hue sensors show up in HomeKit, is there new API to do push instead of poll?”, I found a solution that will indeed detect Hue switch push notifications:

I think this problem is more general. As far as I know it is not possible to fire the same state twice.

I made a template sensor from the last_updated attribute of the zithoek_dimmer. In automation the trigger is fired by a change in the last_updated state and is conditioned on the state itself to toggle my light.

  trigger:
    - platform: state
      entity_id: sensor.zithoek_last_updated, sensor.zithoek_dimmer
  condition:
    condition: state
    entity_id: sensor.zithoek_dimmer
    state: '1_click'
  action:
    - service: light.toggle
      entity_id: light.sta_lamp

Great, I ended up going with exactly the same approach, should have read your post before.
Thanks

think it should be…

# Hue sensors
  - platform: template
    sensors:
      bryggers_temperature:
        friendly_name: Bryggers Temperatur
        value_template:  '{{states.sensor.bryggers_motion_sensor.attributes.temperature}}'
        unit_of_measurement: "°C"

Hiya,

I keep getting an error when setting up the Hue platform. I have copied (samba) the contents of custom_components into the config folder of hassio. Also I have added the sensor like described in the Readme. Last but not least I have the phue.conf in the config folder.

2017-11-20 20:54:28 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 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’

What to do?

\kcdc80

Interesting error, the api must be returning data in a format I’ve not accounted for. Can you create an issue on github and post your anonymised data returned by the api?

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