The Ultimate Smart Home Automation Cookbook

Goodnight Automation is a practical and essential feature for any smart home, providing the perfect way to end your day. While setting up our smart home hub, we established a Night mode but left its activation flexible due to the subjective nature of adult bedtimes. The versatility of Goodnight Automation comes into play here, allowing for manual control over when your home transitions into Night mode. This is especially useful for those nights when routines vary, such as during special events like New Year’s Eve or date nights. You wouldn’t want your home switching to Night mode unexpectedly during these occasions.

With Goodnight Automation, you have the power to manually activate Night mode at your convenience. This automation not only switches the mode but also takes care of turning off all the lights, locking the doors, and setting the thermostat to your preferred nighttime setting. The integration of Goodnight Automation into your smart home setup ensures that your home responds to your lifestyle, rather than dictating it.

Additionally, Goodnight Automation includes the use of a virtual switch, enhancing its flexibility and user-friendliness. This virtual switch can be integrated with your voice assistant, allowing for voice commands to activate the automation. Alternatively, it can be assigned to a button action for even easier access. This level of customization makes Goodnight Automation not just a utility, but a personalized experience that adapts to your unique living habits, ensuring your home is always in sync with your needs.

Automation Details

Required Devices

  • Virtual Device
  • Smart Lighting
  • Smart Locks
  • Smart Thermostats

Triggers:

  • Virtual Switch Turns On

Conditions:

  • Don't Turn Off Bathroom Lights If Occupied

Actions:

  • Set Mode to Night
  • Turn Off All Lights
  • Lock All Doors
  • Lower Thermostat

Important: We are going to be using our All Lights group. Check out this automation to learn how to Create Groups.

We'll only cover a few options for this automation, but the possibilities are endless. You could implement your TVs, Garage door opener, or any device you want.

Novice
Novice

Hubitat

Goodnight Automation

The Official Documentation for Rule Machine

Setting Up the Automation

  1. First, go to Devices and then click Add Device.

    Hubitat Device Screen
  2. Click the Virtual button.

    Hubitat Add Device Screen
  3. Add the Device Name and Device Label.  Of course, you could enter the Device Name, but I like to use that to remind me what it is.  Then the label is the name of the device.

    Hubitat New Virtual Device Screen
  4. For the Device Type select Virtual Switch from the drop-down.

    Hubitat New Virtual Device Type
  5. Add the device to a Room and click Save Device.

    Hubitat New Virtual Device Save
  6. On the Device screen set Enable Auto off for 1 second and click Save Preferences.

    Hubitat Device Settings Screen
  7. Next, go to Apps and click Rule Machine.

    Hubitat App Screen
  8. Select Create New Room Lights Automation…

    Hubitat Rule Machine Screen
  9. Enter a name for the Rule and hit Enter.

    Hubitat Rule Machine Name Screen
  10. Select Trigger Event.

    Hubitat Rule Machine Select Trigger
  11. From the Capability drop-down, select Switch.

    Hubitat Rule Machine Select Capability Trigger
  12. Do the following:

    1. From the Switches drop-down, select the virtual switch we created earlier.
    2. From the Switch Action drop-down make sure it’s set to On.
    3. Then click the Done with this Trigger Event.

    Hubitat Rule Machine Select Switch Trigger Finished
  13. On the Select Trigger Events page, click Don with Trigger Events.

    Hubitat Rule Machine Triggers Finished
  14. Select Actions to Run.

    Hubitat Rule Machine Select Actions
  15. Then click Create Conditions.

    Hubitat Rule Machine Actions Create Conditions
  16. From the Select capability for new Condition drop-down, select Contact.

    Hubitat Rule Machine Actions Select Capability
  17. From the Contact sensors drop-down select our bathroom door sensor, make sure Contact is set to open and click the Done with this Condition button.

    Hubitat Rule Machine Actions Conditions Finished
  18. Then on the Manage or Create Conditions screen, click Done with Conditions.

    Hubitat Rule Machine Actions Conditions Finished
  19. Select the Green Plus Sign to Add New Action.

    Hubitat Rule Machine Actions Add Action
  20. In the Select Action Type drop-down, select Set Mode option.

    Hubitat Rule Machine Actions Select Action Type
  21. Set the following Action settings:

    1. In the Select Which Action, select the Set Mode option.
    2. In the Set the mode drop-down select Night.
    3. Then click the Done with Action button.

    Hubitat Rule Machine Actions Settings
  22. Again,  select the Green Plus Sign to Add New Action.

    Hubitat Rule Machine Actions Add Action
  23. In the Select Action Type drop-down, select Control Switches option.

    Hubitat Rule Machine Actions Select Action Type
  24. Set the following Action settings:

    1. In the Select Which Action, select the Turn switches on/off option.
    2. Next, in the Switches to turn off drop-down, select the All Lights group.
    3. Make sure the Turn on or off switch is set to Off.
    4. Then click the Done with Action button.

    Hubitat Rule Machine Actions Settings
  25. Again,  select the Green Plus Sign to Add New Action.

    Hubitat Rule Machine Actions Add Action
  26. In the Select Action Type drop-down, select Control Locks.

    Hubitat Rule Machine Actions Select Action Type
  27. Set the following Action settings:

    1. In the Select Which Action, select the Lock/Unlock locks option.
    2. Make sure the Lock or Unlock switch is set to Lock.
    3. Next, in the Lock these locks drop-down, select select all of our locks.
    4. Then click the Done with Action button.

    Hubitat Rule Machine Actions Settings
  28. Once again,  select the Green Plus Sign to Add New Action.

    Hubitat Rule Machine Actions Add Action
  29. In the Select Action Type drop-down, select Control Thermostats.

    Hubitat Rule Machine Actions Select Action Type
  30. Set the following Action settings:

    1. In the Select Which Action, select the Set thermostats option.
    2. Select your thermostat.
    3. set the heating and cooling set points.
    4. Then click the Done with Action button.

    Hubitat Rule Machine Actions Settings
  31. Again,  select the Green Plus Sign to Add New Action.

    Hubitat Rule Machine Actions Add Action
  32. In the Select Action Type drop-down, select Conditional Actions.

    Hubitat Rule Machine Actions Select Action Type
  33. Set the following Action settings:

    1. In the Select Which Action, select the IF Expression THEN option.
    2. In the Define Expression element drop-down, select the Condition we created earlier.
    3. Then click the Done with IF Expression Then button.

    Hubitat Rule Machine Actions Select Action
  34. One last time,  select the Green Plus Sign to Add New Action.

    Hubitat Rule Machine Actions Add Action
  35. In the Select Action Type drop-down, select Control Switches option.

    Hubitat Rule Machine Actions Select Action Type
  36. Set the following Action settings:

    1. In the Select Which Action, select the Turn switches on/off option.
    2. Next, in the Switches to turn off drop-down, select the bathroom lights.
    3. Make sure the Turn on or off switch is set to Off.
    4. Then click the Done with Action button.

    Hubitat Rule Machine Actions Select Action
  37. Select END-IF and click the Done with Actions button.

    Hubitat Rule Machine Actions End If
  38. Then click Done to finish the Automation.

    Hubitat Rule Machine Automation Complete

