To answer a question of crankycoder, i’ll start a small new topic.
Since the binding of asterisk isn’t up to date with the latest version of OH2, and since my phones are ‘very’ important to me, I’ve created a small workaround.
The main goal is that my phones start to ring 2 times hortly somebody rings the doorbell, and get a message on my phone (pushover). My asterisk server is running on another server, and I’ve got about 8 phones. I’ve got 2 doorbells, and work with a scenario to ring different phones. So I wanted to to know where the doorbell has been pushed (other source on display phone), and different phones if the house is in sleep mode (my girlfriend works nights, so…).
Maybe this can help somebody, so I post this just for info…
Of course improvements, or other nice solutions are welcome.
My rule on the OH server (/etc/openhab2/rules/bezoek.rules).
var string last_pushover=""
rule "Er werd gebeld"
when
Item contact_WO_DeurbelVoordeur1x changed or
Item contact_WO_DeurbelVoordeur2x changed
then
val String act_pushover=BellsALL.members.sortBy[lastUpdate].last.name.replace('contact_WO_', ' ')
if (act_pushover != last_pushover) {
if (HouseMode.state == "statussleep") {
pushover ("Er werd gebeld via " + act_pushover + ".", "veten")
executeCommandLine("/etc/openhab2/scripts/ringDeurbelAtelier.sh")
logInfo("Alarm", "Er werd gebeld via " + act_pushover + ".")
} else {
pushover ("Er werd gebeld via " + act_pushover + ".")
executeCommandLine("/etc/openhab2/scripts/ringDeurbelNormaal.sh")
logInfo("Alarm", "Er werd gebeld via " + act_pushover + ".")
}
}
end
My script on the OH server (/etc/openhab2/scripts/ringDeurbelNormaal.sh):
Just to start the script on the asterisk server. I like to keep my scripts as much as possible ‘locally’.
#!/bin/sh
sshpass -p 'XXXXXXXX' ssh root@ASTERISKIP /scripts/ringDeurbelNormaal.sh
My script on the Asterisk server (/scripts/ringDeurbelNormaal.sh)
This moves (!!!) a call file towards the asterisk pool folder. Asterisk picks this up directly and act accordenly.
Be care, this must be moved, when you copy it into the pool folder, it doesn’t work.
#!/bin/bash
# Ring alle telefoons, starten vanaf de voordeur.
cp /scripts/ring201DeurVoor.org /scripts/ring201DeurVoor.call
mv /scripts/ring201DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring203DeurVoor.org /scripts/ring203DeurVoor.call
mv /scripts/ring203DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring206DeurVoor.org /scripts/ring206DeurVoor.call
mv /scripts/ring206DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring210DeurVoor.org /scripts/ring210DeurVoor.call
mv /scripts/ring210DeurVoor.call /var/spool/asterisk/outgoing/.
sleep 2
cp /scripts/ring202DeurVoor.org /scripts/ring202DeurVoor.call
mv /scripts/ring202DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring204DeurVoor.org /scripts/ring204DeurVoor.call
mv /scripts/ring204DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring207DeurVoor.org /scripts/ring207DeurVoor.call
mv /scripts/ring207DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring209DeurVoor.org /scripts/ring209DeurVoor.call
mv /scripts/ring209DeurVoor.call /var/spool/asterisk/outgoing/.
sleep 2
cp /scripts/ring201DeurVoor.org /scripts/ring201DeurVoor.call
mv /scripts/ring201DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring203DeurVoor.org /scripts/ring203DeurVoor.call
mv /scripts/ring203DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring206DeurVoor.org /scripts/ring206DeurVoor.call
mv /scripts/ring206DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring210DeurVoor.org /scripts/ring210DeurVoor.call
mv /scripts/ring210DeurVoor.call /var/spool/asterisk/outgoing/.
sleep 2
cp /scripts/ring202DeurVoor.org /scripts/ring202DeurVoor.call
mv /scripts/ring202DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring204DeurVoor.org /scripts/ring204DeurVoor.call
mv /scripts/ring204DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring207DeurVoor.org /scripts/ring207DeurVoor.call
mv /scripts/ring207DeurVoor.call /var/spool/asterisk/outgoing/.
cp /scripts/ring209DeurVoor.org /scripts/ring209DeurVoor.call
mv /scripts/ring209DeurVoor.call /var/spool/asterisk/outgoing/.
And example of a call file (/scripts/ring201DeurVoor.call):
Just some basic stuff like who to call, from where, how long…
cat ring201DeurVoor.org
Channel: Local/201@from-internal
callerid: "Voordeur" <901>
WaitTime: 3
Context: outgoing
Extension: 200
Priority: 1
I repeat the things for my other doorbell. Simply replace all ‘Voor’ (=front) with ‘Achter’ (=back).