Hue motion sensors + remotes: custom component

Anyone here that upgraded to HA 0.89.x and renamed the huesensors custom component using the ZHA component in HA for Lights (Hue connected to ZHA not the Hue Bridge).
When I renamed the component, all my lights connected via the ZHA component now show as unavailable.

Upgraded to. 89.1 running the Hue component. 80, changed the folder to huecustom changed my sensor to huecustom and everything is working fine :slight_smile:

I live in Sweden and have Europe/Stockholm in my Hue bridge and home assistant. All times shows correctly in home assistant except for the “last updated”, this one lags behind one hour and seems to be showing UTC time. I searched the thread and found similar reports but none with any solution.
Is it possible the get the last updated time to match local time?

Some strange stuff. If we use sensor: - platform: hue and folder hue it’s not working.
So renaming to hue*(whatever), both sensor and folder and it’s working? How come?

And, when working with for example: sensor: - platform: hue_custom the tracker card is not picking it up, due to .json file pointing to hue folder…

for my summary:

you rename the (old) Folder
custom_components/hue
to
custom_components/hue_custom

and rename the config from:

binary_sensor:
  - platform: hue
device_tracker:
  - platform: hue
sensor:
  - platform: hue

to

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

or what?

Thats what i had to do to get it working again… you can name the folder and platform anything you like, just not hue…

not exactly…

the old folder was /custom_components/sensor or in a later stadium /custom_components/binary_sensor (and /device_tracker and /sensor )in which you placed the file(s) hue.py.

new situation is indeed /custom_component/hue_custom/ in which you place the file(s) binary_sensor.py (and device_tracker.py and sensor.py if you use the full package)

i do it last week with his guide https://github.com/robmarkcole/Hue-sensors-HASS

–> the folder is custom_components/hue

that is not advisable, since hue is the name of the official component. If you use that, you need to copy the full Hue package (including the native Hue package in HA) into that /custom_component/ folder… that is, if you are overriding a pat of that native component.

CC Hue doesn’t do that, so you might get away with using /custom_component/hue, but it goes against new HA rules and regulations, and will be confusing in the end, when using more custom_components, and you mix naming.

just use /custom_components/hue_custom/ and you’re set. If not, it might work as well, but you’ll be confused soon :slight_smile:

1 Like

ok :smiley: i will set it: /custom_components/hue_custom

yes, but I thought you had already done that …? Hue motion sensors + remotes: custom component

i will update this evening to 0.89.2 :slight_smile: i had it only on the test system

Hopefully robmarkcole will update the .json for tracker card with path:*/hue_custom :+1: Then we are all set

Exactly this. I followed Larsentim’s instructions while on 0.89.2 and it finally worked. Thank you!

trying to refine my templates Im stuck with the way the component calculates lx from light_level, please have a look with me. This is the official Philips Hue table:

Philips Hue definition                 Lux               MeasuredValue
Overcast moonless night sky              0.0001                  0 dark.....
Outdoor: Bright moonlight                1                       1
Home: Night light                        2                    3000
Home: Dimmed light                      10                   10000
Home: ‘Cosy’ living room                50                   17000
Home: ‘Normal’ non-task light          150                   22000
Home: Working / reading                350                   25500
Home: Inside daylight                  700                   28500
Home: Maximum to avoid glare          2000                   33000
Outdoor: Clear daylight            > 10000                 > 40000
Outdoor: direct sunlight            120000                   51000

However, since the CC uses lx = round(float(10 ** ((lightlevel - 1) / 10000)), 2) there is no way I am ever going to get a lx value <1. Meaning, even when pitch dark 0 is measured for light_level, it will always be lx 1, which is 1 step up in the table…

Ideally Im am trying to reach a template for lx like the one I use for light_level (translated Overcast moonless night sky to dark for convenience sake):

      friendly_name_template: >
        Attic:
        {% set light_level = states('sensor.attic_motion_sensor_light_level')|int %}
        {% if light_level == 0 %} dark
        {% elif light_level <=1 %} bright moonlight
        {% elif light_level <=3000 %} night light
        {% elif light_level <= 10000 %} dimmed light
        {% elif light_level <= 17000 %} 'cosy' living room
        {% elif light_level <= 22000 %} 'normal' non-task light
        {% elif light_level <= 25500 %} working / reading
        {% elif light_level <= 28500 %} inside daylight
        {% elif light_level <= 33000 %} maximum to avoid glare
        {% elif light_level <= 40000 %} clear daylight
        {% elif light_level <= 51000 %} direct sunlight
        {% else %} too bright!
        {% endif %}

