I have created a button to enable/disable the hue motion sensor. When checking the status, it does what is expected. The config.on value is changed between true and false
However, after setting it on, it doesnt switch on the lights anymore. The sensor detects movement but it doesnt do anything
When i go to the hue app->accesories, it apparently wakes up the lights and then, the lights are switched on when there is movement detected
I have copied the code from another message:
Has anybody had this problem before? Do i need to call any other endpoint to re-enable the lights integration?
The usual way to do that is to create an input_boolean that serves to indicate when the motion sensor should be used and when it should be ignored.
For example, here’s a basic automation to turn on a light when motion is detected and turn it off if there’s no motion for at least 1 minute:
alias: example
trigger:
- platform: state
entity_id: binary_sensor.bathroom_motion
to: 'on'
- platform: state
entity_id: binary_sensor.bathroom_motion
to: 'off'
for: '00:01:00'
action:
- service: 'light.turn_{{ trigger.to_state.state }}'
target:
entity_id: light.bathroom
If I want to prevent the motion sensor from controlling the light, I add a State Condition to detect the input_boolean’s state. If it’s on then the automation’s action is allowed to execute. If it’s off, the action is disallowed.
alias: example
trigger:
- platform: state
entity_id: binary_sensor.bathroom_motion
to: 'on'
- platform: state
entity_id: binary_sensor.bathroom_motion
to: 'off'
for: '00:01:00'
condition:
- condition: state
entity_id: input_boolean.motion_enabled
state: 'on'
action:
- service: 'light.turn_{{ trigger.to_state.state }}'
target:
entity_id: light.bathroom
By simply turning on/off the input_boolean (via the UI) I can permit or ignore the motion sensor’s activity.
You can create an input_boolean via Configuration > Helpers > Add Helper > Toggle
That’s interesting. My use case is more or less this one. I want the sensor to control the lights, but there will be some scenarios where I want to switch off the sensor and keep the lights on when if there’s no movement
I agree with @123 - if your lights are controlled through HA, it’s probably best to have a simple input_boolean and use it as a condition in your automations.
The reason why I wanted to disable the sensor is that in my case all my lights are Hue lights and they’re directly turned on by the sensor through the Hue app/bridge.