Philips hue motion sensor not triggering

hi all,
I’m fairly new to home Assistant… so apologies if I missed something quite obvious… I’ve searched through the forum without finding a previous or similar issue and all examples look straight forward. but i still can’t seem to trigger the light to come on upon motion being detected. Home Assistant can see my Philips hue motion sensor and is recorded in the log file when motion is detected. So I’ve started from the beginning again using the below config. rather than splitting out to scripts/ and automation/ if reverted back to using in the configuration.yaml.

automation:
alias: Motion Bathroom Light on
trigger:
- platform: state
entity_id: sensor.landing_motion_binary
to: ‘true’
action:
service: script.turn_on
entity_id: script.timed_light

script:
timed_light:
alias: “Turn on light and set timer”
sequence:
# Cancel ev. old timers
- service: script.turn_off
data:
entity_id: script.timer_off
- service: light.turn_on
data:
entity_id: light.bathroom
# Set new timer
- service: script.turn_on
data:
entity_id: script.timer_off

timer_off:
alias: “Turn off light after 1 minute - testing purposes”
sequence:
- delay:
minutes: 1
- service: light.turn_off
data:
entity_id: light.bathroom

below is the entry in my sensors.yaml

  • platform: rest
    resource: !secret rest_motion1
    value_template: ‘{{ value_json.state.presence }}’
    scan_interval: 2
    name: ‘Landing Motion Binary’

the below is the entry in home-assistant.log
16-12-27 18:12:58 homeassistant.loader: Loaded automation.state from homeassistant.components.automation.state
16-12-27 18:12:58 homeassistant.bootstrap: Setting up automation
16-12-27 18:12:58 homeassistant.components.automation: Initialized trigger Motion Bathroom Light on
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state automation.motion_bathroom_light_on=on; friendly_name=Motion Bathroom Light on, last_triggered=None @ 2016-12-27T18:12:58.023760+00:00>, entity_id=automation.motion_bathroom_light_on>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state group.all_automations=on; auto=True, friendly_name=all automations, order=18, entity_id=(‘automation.motion_bathroom_light_on’,), hidden=True @ 2016-12-27T18:12:58.027040+00:00>, entity_id=group.all_automations>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=automation, service=trigger>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=automation, service=reload>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=automation, service=toggle>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=automation, service=turn_on>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=automation, service=turn_off>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=automation>
16-12-27 18:12:58 homeassistant.bootstrap: Setting up script
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=script, service=timer_off>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=script, service=timed_lamp>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state script.timer_off=off; friendly_name=Turn off lamp after 10 minutes, can_cancel=True @ 2016-12-27T18:12:58.079180+00:00>, entity_id=script.timer_off>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state script.timed_lamp=off; friendly_name=Turn on lamp and set timer @ 2016-12-27T18:12:58.081179+00:00>, entity_id=script.timed_lamp>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state group.all_scripts=off; auto=True, friendly_name=all scripts, order=19, entity_id=(‘script.timed_lamp’, ‘script.timer_off’), hidden=True @ 2016-12-27T18:12:58.084189+00:00>, entity_id=group.all_scripts>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=script, service=turn_on>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=script, service=turn_off>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=script, service=toggle>
16-12-27 18:12:58 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=script>

The last few lines write to the log file as motion is detected
16-12-27 18:34:56 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=<state sensor.landing_motion_binary=False; friendly_name=Landing Motion Binary @ 2016-12-27T18:14:22.533997+00:00>, new_state=<state sensor.landing_motion_binary=True; friendly_name=Landing Motion Binary @ 2016-12-27T18:34:56.534222+00:00>, entity_id=sensor.landing_motion_binary>
16-12-27 18:35:08 netdisco.service: Scanning
16-12-27 18:35:14 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=<state sensor.landing_motion_binary=True; friendly_name=Landing Motion Binary @ 2016-12-27T18:34:56.534222+00:00>, new_state=<state sensor.landing_motion_binary=False; friendly_name=Landing Motion Binary @ 2016-12-27T18:35:14.534354+00:00>, entity_id=sensor.landing_motion_binary>
16-12-27 18:35:30 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=<state sun.sun=below_horizon; friendly_name=Sun, next_setting=2016-12-28T16:13:41+00:00, elevation=-19.7, azimuth=257.19, next_rising=2016-12-28T08:38:34+00:00 @ 2016-12-27T18:12:42.894947+00:00>, new_state=<state sun.sun=below_horizon; friendly_name=Sun, next_setting=2016-12-28T16:13:41+00:00, elevation=-19.85, azimuth=257.37, next_rising=2016-12-28T08:38:34+00:00 @ 2016-12-27T18:12:42.894947+00:00>, entity_id=sun.sun>

