Hue motion sensors + remotes: custom component

That’s strange. Maybe it depends on something.

they even report light level and lx when the motion sensor is switched off… which is very nice of course. a bit of a lag tbh, 2 or 3 seconds

Hello,

I’m on Hass.io 141, HassOS 1.13 and have implemented the 0.8 release of Hue-sensors-HASS into my configuration. The sensor with the bundled information is showing up fine in the UI and displays all the correct states when inspected. But for some reason I can’t get the template function to work to create separate temperature and light sensors. This is the sensor part of my configuration:

sensor:
  - platform: hue
    ip_address: !secret hbridge
    token: !secret token
  - platform: template
    sensors:
      flur_temperature:
        friendly_name: 'Temperatur Flur'
        value_template: '{{states.sensor_motion_flur.attributes.temperature}}'
        device_class: temperature
        unit_of_measurement: °C
      flur_light_level:
        friendly_name: 'Lichtniveau Flur'
        value_template: '{{states.sensor_motion_flur.attributes.lx}}'
        device_class: illuminance
        unit_of_measurement: lux

However, the sensors specified here never show up under “current entities” in the states tab nor can I get them to show up when I add the names to groups.yaml. Is there something wrong with the template code that I’m missing? The name used under value_template is correct. There is no error in the log regarding the template section or the sensors I’m trying to create.

Thanks in advance!

- platform: template
  sensors:
    laundry_motion_sensor_battery:
      friendly_name: 'Laundry battery'
      unit_of_measurement: '%'
      value_template: >
        {{state_attr('sensor.laundry_motion_sensor','battery')}}
      device_class: battery       

is what I use, shouldn’t really make a difference I think, but give it a try?

for temperature:

laundry_motion_sensor_temperature:
  friendly_name: 'Laundry temperature'
  value_template: >
    {{state_attr('sensor.laundry_motion_sensor','temperature')}}
  unit_of_measurement: '°C'
  device_class: temperature

you should be able to use the template in the dev-template page, what does it return?

1 Like

That fixed it! Changing it from

{{states.sensor_motion_flur.attributes.temperature}}

to

{{state_attr('sensor.sensor_motion_flur','temperature')}}

created the sensor and made it readable. Thank you!

1 Like

You’re most welcome, glad I could help.

1 Like

So the errors are still there.
I need several restarts to get the motion sensors back.
All lights are still there and the hue app is working fine.
So it seems there is a problem with the customer component.

which errors?
please post you configuration regarding Hue CC’s, version etc etc, so we can help you.

I can confirm that with the latest iteration 1.0.3 all CC’s, binary_sensor, sensor, and device_tracker behave as expected, and deliver the goods.

must be a misconfiguration somewhere if things aren’t as promised :wink:

No misconfiguration.
See my posts above for the logs.
I got time out errors.

a yes, sorry, missed that.
Are these timeout errors during startup only, or do they keep coming?

Before, the CC saw timing error every 0.1 seconds, depending on the polling time that was set in the CC.
These are gone completely now. AS is the ‘flapping’ of the Hue lights.

Initially when upgrading to version 1.0.1 (i think) all errors were gone and sensors and lights were immediate on restart.

Having updated to 1.0.3 now, I can see errors in the logs at startup again, (mainly because I have customizations that can be loaded because the base sensors aren’t initialized yet). I also see the famous error connecting to Hue bridge again unfortunately…

So, I am in a mixed bag really. Better than before, we now have true binary_sensors, and lights seem to be solid. We do have above errors again unfortunately indicating something still isn’t right…

My sensor was fine and now is not working at all, no entity or data…
Although my remotes still work…

I didn’t see any related error in the logs…

1.0.3 introduced binary_sensor for Motion. You’ll need to update the config.

1 Like

Did you update to the latest version?
If so you need to change to binary_sensor and adjust all template sensors to use that .

2 Likes

So sorry, I missed that part… never mind then lol
Thank you!

Just wanted to report that 1.0.3 is working great in my environment. Is there anything in particular you want feedback on or that we should be paying special attention to?

Also, may I ask what the device_tracker does? I have enabled it but don’t see anything Hue related in known_devices.yaml.

Question (maybe I missed a conversation there too but…)
Why bother changing to a binary sensor if temp and lx aren’t separate binary sensors as well and we still need to template those?

BTW, it works fine.

the main sensor now is a binary_sensor, where it before was a regular sensor. Discussion was concluded that that main motion sensor should be a binary_sensor. As result of that, all templated sensors now have to be created from that binary_sensor.

Admittedly a bit awkward, but just the way it is now.
Still hoping this CC will develop into automatic creation of these template sensors too, so we don’t have to do that manually either. Did suggest to @yottatsa already to have the user set flags in a configuration setting if templates are desired, and if yes for which attributes. Eg:

create_template: true
lx: true
temperature: true
light_level: false

etc
etc

1 Like

Thanks. I guess it’s one less template to create then lol

If I configure:

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

Should the motion sensors then automagically show up as binary_sensor (motion) entities?

I have done so, but I don’t see any motion sensors. Reverting back to 1.02 does show them.

yes indeed…

adding binary_ infront of all you sensors (and customizations, and templates sensors based in them) takes are off it.
Or, should take care of it…