#Smart switch toggled off to on and presence issue

1 messages · Page 1 of 1 (latest)

drowsy radish
#

The challenge: I am sitting on the floor working on something the laundry room and its low enough to where the presence sensor cannot see me as there is a washer and dryer blocking it. There are times when I want the presence automation to not be triggered if I manually flipped the switch from off to on. I can see in the activity log me turning the switch off and on. So I need to some how create a way that if I manually toggle the switch that it stays on. I could even be ok with saying if presence already ran and I toggled it myself from off to on then stay on until I turn it back off manually then reactivate the check for presence. I tried this with a separate automation and script but couldn't quite get the right setup. So I am stumped on how to tackle this one.

burnt knoll
#

Easiest way is to create a toggle helper called “light override” or something like that. When you turn the lights on manually, you have an automation turn that override on too. When you turn the lights off manually, your automation turns that override off. You can determine if a person manually toggled the lights by using context: https://community.home-assistant.io/t/how-to-use-context/723136

Then in your motion detection automation, you have a condition check to make sure the override is off.

drowsy radish
#

Thanks I will review and see if I am able to get this to work.

drowsy radish
#
description: ""
triggers:
  - trigger: state
    entity_id:
      - switch.0xa4c138e43ad901d4
    from:
      - "off"
    to:
      - "on"
    id: LaundryLightSwitchOfftoOn
  - trigger: state
    entity_id:
      - switch.0xa4c138e43ad901d4
    from:
      - "on"
    to:
      - "off"
    id: LaundryLightSwitchOntoOff
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - LaundryLightSwitchOfftoOn
          - condition: template
            value_template: "{{ trigger.to_state.context.id != none }}"
          - condition: template
            value_template: "{{ trigger.to_state.parent_id != none }}"
          - condition: template
            value_template: "{{ trigger.to_state.context.user_id == none }}"
        sequence:
          - action: automation.turn_off
            metadata: {}
            target:
              entity_id: automation.laundry_room_switch_on_presence_detected
            data:
              stop_actions: true
      - conditions:
          - condition: trigger
            id:
              - LaundryLightSwitchOntoOff
          - condition: template
            value_template: "{{ trigger.to_state.context.id != none }}"
          - condition: template
            value_template: "{{ trigger.to_state.parent_id != none }}"
          - condition: template
            value_template: "{{ trigger.to_state.context.user_id == none }}"
        sequence:
          - action: automation.turn_on
            metadata: {}
            target:
              entity_id: automation.laundry_room_switch_on_presence_detected
            data: {}
#

This works and disables the automation and renables it. However it still activates even when presence automation runs.

drowsy radish
#

It is like it is ignoring all the conditions that I set for it to run.

#

Its just taking the fact that the presence sensor is turning an automation on for laundry light switch.

burnt knoll
#

trigger.to_state.parent_id is not correct. Use trigger.to_state.context.parent_id

#

you should be able to look at the automation trace after it triggers and see what is in trigger.to_state and also see which conditions matched and which ones didn't. That would have led you down the path of discovering that your condition is incorrect