Skip to content

Send a text message when an appliance is turned on during certain times of the day

License

Notifications You must be signed in to change notification settings

Wilsh/powerdetect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

powerdetect

Purpose

This program was written to provide a notification when a remotely-located audio system is left on past a certain time of day. This is accomplished by triggering a button on a USB-connected gamepad via a low-voltage circuit that is activated when the audio system is on. If the gamepad button is triggered during a certain time, a text message is sent to a cell phone.

Method

Because of intermittent errors that arise from reading the gamepad input, a wrapper program is used to run the main program. To ensure continuous operation, the wrapper program will restart the main program when it exits. Errors, events, and the audio system's status are logged for a minimum of one week.

Configuration

  • Replace all instances of [path] with the absolute path of the powerdetect folder in the following files:

    • powerdetect.c
    • wrapper.c
    • cleanup.sh
    • powerdetect.sh
  • Change the macros PHONE and TEXTMESSAGE in powerdetect.c to the phone number to be notified and the message that will be sent.

    • The text message delivery service originally used for this program is no longer free. As a result, text messages are now sent via email using a carrier-specific email address (e.g. [email protected]).
  • Enable dependencies. For Debian-based systems:

sudo modprobe joydev
sudo modprobe analog
sudo modprobe xpad

The mail command must be operational.

  • Compile programs with make

  • Schedule scripts for automatic operation and weekly cleanup:

sudo crontab -e

Add these lines (replace [path] with the absolute path of the powerdetect folder):

@reboot [path]/powerdetect/powerdetect.sh
0 0 * * 1 [path]/powerdetect/cleanup.sh

About

Send a text message when an appliance is turned on during certain times of the day

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published