#Sonoff switch automation

1 messages · Page 1 of 1 (latest)

polar shard
#

alias: Entrance_Light
description: Turn on the entrance light
trigger:

  • type: motion
    platform: device
    device_id: aeccbc62866ee282ae192697e3705b07
    entity_id: d6e5c440d8ae501a13de0cf0128b8cfa
    domain: binary_sensor
    id: MotionSensor3_Hallway_Detected
  • type: no_motion
    platform: device
    device_id: aeccbc62866ee282ae192697e3705b07
    entity_id: d6e5c440d8ae501a13de0cf0128b8cfa
    domain: binary_sensor
    id: MotionSensor3_Hallway_Cleared
    for:
    hours: 0
    minutes: 2
    seconds: 0
    condition:
  • condition: sun
    before: sunrise
    after: sunset
    before_offset: -01:00:00
    after_offset: -01:00:00
    action:
  • if:
    • condition: trigger
      id:
      • MotionSensor3_Hallway_Detected
        then:
    • type: turn_on
      device_id: a22119c5e75d3cba5ba96a39e2f7b22c
      entity_id: f35b3aa9e6106a487588ace83001e8bd
      domain: switch
      else:
    • if:
      • condition: trigger
        id:
        • MotionSensor3_Hallway_Cleared
          then:
      • type: turn_off
        device_id: a22119c5e75d3cba5ba96a39e2f7b22c
        entity_id: f35b3aa9e6106a487588ace83001e8bd
        domain: switch
        mode: single
#

alias: Entrance_Light_from_upstairs
description: Turn on the entrance light from upstairs
trigger:

  • type: motion
    platform: device
    device_id: b6768ec1f085ee7f1929773d33c5dae3
    entity_id: 8b35a5aea18064f332bc359c7db48840
    domain: binary_sensor
    id: MotionSensor4_Hallway_Detected
  • type: no_motion
    platform: device
    device_id: b6768ec1f085ee7f1929773d33c5dae3
    entity_id: 8b35a5aea18064f332bc359c7db48840
    domain: binary_sensor
    id: MotionSensor4_Hallway_Cleared
    for:
    hours: 0
    minutes: 3
    seconds: 0
    condition:
  • condition: sun
    before: sunrise
    after: sunset
    before_offset: -01:00:00
    after_offset: -01:00:00
    action:
  • if:
    • condition: trigger
      id:
      • MotionSensor4_Hallway_Detected
        then:
    • type: turn_on
      device_id: a22119c5e75d3cba5ba96a39e2f7b22c
      entity_id: f35b3aa9e6106a487588ace83001e8bd
      domain: switch
      else:
    • if:
      • condition: trigger
        id:
        • MotionSensor4_Hallway_Cleared
          then:
      • type: turn_off
        device_id: a22119c5e75d3cba5ba96a39e2f7b22c
        entity_id: f35b3aa9e6106a487588ace83001e8bd
        domain: switch
        mode: single
  • id: '1718231664600'
    alias: Hallway_temporary_lamp
    description: Turn on the entrance light from upstairs
    trigger:
    • type: motion
      platform: device
      device_id: b6768ec1f085ee7f1929773d33c5dae3
      entity_id: 8b35a5aea18064f332bc359c7db48840
      domain: binary_sensor
      id: MotionSensor4_Hallway_Detected
    • type: no_motion
      platform: device
      device_id: b6768ec1f085ee7f1929773d33c5dae3
      entity_id: 8b35a5aea18064f332bc359c7db48840
      domain: binary_sensor
      id: MotionSensor4_Hallway_Cleared
      for:
      hours: 0
      minutes: 3
      seconds: 0
      condition:
#
  • condition: sun
    before: sunrise
    after: sunset
    before_offset: -01:00:00
    after_offset: -01:00:00
    action:
    • if:
      • condition: trigger
        id:
        • MotionSensor4_Hallway_Detected
          then:
      • type: turn_on
        device_id: d1359a619afdc6b0460905931e9d3ab5
        entity_id: b8325217e48512071316c07325e9e70e
        domain: switch
        else:
      • if:
        • condition: trigger
          id:
          • MotionSensor4_Hallway_Cleared
            then:
        • type: turn_off
          device_id: d1359a619afdc6b0460905931e9d3ab5
          entity_id: b8325217e48512071316c07325e9e70e
          domain: switch
          mode: single
rough oriole
#

If you are using multiple sensors to detect if someone is in the area (hallway), I would start to create a binary sensor to merge them. It will greatly simplify the logic.

polar shard
rough oriole
#

No, it's just becoming unreadable/unmanageable... Help yourself, split the complexity 😉

#
{{ is_state("binary_sensor.helper_mi_smart_band_4_is_home","on") or
is_state("binary_sensor.helper_gsm_on_lan","on") or   
is_state("binary_sensor.helper_itrack_is_home","on") or
is_state("sensor.helper_phone_gps_home","Home") or
is_state("binary_sensor.helper_phone_ibeacon_home","on")
}}
#

Here is my "super boolean" which is true (or false) if i'm detected "home". That is super convenient. U can do the same for your presence sensors

rough oriole
#
condition: sun
  before: sunrise
  after: sunset

is it evaluated with 'OR' ...or both conditions must be true (AND) ... ??????