I can’t however build the same template for lx, have a look:

      friendly_name_template: >
        Attic:
        {% set lux = states('sensor.attic_motion_sensor_lux')|int %}
        {% if lux <=1 %} moonlight
        {% elif lux <=2 %} night light
        {% elif lux <= 10 %} dimmed light
        {% elif lux <= 50 %} 'cosy' living room
        {% elif lux <= 150 %} 'normal' non-task light
        {% elif lux <= 350 %} working / reading
        {% elif lux <= 700 %} inside daylight
        {% elif lux <= 2000 %} maximum to avoid glare
        {% elif lux <= 10000 %} clear daylight
        {% elif lux <= 120000 %} direct sunlight
        {% else %} too bright!
        {% endif %}

adding a first line to this template {% if lux <1 %} dark is useless, for it will never be <1… Mind you, this isn’t a silly detail, we can distinguish dark from moonlight with our eyes, and so does the hue sensor. Making it a float in the template doesn’t help, because of the way the rounding is done in the component…

might be able to do something with a template based in the light_level attribute, but feel this should really be refined in the component for lx value calculating. @robmarkcole @yottatsa what could we do to realize that?

thanks!

1 Like

This error showed back up in my logs again. It was what happened previously. If I was to venture a guess by some of the other templating I was fooling around with it would be that the entity is unavailable and returning none/null? I have always been trying to nail down issues with disconnecting devices and am still working through that. In any case should I define what should happen when none is returned for the template. How would that look?

   Error parsing value: 'value_json' is undefined (value: None, template: {{value_json.config.on}})
Connection lost. Reconnecting…

when does this show up? at startup, or during regular on-time.

if the first, it might be because the sensors havent been initialized yet, I get heaps of those during startup. (not the Connection lost. Reconnecting… though, that new to me)

not sure if you need to do anything when none is returned, does your system choke on it?

Hey everyone! Be nice I am new and this is starting to drive me absolutely nuts with trying to get the Hue Sensors working on home assistant ver. 0.89.2 (Hass.io for the pi).

So far I have followed instructions and put the following in but it still comes up and says the sensors can’t be found when I check config.

in /config/custom_components I have put the “binary_sensor.py” “device_tracker.py” and “sensor.py” (Both in a folder /custom_companents/hue and /custom_components/hue_custom with no luck)

In the configuration.yaml file I included the following;

In the group.yaml file I included the following; (obviously got no sensors to add since I can’t find them as active entities)

Since making the configuration.yaml point to /hue_custom it would appear when I check my configuration it doesn’t display the units as missing now; however, there are still some issues in the logs?

and

Anyway, I have likely missed a ridiculous little step, but your help would be greatly appreciated as it’s driving me bananas!

Hi, let’s go through this step by step - I may be duplicating what you have said, but lets do it :slight_smile:

The first thing is to create a folder under /config/custom_components called hue_custom

In this folder you need to put the following files:
binary_sensor.py
sensor.py
device_tracker.py

Next you need to go to the configuration.yaml (assuming it is one big file and not split out) and put:

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

Check your config and restart HA.

If you are using HA and have SSH access while HA is restarting, tail the log in the /config directory:

tail -f home-assistant.log

Once it is up look for new entities in the developer tools:

33

Second from the left


You can search in the ‘Filter Entities’ bit if you want.

Sorry if this is dumbed down, but I have no knowledge of what you know and what you don’t - I hope it helps :slight_smile:

I think your config is wrong. You have the binary_sensor and device_tracker inside the sensor config. Yaml is sensitive to indentation.

sensor:
  - platform: hue_custom
binary_sensor:
  - platform: hue_custom
device_tracker:
  - platform: hue_custom
1 Like