Motion Sensor/Closet Light Switch Conundrum

Goal

  1. Have light in the large walk-in closet come on automatically when the motion sensor that monitors the door sees motion.
  2. Allow the light switch for the closet to turn off the closet light
  3. Allow the light to be turned off remotely when a dog opens the closet door and it is inconvenient to go back to the closet

Challenge

  1. Generic Smart Home automation
  2. The switch that controls the light is located inside the closet itself and the closet door swings into the closet. As a result, when the goal is to turn off the light and then close the door, the motion detector registers motion and turns the light back on.

Options

  1. Relocate the motion sensor so that it is not triggered by using the switch or closing the door. This option was rejected because it caused too long a delay in turning on the light when someone is walking into the closet
  2. Use automation capabilities within Hubitat HE to turn on the light when normal motion has occurred, but to create a modifiable grace period after the switch turns off the light during which the motion sensor is ignored.

Common Assumptions

  1. Hubitat Elevation is installed and running
  2. Hubitat Dashboard Built-In App is installed
  3. Hubitat Rule Machine 4.0 Built-In App is installed

Solution Description

  1. Install a Smart Wall Switch to control the light
  2. Install a Motion Sensor that registers doorway activity
  3. Pair both devices to Hubitat
  4. Inside Rule Machine Create 2 Global variables
    1. Seconds of Delay For Master Closet (This will be used to specify how many seconds the motion sensor should be ignored for after the light is turned off)
      1. Type-Number
      2. Initial Value - 5 (seconds)
    2. Ignore Master Closet Sensor (This will be used to know whether to ignore motion sensor triggers to turn on the light)
      1. Type-Boolean
      2. Initial Value - False
  5. Inside Rule Machine Create Variable Connectors for these 2 variable. The connector is needed to display allow the dashboard to interact with the variables' values.
  6. Create a tile on a dashboard to show and allow alteration of the Seconds of Delay For Master Closet variable. (During initial building and troubleshooting I also built tiles for the motion sensor, light switch and the Ignore Master Closet Sensor variable, but these are not really needed for the process in the long run)
  7. Create the required rules:
    • Rule 1:


Original Version

Updated Version

      • When motion detected and Ignore Master Closet Sensor is False, then turn on the switch
      • I also had to update the rule because sometimes the motion sensor would be triggered by the action turning off the light and the portion of the rule to turn the light on would happen immediately after the light was turned off resulting in the light popping right back on. The image above shows the updated rule.
      • Because I found the Rule Machine interface confusing to build this rule, I wanted to put a step by step on how to build theis rule:
        1. Select Apps
        2. Select Rule Machine
        3. Select Create New Rule
        4. Name Rule
        5. Select Select Trigger Events
        6. Select Motion from the drop down
        7. Click the Motion sensors Click to Set
        8. Select the correct Motion Sensor
        9. Click the Update button or Motion sensors Click to Set
        10. By default the Motion becomes field should be active, but if not select if from the Motion becomes drop down
        11. Click Done with this Trigger Event
        12. Click Done with Trigger Events
        13. Click Select Actions to Run
        14. Click Select Action Type to Add to get drop down
        15. Click Conditional Actions from the drop down
        16. Click Select Which Action to get drop down
        17. Click IF (conditions) THEN from the drop down
        18. Click Click to set to get the Define condition drop down
        19. Click --> New Condition from the drop down
        20. Click Click to set to get the capability for Action Condition drop down
        21. Click Variable from the drop down
        22. Click Click to set to get Variable drop down
        23. Click the global variable created earlier from the drop down. In my case that is Ignore Master Closet Sensor
        24. Click Click to set to get the Boolean drop down
        25. Click False from the drop down
        26. Click Done with this Condition
        27. Click Done with Conditional Action
        28. Click Select Action Type to Add to get drop down
        29. Click Control Switches, Push Buttons
        30. Click Select Which Action to get drop down
        31. Click Turn Switches on
        32. Click Turn switches on to get list of switches
        33. Select the correct Switch
        34. Click Update
        35. Click Select Action Type to Add to get drop down
        36. Click Conditional Actions from the drop down
        37. Click Select Which Action to get drop down
        38. Click END-IF (conditions) THEN from the drop down
        39. Click Done with this action
        40. Click Done with Actions
        41. Click Done
    • Rule 2:
      • When the switch is turned off, set Ignore Master Closet Sensor to True, delay as many seconds as specified in Seconds of Delay For Master Closet then set Ignore Master Closet Sensor to False
      • Because I found the Rule Machine interface confusing to build this rule, I wanted to put a step by step on how to build this rule:
        1. Select Apps
        2. Select Rule Machine
        3. Select Create New Rule
        4. Name Rule
        5. Select Select Trigger Events
        6. Select Switch from the drop down
        7. Click the Switches Click to Set
        8. Select the correct switch
        9. Click the Update button or Switches Click to Set
        10. Click the Switch turns drop down
        11. Click off
        12. Click Done with this Trigger Event
        13. Click Done with Trigger Events
        14. Click Select Actions to Run
        15. Click Select Action Type to Add to get drop down
        16. Click Set Mode or Variables, Run Custom Action from the drop down
        17. Click Select Which Action to get drop down
        18. Click Set Variable from the drop down
        19. Click Click to set to get the Select Variable to Set drop down
        20. Click the global variable created earlier from the drop down. In my case that is Ignore Master Closet Sensor
        21. Click Click to set to get the options for the variable drop down
        22. Click True
        23. Click Done with this action
        24. Click Select Action Type to add to get drop down
        25. Click Delay or Repeat Actions, Wait from the drop down
        26. Click Select Which Action to get drop down
        27. Click Delay Actions from the drop down
        28. At this point if I wanted to come back and change the delay but modifying the rule directly you can, however, because I wanted it to be adjustable via the dashboard, I put the global variable (Seconds of Delay For Master Closet) into the Seconds field surrounded by % ie. %Seconds of Delay For Master Closet%
        29. Click Done with this action
        30. Click Select Action Type to add to get drop down
        31. Click Set Mode or Variables, Run Custom Action from the drop down
        32. Click Select Which Action to get drop down
        33. Click Set Variable from the drop down
        34. Click Click to set to get the Select Variable to Set drop down
        35. Click the global variable created earlier from the drop down. In my case that is Ignore Master Closet Sensor
        36. Click Click to set to get the options for the variable drop down
        37. Click False
        38. Click Done with this action
        39. Click Done with Actions
        40. Click Done

7. Test the automation

8. If the delay when the motion sensor will be ignored needs to be changed, then the variable's value either be changed inside Rule Machine or via the dashboard tile