Hue motion sensors + remotes: custom component

I not sure it’s available to the UK yet, I’ll keep searching :slight_smile:

Hi, need some help with the Hue Dimmers…
I’ve been using this component for a very long time and it generally works great.
The only issue I’m having since the beginning is with the Hue Dimmer setup with automations setting scenes with the buttons.
Often, randomly, I need to click it more then once to get it to trigger the scene…

example of my sensors for the last updated:

# For hue remotes (last update)
  - platform: template
    sensors:
      interrupteur_sous_sol_last_updated:
        friendly_name: Hue remote sous-sol Last Updated
        value_template: '{{ states.sensor.interrupteur_sous_sol.attributes.last_updated }}' 
  - platform: template
    sensors:
      interrupteur_sous_sol_battery:
        friendly_name: Interrupteur sous-sol batterie
        value_template: '{{ states.sensor.interrupteur_sous_sol.attributes.battery }}'
        unit_of_measurement: "%" 
        icon_template: >-
          {% set battery_level = states('sensor.interrupteur_sous_sol_battery')|int('unknown') %}
          {% set battery_round = (battery_level|int / 10)|int * 10 %}
          {% if battery_level == 'unknown' %}
            mdi:battery-unknown
          {% else %}
            {% if battery_round >= 100 %}
              mdi:battery
            {% elif battery_round > 0 %}
              mdi:battery-{{ battery_round }}
            {% else %}
              mdi:battery-alert
            {% endif %}
          {% endif %}          

ex of automation:

- id: huesoussol1click
  alias: hue_remote_soussol_1click
  trigger:
  - entity_id: sensor.interrupteur_sous_sol_last_updated
    platform: state
  condition:
  - condition: state
    entity_id: sensor.interrupteur_sous_sol
    state: 1_click_up
  action:
  - data:
      entity_id: scene.soussol_relaxe
    service: scene.turn_on        

Had to use the 1_click_up instead of 1_click because the last one doesn’t always triggers (need to hold it for like 1 -2 sec)
Maybe I’m doing something wrong too…

Is it possible to set the brighter/dimmer buttons on the remote to continue to function as dimmers. Here’s what I got so far which works as a slider in the front end bot not on the remote. Is some one able to point me in the right direction?

- alias: Lamp Dimmer
  trigger:
    - platform: state
      entity_id: sensor.living_room_switch
      to: '2_click_up'
    - platform: state
      entity_id: input_number.livingroom_brightness
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: light.living_room_lamp
      state: 'on'
    - condition: state
      entity_id: light.living_room_pendant
      state: 'off'
  action:
    service: light.turn_on
    data_template:
      entity_id: light.living_room_lamp
      brightness: "{{ states('input_number.livingroom_brightness') | int }}"

When I put the python file in my custom_components/sensor directory, home assistant will no longer restart or check my config file. Do I add the python file and add the hue sensor in my config at the same time?

I don’t think you’re doing anything wrong. This was my experience too — clicks were often ignored.

I’ve reverted to using the regular Hue app for click events (to turn lights on/off/dim/brighten) and I still use this for hold events, because HA has no problem registering those, and it’s something the Hue app doesn’t support.

For what it is worth, having watched what happens to the remotes in HA, I see that the click events appear only very, very briefly, followed consistently by click_up. I have set my automations on the click_up state and it works consistently everywhere.

1 Like

yeah… problem is I don’t use only Hue lights so I was using those to turn on scenes…
I really thought I found the perfect remote at this price, giving 8 possible buttons. I’ll look into testing something else, z-wave maybe, not sure…
The Aeotec Aeon Labs Wallmote Quad ZW130-A seems great but the price is just ridiculous… I find it weird you can get a Google Home Mini at 30$ on sale (can you so much with it) but, besides this remote, need to pay at least double to get buttons…

Hope this is something that can be resolved in the future…

