HomeGenie Forum
Automation Program Plugins and Wizard Scripting => APP Contributions => Topic started by: nolio on December 07, 2014, 09:11:32 PM
-
Hi,
I create a script (all in french for now) to add function in a centralize place (before i add code in the "90-Security Alarm System", or wizard script). So now my script permit in the 3 following case :
- Alarm on
- Alarm off
- Alarm triggered
To do the following actions :
- Send SMS (only with an USB key and gammu configured) : see here for more detail : http://www.homegenie.it/forum/index.php?topic=6.msg117#msg117 (http://www.homegenie.it/forum/index.php?topic=6.msg117#msg117))
- Alert on Karotz (under openkarotz)
- Activate the webcam detection on "Synology Surveillance Station"
- Move Shutter
All this function are only activate in case of the field are fill in.
If some people think it can useful for us too, i probably have to :
- Traduce in English
- Add customize field
So tell me :).
It takes me some times (probably because i am not a programmer), but i found the result very useful and i am proud to success :).
Thanks Gene for the help on debugging script and for the good job on HomeGenie.
Bye
-
Hi Nolio,
I think you have made a good job. I will try it as soon as possible.
Cheers
Dani
-
Hi,
I update this script :
- Translation in english
- Correction to permit to send 2 sms (suppress the runasync because gammu doesn't support to launch 2 command line too quickly)
- Add the field for customize opekarotz alert
Bye
-
Hi,
I work on 2 modifications on the sms part, by using of gammu-smsd instead of gammu :
- More reliable send of sms : the sms are store and send when the "phone" is "ready" (not lost if phone is not ready like gammu)
1/ Install gammu-smsd :
[/list]apt-get install gammu-smsd
2/ Configure by editing /etc/gammu-smsdrc :
[gammu]
port = /dev/ttyUSB?
connection = at19200
3/ Test configuration :
echo "test !!" | gammu-smsd-inject TEXT <your phone number>
4/ Modify in my "Alarm add on" HG script :
this :
Arguments = "-c \"echo '"+text+"' | /usr/bin/gammu --sendsms TEXT "+tel+"\"",
by this :
Arguments = "-c \"echo '"+text+"' | gammu-smsd-inject TEXT "+tel+"\"",
- Permit to enable/disable alarm by sending a sms (by sending "alarm on" or "alarm off" in a sms)
1/ Configure by editing /etc/gammu-smsdrc :
[smsd]
runonreceive = /home/pi/receivesms.sh
2/ create file receivesms.sh in /home/pi/ (for example) :
#!/bin/sh
if [ "$SMS_1_TEXT" = "alarm on" ] ; then
wget 0 q t 1 --http-user=admin --http-password='<your HG password>' --auth-no-challenge "http://<your HG IP address>:<your HG port>/api/HomeAutomation.HomeGenie.Automation/90/Control.On/1393535869092" >/dev/null 2>&1
fi
if [ "$SMS_1_TEXT" = "alarm off" ] ; then
wget 0 q t 1 --http-user=admin --http-password='<your HG password>' --auth-no-challenge "http://<your HG IP address>:<your HG port>/api/HomeAutomation.HomeGenie.Automation/90/Control.Off/1393536682120" >/dev/null 2>&1
fi
Bye
-
I dont understand about this
/90/Control.On/1393535869092
How to on off my gpio?
Thx for help
-
I dont understand about this
/90/Control.On/1393535869092
It permit to turn the alarm on by the api.
How to on off my gpio?
Thx for help
You need to find the control api of gpio.
http://www.homegenie.it/docs/api/overview.html (http://www.homegenie.it/docs/api/overview.html)
-
http://169.254.122.100/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/100 (http://169.254.122.100/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/100)
Show like this
{
"Name": "GPIO Modules",
"Description": "",
"DeviceType": "Program",
"Domain": "HomeAutomation.HomeGenie.Automation",
"Address": "100",
"Properties": [
{
"Name": "ConfigureOptions.GPIO17",
"Description": "GPIO17 (IN, OUT or OFF)",
"Value": "OFF",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "ConfigureOptions.GPIO18",
"Description": "GPIO18 (IN, OUT or OFF)",
"Value": "OFF",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "ConfigureOptions.GPIO21",
"Description": "GPIO21 (IN, OUT or OFF)",
"Value": "OFF",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "ConfigureOptions.GPIO22",
"Description": "GPIO22 (IN, OUT or OFF)",
"Value": "OUT",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "ConfigureOptions.GPIO23",
"Description": "GPIO23 (IN, OUT or OFF)",
"Value": "OUT",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "ConfigureOptions.GPIO24",
"Description": "GPIO24 (IN, OUT or OFF)",
"Value": "OFF",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "ConfigureOptions.GPIO25",
"Description": "GPIO25 (IN, OUT or OFF)",
"Value": "OUT",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "ConfigureOptions.GPIO4",
"Description": "GPIO04 (IN, OUT or OFF)",
"Value": "OFF",
"UpdateTime": "2015-07-29 19:20:04Z"
},
{
"Name": "Program.Status",
"Description": "",
"Value": "Idle",
"UpdateTime": "2015-07-29 19:20:10Z"
},
{
"Name": "VirtualModule.ParentId",
"Description": "",
"Value": "100",
"UpdateTime": "2014-04-11 18:45:32Z"
},
{
"Name": "Widget.DisplayModule",
"Description": "",
"Value": "",
"UpdateTime": "2014-04-11 18:45:31Z"
} ],
"RoutingNode": ""
}
Then i use my web browser with this URL
http://169.254.122.100/api/HomeAutomation.HomeGenie.Automation/100/ConfigureOptions.GPIO22/Control.On (http://169.254.122.100/api/HomeAutomation.HomeGenie.Automation/100/ConfigureOptions.GPIO22/Control.On) <--- Nothing happen
http://169.254.122.100/api/HomeAutomation.HomeGenie.Automation/100/GPIO22/Control.On (http://169.254.122.100/api/HomeAutomation.HomeGenie.Automation/100/GPIO22/Control.On) <--- Nothing happen
http://169.254.122.100/api/RaspberryPi.GPIO/22/Control.On (http://169.254.122.100/api/RaspberryPi.GPIO/22/Control.On) <--- Nothing happen
Any somthing missing? Pls help
-
I found my problem ;D
I modificate on RaspberryPi.Gpio Program modul
on last script im change with this
// implement web serice API Control.On, Control.Off, Control.Toggle
// for the domain RaspberryPi.GPIO
When.WebServiceCallReceived("RaspberryPi.Gpio", ( args ) =>
{
string[] reqs = ((string)args).Split('/');
var res = "{ 'ResponseValue' : 'ERROR' }";
//Command cmd = new Command((string)args);
try
{
string command = reqs[2];
string Gpioid = reqs[1];
var module = Modules.InDomain("HomeGenie.Gpio").WithAddress(Gpioid).Get();
//
switch(command)
{
// eg. http://hg_address/api/RaspberryPi.GPIO/1/Control.On (http://hg_address/api/RaspberryPi.GPIO/1/Control.On)
case "Control.On":
connection[Gpioid] = true;
Program.RaiseEvent(module, "Status.Level", "1", "Gpio " + Gpioid);
res = "{ 'ResponseValue' : 'OK' }";
break;
break;
// eg. http://hg_address/api/RaspberryPi.GPIO/3/Control.Off (http://hg_address/api/RaspberryPi.GPIO/3/Control.Off)
case "Control.Off":
connection[Gpioid] = false;
Program.RaiseEvent(module, "Status.Level", "0", "Gpio " + Gpioid);
res = "{ 'ResponseValue' : 'OK' }";
break;
// eg. http://hg_address/api/RaspberryPi.GPIO/9/Control.Toggle (http://hg_address/api/RaspberryPi.GPIO/9/Control.Toggle)
case "Control.Toggle":
connection[Gpioid] = !connection[Gpioid];
Program.RaiseEvent(module, "Status.Level", connection[Gpioid] ? "1" : "0", "Gpio " + Gpioid);
res = "{ 'ResponseValue' : 'OK' }";
break;
}
//
return "{ 'ResponseValue' : 'OK' }";
}
catch (Exception ex)
{
res = ex.Message + " " + ex.StackTrace;
}
// unable to process request
return res;
});
Now its can on off gpio using web call thanks ITS GREAT SOFWARE ;D ;D ;D ;D
-
i have create new program to control sms gpio ON or OFF
i use like sample
runonreceive = /home/pi/receivesms.sh
my scipt like this
if [ "$SMS_1_TEXT" = "23on" ] ; then
wget 0 q t 1 --http-user=admin --http-password='' --auth-no-challenge "http://169.254.122.100/api/RaspberryPi.Gpio/GPIO23/Control.On" >/dev/null 2>&1$
fi
noting happen with my gpio
scrip no 2
if [ "$SMS_1_TEXT" = "23on" ] ; then
curl 'http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On' (http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On')
fi
notting happen to with my gpio
PLS HELP WHAT HAPPEN THIS?
I use smstools3 with curl it can executed gpio can on and off
-
I have remove
this -->if [ "$SMS_1_TEXT" = "23on" ] ; then
curl 'http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On' (http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On')
and this ->fi
so it just
curl 'http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On' (http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On')
i send some sms then its on. i use new gammu. OMG how to fix this :( :( :( :( :( :( :(
-
I have remove
this -->if [ "$SMS_1_TEXT" = "23on" ] ; then
curl '[url]http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On'[/url] ([url]http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On'[/url])
and this ->fi
so it just
curl '[url]http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On'[/url] ([url]http://localhost/api/RaspberryPi.Gpio/GPIO23/Control.On'[/url])
In that case, every sms receive will turn on your GPIO23, is that you want ?
I update my script like that :
if [[ "$SMS_1_TEXT" == *"xxxxxxxxx"* ]] ; then
and with at the begining (don't care of case):
shopt -s nocasematch
and at the end (care of case again):
shopt -u nocasematch
With "xxxxxxxxx", the string to test.
Perhaps you can try ...
Good luck.
-
I have remove my gammu, then i use SMS server tools 3, now work properly, i have problem installing gammu.
I will share my sms remote control soon
:):)
-
Ok what kinds of problem with gamma install ?
Share share :-)
-
i have install newer version gammu. its canot send and receive sms. i dont know why. im not familiar with gammu, and not unix/linux user. Im reinstall with old version, can send sms but can not receive sms, may problem with receive daemon. Im tired to try use gammu like on tutorial. Im know Visual Studio so then use java python bash ksh it make me dizzy im newbie in here, blank dont know how to write script, than i back to sms tools 3, its more simple and have facility like gammu.
I will share soon, now i want HG GPIO can remote use jaber xmpp. Try to loving linux/unix :D:D:D:D:D
-
Hi all,
Since some month, i use SMS every day to arm/disarm my HomeGenie alarm.
But last week, i update my bash script to do more (with HomeGenie API) :
1/ Receive some device information : temperature, level status
2/ Do some actions : close, open, nearly close shutter
Example in the joint picture.
I share with you the script (which is not perfect but it work fine !) "receivesms.sh", but it is just an example customize with my own devices, so you have to customize to your ;) :
#!/bin/bash
shopt -s nocasematch
if [[ "$SMS_1_TEXT" == *"alarm on"* ]] ; then
wget 0 q t 1 --http-user=admin --http-password='<HG password>' --auth-no-challenge "http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie.Automation/90/Control.On/1393535869092" >/dev/null 2>&1
fi
if [[ "$SMS_1_TEXT" == *"alarm off"* ]] ; then
wget 0 q t 1 --http-user=admin --http-password='<HG password>' --auth-no-challenge "http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie.Automation/90/Control.Off/1393536682120" >/dev/null 2>&1
fi
if [[ "$SMS_1_TEXT" == *"camou"* ]] ; then
wget 0 q t 1 --http-user=admin --http-password='<HG password>' --auth-no-challenge "http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Automation/Programs.Run/1042" >/dev/null 2>&1
fi
if [[ "$SMS_1_TEXT" == *"ouvert"* ]] ; then
wget 0 q t 1 --http-user=admin --http-password='<HG password>' --auth-no-challenge "http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Automation/Programs.Run/1041" >/dev/null 2>&1
fi
if [[ "$SMS_1_TEXT" == *"fermet"* ]] ; then
wget 0 q t 1 --http-user=admin --http-password='<HG password>' --auth-no-challenge "http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Automation/Programs.Run/1000" >/dev/null 2>&1
fi
if [[ "$SMS_1_TEXT" == *"temper"* ]] ; then
TempDetectSalon="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/31/ | grep -A 1 -B 1 "Sensor.Temperature" | grep -Po '(?<="Value": ")[^"]*')"
TempDetectSalon3="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/54/ | grep -A 1 -B 1 "Sensor.Temperature" | grep -Po '(?<="Value": ")[^"]*')"
TempDetectGarage="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/61/ | grep -A 1 -B 1 "Sensor.Temperature" | grep -Po '(?<="Value": ")[^"]*')"
gammu-smsd-inject TEXT "$SMS_1_NUMBER" -text "DetectSalon : $TempDetectSalon // DetectSalon3 : $TempDetectSalon3 // DetectGarage : $TempDetectGarage //" >/dev/null 2>&1
fi
if [[ "$SMS_1_TEXT" == *"volet"* ]] ; then
Volet1="$(curl -u admin:<HG password>-s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/50/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
Volet2="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/57/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
Volet3="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/58/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
Volet4="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/62/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
Volet5="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/63/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
gammu-smsd-inject TEXT "$SMS_1_NUMBER" -text "Volet1 : $Volet1 // Volet2 : $Volet2 // Volet3 : $Volet3 // Volet4 : $Volet4 // Volet5 : $Volet5 //" >/dev/null 2>&1
fi
if [[ "$SMS_1_TEXT" == *"level"* ]] ; then
DetectSalon="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/31/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
DetectSalon3="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/54/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
DetectGarage="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/61/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
PorteGarage="$(curl -u admin:<HG password> -s http://<HG @IP>:<HG port>/api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.ZWave/20/ | grep -A 1 -B 1 "Status.Level" | grep -Po '(?<="Value": ")[^"]*')"
gammu-smsd-inject TEXT "$SMS_1_NUMBER" -text "DetectSalon : $DetectSalon // DetectSalon3 : $DetectSalon3 // DetectGarage : $DetectGarage // PorteGarage : $PorteGarage //" >/dev/null 2>&1
fi
shopt -u nocasematch
Bye