Hue motion Sensor and Alarm

Hi guys,

Need your help concerning Hue Motion Sensor and Alarm.

I added in my configuration file a switch in order to turn on/off my Hue Motion Sensor

switch:
    platform: rest
    resource: http://IP/api/KEY/sensors/ID/
    name: 'Hue Motion Sensor Salon'
    method: put
    body_on: '{"config": {"on":true}}'
    body_off: '{"config": {"on":false}}'
    is_on_template: '{{ value_json.config.on == true }}'
    headers:
        Content-Type: application/json

Here my automations.yaml :

`- alias: 'Salon Hue Sensor Turn Off'
  trigger:
    platform: state
    entity_id: switch.hue_motion_sensor_salon
    from: 'on'
    to: 'off'
  action:
    service: telegram_bot.send_message
    data:
      message: 'Salon Hue Sensor Turned off'
      
- alias: 'Salon Hue Sensor Turn On'
  trigger:
    platform: state
    entity_id: switch.hue_motion_sensor_salon
    from: 'off'
    to: 'on'
  action:
    service: telegram_bot.send_message
    data:
          message: 'Salon Hue Sensor Turned on'
`

Now, I would like to put an alarm (https://www.home-assistant.io/integrations/manual) in order to arm or disarm this sensor.
But Iā€™m not sure about the relation between alarm control panel and the automations.yaml

Thanks for your help

Hue motion sensors are natively supported by the Philips Hue integration as binary sensors.

And how you can turned them off with native support !?

A motion Sensor cannot be turned off, it turns itself off after a defined time. Problem with Hue sensors is that they turn off quite quickly. You can use the ā€žforā€œ attribute in your automationā€˜s trigger to compensate.

Iā€™m sorry but iā€™m not agree with you.
With my switch (in my first post) I can turn off or on my sensor (aka when Iā€™m in my house, I donā€™t want that sensor detect me so I turn it off. Working well for the moment.

Ah, I see. Never tried that, but you could alternatively enable or disable the associated automation, based on your presence. Or you make your presence a condition in your automation.

Up !

Any idea ?

Objective :
Arm the alarm => activate Hue Motion Sensor
Disarm the alarm => deactivate Hue Motion Sensor

Hi @gautier23 !

Iā€™m working on a similar idea using Hue motion sensors to trigger an alarm.

You can see my draft progress in my config files there :

It looks a bit simpler than using a switch, so I donā€™t have to manually disable it, itā€™s automagically disabled based on presence.

Hope this inspires you :slight_smile:

fyi, Ive experimented in the past with the various options to switch the Hue motion sensors, and finally settled with these for all my motion sensors. I switch them on/off depending on the scenes and automations my House is in, and yes, when home mode away and alarm on, they are switched automatically accordingly. Works flawlessly:

      laundry_motion_sensor_switch:
        friendly_name: 'Laundry motion sensor switch'
        command_on: >
          curl -X PUT -d '{"on":true}' "http://192.168.1.212/api/dredactedQq/sensors/22/config/"
        command_off: >
          curl -X PUT -d '{"on":false}' "http://192.168.1.212/api/dredactedQq/sensors/22/config/"
        command_state: !secret get_laundry_config
        value_template: >
          {{value_json.config.on}}

which seemed to be the most reliable and lightest in the HA system. rest sensors take a lot of Ha and frequently cause issues (in my setup, so I use them a lightly as possible)ā€¦

switching these is as simple as any other regular switch. Not sure what your challenge is in that aspect?

to give you an idea:

  home_mode_locked_on:
    alias: 'Home mode Locked on'
    sequence:
      - service: input_select.select_option
        data:
          entity_id: input_select.theme
          option: 'darkred'
      - service: input_boolean.turn_on
        entity_id: input_boolean.motion_detection
      - condition: template
        value_template: >
          {{ is_state('input_boolean.home_mode_dogs_free', 'on')}}
      - service: switch.turn_off
        entity_id: switch.frontdoor_motion_sensor_switch
      - service_template: >
          script.alarm_arm_{{'home' if is_state('group.family','home') else 'away'}}

btw, Im using a reversed sequence: (automatically) selecting a home mode, which sets the motion sensors amongst others, and sets the alarm mode.

but, that really doesnā€™t matter. If you want to set the motion detection based on the state of the alarm, just use the alarm_panel state as trigger, and set the motion detection in a service_template based on the trigger.to_state.state.

1 Like

Hi @Twan,

I will check your solution quickly !
Thx for share anyway :slight_smile: much appreciated.

Gautier

1 Like

Hi @Mariusthvdb,

I want to try your solution to turn off/turn on my Hue Motion Sensor, but Iā€™m not sure about your code.
Sorry but Iā€™m novice with HA.
Do you have an example of how integrate your code :

      laundry_motion_sensor_switch:
        friendly_name: 'Laundry motion sensor switch'
        command_on: >
          curl -X PUT -d '{"on":true}' "http://192.168.1.212/api/dredactedQq/sensors/22/config/"
        command_off: >
          curl -X PUT -d '{"on":false}' "http://192.168.1.212/api/dredactedQq/sensors/22/config/"
        command_state: !secret get_laundry_config
        value_template: >
          {{value_json.config.on}}

Are you putting this code in configuration.yaml ? Under ā€œswitchā€ section ? Do I need to add ā€œplatform: command_lineā€ ?

Thanks for ur help :slight_smile: and have a great day.

sure, and yes, this is where you put these switches:

switch:
  - platform: command_line
    switches:
      laundry_motion_sensor_switch:
        friendly_name: 'Laundry motion sensor switch'
        command_on: >
          curl -X PUT -d '{"on":true}' "http://192.168.1.212/api/dredactedQq/sensors/22/config/"
        command_off: >
          curl -X PUT -d '{"on":false}' "http://192.168.1.212/api/dredactedQq/sensors/22/config/"
        command_state: !secret get_laundry_config
        value_template: >
          {{value_json.config.on}}

Thanks,

One question leads to anotherā€¦
My (hue) sensor are like that :
image

I adapted your code to fit mine variable :

switch:
  - platform: command_line
    switches:
      binary_sensor.capteur_salon_motion:
        friendly_name: 'Salon motion sensor switch'
        command_on: >
          curl -X PUT -d '{"on":true}' "http://IP/api/KEY/sensors/21/config/"
        command_off: >
          curl -X PUT -d '{"on":false}' "http://IP/api/KEY/sensors/21/config/"
        #command_state: !secret get_laundry_config
        value_template: >
          {{value_json.config.on}}

And got this error :

and get this error : Invalid config for [switch.command_line]: invalid slug binary_sensor.capteur_salon_motion (try binary_sensor_capteur_salon_motion) for dictionary value @ data['switches']. Got OrderedDict([('binary_sensor.capteur_salon_motion', OrderedDict([('friendly_name', 'Salon motion sensor switch'),

PS : ā€œget_laundry_configā€ is script that you call to obtain the state ?

you dont want binary_sensor in the switch name probablyā€¦

and this is my laundry config:

get_laundry_config: curl -X GET http://192.168.1.212/api/dmHredacted9pQq/sensors/22
1 Like