status windows and doors and may more

Support for our english speaking visitors

Moderator: Co-Administratoren

Antworten
alchy
Beiträge: 10754
Registriert: 24.02.2011, 01:34
System: CCU
Hat sich bedankt: 65 Mal
Danksagung erhalten: 673 Mal

status windows and doors and may more

Beitrag von alchy » 30.06.2015, 16:28

for my buddy omicronCZ :wink:

he need a script to send information by mail ore what ever ( we will establish :D )
with the current values of the windows and doors from group Security > F R O M H E R E <

Here we go, my 50cents:

1st: simple script, only for displaying at script executer.

Code: Alles auswählen

!Windows and doors current value by Alchy
var sec=dom.GetObject("Security");
string i;
string slist;
string since;
string status_new;
slist="windows and doors: \r\n";
foreach(i,sec.EnumUsedIDs()) {
var item=dom.GetObject(i);
var dev=dom.GetObject(item.Device());
if((dev.HssType()=="HM-Sec-RHS") || (dev.HssType()=="HM-Sec-SC") || (dev.HssType()=="HM-Sec-SC-2") || (dev.HssType()=="HM-Sec-SCo")) {
var since = item.LastTimestamp().ToString("%d.%m.%y %H:%M");
if (since == "01.01.70 01:00") {since = " unknow time";}
var where = dom.GetObject(item.ChnRoom());
var status = item.DPByHssDP("STATE").Value();
if (status == 0 ) { status_new = "locked"; }
if (status == 1 ) { status_new = "tilted"; }
if (status == 2 ) { status_new = "open"; }
slist=slist # dev.Name() #" - status: " # status_new #" - since: "  # since #" - at room: " # where #"\r\n";
}
}
WriteLine(slist); 
buddy, now it's your turn. :mrgreen:
Give me mor information, what you need or not need.

Alchy
Zuletzt geändert von alchy am 08.07.2015, 22:34, insgesamt 1-mal geändert.

Blacklist................... almost full
Ignoranz ist die Summe aller Maßnahmen die man ergreift, um bestehende Tatsachen nicht sehen zu müssen.

© Sandra Pulsfort (*1974)

Lies bitte die Logik von WebUI Programmen und die Tipps und Tricks für Anfänger.

Wichtig auch CUxD ersetzt System.exec. Die HM Script Doku (Downloadart Skripte) hilft auch weiter.
Zum Testen von Scripten den >> HomeMatic Script Executor << von Anli benutzen.

omicronCZ
Beiträge: 214
Registriert: 31.07.2011, 17:37
System: CCU
Wohnort: Czech Rep.
Hat sich bedankt: 83 Mal
Danksagung erhalten: 14 Mal

Re: status windows and doors and may more

Beitrag von omicronCZ » 30.06.2015, 18:24

Thanks Alchy :-)
But I guess I wrote it wrong even in the original thread of smoke detectors, now I realize that's probably not easy to adapt ...

I wanted to know whether I was able simply with HM script add the only information about which sensor (of the group "Security"), activated the launch of the my "Master Alarm - Intrusion Detection" HM program.
Master Alarm PRG.jpg
The program checked over the variables:
- Status of all controlled windows with rotary sensors "HM-Sec-RHS" where is the trigger state "OPEN"
- Status of all controlled door sensor "HM-Sec-SC", where is the trigger state "OPEN"
- Status of all controlled PIR sensors "HM-Sec-mdir" where is the trigger state "MOTION DETECTED"

If any of these conditions, there will be some alarm sequence, which also sends alarm e-mail and Pushover messages , to which I would like to inserted just as some information about that which sensor caused the alarm...

One more question, how is it possible for each sensors to detect not only their ground state (which goes through the HM program), but also the "SABOTAGE" state, when trying to open their illegal?

Thank you very much for your help with a solution.

alchy
Beiträge: 10754
Registriert: 24.02.2011, 01:34
System: CCU
Hat sich bedankt: 65 Mal
Danksagung erhalten: 673 Mal

Re: status windows and doors and may more

Beitrag von alchy » 01.07.2015, 00:18

damned, misunderstood, sorry :cry:
I can't help w/o information. :evil:

You can use the other programm to know the name of the trigger device, not this with the Variables.
Please post a screen from the program, that change your SYSvar VAR PIR Dorway Status
or "VAR WindowsAnyFullOpen" ....

hopefull, example for the programm that the Status of all controlled PIR sensors "HM-Sec-mdir" where is the trigger state "MOTION DETECTED"

