Hello,
I have installed a few Shelly Blu Motion devices to control the lights automatically. Additionally, I would like to be able to manually operate the light switch in a classic way when needed, and the light should not turn off automatically. To achieve this,
I have created a rule that works quite well. I found some code snippets here.
If the light is already on automatically and I press the light switch too quickly (on/off/on), my manual rule is not activated, and the light automatically turns off after a while. Here is my code.
Any ideas? Thanks in advanced
alias: Light manual
description: ""
triggers:
- trigger: state
entity_id:
- switch.shelly_1_switch_0
to: "on"
- trigger: state
entity_id:
- switch.shelly_1_switch_0
to: "off"
conditions:
- condition: template
value_template: "{{ trigger.to_state.context.id != none }}"
- condition: template
value_template: "{{ trigger.to_state.context.parent_id == none }}"
- condition: template
value_template: "{{ trigger.to_state.context.user_id == none }}"
actions:
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.auto_light_on
- action: notify.persistent_notification
metadata: {}
data:
title: test
message: |
"ID. | Parent | user"
to_state: {{ trigger.to_state }}
context.id: {{ trigger.to_state.context.id }}
context.parent_id: {{ trigger.to_state.context.parent_id }}
context.user_id: {{ trigger.to_state.context.user_id }}
enabled: true
mode: single
alias: Light on automatically
description: ""
triggers:
- type: motion
device_id: 123
entity_id: 987
domain: binary_sensor
trigger: device
conditions:
- condition: state
entity_id: switch.shelly_1_switch_0
state: "off"
- condition: numeric_state
entity_id: sensor.bthome_sensor_6749_illuminance
below: 1
actions:
- type: turn_on
device_id: 456
entity_id: 654
domain: switch
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.auto_light_on
mode: single
alias: Light off automatically
description: ""
triggers:
- type: no_motion
device_id: 123
entity_id: 987
domain: binary_sensor
trigger: device
conditions:
- condition: state
entity_id: switch.shelly_1_switch_0
state: "on"
- condition: state
entity_id: input_boolean.auto_light_on
state: "on"
actions:
- type: turn_off
device_id: 456
entity_id: 654
domain: switch
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.auto_light_on
mode: single