Scheduling with At and cron for solat time

  • Platform information:
    • Hardware: _Raspberrry Pi3 with 16GB _
    • OS: OpenhabianPi
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2

I have a installation on Openhab but I am not sure where to start. Currently I am using a raspberry PI to run a script daily at a particular time of day based on a file. This time in the file will change almost daily since it is calculated based on complex mathematical calculation from a website, The time are referred as solat time where it corresponds to 5 daily prayer eg zohor, asar, maghrib, isya and subuh. An example for zohor the time will be 13:10. I will then use unix at command to execute the script based on offset of the zohor time where it will do a set trigger on ptzoptics camera. The current time trigger is only support for cron but not supporting “at” command. I have also tried creating a binding but my java skill is basic, prove a little bit complex to me, but I am good at unix scripting.

below is how the file is generated (shell script) -
#! /bin/bash -l
my_array=($(lynx -dump http://www2.e-solat.gov.my/xml/today/?zon=SGR01|
cut --complement -d “,” -f 1,3,4|
grep -v H.S|cut --complement -d “M” -f 1))

arrayLen=${#my_array[@]}
arrayWaq=(“Imsak” “Subuh” “Syuruk” “Zuhur” “Asar” “Maghrib” “Isyak”)
#actual solat time
echo “${my_array[5]}” > /home/pi/zohor
echo “${my_array[7]}” > /home/pi/maghrib
echo “${my_array[8]}” > /home/pi/isya
#solat time with offset
date -d “${my_array[3]} 32 minutes” +"%H:%M" > /home/pi/ONsubuh32m
date -d “${my_array[7]} 29 minutes” +"%H:%M" > /home/pi/ONmaghrib29m

This is how the script is run -

#Set kuliah maghrib after , 30 min set camera at kuliah table
at $(</home/pi/ONmaghrib30m) </home/pi/ptz-kuliah1.sh

it will great if someone can help me as it will help a lot , I think a lot of people will benefit of this as it can be used in house of worship in all over the world.

Salaam Alaikum,
What do you want to do?
If you want to execute the script from openHAB, use the executeCommandLine action

If you want to display the prayer times, I currently use node-red and javascript
At every prayer time, for example, the adhan gets player on speakers, the tv pauses and display an image. Before and after Maghrib, the lights get turned on and off…

Waalaikum salam,
What a surprise, did not expect someone had done it before. I want to be able to execute some tasks based on the prayer time with some time offsets and trigger.

Turn on light at Jumaat Zohor, perform a script to turn on camera at 10 minutes after Zohor and turn to a different angle after the Imam move from mimbar. The activity is a mix of sonoff tasmota activation , PIR detection and time offset action which calls a URL (I am using lynx to call in command line)

Will you be able to share your codes? The solat time in our country follows calculation from the JAKIM (a govt body that regulates the falaq time) . Maybe I can get some ideas from it. Thank you.

I used node-red to do the calculation and send the notifications to openHAB
When are you available so that I can help you set it up on a private chat.
That way we can do it step by step without clogging up the forum. When we are finished, I’ll publish a tutorial. You can be my tester!!

Let me know when you have a couple of hours available

Thank you. I will build a new RAspberry Pi 3 with openhab and node red and let you know when I am ready. Can you PM me? I am unable to PM and let me know which time slot you are available , your time is GMT right? my time is GMT+8

:+1:

This is true but the equivalent of the at command is Timers. In your rules, as I suspect you will see as you work with Vincent, you can schedule a chunk of code to execute at a certain time. So if you can get the time then you can schedule your actions to take place at that time or at that time plus or minus an offset.

And to both of you, I wouldn’t worry too much about clogging up the forum. The back and forth conversation when building up something like this is very informative and helps new and even experienced users learn more.

@rlkoshak
It may just be a lot of trial and errors with step by steps and pictures and a lot of back and fro.
I was planning to make a tutorial for it anyway. It will give me a “bigger picture” on how to present it succinctly and accurately the first time around.