Hi there,
I’m trying to distinguish how a light got switched on (tuya motion sensor or physical switch (through shell1 pm). The normal case is motion sensor and in my automation I want to make sure that I adhere to some logic when it was triggered by hand (light switch). In the forum I’ve seen that accessing trigger.to_state.context.parent_id == none (Work with "Triggered by" in automations - #8 by 123) gives some clues on how it got triggered. However, my problem is that my automation is in the context of a motion sensor and therefore I don’t have trigger.to_state.context of the light/shelly device, any advice?
Here my automation:
alias: Garage Light off
description: ""
trigger:
- type: no_motion
platform: device
device_id: xxx
entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_motion
domain: binary_sensor
condition:
- condition: template
value_template: >
{{ (as_timestamp(now()) -
as_timestamp(state_attr('automation.garage_light_on','last_triggered'), 0)
< 10 * 60)}}
action:
- type: turn_off
device_id: xxx
entity_id: switch.shelly_1pm_garage_switch_0
domain: switch
mode: single