1 . Create a new system variables according to picture Name VAR PIR Dorway Info
create-systemvariable.jpg
2. edit your programm, that change the sysvar VAR PIR Dorway Status
my example:
programm_pir.jpg
3 the script:

Code: Alles auswählen

!call the nam of the triggered pir and time and write the info at a sysvar
string slist = "";
object dp = dom.GetObject("$src$");
var ch = dom.GetObject(dp.Channel());
var dev = dom.GetObject(ch.Device());
ch = ch.Name();
dev = dev.Name();
string stime = system.Date("%d.%m. %H:%M Uhr");
slist = slist # dev #" at: "#stime ;
dom.GetObject('VAR PIR Dorway Info').State(slist);
and save.
Now at "VAR PIR Dorway Info" you see the last triggered PIR. :mrgreen:
For more, i need information about the sending program. (Mail, Pushover, what ever)

This example you can also exactly use for the program that changing the sysvar
"VAR WindowsAnyFullOpen"
Only exchange the Name of the Sysvar (may "VAR WindowsAnyFullOpen Info") and exchange the name of the Sysvar at the last row from the script too....
But unfortunately not for the smoke detectors :twisted:
If you organised the smoke detectors in groups you can not call them individually at a HM programm.

Last answer for today, my flight is called.

For Sabotage you can also use this script. unfortunately only if you can select this at a HM program according to picture and ^^ example.
programm_sabotage.jpg
Alchy

Blacklist................... almost full
Ignoranz ist die Summe aller Maßnahmen die man ergreift, um bestehende Tatsachen nicht sehen zu müssen.

© Sandra Pulsfort (*1974)

Lies bitte die Logik von WebUI Programmen und die Tipps und Tricks für Anfänger.

Wichtig auch CUxD ersetzt System.exec. Die HM Script Doku (Downloadart Skripte) hilft auch weiter.
Zum Testen von Scripten den >> HomeMatic Script Executor << von Anli benutzen.

alchy
Beiträge: 10754
Registriert: 24.02.2011, 01:34
System: CCU
Hat sich bedankt: 65 Mal
Danksagung erhalten: 673 Mal

Re: status windows and doors and may more

Beitrag von alchy » 29.07.2015, 12:43

omicronCZ asked me to publish the following script.
What does the script?
It sends a message when a motion has detected a movement, or a window has been opened, or a sabotage contact is triggered. But only within an adjustable time.
Trigger for the script is an alarm variable according to the information at the thread.
Its send the Name of the Trigger and other information...

Alchy

Code: Alles auswählen

! Master intrusion detect by Alchy for omicronCZ v0.2
! checked a functions/rooms/favourites for:
! windows sensors open? pir motion detected? sabotage ? and send the device name information by pushover and/or mail 
! but only if this action x seconds bevor now 
 
