Today, I was working on a project, and I came across this thing called Asterisk. It is a pretty cool open-source framework for building communications applications. I wanted to set it up so that when it’s getting dark outside, Asterisk will automatically trigger some actions, such as turning on the lights or playing some relaxing music. Let’s call it “aster twilight” for now.
Get Asterisk up and running
First, I had to get Asterisk up and running on my server. I followed the instructions on their website, which were pretty straightforward. Basically, I just downloaded the source code, compiled it, and installed it. This took a while, but it was not too difficult.

Once I had Asterisk installed, I needed to configure it. I spent some time reading the documentation and playing around with the configuration files. There are a lot of options, but I was able to figure out the basics pretty quickly.
Mess with cron
Next, I needed to find a way to determine when it was getting dark outside. I did some research and found a handy Linux utility called cron. This tool allows you to schedule commands to run at specific times. Perfect! Then, I messed with cron to see when is the actual time for twilight.
Write some scripts
Now it’s time to write some scripts. I wanted to use Asterisk’s AGI (Asterisk Gateway Interface) to interact with external programs. This way, I could have more control over what happens during twilight. I wrote a simple script that would:
- Get the current time.
- Check if it’s within the twilight period.
- If it is, trigger some actions using Asterisk’s dialplan.
Set up the dialplan
Speaking of the dialplan, this is where things get interesting. Asterisk’s dialplan is basically a set of instructions that tell Asterisk what to do when certain events occur. In my case, I wanted it to:
- Play some music.
- Turn on the lights. I had some smart light bulbs that I could control via an API.
- Maybe even send me a notification on my phone.
I spent a good chunk of time tweaking the dialplan to get it just right. There was a lot of trial and error involved, but eventually, I got it working the way I wanted.
Test the whole thing out
Finally, it was time to test the whole thing out. I set up a cron job to run my script every minute and waited for twilight to approach. When the time came, my script ran, and it worked! The music started playing, the lights turned on, and I got a notification on my phone. It was pretty awesome to see it all come together. It was amazing! I can just chill now!
This was a fun little project that taught me a lot about Asterisk, cron, and scripting. I am excited to see what other cool things I can do with this setup in the future.
