Hue motion sensors + remotes: custom component

Hi,
I am using Hassio on a Raspberry Pi. Installed everything 2 months ago.
Hue was integrated via “Discovery”.
I cann see all lights and also motion sensors. Via API Debug tool I also implemented the sources for temperature and brightness.
My problem is now: How can I additionally implement the 4 button Hue dimmer switches and see it in my entity list?
Via API debug tool I did also my remotes, e.g.
‘’’
},
“107”: {
“state”: {
“buttonevent”: 1002,
“lastupdated”: “2019-07-20T04:49:24”
},
“swupdate”: {
“state”: “noupdates”,
“lastinstall”: “2019-07-20T04:47:10”
},
“config”: {
“on”: true,
“battery”: null,
“reachable”: true,
“pending”: []
},
“name”: “Switch1”,
“type”: “ZLLSwitch”,
“modelid”: “RWL021”,
“manufacturername”: “Philips”,
“productname”: “Hue dimmer switch”,

To me this means, I just have to know how to write the code in my configuration.yaml.
For the sensor I did it like this:

  • platform: rest
    resource: http://192.168.178.83/api/KEY/sensors/42
    value_template: ‘{{ value_json.state.temperature | float / 100 }}’
    unit_of_measurement: °C
    name: ‘Hof Temperatur’
    ‘’’

Thanks for your support,
Chris

I have a question and an issue probably related to it. I have an automation to open and close my curtains with the button I and O (1 and 4) on a Hue Dimmer Switch. It works great with this component, but everytime time I restart the system it somehow activates the O automation and closes the curtains. I can add initial_state: false to the automation but that would require me to turn it on on every restart, power outage, upgrade, etc.

The related question would be, what is the difference between 4_click and 4_click_up? I’ve read the whole thread and I can’t seem to find a definitive answer. Could that have something to do with my issue? Here’s my automation:

- id: '1560748807276'
  alias: Dimmer Button 0 Hold
  trigger:
  - entity_id: sensor.living_room_switch
    platform: state
  condition:
      - condition: state
        entity_id: sensor.living_room_switch
        state: '4_hold_up'
  action:
  - service: cover.close_cover
    data:
      entity_id: cover.shelly_shsw_25_e667c2

On every restart I get Dimmer Button 0 Hold has been triggered in the Logbook

Hmm, that’s a tough one…My guess is that on a reboot the last_updated of sensor.living_room_switch gets updated, which triggers your automation. This doesn’t happen for me, at least not with the FOH switch. I wonder what the trigger.from_state is; maybe it’s switching from something like None or unknown and you could check for that as a condition.

I’m guessing on every reboot the component is reading the state directly from the Hue Hub. I’ve tried issuing a command to put the remote on standby state after every click (as described here) but once you reboot, the state goes back to the last click used and it triggers the automation. Very weird indeed.

if it passes the condition, you can be positive the state to be correct, and no other state is set at that time.

Why not use that as a template trigger? to be sure it only triggers on that specific state, and not all other state (and attribute) changes of the entity_id?

- id: '1560748807276'
  alias: Dimmer Button 0 Hold
  trigger:
    platform: template
    value_template: >
      {{ is_state('sensor.living_room_switch','4_hold_up')}}
  action:
    service: cover.close_cover
    entity_id: cover.shelly_shsw_25_e667c2

It’s a good idea, but what if the state after reboot is '4_hold_up'? Wouldn’t that trigger the automation at start up?

well, tbh, not sure about that.
One would hope the state would be restored at startup, and hence not cause a state change (which would indeed trigger the automation)

you’d have to try…

Hey guys,

I have my tap switch working with HA now, how can I stop the switch from performing tasks on the hue hub when pressing the button?

Say I have it controlling my blinds in HA, but it’s also controlling the lights through the app settings…

delete the configuration in the app for the switch…

Had to remove the switch from the app to remove the config and then add it again without configuring it.

Thanks for the help

I did ask on here a couple of months ago if anyone had a link to the steps necessary to keep the custom component working after upgrading from HA 90, but sadly no replies.

So I just tried again - upgraded to 0.96.5 - and all my configured Hue Switches now show as Not Found (they worked perfectly under the 90 version).

If someone could point me at some docs on the required steps I would be most grateful

For clarity, my custom components folder currently contains a huesensor folder, with binary_sensor.py, device_tracker.py and sensor.py (all at version 1.0.5). I also have a custom_components/sensor folder that contains hue.py at version 0.7

Ok have you completely disabled the official then and control your lights without the hue component. I still use the official component for control of hue lights. I do however require the motion sensors work with other automations so require the CC. I don’t think this is an optimal situation. I’m guessing it’s not an easy feat to pare out the motion sensing part of the official component or develop a CC that does everything but wanted to check in and see

@redsix sorry I don’t have switches but if you are referring to the “great migration” CC were moved to a different folder structure. Have a look at the GIT repository and emulate the structure in your own CC structure. You might wanna have a look at the new HACS system set up as that seems to be the future of things custom related. Sorry maybe somebody else can chime in who has switches

Hi David

Thanks for taking the time to reply.

I have not intentionally set up two ways of doing things! If I simply delete BOTH custom component sub-folders, will I revert to the built-in components?

A 3-5 second delay that many have reported would not be an issue for me, as my sole use-case is switching on garden lighting that is controlled by TPLink switches, so a delay is acceptable!

Edited to add: Just deleted all the files in the csutom_components sub-folders, but Configurator will not allow me to delete the folders themselves - it says files are still present.

Installed HACS, but cannot see any sign of the Hue Motion Sensor component in the store?
EDIT: Doh! Never mind. Figured out I have to add Robs repo!..and having added the Repo to HACS then installed the Custom Component through there, my Hue switches are working again.Thanks for the assist, and it looks like HACS will make everything much easier going forward!

not sure if there are any docs, but it is not that complex at all. the custom component setup hasn’t changed that much really. In fact, all I have is:

binary_sensor:
  - platform: hue_custom
sensor:
  - platform: hue_custom

device_tracker:
  - platform: hue_custom

and the files are located in:

/config/custom_components/hue_custom

(note that I dont follow the CC guideline using folder-name hue_sensor, because I’ve always felt that to be an incorrect naming… which is of no consequence, as long as you set that folder correctly everywhere in your config.)

HA discovered the same sensors when the newly integrated Hue component was introduced, so I now have 2 of each…

40

I use the sensors made by the CC, because that has always worked fine, and saw no reason to change a nicely working setup. Especially since people are complaining about the response time of the new sensors. (something I couldn’t really confirm, since they work nicely in my setup also)

Hope this suffices, if not, please let us know.

How do I install this? I’m learning HA and the readme on github is not clear for me. Do I need to add the git repository to HA. Do I need to copy files manually?

I did manage to get the RESTful code implemented and working.

Step 1: Install HACS, using the instructions here

Step 2: Once HACS is installed (and you may need to restart HA - can’t remember) you will see a new ‘Community’ menu in the left bar - Click it.

Step 3: Click Settings at the top, right

Step 4: Add a custom repository using Url https://github.com/robmarkcole/Hue-sensors-HASS and set the type to Integration

Step 5: Click the repo you just added and you should see Hue sensor custom component, with a link to install it.

These are the steps I followed and which worked perfectly for me

Regards
Steve

1 Like

thanks! exactly what I was looking for

Where does the device_tracker store the device information? I have old phone that is showing as “home” all the time eventhough it is deleted from Hue web portal and from known_devices.yaml and all other places I could found it. I even deleted the HASS database but still that old phone is showing there…

When enabling this custom component does it disable the official integrated one? ie binary sensor for motion sensor