Home Assistant

Goodnight Automation

The Official Documentation for Automation editor

Setting Up the Automation

  1. First, we need to go to Settings and Devices & Services.

    Home Assistant Settings Screen
  2. At the top of the screen, click Helpers, then the blue Create Helper button at the bottom.

    Home Assistant Create Helper
  3. In the Create helper pop-up window, select Toggle.

    Home Assistant Create Helper
  4. Name the virtual switch.  Then click Create.

    Home Assistant Create Toggle
  5. Next, we need to go to Settings and Automations & Scenes.

    Home Assistant Settings Screen
  6. Click the blue Create Automation button.

    Home Assistant Automations Screen
  7. Choose Create new automation.

    Home Assistant Create Automation Screen
  8. Click Add Trigger.

    Home Assistant New Automation Screen
  9. From the list, select State.

    Home Assistant Trigger State
  10. In the Entity box select our virtual switch we created earlier and set the “To” option to On.  Then click the Add Action button.

    Home Assistant Trigger Virtual Switch On
  11. From the Action type list, select Call service.

    Home Assistant Actions Call Service
  12. Perform the following actions:

    1. In the Service drop-down, select Input select: Select.
    2. Click the Choose entity button
    3. select our Mode helper.
    4. In the Options to be selected, type Night.
    5. Then click the Add Action button.

    Home Assistant Actions Turn Off Group
  13. From the Action type list, select Call service.

    Home Assistant Actions Call Service
  14. In the Service drop-down select Light: Turn off.  Click the Choose entity button and select our All Lights Group.  Then click Add Action.

  15. From the Action type list, select Device.

    Home Assistant Actions Device
  16. We will be adding three devices as follows:

    1. Select our locks and for the Action choose Lock.
    2. Then we’ll select our Smart Thermostat.
    3. We’ll set the Action to “Change My ecobee Current Mode option”.
    4. Set the Option to sleep.
    5. Then click the Add Action button.

    Home Assistant Actions Add Devices
  17. From the Action type list, select If-then.

    Home Assistant Actions If-Then
  18. Click the Add Condition button.

    Home Assistant Actions Add Condition
  19. From the list, select the Device option.

    Home Assistant Condition Select Device
  20. In the Device drop-down, select our bathroom door contact sensor, set the condition to open, and then click the Add Action button.

    Home Assistant Condition Add Device
  21. From the Action type list, select Call service.

    Home Assistant Actions Add Action Call Service
  22. In the Service drop-down, select Light: Turn off.  Next, click the Choose device button and select our bathroom lights.  Then click the Add Action button outside the if statement.

    Home Assistant Actions Turn Off Bathroom Lights
  23. From the Action type list, select Call service. Then in the Service drop-down select Input Boolean: Turn off.  Then click Choose entity and select our virtual switch we created earlier.

    Home Assistant Actions Select Virtual Switch
  24. Our completed action list should look like this.

    Home Assistant Complete Action List
  25. At the bottom right corner, click the blue Save button.  Next, name the automation and click save again.

    Home Assistant Name and Save Automation

Amazon Alexa

Goodnight Automation

The Official Documentation for Alexa Routines

This routine will use the Virtual Switch we shared with Alexa from the other hubs.

Setting Up the Automation

  1. First, Click the More button at the bottom right of the screen.

    Alexa Home Screen
  2. Click the Routines button.

    Alexa More Menu
  3. Click the plus sign to add a new routine.

    Alexa Routines Screen
  4. Click the plus sign by Enter routine name.

    Alexa New Routine Screen
  5. Enter a name for the routine and click next.

    Alexa Routine Name
  6. Click the plus sign by When this happens.

    Alexa New Routine Screen
  7. On the When This Happens screen, click Voice.

  8. You can just enter the phrase you want to trigger this routine and click Next.

    Alexa Trigger Voice
  9. Click the plus sign by Add action.

    Alexa New Routine Screen
  10. On the Add New screen, select Smart Home.

    Alexa Add New Action Menu
  11. Scroll to the bottom and select All Devices.

    Alexa Action Smart Home Menu
  12. Please scroll through the list of devices till you find our Goodnight virtual switch we shared with Alexa.

    Alexa Action Select Device
  13. Ensure it set to turn On and click next.

    Alexa Device Switch Settings
  14. Click Save to complete the routine.

    Alexa Complete Routine