What do you do when you’re going to sleep?

  • Switch off TV & Cable decoder / TiVo / etc
  • Switch off Lights
  • Check door locks
  • Switch off other devices

Why not automate this? In the mean time you can use this automation to keep track of when you go to bed and when you wake up.

Equipment

To tell the system that you’re going to sleep or wake-up:

  • Mount a motion sensor under your bed pointing to your side of the bed (if you’re usually the last person to go to sleep)
  • Mount a KAKU wall switch and label it “sleep” (on) and “awake” (off), like the AWST8800
  • (optional) To monitor a “wake up” state you can use a motion sensor in (for example) the livingroom.
    (if motion in the livingroom = the first wake-up)

Based on these sensors or switches a Homeseer device “Sleep state” will be set so the system knows if you’re sleeping or awake.

Automate?

Here’s an overview of the devices & events. The next chapter has the detailed steps & events.

  • Device: Device for sleep-state (on/off), sleep time (optional), wake-up time (optional)
  • Event SLEEP: triggered by the sleep-state device
    • turn off lights in livingroom except for 1
      (otherwise you’re standing in the dark – you could auto turn-off this light after 5 minutes)
      turn off equipment that’s not needed during your sleep
      check if all doors are locked (if you have that functionality. It’s on my wishlist)
    • write time in sleep time device (optional)
    • write sleep time in database (optional)
  • Event WAKE-UP: triggered by the sleep-state device
    • write time in wake-up device (optional)
    • write wake-up time in database (optional)
  • Event: (optional) reset (empty) sleep-time and wake-up time devices, if your sleep and wake-up times are recorded in devices.
  • Event: (optional) Record sleep/wake-up times in database

How

  • Device sleep/wake-up time: “status only”: S30 (Today wakeup) and S31 (Today sleep)
    these will be used to store the time when you woke up or went to sleep
    –> device S30 and S31
  • Device sleep/wake-up button: S32 (Sleep) which is controlled by a switch or motion sensor
  • Event “Sleep started” (triggered by the S32 Sleep device)
    condition
    : time after 21:59 and before 02:00  (to prevent accidental presses)
    action
    : &hs.setdevicestring “S31“,Mid(hs.stringitem(Now(),2,” “),1,Len(hs.stringitem(Now(),2,” “))-3)
                to set the Sleep start time in device S31 (see the S30/S31 screenshot example)
    action
    : DJ_DBlogging_05.vb(“Main”,”Presence|Sleep|ssS31|djdate|djtime|prname|prstate”)
                optional: write sleep time in database (using my Database script)

    condition
    : time after 22:00 and time before 02:00
    action
    : writelog “SLEEP”,”Pressed sleep button, going to sleep now”
                just to see that the script started in the Homeseer log.
    action
    : Run event: Turn off TV (through IR, Power or both)
    action
    : Device: Switch 1 light on
    action
    : Device: Switch other lights off
  • Event “Sleep RESET” at 21:58
    action: &hs.setdevicestring “S31“,”…”
                to clear the Sleep time device (string) that was recorded before
  • Event “Wake-up started” (triggered by Motion sensor in livingroom)
    condition
    : time after 05:00 and time before 09:00
                    to prevent accidental motion triggers. After 9am it should not be triggered, we’re early.
    action
    : &hs.setdevicestring “S30“,Mid(hs.stringitem(Now(),2,” “),1,Len(hs.stringitem(Now(),2,” “))-3)
                to set the Sleep start time in device S31 (see the S30/S31 screenshot example)
    action
    : &hs.setdevicevalue “S30“,1
                Sounds crazy, but I don’t know why I’m setting the device value to 1 here ;-)
    action
    : DJ_DBlogging_05.vb(“Main”,”Presence|Wakeup|ssS30|djdate|djtime|prname|prstate”)
                optional: write sleep time in database (using my Database script)
  • Event “Wake-up RESET” at 04:00

action: &hs.setdevicestring “S30“,”…”
            to clear the Wake-up time device (string) that was recorded before
action
: &hs.setdevicevalue “S30“,0
            Like the previous event: don’t know why I’m setting the device value

 

… Boy… All of that just to automate some actions and recording wake-up and sleeping times?

Comments are closed.