Triggering the automation in Home Assistant will turn on the light and it will turn off in 1 minute. But motion via th sensor is not working.

Any help / suggestions will be very welcome. I’ve been on this for the 2 days and losing my hair…

1 Like

has anybody got the Philips Hue motion sensor working with HA. I’ve found many more related posts here and tried all but still can’t get the sensor to switch on the light when motion detected. Thanks

Hi,

Your script seems fine and when you manually trigger the automation it works… then I would suspect this line in your automation
to: 'true'
mine return a value True/False (starting with uppercase) instead of true/false

Give a try with
to: 'True'

Seriously!! 3 days of pulling my hair out. That fixed it. Thanks Fabrice… Where do i send the pint of Guinness!

2 Likes

Great I got it! :beers: cheers :slight_smile:

Let me know how long your “motion automation” takes to turn on the light.
I am also using hue motion sensor with hue bulbs, for me it takes around 7-9 seconds to turn on.

It takes about 2 seconds when using automation: in the configuration.yaml file. When I had the automation split into separate automation.yaml and script.yaml - I noticed when i manually triggering the automation it would take approx 7 - 9 seconds. I’ll revert back to splitting the automation and test again tonight. I will let you know.

I’ve just tested using separate files and its about 2 - 3 seconds.

this is my automation/Landing_bathroom_motion.yaml

landing_bathroom_motion automation

alias: Motion Bathroom Light on
trigger:

  • platform: state
    entity_id: sensor.landing_motion_binary
    to: ‘True’
    condition:
  • condition: time
    after: ‘19:00:00’
    before: ‘06:00:00’
    action:
    service: script.turn_on
    entity_id: script.timed_light

… this is my scripts/timed_light.yaml

timed_light script

alias: "Turn on light and set timer"
sequence:
  # Cancel ev. old timers
  - service: script.turn_off
    data:
       entity_id: script.timer_off
  - service: light.turn_on
    data:
      entity_id: light.bathroom
      brightness: 150
  # Set new timer
  - service: script.turn_on
    data:
      entity_id: script.timer_off

… and my scripts/timer_off.yaml

timer_off script

alias: "Turn off light after 10 minutes"
sequence:
  - delay:
      minutes: 10
  - service: light.turn_off
    data:
      entity_id: light.bathroom

…and one :beer: for you

Thanks a lot, I think you are right about the way to split the configuration.yaml

with the delay of 7-9 seconds I was splitting the script this way in configuration.yaml
script: !include_dir_named script

Now I am splitting it like this
script: !include_dir_merge_named script
and it works as fast as when you manage it with the hue app

here is my automation in automation/kitchen_dining_motion_sensor.yaml

alias: Kitchen Dining Motion Sensor
trigger:
  - platform: state
    entity_id: binary_sensor.kitchen_hue_motion_sensor_motion
    to: 'on'
condition:
  - condition: time
    after: '23:00:00'
    before: '06:00:00'
action:
  - service: script.turn_on
    data:
      entity_id: script.kitchen_dining_motion_sensor

and my script in script/kitchen_dining_motion_sensor.yaml

kitchen_dining_motion_sensor:
  alias: Kitchen Dining Motion Sensor
  sequence:
    - service: script.turn_off
      data:
        entity_id: script.kitchen_dining_motion_sensor_timer
    - service: light.turn_on
      data:
        entity_id: light.kitchen
        brightness: 25
        color_temp: 500
        rgb_color: [122,74,14]
#        xy_color: 0.5612,0.4042
    - service: light.turn_on
      data:
        entity_id: light.dining
        brightness: 1
        color_temp: 500
        rgb_color: [21,9,0]
#        xy_color: 0.5609,0.4042
    - service: script.turn_on
      data:
        entity_id: script.kitchen_dining_motion_sensor_timer

kitchen_dining_motion_sensor_timer:
  alias: Kitchen Dining Motion Sensor Timer
  sequence:
    - delay:
        minutes: 1
    - service: light.turn_off
      data:
        entity_id: light.kitchen
    - service: light.turn_off
      data:
        entity_id: light.dining

that’s excellent!