Hi, I am new to HA (coming from Domoticz) and really like the platform and its community.
I am now setting up my HA environment but struggle with the Hue Motion Sensor. I already have the Hue Lights running using the discovery component. Now I want to do some automation with the sensor, but I can’t get it running. I have tried a lot of things, read through the forum, but I am now out of options. Maybe I need to go to the REST platform in order to use my hue sensor.
When I insert the following in my configuration.yaml the configuration.yaml does not pass the validator anymore.

 sensor:
  - platform: hue
    ip_address: 192.168.2.15
    token: ##token## 

Running HA on RPI3+. I am at version 0.84.1 of HA and using the latest hue.py which I have put in the custom_components/sensor folder. I have a couple of questions:

  • why is the configuration file no longer valid if I include the hue sensor?
  • does the hue custom component work in combination with the discovery component?
  • do you need to use the same API key as is created for the discovery component?
  • do I need to insert also the hue bridge in my configuration file?
hue:
  bridges:
    - host: 192.168.2.15
  • I don’t see any hue entities in the state view (developer tools). Where do I look for these hue entities? I have not yet added the hue entities in the front end display since I first need to find out the naming of these entities.

Hope that somebody can point me in the right direction.

Finally, I found the mistake :wink:
When copy the hue.py file to the custom_components/sensor folder, the file transformed in a html file.

Is somebody looking to “standardize” this component?

2 Likes

I recently moved and thus changed the name of my sensor via the hue app. I updated the sensor templates to match the new name and lux and motion is still working but temperature is reporting as unknown… ideas?

Hi. On my Rpi3 with HA in an env, and on 0.84.6, since i guess 0.84.0 i don’t have some groups and some other problems with the Hue. Now i have in the logs:

File “/home/homeassistant/.homeassistant/custom_components/sensor/hue.py”, line 74
elif response[‘type’] == “ZLLTemperature”:
^
SyntaxError: invalid syntax
2018-12-22 17:11:34 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved

Any idea? I copied the latest hue.py in raw mode.

What do you mean ‘raw mode’? Chance you edited the file by accident?

Raw-mode like when you go to https://github.com/robmarkcole/Hue-sensors-HASS/blob/master/custom_components/sensor/hue.py and in the ‘title’ bar you find a RAW button. I think it is easy to have a problem when copying-pasting code.

But as i also had (have) a problem with Lovelace not rendering, i’ve decided to build the whole HA from scratch again. And currently the Hue component is working, so must have been something i did wrong, thank you.

Python is sensitive to white space, so I would caution against copy-paste code in that way. Better to download the zip file and extract the file from there, if you aren’t comfortable with git

1 Like

Where did you you buy your Niko switch. I cannot find them anywhere.

Hi, I am trying to get token but I can’t pass thru first step. It gaves me this error. Do you have any hint what to do?

C:\Users\tomas>CURL -X POST -d '{"devicetype":"my_hue_app"}' http://192.168.1.13/api --header "Content-Type:application/json"
[{"error":{"type":2,"address":"","description":"body contains invalid json"}}]

Following, i get the same error

Sorry to bump this but since this seems to be a common issue (and known), just wondering if this is being looked at to eventually fix it (or if there is another way of configuring it).
I tried an iOS third party app for the Hue and tested configuring assignments to the buttons; this triggers every time. Not sure if this is using the same way to control it…

Everything else with this component works perfectly for me (sensors, etc…), only this annoying issue where the buttons pressed don’t always get registered on first press…

Yea, I installed this component specifically for the button control. But quickly gave up and just stayed with the iOS app to configure button controls. Of course without the ability to control non hue lights. The dimmer control seemed to be one of the area’s I found the most different. I do see some people have made automations to handle dimming by 10%, but still not with simplicity of the app. My current config (iOS app), is that pressing up cycles through 4 lighting scenes in that room. Pressing the off button turns off all lights, and the dimmers dim which ever lights are currently on. Pretty basic.

This custom component is great though, and does a lot of things that I could not otherwise do.