ZHA - Use Philips Hue SML001 as Occupancy Sensor for light control

Hi @pjmbarlick,
Currently you can only pick one entity for the lights, but you can put a number of lights into a group and then select the group entity.
That’s how I am using to for my garage, that has three separate lights in it e.g.

- platform: group
  name: Garage Light Group
  entities:
    - light.garage_ceiling_front
    - light.garage_ceiling_rear
    - light.garage_ceiling_middle

and then use light.garage_light_group for the light entity in the Blueprint.

Hello

I bought Ikea motion sensors and then realized about the 120s or more of refresh time. It is really annoying

So with this blueprint and a philips motion sensor I can use it properly like with no delays. So when I leave the motion sensor I receive that event instantly (or within few seconds) to turn off the light or whatever I want?

Is the luminance sensor required for this to work or I can ignore it?

@Rachdingue Yes. When used with the Philips motion sensor the occupancy will be detected immediately and you can program the occupied to unoccupied delay to be just a few seconds.

The blueprint requires a luminance sensor as it stands, but you can remove the sensor from the input: section and any references to it from the action: section if you do not want to use it.

1 Like

I just imported this, deleted the automation I had linked to the motion detector, created the automation from the blue print… and it doesn’t work for me. I am not sure what is what…

Hi @keithterrill,
Are you able to be a bit more specific about “doesn’t work for me”?
What doesn’t work? Have you used the automations trace view to see what is happening?
Can you post the entry that was created in your automations.yaml file (the one that uses this blueprint) or click the “Download trace” button and share the trace.
Maybe I can give some hints on what might not be working if I can see that.

I have many many years of computer hardware and software experience. However, I am a noob when it comes to Home Assistant having just picked it up around Thanksgiving time.

I set this up, I thought, to turn on the sink light when I entered the room. It doesn’t come on, except it did this morning when I went through the room… just the one time.

I am not even sure what I am looking at, nor if this is of any help to you.

Blueprint Config

id: '1640310369664'
alias: Occupancy Detection Response (SML001)
description: ''
use_blueprint:
  path: WizBangCrash/occupancy-response-sml001.yaml
  input:
    sensitivity: 2
    ieee_id: 00:17:88:01:09:19:4b:ad
    occupancy_entity: binary_sensor.philips_sml001_ad4b1909_occupancy
    illuminance_entity: sensor.philips_sml001_ad4b1909_illuminance
    light_entity: light.sink_light_level_light_color_on_off
    luminance_value: 4
    nighttime_brightness: 40

Automation Config

variables:
  ieee_id: 00:17:88:01:09:19:4b:ad
  disable_entity: {}
  media_entity: {}
mode: single
trigger:
  - platform: homeassistant
    event: start
  - platform: state
    entity_id: binary_sensor.philips_sml001_ad4b1909_occupancy
condition:
  - alias: Exit if sensor is disabled
    condition: template
    value_template: >-
      {{ True if not disable_entity else is_state(disable_entity.entity_id,
      'off') }}
  - alias: Exit if media player on
    condition: template
    value_template: >-
      {{ True if not media_entity else is_state(media_entity.entity_id, 'off')
      }}
action:
  - alias: What caused the trigger?
    choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.platform == ''homeassistant'' }}'
        sequence:
          - service: zha.set_zigbee_cluster_attribute
            data:
              ieee: '{{ ieee_id }}'
              endpoint_id: 2
              cluster_id: 1030
              cluster_type: in
              attribute: 16
              value: 180
          - service: zha.set_zigbee_cluster_attribute
            data:
              ieee: '{{ ieee_id }}'
              endpoint_id: 2
              cluster_id: 1030
              cluster_type: in
              attribute: 48
              value: 2
      - conditions:
          - condition: template
            value_template: |
              {{
                trigger.platform == 'state'
                and trigger.to_state.state == 'on'
              }}
          - condition: numeric_state
            entity_id: sensor.philips_sml001_ad4b1909_illuminance
            below: 4
        sequence:
          - alias: Night time or day time?
            choose:
              - conditions:
                  - condition: time
                    after: '22:00:00'
                    before: '07:00:00'
                sequence:
                  - service: light.turn_on
                    entity_id: light.sink_light_level_light_color_on_off
                    data:
                      brightness_pct: 40
                      kelvin: 3000
            default:
              - service: light.turn_on
                entity_id: light.sink_light_level_light_color_on_off
                data:
                  brightness_pct: 75
                  kelvin: 4500
      - conditions:
          - condition: template
            value_template: |
              {{
                trigger.platform == 'state'
                and trigger.to_state.state == 'off'
              }}
        sequence:
          - service: light.turn_off
            entity_id: light.sink_light_level_light_color_on_off
    default: []
