Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [gelöst] Surveillance Station Home Mode steuern

    NEWS

    • Cloud/Vis-Offline-Weihnachtsangebot 2024

    • js-controller Lucy (Version 7.0) jetzt im Stable Repository

    • ioBroker 10-Jahres Community Treffen - ein kleiner ReCap

    [gelöst] Surveillance Station Home Mode steuern

    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      ak1 last edited by

      An einer Lösung bin ich auch sehr interessiert!

      Wenn jemand Erfolg damit hat, bitte hier beschreiben.

      Ich habe ein Skript zum Schalten des Home Mode der Surveillance Station auf meiner CCU2 laufen, zumindest test-weise. Lieber hätte ich es aber auch auf dem ioBroker

      Gruß

      Stefan

      1 Reply Last reply Reply Quote 0
      • M
        MKaiser96 last edited by

        Hallo,

        seit langem melde ich mich wieder. Mittlerweile habe ich das Problem gelöst. Beim Anmelden Anmelden wird eine SID generiert. Diese muss jedem Befehl angefügt werden.

        7256_home_mode_steuern_blockly.png

        URL für den Login:

        http://<ip_des_nas>:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=<account>&passwd=<passwort>&session=SurveillanceStation&format=sid

        URL zum Aktivieren:

        http://<ip_des_nas>:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true

        URL zum Deaktivieren:

        http://<ip_des_nas>:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=false

        Ich hoffe, ich konnte euch helfen.</ip_des_nas></ip_des_nas></passwort></account></ip_des_nas>

        1 Reply Last reply Reply Quote 0
        • AlCalzone
          AlCalzone Developer last edited by

          Warum führst du die nachfolgenden Requests nicht innerhalb des Callbacks des ersten aus anstatt im Timeout? Was, wenn der erste länger dauert als 2s?

          1 Reply Last reply Reply Quote 0
          • M
            MKaiser96 last edited by

            Ich hatte da immer Probleme, dass er die SID noch nicht verarbeitet hat und so der Befehl nicht geschalten wurde.

            1 Reply Last reply Reply Quote 0
            • A
              ak1 last edited by

              Markus, herzlichen Dank für Dein Feedback! Das ist sehr hilfreich.

              @AlCalzone: Deine Rückfrage suggeriert, dass Du an einen optimierten Programmablauf denkst. Wie würde der aussehen?

              Gruß

              Stefan

              1 Reply Last reply Reply Quote 0
              • D
                dominik.braun82 last edited by

                Hi.

                Ich bekomme es nicht hin…

                Siehe Bild anbei mit 2 Fragen...
                7511_2018-08-31_12h16_27.jpg

                Wäre echt dankbar über eine Info… 😢

                1 Reply Last reply Reply Quote 0
                • AlCalzone
                  AlCalzone Developer last edited by

                  @ak1:

                  @AlCalzone: Deine Rückfrage suggeriert, dass Du an einen optimierten Programmablauf denkst. Wie würde der aussehen? `

                  Quick'n'dirty in Photoshop:
                  1097_home_mode_steuern_blockly.png
                  Eben den zweiten Request direkt nach Beendigung des ersten.

                  1 Reply Last reply Reply Quote 0
                  • M
                    MKaiser96 last edited by

                    SID und result sind neu erzeugte Variablen. Zu finden im Blockly und Variablen.

                    1 Reply Last reply Reply Quote 0
                    • D
                      dominik.braun82 last edited by

                      Hi. Danke für die Info, habe jetzt alles gefunden und so eingetippt.

                      Anbei die Fehlermeldung….

                      eine Idee was da noch falsch ist ?

                      7511_2018-08-31_21h57_37.jpg

                      1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User last edited by

                        Hallo Zusammen,

                        @ dominik.braun82… kann es sein das Du mit dem ersten Http Aufruf ein Sitzungsobjekt erzeugst (SessionID, Token oder was auch immer), welches Du dann in die folgenden Aufrufe übernehmen bzw. vereerben musst, um dann dann eine gewünschten Funktionen aufzurufen um an gewünschte Informationen zu kommen?

                        Ich vermute hier mal, es handelt sich um Web Interface ob nun REST, SOAP oder was auch immer.... und Du setzt die Befehle zwar nacheinander auf, aber übernimmst die Ergebnisse oder wichtige Objekt nicht aus den vorherigen Aufrufen.....

                        Beispiel:

                        https://192.168.x.xxx/api/login?usernam ... d=12345678

                        erzeugt einen Token mit dem Inhalt "8242E644EC6387EB68A2FFA7DEC1729"

                        Dieses Objekt muss ich mir merken und im folgenden verwenden......

                        Beispiel: Nächster Befehl soll mir Endkonten liefern....

                        https://192.168.x.xxx/api/lora/packets? ... FA7DEC1729

                        Das Sitzungsobjekt lebt nicht ewig, deswegen muss es erneuert werden, doch dazu braucht es noch mehr Info zu dem Dienst welchen Du verwendest...

                        Herzliche Grüße

                        Equilora aka Harald

                        1 Reply Last reply Reply Quote 0
                        • D
                          dominik.braun82 last edited by

                          Ich versteh leider…. ähhm… nix :lol:

                          Ich habe einfach das blocky nachgebaut und ausgeführt.

                          Beo "MKaiser96" funktioniert es und bei mir nicht.

                          Wenn ich die links in den Browser eingebe funktioniert alles.... bei Iobroker nicht.

                          Gibt es die Möglichkeit die html Befehler wo anders aufzurufen? Javascript o.ä.?

                          Danke, Gruß

                          1 Reply Last reply Reply Quote 0
                          • A
                            ak1 last edited by

                            Kurze Rückmeldung: Bei mir funktioniert das Skript wunderbar. Vielen Dank!

                            1 Reply Last reply Reply Quote 0
                            • D
                              dominik.braun82 last edited by

                              das is doch intressant…. was ist dann an meinem System anders?

                              Hat jemand eine Idee?

                              Evtl. soll ich mal was ausprobieren? Irgendwelche Ideen?

                              Gruß

                              1 Reply Last reply Reply Quote 0
                              • D
                                dominik.braun82 last edited by

                                wenn ich eine Variable erstelle, in Diesem Fall die "SSI" und "result". Muss ich da etwas beachten?

                                Ich habe die einfach in Blockly angelegt, sonst nichts. Ist das korrekt?

                                Wo könnte es noch dranhängen?

                                1 Reply Last reply Reply Quote 0
                                • A
                                  ak1 last edited by

                                  Ich kann Dir leider nicht sagen, was bei Dir im Skript falsch ist. Allerdings gibt es ja die Möglichkeit, ein Blockly-Skript zu ex- und importieren. Außerdem kann man sich ja auch den Java Script Code anzeigen lassen. Ich poste das mal hier. Achtung, natürlich müssen URL zum Synology, User und Password passend eingetragen werden.

                                  Blockly:

                                   <xml xmlns="http://www.w3.org/1999/xhtml"><block type="comment" id="?eH]L9k:Ib4wfolmT[cy" x="87" y="-838"><field name="COMMENT">Skript ändert den HomeMode der Synology</field>
                                      <next><block type="comment" id="qwy:_@:WY|8mC9_eS9VZ"><field name="COMMENT">Surveillance Station - True oder False</field>
                                          <next><block type="comment" id="pYyx,Cg!,cdg:|,-?u]a"><field name="COMMENT">Trigger ist eine Objektänderung</field>
                                              <next><block type="on" id="bcuLKEa;9pP{IH#th[!4"><field name="OID">control.0.SurveillanceStation.HomeMode</field>
                                                  <field name="CONDITION">ne</field>
                                  
                                                  <statement name="STATEMENT"><block type="comment" id="N;:SDq:TI*zH~2%Q!USS"><field name="COMMENT">Login URL - Hardcoded</field>
                                                      <next><block type="comment" id="OA!{bdbR=I{~*en2b:)q"><field name="COMMENT">IP-Adresse, User und Password</field>
                                                          <next><block type="request" id="]5K08@Y}juiF3ry_yR,5"><mutation with_statement="true"></mutation>
                                                              <field name="WITH_STATEMENT">TRUE</field>
                                                              <field name="LOG">log</field>
                                                              <value name="URL"><shadow type="text" id="6xTZA,IEA?{.C1Vdb?Cy"><field name="TEXT">http://<ip>:<port>/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=<user>&passwd=<password>&session=SurveillanceStation&format=sid</password></user></port></ip></field></shadow></value> 
                                                              <statement name="STATEMENT"><block type="comment" id="kfmW-jlXfUvR7zTJ~foA"><field name="COMMENT">Session Token speichern</field>
                                                                  <next><block type="variables_set" id="(p/#.2{RZ:jCLk:|fDem"><field name="VAR">SID</field>
                                                                      <value name="VALUE"><block type="text_getSubstring" id="%lkY=i]*JF@E0myBY?BW"><mutation at1="true" at2="true"></mutation>
                                                                          <field name="WHERE1">FROM_START</field>
                                                                          <field name="WHERE2">FROM_START</field>
                                                                          <value name="STRING"><block type="variables_get" id="#PF-urAJ.U[8f*`Y-zo_"><field name="VAR">result</field></block></value> 
                                                                          <value name="AT1"><block type="math_number" id="SY!!u?`fRv~OB~mV#.Xa"><field name="NUM">16</field></block></value> 
                                                                          <value name="AT2"><block type="math_number" id="w`gmrBn9Q6m~w+03E?m-"><field name="NUM">44</field></block></value></block></value> 
                                                                      <next><block type="controls_if" id="Db`]sKv_sx4,FmCL6fSw"><mutation else="1"></mutation>
                                                                          <value name="IF0"><block type="logic_compare" id="spM:Gz:Z[P.]1]ox35}{"><field name="OP">EQ</field>
                                                                              <value name="A"><block type="on_source" id="Y^d7bV_BZgTPBw;H2iSq"><field name="ATTR">state.val</field></block></value> 
                                                                              <value name="B"><block type="logic_boolean" id="-(aA^IEaKFj7wR.rFAv9"><field name="BOOL">TRUE</field></block></value></block></value> 
                                                                          <statement name="DO0"><block type="comment" id="I2{%uXwh=5QeIBDx~Ael"><field name="COMMENT">HomeMode aktivieren</field>
                                                                              <next><block type="request" id="3aL?,iT88;4Oqr8%,Ld("><mutation with_statement="false"></mutation>
                                                                                  <field name="WITH_STATEMENT">FALSE</field>
                                                                                  <field name="LOG">log</field>
                                                                                  <value name="URL"><shadow type="text" id="F[va5([*)3rV3Rg@6~wi"><field name="TEXT">text</field></shadow> 
                                                                                    <block type="text_join" id="8R*S`Q[e9i{fAL1@!k-N"><mutation items="3"></mutation>
                                                                                      <value name="ADD0"><block type="text" id="jd]vc_DXPp^Tw*ZaLRfX"><field name="TEXT">http://<ip>:<port>/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true</port></ip></field></block></value> 
                                                                                      <value name="ADD1"><block type="text" id="oZlPa`0xRseA13.]CJY{"><field name="TEXT">&_sid=</field></block></value> 
                                                                                      <value name="ADD2"><block type="variables_get" id="q*X^^TUvaA2isu8i)*I/"><field name="VAR">SID</field></block></value></block></value></block></next></block></statement> 
                                                                          <statement name="ELSE"><block type="comment" id="KHLxjEaDm@8@r)d`97%s"><field name="COMMENT">HomeMode deaktivieren</field>
                                                                              <next><block type="request" id="]93]eVKY/acmPP(XI1.2"><mutation with_statement="false"></mutation>
                                                                                  <field name="WITH_STATEMENT">FALSE</field>
                                                                                  <field name="LOG">log</field>
                                                                                  <value name="URL"><shadow type="text" id="tu@raUM{Bs7+bD51l3O{"><field name="TEXT">text</field></shadow> 
                                                                                    <block type="text_join" id="32wM[yij4H};]B.qIh?|"><mutation items="3"></mutation>
                                                                                      <value name="ADD0"><block type="text" id="t[o_dsQTIqL3Ei_uI2rD"><field name="TEXT">http:/<ip>:<port>/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=false</port></ip></field></block></value> 
                                                                                      <value name="ADD1"><block type="text" id="YH`Zf[axlAw4o)A6TkU8"><field name="TEXT">&_sid=</field></block></value> 
                                                                                      <value name="ADD2"><block type="variables_get" id="h!d5UEvaUZtV~b3L8vTX"><field name="VAR">SID</field></block></value></block></value></block></next></block></statement></block></next></block></next></block></statement></block></next></block></next></block></statement></block></next></block></next></block></next></block></xml> 
                                  
                                  

                                  Skript:

                                  var SID, result;
                                  
                                  // Skript ändert den HomeMode der Synology
                                  // Surveillance Station - True oder False
                                  // Trigger ist eine Objektänderung
                                  on({id: "control.0.SurveillanceStation.HomeMode"/*HomeMode*/, change: "ne"}, function (obj) {
                                    var value = obj.state.val;
                                    var oldValue = obj.oldState.val;
                                    // Login URL - Hardcoded
                                    // IP-Adresse, User und Password
                                    try {
                                      require("request")('http://<ip>:<port>/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=<user>&passwd=<password>&session=SurveillanceStation&format=sid', function (error, response, result) {
                                        // Session Token speichern
                                      SID = result.slice(15, 44);
                                      if ((obj.state ? obj.state.val : "") == true) {
                                        // HomeMode aktivieren
                                        try {
                                          require("request")((['http://<ip>:<port>/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true','&_sid=',SID].join(''))).on("error", function (e) {console.error(e);});
                                        } catch (e) { console.error(e); }
                                        console.log("request: " + (['http://<ip>:<port>/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true','&_sid=',SID].join('')));
                                      } else {
                                        // HomeMode deaktivieren
                                        try {
                                          require("request")((['http://<ip>:<port>/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=false','&_sid=',SID].join(''))).on("error", function (e) {console.error(e);});
                                        } catch (e) { console.error(e); }
                                        console.log("request: " + (['http://<ip>:<port>/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=false','&_sid=',SID].join('')));
                                      }
                                      }).on("error", function (e) {console.error(e);});
                                    } catch (e) { console.error(e); }
                                    console.log("request: " + 'http://<ip>:<port>/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=<user>&passwd=<password>&session=SurveillanceStation&format=sid');
                                  });</password></user></port></ip></port></ip></port></ip></port></ip></port></ip></password></user></port></ip> 
                                  

                                  Vielleicht hilft Dir das ja.

                                  1 Reply Last reply Reply Quote 0
                                  • D
                                    dominik.braun82 last edited by

                                    Danke… eine Frage noch dazu.

                                    Wo wird das script eingefügt?

                                    Blockly ist ja klar 🙂

                                    1 Reply Last reply Reply Quote 0
                                    • A
                                      ak1 last edited by

                                      Wenn Du ein Blockly im Editor geöffnet hast, dann hast Du oben rechts "Enginetyp", "Blöcke prüfen", "Zeige Code" und die Icons für Import und Export.

                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        dominik.braun82 last edited by

                                        ja das wusste ich aber die Frage ist, warum 2 scripte aufgeführt sind.

                                        einmal "blockly" und einmal "script".

                                        Muss ich beide scripte importieren?

                                        wenn ich einen script importiere ist nur ein kleines schwarzes Symbol zu sehen :roll:

                                        7511_2018-09-02_12h17_50.jpg

                                        ist das korrekt?

                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          ak1 last edited by

                                          Nee, der schwarze Klecks ist nicht normal.

                                          Ich habe ein Blockly, was annähernd so aussieht, wie Du es aus dem Thread hier kennst. Genau das, solltest Du importieren können.

                                          Wenn Du ein Blockly im Editor hast, dann kannst Du Dir mit "Zeige Code" den Java Script Code dazu anzeigen lassen. Den habe ich halt (zur Info für Dich) ebenfalls gepostet.

                                          Aber irgendwas ist an dem geposteten Blockly faul. Wenn ich das importiere, habe ich auch nur den schwarzen Klecks. Lass mich nochmal schauen…

                                          1 Reply Last reply Reply Quote 0
                                          • A
                                            ak1 last edited by

                                            Probiere es mit dem nochmal:

                                             <xml xmlns="http://www.w3.org/1999/xhtml"><block type="comment" id="?eH]L9k:Ib4wfolmT[cy" x="87" y="-838"><field name="COMMENT">Skript ändert den HomeMode der Synology</field>
                                                <next><block type="comment" id="qwy:_@:WY|8mC9_eS9VZ"><field name="COMMENT">Surveillance Station - True oder False</field>
                                                    <next><block type="comment" id="pYyx,Cg!,cdg:|,-?u]a"><field name="COMMENT">Trigger ist eine Objektänderung</field>
                                                        <next><block type="on" id="bcuLKEa;9pP{IH#th[!4"><field name="OID">control.0.SurveillanceStation.HomeMode</field>
                                                            <field name="CONDITION">ne</field>
                                            
                                                            <statement name="STATEMENT"><block type="comment" id="N;:SDq:TI*zH~2%Q!USS"><field name="COMMENT">Login URL - Hardcoded</field>
                                                                <next><block type="comment" id="OA!{bdbR=I{~*en2b:)q"><field name="COMMENT">IP-Adresse, User und Password</field>
                                                                    <next><block type="request" id="]5K08@Y}juiF3ry_yR,5"><mutation with_statement="true"></mutation>
                                                                        <field name="WITH_STATEMENT">TRUE</field>
                                                                        <field name="LOG">log</field>
                                                                        <value name="URL"><shadow type="text" id="6xTZA,IEA?{.C1Vdb?Cy"><field name="TEXT">http://192.168.1.100:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=username&passwd=password&session=SurveillanceStation&format=sid</field></shadow></value> 
                                                                        <statement name="STATEMENT"><block type="comment" id="kfmW-jlXfUvR7zTJ~foA"><field name="COMMENT">Session Token speichern</field>
                                                                            <next><block type="variables_set" id="(p/#.2{RZ:jCLk:|fDem"><field name="VAR">SID</field>
                                                                                <value name="VALUE"><block type="text_getSubstring" id="%lkY=i]*JF@E0myBY?BW"><mutation at1="true" at2="true"></mutation>
                                                                                    <field name="WHERE1">FROM_START</field>
                                                                                    <field name="WHERE2">FROM_START</field>
                                                                                    <value name="STRING"><block type="variables_get" id="#PF-urAJ.U[8f*`Y-zo_"><field name="VAR">result</field></block></value> 
                                                                                    <value name="AT1"><block type="math_number" id="SY!!u?`fRv~OB~mV#.Xa"><field name="NUM">16</field></block></value> 
                                                                                    <value name="AT2"><block type="math_number" id="w`gmrBn9Q6m~w+03E?m-"><field name="NUM">44</field></block></value></block></value> 
                                                                                <next><block type="controls_if" id="Db`]sKv_sx4,FmCL6fSw"><mutation else="1"></mutation>
                                                                                    <value name="IF0"><block type="logic_compare" id="spM:Gz:Z[P.]1]ox35}{"><field name="OP">EQ</field>
                                                                                        <value name="A"><block type="on_source" id="Y^d7bV_BZgTPBw;H2iSq"><field name="ATTR">state.val</field></block></value> 
                                                                                        <value name="B"><block type="logic_boolean" id="-(aA^IEaKFj7wR.rFAv9"><field name="BOOL">TRUE</field></block></value></block></value> 
                                                                                    <statement name="DO0"><block type="comment" id="I2{%uXwh=5QeIBDx~Ael"><field name="COMMENT">HomeMode aktivieren</field>
                                                                                        <next><block type="request" id="3aL?,iT88;4Oqr8%,Ld("><mutation with_statement="false"></mutation>
                                                                                            <field name="WITH_STATEMENT">FALSE</field>
                                                                                            <field name="LOG">log</field>
                                                                                            <value name="URL"><shadow type="text" id="F[va5([*)3rV3Rg@6~wi"><field name="TEXT">text</field></shadow> 
                                                                                              <block type="text_join" id="8R*S`Q[e9i{fAL1@!k-N"><mutation items="3"></mutation>
                                                                                                <value name="ADD0"><block type="text" id="jd]vc_DXPp^Tw*ZaLRfX"><field name="TEXT">http://192.168.1.100:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true</field></block></value> 
                                                                                                <value name="ADD1"><block type="text" id="oZlPa`0xRseA13.]CJY{"><field name="TEXT">&_sid=</field></block></value> 
                                                                                                <value name="ADD2"><block type="variables_get" id="q*X^^TUvaA2isu8i)*I/"><field name="VAR">SID</field></block></value></block></value></block></next></block></statement> 
                                                                                    <statement name="ELSE"><block type="comment" id="KHLxjEaDm@8@r)d`97%s"><field name="COMMENT">HomeMode deaktivieren</field>
                                                                                        <next><block type="request" id="]93]eVKY/acmPP(XI1.2"><mutation with_statement="false"></mutation>
                                                                                            <field name="WITH_STATEMENT">FALSE</field>
                                                                                            <field name="LOG">log</field>
                                                                                            <value name="URL"><shadow type="text" id="tu@raUM{Bs7+bD51l3O{"><field name="TEXT">text</field></shadow> 
                                                                                              <block type="text_join" id="32wM[yij4H};]B.qIh?|"><mutation items="3"></mutation>
                                                                                                <value name="ADD0"><block type="text" id="t[o_dsQTIqL3Ei_uI2rD"><field name="TEXT">http://192.168.1.100:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=false</field></block></value> 
                                                                                                <value name="ADD1"><block type="text" id="YH`Zf[axlAw4o)A6TkU8"><field name="TEXT">&_sid=</field></block></value> 
                                                                                                <value name="ADD2"><block type="variables_get" id="h!d5UEvaUZtV~b3L8vTX"><field name="VAR">SID</field></block></value></block></value></block></next></block></statement></block></next></block></next></block></statement></block></next></block></next></block></statement></block></next></block></next></block></next></block></xml> 
                                            
                                            
                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            1.3k
                                            Online

                                            30.6k
                                            Users

                                            77.2k
                                            Topics

                                            1.2m
                                            Posts

                                            12
                                            50
                                            5006
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo