- An installation of MagicMirror2
-
Navigate to the MagicMirror/modules directory.
-
Execute
git clone https://github.com/dbeltjr/MMM-TouchAlarm.git
-
Configure the module as per below
-
Restart MagicMirror
{ module: 'MMM-TouchAlarm', position: 'bottom_left', config: { snoozeMinutes: 10, // I want to snooze longer alarmTimeoutMinutes: 5, // Stop the alarm automatically after 5 minutes alarmSoundFile: 'blackforest.mp3', // Play some birds alarmSoundFadeSeconds: 60 // Increase the volume slowly // ... } }
-
If you hit snooze, the alarm time will be updated. So the next day you have to reset the alarm and reduce it by the snoozed time.
-
If you close an alarm it will not be automatically reset for the next day, you'll have to click the bell again.
Option | Default | Description |
---|---|---|
minutesStepSize |
5 |
Increasing/Decreasing the minutes in the configuration screen with this step size. |
snoozeMinutes |
5 |
Alarm will be fired again in x minutes after snoozing. |
alarmTimeoutMinutes |
5 |
Stop the alarm automatically after this amount of minutes. |
--- | --- | --- |
alarmSound |
true |
Should an alarm sound be played. |
alarmSoundFile |
'alarm.mp3' |
Name and extension of your alarm sound. File needs to be placed in ~/MagicMirror/modules/MMM-TouchAlarm/sounds . Standard files are alarm.mp3 and blackforest.mp3 . Alternatively specify a web stream http or https . |
alarmSoundMaxVolume |
1.0 |
The maximum volume of alarm (between 0.0 and 1.0). |
alarmSoundFade |
true |
Should the alarm sound file be faded. |
alarmSoundFadeSeconds |
30 |
Within how many seconds should the alarm reach the configured alarmSoundMaxVolume . |
Expert Options | ||
debug |
false |
If set to true it will show some debug information in the console. |
alarmStoreFileName |
alarm.json |
File name to store information even if the Magic Mirror restarts. |
There are already two alarm sounds:
- alarm.mp3 | From Alexander licensed under CC BY-NC 4.0
- blackforest.mp3 | From Alexander licensed under CC BY-NC 4.0
MMM-TouchAlarm-ALARM-CHANGED
-> will sendhour
: number,minutes
: number,active
: boolean,nextAlarm
: moment-timestampMMM-TouchAlarm-ALARM-FIRED
-> will sendhour
: number,minutes
: numberMMM-TouchAlarm-ALARM-SNOOZE
-> will sendhour
: number,minutes
: number
Caveat - This was created for a Raspberry Pi 3B+ with the official 7" Touch Screen and may need to be adjusted for any other particular application
- Go to home directory
cd ~
- Install jq
sudo apt-get install jq
-
Move
update_cron.sh
to your home directory -
Edit script to put in proper file paths
sudo nano update_cron.sh
-
Modify these two lines for proper file path to alarm.json:
newHour=$("$jqPath" -r '.hour' /home/dietpi/MagicMirror/modules/MMM-TouchAlarm/alarm.json) newMinutes=$("$jqPath" -r '.minutes' /home/dietpi/MagicMirror/modules/MMM-TouchAlarm/alarm.json)
-
If a different command needs to be used in cron to adjust screen brightness, it must be edited in the script as well under:
# Construct the new cron entry cron_entry="$newMinutes $newHour * * * /usr/bin/sudo sh -c 'echo \"255\" > /sys/class/backlight/rpi_backlight/brightness'"
-
Save and Exit
-
Execute
sudo chmod +x update_cron.sh
to ensure script has execute permission -
Edit Cron under root user
sudo crontab -e
-
Add the following at the end of crontab:
30 21 * * * /usr/bin/sudo sh -c 'echo 10 > /sys/class/backlight/rpi_backlight/brightness' */10 * * * * /home/dietpi/update_cron.sh # This is my special cron job 0 6 * * * /usr/bin/sudo sh -c 'echo 255 > /sys/class/backlight/rpi_backlight/brightness'
This reduces the screen brightness to "10" at 9:30 PM and then runs the update_cron.sh every 10 minutes. It copies the hour and minutes from alarm.json and updates the cron task after the phrase "# This is my special cron job" Anything edited below "# This is my special cron job" will be deleted and re-added each time the alarm is changed.
-
Save and Exit crontab