Relay turns by itself

Hello everyone,

I have two channel Agara smart relay (with neutral) that i connected to light switch.
Sometimes (about 1 time in a day) it turns out by itself.

I have created an automation to catch the context and checks if light was turn on manually or by HA event:

alias: Turn off IsBathroomLightTurnedByMotion
description: Check YAML for conditions
trigger:
  - platform: device
    type: turned_on
    device_id: ae4e21bec7d71087ed4a201ada692bd5
    entity_id: f9b3e30e0af513263aa1952c7ca41b3f
    domain: switch
condition:
  - "{{ trigger.to_state.context.id != none }}"
  - "{{ trigger.to_state.context.parent_id == none }}"
  - "{{ trigger.to_state.context.user_id == none }}"
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.isbathroomlightturnedbymotion
trace:
  stored_traces: 15
mode: single

This is what I see in the traces that correlate with the mysterious event :slight_smile: :

this:
  entity_id: automation.turn_off_isbathroomlightturnedbymotion
  state: 'on'
  attributes:
    id: '1693350877372'
    last_triggered: '2023-09-03T02:05:11.408712+00:00'
    mode: single
    current: 0
    friendly_name: Turn off IsBathroomLightTurnedByMotion
  last_changed: '2023-08-31T19:18:56.507440+00:00'
  last_updated: '2023-09-03T02:05:11.409673+00:00'
  context:
    id: 01H9CCJWBGHSDST1FDMF595A57
    parent_id: 01H9CCJWBG269A4TFY3VW9MK7G
    user_id: null
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: device
  entity_id: switch.master_bedroom_l1
  from_state:
    entity_id: switch.master_bedroom_l1
    state: 'off'
    attributes:
      icon: mdi:lightbulb
      friendly_name: Main Light
    last_changed: '2023-09-03T03:03:55.362430+00:00'
    last_updated: '2023-09-03T03:03:55.362430+00:00'
    context:
      id: 01H9CFYDNRTS5T6T9QVQFX17MY
      parent_id: 01H9CFRXWQB1P62BQ8GX6G7JD2
      user_id: null
  to_state:
    entity_id: switch.master_bedroom_l1
    state: 'on'
    attributes:
      icon: mdi:lightbulb
      friendly_name: Main Light
    last_changed: '2023-09-03T03:20:51.973385+00:00'
    last_updated: '2023-09-03T03:20:51.973385+00:00'
    context:
      id: 01H9CGXEG52TNGZ2AEMJY61EQ5
      parent_id: null
      user_id: null
  for: null
  attribute: null
  description: state of switch.master_bedroom_l1

I am kind of new here and trying to understand if I can find a device or automation based on the parent_id:

  context:
    id: 01H9CCJWBGHSDST1FDMF595A57
    parent_id: 01H9CCJWBG269A4TFY3VW9MK7G
    user_id: null

Do you have any thoughts?