id: '1640310369664'
alias: Occupancy Detection Response (SML001)
description: ''

@keithterrill It looks like the Blueprint Config is set up correctly, so we need to understand if the automation is ever being triggered and if it is, what is occurring.
Have you used the “Debug Automation” function before (the middle icon of the three icons shown to the right of the automation listed in the Automations View)?

Screenshot 2022-01-04 at 23.00.55

Click on this button and see if the automation has been triggered. Refer to the documentation on debugging automations here: Troubleshooting Automations - Home Assistant

Feel free to click the trace download button and send me a trace if it’s not making any sense.

1 Like

Hi, i have been using your Blueprint successfully for the past 3 weeks and it worked so far, flawlessly! Thanks for that!

Now i want to manually enable/disable the sensor. I want to enable/disable the sensor with a Hue Dimmer v2 (using this blueprint ZHA - Philips Hue v2 Smart Dimmer Switch and Remote - RWL022). I can already manually turn on&off the lights, but this automation keeps turning the lights off after the timeout i set (as it should to this point, so no problem thus far).

Now I created two helpers (Type - Toggle), one for enabling and one for disabling the sensor and added it to this automation like in your screenshot.
My problem is how to trigger this boolean correctly? In the dimmer blueprint i selected “Action Type - Condition → Condition Type - State → Entity - input_boolean.disable_sensor → State - on”. After saving the automation and pressing the power button two times (thats how i configured it for now) nothing changes, the occupancy sensor is still detecting occupancy.

Any help would be greatly appreciated and I hope my problem was appropiately described.

Hi, thanks for this blueprint. i was also stuck when trying to use the standard Hue motion one as it seems to be linked to the wrong entity in the SML001.

The issue i am having, that i don’t see anyone else reporting, is that the light only stays on for the time that occupancy is detected by the sensor. the 180s delay is ignored. i have changed other delay time periods but it always seems to go off after about 5-10s unless there is continuous movement.

No-one else seeing this?

1 Like

I actually came back here because I have noticed the exact same issue, tried playing around with the settings and config a bit. But unfortunately I can’t get it to work myself.

i got this working fine in the end. My issues was that i had this automation and Adaptive Lighting fighting over the same lights. once i removed the adaptive lighting settings for this light it started working fine

are people still using this blueprint? does it work reliably like it would using a hue bridge? I just added a Phillips hue motion sensor using a conbee 2 with zha and it kind of seemed overly sensitive to triggering with occupancy I guess with this blueprint it can be fine tuned and work well? or has anyone switched over to zigbee2mqtt which i heard the hue sensor works well out of the box?

Hi there.
I recently added all my devices to ZHA instead of Philips bridge. And now trying the blueprint for the sensor. I am seeing the same issue as you where the light is only on while the occupancy is detected and turns off quickly after, the timeout 180 is not used. Did you ever find a fix for this.? Looks like there is not a lot of blueprints for the sensor or at least I can’t find them :grinning_face_with_smiling_eyes:

Now see you mention adaptive lighting was the cause. Here I just have a group of lights, mixed ikea / hue that turns on by the sensor and turn off again 10 seconds after instead of waiting the 180.

1 Like

yeah this is all working well for me still. Yes in my case i believe it was adaptive lighting that was conflicting with the timeout period. But for you and in general there must be something else that is also trying to control your bulbs and conflicting with the timeout settings

I haven’t used this Blueprint in a long while (I ended up going back to the Hue Bridge as ZHA is still not stable enough for my liking). Are you sure you have input the motion sensor Zigbee network id correctly? The default timeout 10s if I remember correctly, so if the 180s is not working it sounds like the unoccupied settings have not been programmed in the sensor.

Hi @wizbang :slight_smile:

you could get the Zigbee ieee device id as described here: Best way to get ZHA device ieee address?

best wishes :slight_smile:
Jesko

1 Like

Edit - just made my own blueprint instead. It automatically finds the ieee address and simplifies a few things.

Thanks for your blueprint which inspired mine.

Thanks your’e a hero

I do experience the exact samme issue as well, using Z2M to handle all of my devices through SkyConnect.
Found a way around the issue yet? :smiley:

I’ve solved it now on my end. This is the solution I ended up with, having the lights turned on for 60 seconds.
I hope this helps other users who are struggling with the Z2M setup as it seems the cluster function in this blueprint is the issue (just guessing here).