Hue motion sensors + remotes: custom component

you also need to add this in your sensors configuration:

- platform: hue
  ip_address: !secret hue_ip
  token: !secret hue_api_key

(and of course the correct entries in your secrets file)

Hi all, I created a seperate thread to discuss development of a next gen component. Lets keep this thread for discussion about the custom component.
Cheers

2 Likes

I’ve changed the scan interval - lowering and raising … all it does is change the # of errors that show up… It’s showing two errors per scan interval for whatever reason… initially (with no scan_interval set) - it was doing two per Second… Changing it, to say 60 - makes it output two errors per minute. Doesn’t change anything else though.

Also - since I have philips hue integration through discovery already established (for lights) – should I be using that token it already uses? and if so, which file and which # is the token I could use? or should they be different (as they are now).

Also - with the introduction of the new thread regarding official implementation - does that mean that if this isn’t working (like it is for many ppl) - is there no support going forward. ie should I stop posting in this thread?

My Hue kit is in a box as recently moved house, can anyone on the thread help?
I’l get my kit together and start on the new component soon

I just figured it out… After looking at your other reported issues in github - this one: https://github.com/robmarkcole/Hue-sensors-HASS/issues/16

Is why its not connecting,… I turned off (in the Hue app) one of the motion sensors I haven’t setup in the new house, the other day… since then it errors out like this… As soon as I re-enable them - the custom component works perfectly fine…

1 Like

Hi guys, I have a question regarding the switch.
Via the hue app you are able to cycle through the light setting with each press of the first button.

Is it possible to do the same via HA as I would like an automation that with 1 click turns on the light, yet sets it to dimmed if after a certain time, but still have the option to cycle through if needed.

What delay times are you experiencing from when motion occurs and when Home Assistant shows motion?

Hello guys!

I´m new to HA but somehow managed to get the custom component working. Only thing I did not get (in the otherwise very good documentation) is where and how do I get the names for my sensors from? In HA there are no values for temp and lux in the frontend (see screenshot).

All examples I could find use something like this “states.sensor.kitchen_motion_sensor.attributes.temperature”. Does this mean this sensor needs to be assigned to the room “kitchen” in the Philips Hue app? What if I use 2 sensors in one room? How do I adress a specific sensor in my house?

Thanks in advance for your help and greetings from Germany!

P.S: Sorry if this is the wrong place to put this question. This is all new to me :slight_smile:

Can anyone confirm the delay time with the Hue motion sensor? Specifically the time between when motion physically occurs and when Home Assistant updates?

I can’t say specifically but I have an automation which turns on/off a light using a python script with motion from a Hue sensor and as soon as we walk into the area the light comes on. That’s probably the most delay sensitive use-case and it works fine in our household.

1 Like

I too would like to know if this is possible.
thanks

I’d like to share a small update that I made today in the code. I saw the Niko had released a new switch! Being as I am I bought it and saw that it wasn’t compatible with the script used above. I adapted it to be compatible with FOH products (it’s a new ‘modelid’).

Result:

The adapted code looks like this:

    def parse_hue_api_response(response):
    """Take in the Hue API json response."""
    data_dict = {}    # The list of sensors, referenced by their hue_id.

    # Loop over all keys (1,2 etc) to identify sensors and get data.
    for key in response.keys():
        sensor = response[key]
        modelid = sensor['modelid'][0:3]
        if modelid in ['RWL', 'SML', 'ZGP', 'FOH']:
            _key = modelid + '_' + sensor['uniqueid'][:-5]

            if modelid == 'RWL':
                data_dict[_key] = parse_rwl(sensor)
            elif modelid == 'ZGP':
                data_dict[_key] = parse_zgp(sensor)
            elif modelid == 'FOH':
                data_dict[_key] = parse_foh(sensor)
            elif modelid == 'SML':
                if _key not in data_dict.keys():
                    data_dict[_key] = parse_sml(sensor)
                else:
                    data_dict[_key].update(parse_sml(sensor))

        elif sensor['modelid'] == 'HA_GEOFENCE':
            data_dict['Geofence'] = parse_geofence(sensor)
    return data_dict

def parse_foh(response):
    """Parse the json response for a ZGPSWITCH Friends of Hue switch."""
    name_raw = response['name']
    arr = name_raw.split()
    arr.insert(-1, 'switch')
    name = ' '.join(arr)
    TAP_BUTTONS = {20: 'top_left', 21: 'bottom_left', 22: 'bottom_right', 23: 'top_right'}
    press = response['state']['buttonevent']
    if press is None:
        button = 'No data'
    else:
        button = TAP_BUTTONS[press]
    
    data = {'model': 'ZGP',
            'name': name,
            'state': button,
            'last_updated': response['state']['lastupdated'].split('T')}
    return data

Can you share the (relevant parts of the) involved yaml-files?

My HA on a Rpi3 makes for variable delays, i guess depending on other stuff the Rpi is doing. I also sometimes have it miss automation (to turn on a light as soon as a sendos measures below a certain lux value)… I have a Hue motion sensor that should turn on a lamp, but often it simply doesn’t. For the stuff you can do in Hue, so without HA involved, the response time of lights to motion are very fast.

This has been great to make my Hue dimmer switch infinitely more useful.

The only thing that would improve this is if there were an idle state, or some more accurate way of telling when a button is pressed more than once. I am trying to replicate the original Hue dimmer functionality where pressing the brightness up/down multiple times will increase/decrease the brightness.

Where did you purchase the new Niko Switch?

Hi,

I’m stuck at the configuration.yaml stage.

I understand I need to add:

- platform: hue
ip_address: !secret hue_ip
token: !secret hue_api_key

I believe my ip_address and token values are correct.

However running hassio ha check returns tons of error messages no matter what I try.
I’ve been through the [sensor template documentation](https://www.home-assistant.io/components/sensor.template/) many times.

Here is my best attempt in the configuration file:

sensor:
  # Weather prediction
  - platform: yr
  - platform: hue
    ip_address: 10.0.1.4
    token: FZQjDNswcg234234234200004stEwNowowJsTpsB
    sensors:
      office_motion:
        friendly_name: office motion
        device_class: motion
        value_template: '{{ states("sensor.office_motion") == "on" }}'

Here is the error message I get:

core-ssh:~# hassio ha check

ERROR

INFO:homeassistant.util.package:Attempting install of colorlog==3.1.4

Testing configuration at /config

Failed config

General Errors: 

- Platform not found: sensor.hue

Successful config (partial)

Your help would be very much appreciated.

do you have a hue.py file in /config/custom_components/sensor folder?

1 Like

@Gabriel thank you so much. I had to go through so many re-installs so many times that I forgot this basic step… my mistake really. Thank you for your input

https://www.hubo.be/nl/p/niko-dimmer-voor-philips-hue-antraciet/904605.html

You can even buy it online… :grin: