I have been working on this and wanted to share what I think is a good solution, but also solicit feedback if anyone has suggestions for solving this is a better way.
I recognize that this is likely somewhat redundant with this discussion:
I am starting to document my Smart Home journey on my own website, and so have the description on my personal site.
Goal
- Have light in the large walk-in closet come on automatically when the motion sensor that monitors the door sees motion.
- Allow the light switch for the closet to turn off the closet light
- 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
- Generic Smart Home automation
- 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
- 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
- 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
- Hubitat Elevation is installed and running
- Hubitat Dashboard Built-In App is installed
- Hubitat Rule Machine 4.0 Built-In App is installed
Solution Description
- Install a Smart Wall Switch to control the light
- Install a Motion Sensor that registers doorway activity
- Pair both devices to Hubitat
- Inside Rule Machine Create 2 Global variables
- 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) - 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 - 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.
- 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)
- Create the required rules:
- Rule 1:
- When motion detected and Ignore Master Closet Sensor is False, then turn on the switch
- 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:
Many Tedious Steps
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 Done with this action
36. Click Select Action Type to Add to get drop down
37. Click Conditional Actions from the drop down
38. Click Select Which Action to get drop down
39. Click END-IF (conditions) THEN from the drop down
40. Click Done with this action
41. Click Done with Actions
42. 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:
- 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
Many Tedious Steps
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
-
Test the automation
-
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