! ++++++ Setup functions ++++++
var FUNCTIONS = "Security"; ! function, Room or favorites which check 
var LOSTTIME = 10; ! time in seconds for OFFset ( action send only messages if last action time of the sensors is < now

!+++++++ Pushover Setup ++++++
var USE_PUSHOVER = "yes"; 
var PUSH_CUXD_ID = "CUX2801001:2"; ! serial from the CMD_EXEC incl. canal number 
var USERKEY = "+++++++"; !your own user key
var TOKEN = "+++++++"; ! your own api token
var RETRY = "30"; 
var EXPIRE = "120"; 
var SOUND = "siren"; 
var PRIO = "1"; ! -1 low 0 normal 1 high

!+++++++ Setup Mail ++++++
! 1. CUXD incl. exec device is installed ( http://homematic-forum.de/forum/viewtopic.php?f=37&t=15298 )
! 2. mail addon is installed tested ( http://www.homematic-inside.de/software/email ) 
! 3. at the mail addon at TCL index tab the first line is "set serviceliste [encoding convertfrom utf-8 [lindex $argv 1]]" w/o " 
! 4. you wrote "$serviceliste" w/o " at the mail ID template
var USE_MAIL = "yes"; !   use ? yes or no
var MAIL_ID = "03"; !  which mail ID template you use
var MAIL_CUXD_ID = "CUX2801001:1"; !  Serial from the CMD_EXEC incl. canal number


! DONT TOUCH behind this line

object sec = dom.GetObject(""#FUNCTIONS#"");
string itemId;
string slist = "";
foreach(itemId, sec.EnumUsedIDs()) {
    var item = dom.GetObject(itemId);
    if (item.IsTypeOf(OT_CHANNEL)) {
    var device = dom.GetObject(item.Device());
    var hssType = item.HssType();
    var triggered = false;
    string trigger = ""; 
    integer now = system.Date("%F %T").ToTime().ToInteger();
    var span = "dont worry";
integer LASTACTION = 100;
if ( hssType == "SHUTTER_CONTACT") { 
var triggered = item.DPByHssDP("STATE").Value(); 
integer LASTACTION = item.DPByHssDP("STATE").Timestamp().ToInteger();
integer span = now - LASTACTION;
if ( triggered )  { trigger = "opened"; }
}
if ( hssType == "ROTARY_HANDLE_SENSOR") { 
var triggered = item.DPByHssDP("STATE").Value(); 
integer LASTACTION = item.DPByHssDP("STATE").Timestamp().ToInteger();
integer span = now - LASTACTION;
if ( triggered > 0 ) { triggered = "true"; 
if ( triggered )  { trigger = "opened"; }}}

if ( hssType == "MOTION_DETECTOR") { 
var triggered = item.DPByHssDP("MOTION").Value();
integer LASTACTION = item.DPByHssDP("MOTION").Timestamp().ToInteger();
integer span = now - LASTACTION;
if ( triggered) { trigger = "motion detetected"; }} 
if ( (triggered == true) && ( span <= LOSTTIME) ) { slist = slist #device #" why? " #trigger #" " #triggered #" " #span #" seconds before \n";}

var sabotage =  item.DPByHssDP("ERROR").Value(); 
integer LASTACTION = item.DPByHssDP("ERROR").Timestamp().ToInteger();
integer span = now - LASTACTION;
if ( sabotage == 7 ) { sabotage = "true"; }
if ( (sabotage)  && ( span <= LOSTTIME ) ) { slist = slist #device #" why? Sabotage " #sabotage #" " #span #" seconds before \n" ; }

}
}

if ( USE_PUSHOVER == "yes") {
       string message;
       string newmessage;
       string messageindex;
       message = "";
       message = message # slist;
       foreach(messageindex,message.Split(" ")) {newmessage = newmessage+messageindex+"%20";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("Ä")) {newmessage = newmessage+messageindex+"%C3%84";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("Ö")){newmessage = newmessage+messageindex+"%C3%96";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("Ü")){newmessage = newmessage+messageindex+"%C3%9C";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("ä")){newmessage = newmessage+messageindex+"%C3%A4";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("ö")){newmessage = newmessage+messageindex+"%C3%B6";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("ü")){newmessage = newmessage+messageindex+"%C3%BC";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("ß")){newmessage = newmessage+messageindex+"%C3%9F";}
              message = newmessage;
              newmessage = "";
        foreach(messageindex,message.Split("°")){newmessage = newmessage+messageindex+"%C2%B0";}
              message = newmessage;
              newmessage = "";
              message = message.Substr(0, message.Length()-51);
}

if ( message <> "") { 
 if ( USE_MAIL == "yes"){ dom.GetObject("CUxD."#MAIL_CUXD_ID#".CMD_EXEC").State("/etc/config/addons/email/email "#MAIL_ID#" '"#slist#"'"); }
 if ( USE_PUSHOVER == "yes") { dom.GetObject("CUxD."#PUSH_CUXD_ID#".CMD_EXEC").State("LD_LIBRARY_PATH=/usr/local/addons/cuxd /usr/local/addons/cuxd/curl -s -k -d token='"#TOKEN#"' -d user='"#USERKEY#"' -d message='"#message#"' -d PRIOrity='"#PRIO#"' -d sound='"#SOUND#"' -d retry='"#RETRY#"' -d expire='"#EXPIRE#"' https://api.pushover.net/1/messages.json"); }
}
}

Blacklist................... almost full
Ignoranz ist die Summe aller Maßnahmen die man ergreift, um bestehende Tatsachen nicht sehen zu müssen.

© Sandra Pulsfort (*1974)

Lies bitte die Logik von WebUI Programmen und die Tipps und Tricks für Anfänger.

Wichtig auch CUxD ersetzt System.exec. Die HM Script Doku (Downloadart Skripte) hilft auch weiter.
Zum Testen von Scripten den >> HomeMatic Script Executor << von Anli benutzen.

Antworten

Zurück zu „HomeMatic - english“