Ankündigung

Einklappen
Keine Ankündigung bisher.

Rhasspy Sprachsteuerung + php-Nachhilfe

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Rhasspy Sprachsteuerung + php-Nachhilfe

    Hallo zusammen,

    nachdem die Plattform der offline Spracherkennung snips nun endgültig geschlossen ist, haben sich mehrere Alternativen aufgetan.
    Die -meiner Ansicht nach- vielversprechendste und bereits weit entwickelte Alternative stellt die diesmal wirklich offene Plattform Rhasspy dar. Dieses github-Projekt ist relativ weit entwickelt und die dazugehörige community arbeitet mit Hochdruck an der Weiterentwicklung.
    Siehe hier https://community.rhasspy.org/

    Ein sehr gutes und ausführliches howto gibt es auch bereits. Siehe hier: https://rhasspy.readthedocs.io/en/latest/

    MQTT und API sind bereits möglich, wobei in den kommenden Wochen das MQTT-Protokoll mit der Version 2.5 noch erweitert werden soll.
    Der bestehende „snips“-LBS (19000289) von vento66 kann weitestgehend auch für Rhasspy verwendet werden.
    d.JPG

    Auf der Rhasspy gui lassen sich intents, slots und zusammenstellen. Alternativ können die *.inis auch per FTP bearbeitet und angepasst werden. Der etwas geänderte hat derzeit die ID 19100004

    Auf der gui von Rhasspy schaut ein Beispiel derzeit wie folgt aus:
    c.JPG



    Trainierte Sätze:
    b.JPG

    Hier kann nochmal per Eingabe getestet werden, welche json string ausgegeben wird ohne den Einfluss von Sprache:
    a.JPG


    Ein Manko mit dem bestehenden „snips“-LBS gibt es allerdings noch. Ich hab nun schon mehrere Wochen versucht es zu lösen, allerdings ohne Erfolg. Vielleicht findet sich ja jemand, der es noch einbauen könnte.
    Der bestehende LBS verarbeitet derzeit die slots:
    • Slot name device
    • Slot name OnOff
    • Slot name value

    Nachteil dabei ist, dass im Grunde noch ein slot für „location“ fehlt. Schwierig bzw. umständlich dabei wird es bei Sätzen wie:
    f.JPG

    Für dieses aufgeführte Beispiel gibt es allein schon zahlreiche Möglichkeiten, was in welcher Reihenfolge gesprochen werden könnte. Zum Beispiel diese hier:

    e.JPG

    Jede einzelne Variante muss angelegt und trainiert werden. Um dies zu vereinfachen und
    Folgende Optimierung für den Baustein könnte ich mir folgendes vorstellen:

    An E10 liegt nicht nur „mia“, sondern „mia|nachbarseite“ an und der Baustein soll dabei folgendes machen:

    Wenn am Eingang [n] Trennzeichen | vorhanden, dann nutze Variable 1 [mia] für slot_room und Varibale 2 [nachbarseite] für slot_location. Ansonsten nehme Variable 1 als slot_name. Im Anschluss soll der Baustein durchlaufen und den entsprechenden Ausgang belegen.

    Damit wären alle Optionen abgedeckt und man kann die „slot-Sätze“ relativ schnell in der gui zusammenbauen.

    In den vergangenen Wochen habe ich es mit dutzenden funktionen (explode, preg_split,str_split, usw.) und vielen vielen Variationen versucht, immer ohne Erfolg.

    Kann hier jemand weiterhelfen?

    So schaut der code derzeit aus

    PHP-Code:
    ###[DEF]###
    [name = RhasspySpeech v0.1]

    [e#1 option = Debug #init=8 ]
    [e#2 trigger = MQTT Payload ]
    [e#3 important = Rhasspy IntentName #init=switchlight ]
    [e#4 important = Slot Name Device #init=rooms_name ]
    [e#5 important = Slot Name OnOff #init=switchstate_name ]
    [e#6 important = Slot On Synonyms #init=ein,an,einschalten,auf,aufdrehen]
    [e#7 important = Slot Off Synonyms #init=aus,ausschalten,ab,abdrehen ]
    [e#8 option = Slot Name Value #init=brightness ]
    [e#9 option = Multiplikator #init=2.55 ]

    [e#10 = Names 0 ]
    [e#11 = Names 1 ]
    [e#12 = Names 2 ]
    [e#13 = Names 3 ]
    [e#14 = Names 4 ]
    [e#15 = Names 5 ]
    [e#16 = Names 6 ]
    [e#17 = Names 7 ]
    [e#18 = Names 8 ]
    [e#19 = Names 9 ]

    [a#10 = Output 0 ]
    [a#11 = Output 1 ]
    [a#12 = Output 2 ]
    [a#13 = Output 3 ]
    [a#14 = Output 4 ]
    [a#15 = Output 5 ]
    [a#16 = Output 6 ]
    [a#17 = Output 7 ]
    [a#18 = Output 8 ]
    [a#19 = Output 9 ]

    [v#100 = 0.1 ] // Version
    [v#101 = 19100002 ] // LBS ID
    [v#102 = RhasspySpeech] // LBS name
    [v#103 = 3 ] // Loglevel
    [v#104 = 1 ] // One logfile per instance
    [v#105 = 1 ] // log ID in each line

    ###[/DEF]###


    ###[HELP]###
    ###[/HELP]###

    ###[LBS]###
    <?php
    function LB_LBSID($id) {
    if (
    $E=logic_getInputs($id)) {
    if (
    $E[2]['refresh'] == && $E[2]['value'] != "") {
    setLogicElementVar($id103$E[1]['value']); // set loglevel to #VAR 103
    LB_LBSID_logging($id"LBS: LBS started",7);
    LB_LBSID_logging($id"LBS: Payload changed to ".$E[2]['value'], 6);

    $jsonArray json_decode($E[2]['value'], true);
    if(
    json_last_error() == JSON_ERROR_NONE){

    $slotName strtolower(trim($E[4]['value']));

    $OnArray explode(",",strtolower(trim($E[6]['value'])));
    LB_LBSID_logging($id,"On Array ",8,$OnArray);

    $OffArray explode(",",strtolower(trim($E[7]['value'])));
    LB_LBSID_logging($id,"Off Array ",8,$OffArray);

    $jsonArray json_decode($E[2]['value'], true);
    for (
    $i 10$i 20$i++) {
    LB_LBSID_logging($id"Lese Eingang $i ".$E[$i]['value'],8);
    if(
    $E[$i]['value'] != ''){
    $locationArray[$i] = strtolower(trim($E[$i]['value']));
    }
    }
    LB_LBSID_logging($id,"Device Array ",8,$locationArray);

    $intentName explode(":",$jsonArray["intent"]["intentName"]);
    $intentName strtolower(trim($intentName[1]));

    $pos $loc $ent '';
    unset(
    $val);
    $Name false;
    if ( 
    $intentName == strtolower(trim($E[3]['value'])) ) {
    $ent $intentName;

    foreach(
    $jsonArray['slots'] as $slots ){
    if(
    strtolower(trim($slots['slotName'])) == strtolower(trim($E[5]['value']))){
    $Name=true;
    break;
    }

    }

    $brightArray explode(","strtolower($E[8]['value']));
    LB_LBSID_logging($id,"Bright Array ",8,$brightArray);
    $switch 0;

    foreach(
    $jsonArray['slots'] as $slots ){
    if(
    strtolower(trim($slots['slotName'])) == strtolower(trim($E[8]['value']))){
    $Name=true;
    break;
    }

    }
    if(
    $Name){
    foreach(
    $jsonArray['slots'] as $slots ){
    if(
    in_array(strtolower(trim($slots['value']['value'])),$locationArray)){
    if(
    strtolower(trim($slots['slotName'])) == $slotName){
    $loc $slots['value']['value'];
    $posarray = (array_keys($locationArraystrtolower(trim($slots['value']['value']))));
    $pos $posarray[0];
    break;
    }
    }
    }
    foreach(
    $jsonArray['slots'] as $slots ){
    if(
    in_array(strtolower(trim($slots['value']['value'])),$OnArray)){
    $val 1;
    LB_LBSID_logging($id,"On found $val ",8);
    $switch 1;
    break;
    }
    }
    foreach(
    $jsonArray['slots'] as $slots ){
    if(
    in_array(strtolower(trim($slots['value']['value'])),$OffArray)){
    $val 0;
    $switch 1;
    LB_LBSID_logging($id,"Off found $val $pos",8);
    break;
    }
    }

    if(
    $switch != 1){
    foreach(
    $jsonArray['slots'] as $slots ){
    if(
    in_array(strtolower(trim($slots['slotName'])),$brightArray)){
    $switch 0;
    $val $slots['value']['value'];
    LB_LBSID_logging($id,"val found $val ",8);
    break;
    }
    }
    }

    if(
    $ent != ''){LB_LBSID_logging($id,"Snips IntentName found: $ent ",8);}
    if(
    $loc != ''){LB_LBSID_logging($id,"Slot Name Device found: $loc ",8);}else{LB_LBSID_logging($id,"Slot Name Device not found",8);}
    if(
    $val != ''){LB_LBSID_logging($id,"Slot Name Value found: $val ",8);}else{LB_LBSID_logging($id,"Slot Name Value not found",8);}
    if(
    $pos != ''){LB_LBSID_logging($id,"Slot Name Device Key found: $pos,8);}else{LB_LBSID_logging($id,"Slot Name Device not in array",8);}
    }
    if(isset(
    $val) && $pos != ''){
    LB_LBSID_logging($id,"switch $switch"$E[9]['value'],1);
    if(
    $E[9]['value'] != '' && $switch == 0){
    $val round(($val*$E[9]['value']),0);
    LB_LBSID_logging($id,"Multiplikator erkannt ".$E[9]['value']." Neuer Wert $val,8);
    }
    logic_setOutput($id,$pos$val);
    LB_LBSID_logging($id,"Ausgang $pos auf $val gesetzt" ,8);
    }
    }else{
    LB_LBSID_logging($id,"Snips IntentName not found",8);
    }
    }else{
    if(
    phpversion() < 5.5){
    LB_LBSID_logging($id,"incorrect JSON string " ,3);
    }else {
    LB_LBSID_logging($id,"incorrect JSON string - ".json_last_error_msg() ,3);
    }
    }
    }

    }
    }


    function 
    LB_LBSID_logging($id$msg$priority$var NULL){
    $E getLogicEingangDataAll($id);
    $logLevel getLogicElementVar($id103);
    if (
    is_int($priority) && $priority <= $logLevel && $priority 0) {
    $logLevelNames = array(
    'none',
    'emerg',
    'alert',
    'crit',
    'err',
    'warning',
    'notice',
    'info',
    'debug'
    );
    $version getLogicElementVar($id100);
    $lbsNo getLogicElementVar($id101);
    $logName getLogicElementVar($id102) . "-LBS$lbsNo";
    $logName preg_replace('/ /''_'$logName);
    if (
    logic_getVar($id104))
    $logName .= "-$id";
    if (
    logic_getVar($id105) == 1)
    //$msg .= " ($id)";
    strpos($_SERVER['SCRIPT_NAME'], $lbsNo) ? $scriptname 'EXE' $lbsNo $scriptname 'LBS' $lbsNo;
    writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t" $msg);
    if (isset(
    $var)) {
    writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t================ ARRAY/OBJECT START ================");
    writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t" json_encode($var));
    writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t================ ARRAY/OBJECT END ================");
    }
    }
    }


    ?>
    ###[/LBS]###

    ###[EXEC]###
    <?
    // nothing to do
    ?>
    ###[/EXEC]###



    BTW:
    Irgendwann bin ich umgestiegen und habe mir einen (eigentlich) ganz simplen Baustein zusammen bauen wollen, der im ersten Schritt die Trennung eines Eingangs vornimmt und auf dem entsprechenden Ausgang wieder ausgibt. Ebenfalls ohne Erfolg.
    Woran hapert es hierbei?

    g.JPG

    PHP-Code:
    ###[DEF]###
    [name = Liste zerlegen (0.2) ]

    [e#1 TRIGGER = Liste ]
    [e#3 OPTIONAL = Trenner #init=\|]

    [a#1 = Liste ]
    [a#2 = Element 1 ]
    [a#3 = Element 2 ]
    ###[/DEF]###

    ###[LBS]###
    <?
    function LB_LBSID($id) {
    if ($E=logic_getInputs($id)) {

    $temp = explode('|',$E[1]['value']);
    logic_setOutput($id,$i,$temp);
    }
    }
    ?>
    ###[/LBS]###


    Danke und Gruß


    edit:
    Matrix Voice ist ebenfalls auf Rhasspy aufmerksam geworden und hat bereits erste Installationsanleitungen und Tipps hochgeladen:

    https://www.hackster.io/matrix-labs/...sistant-faa221
    https://www.hackster.io/matrix-labs/...creator-97f92e
    Angehängte Dateien
    Zuletzt geändert von ThomasCologne; 06.02.2020, 23:53.

    #2
    Danke fuer das ausfuehrliche Posting!

    Zitat von ThomasCologne Beitrag anzeigen
    Woran hapert es hierbei?
    $temp ist ein Array, Du musst angeben welches Element du haben willst und nicht das Array auf den Ausgang legen.
    Den LBS gibts aber auch in fertig: https://service.knx-user-forum.de/?c...ad&id=19000107

    Kommentar


      #3
      Zitat von wintermute Beitrag anzeigen
      Den LBS gibts aber auch in fertig
      Den hatte ich ja genutzt um ihn "auseinander zu pflücken" und daran die Ausgabe zu testen. Nur, um dann später die Funktion in dem eigentlichen LBS für den Rhassp einbauen zu können.
      Allerdings erwartet der 107 eine Eingabe an E2, die ja in dem Rhasspy LBS eigentlich nicht notwendig sein muss.

      Kommentar


        #4
        Dann halt die Zeile
        Code:
        logic_setOutput($id,$i,$temp);
        ersetzen durch
        Code:
        logic_setOutput($id,2,$temp[0]);
        logic_setOutput($id,3,$temp[1]);

        Kommentar


          #5
          Zitat von wintermute Beitrag anzeigen
          [0]
          DAS war der entscheidende Tipp! Danke!
          Nun kann ich versuchen weiter zu tüfteln, sodass diese getrennte Ausgabe in dem Rhasspy LBS auch genutzt werden kann.

          Kommentar


            #6
            Nabend zusammen,

            also irgendwie klappt die gewünschte Auswertung nicht so, wie es soll.
            Kann hier nochmal jemand drüber schauen, ob der Ansatz überhaupt stimmt oder bereits völlig daneben ist?

            Denn wenn folgender json gesendet wird,
            a.JPG

            kommt folgende Auswertung:
            Code:
             [TABLE="border: 0, cellpadding: 0, cellspacing: 0"]
             	 		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]296931[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: LBS: LBS started[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]298588[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: LBS: Payload changed to {"sessionId": "", "siteId": "default", "input": "mia strasse hoch", "intent": {"intentName": ":moveshutter", "confidenceScore": 1.0}, "slots": [{"slotName": "rooms_name", "confidence": 1, "value": {"kind": "rooms_name", "value": "mia"}, "rawValue": "mia"}, {"slotName": "location_name", "confidence": 1, "value": {"kind": "location_name", "value": "strasse"}, "rawValue": "strasse"}, {"slotName": "updown_name", "confidence": 1, "value": {"kind": "updown_name", "value": "hoch"}, "rawValue": "hoch"}], "asrTokens": [], "asrConfidence": 1}[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]300425[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: On Array[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]300790[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT START ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]300892[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ["hoch"][/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]300959[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT END ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]304001[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: Off Array[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]304310[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT START ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]304402[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ["runter"][/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]304553[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT END ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]306574[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: rooma12.1 Array[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]306761[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT START ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]306833[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: "mia"[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]306927[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT END ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]308072[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: loca12.2 Array[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]308213[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT START ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]308320[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: "strasse"[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]308386[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT END ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]309478[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: roomb13.1 Array[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]309593[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT START ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]309664[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: "mia"[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]309750[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT END ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]311798[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: locb13.2 Array[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]312994[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: Bright Array[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]313114[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT START ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]313213[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ["brightness"][/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]313314[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: ================ ARRAY/OBJECT END ================[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]315095[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: On found 1[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]316308[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: Snips IntentName found: moveshutter[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]317423[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: Slot Name Room found: mia[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]318523[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: Slot Name location found: mia[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]319679[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: Slot Name Value found: 1[/TD]
             		[/TR]
             		[TR]
             			[TD]2020-02-11 22:43:36[/TD]
             			[TD]321058[/TD]
             			[TD]6421[/TD]
             			[TD]debug[/TD]
             			[TD]LBS19100002 [v0.1]: Slot Name Device not in array[/TD]
             		[/TR]
             	 [/TABLE]
            Der LBS schaut mittlerweile so aus:
            PHP-Code:
            ###[DEF]###
            [name = RhasspySpeech v0.1]

            [e#1 option = Debug #init=8 ]
            [e#2 trigger = MQTT Payload ]
            [e#3 important = Rhasspy IntentName #init=switchlight ]
            [e#4 important = SlotName Room #init=rooms_name ]
            [e#5 important = SlotName OnOff #init=switchstate_name ]
            [e#6 important = Slot On Synonyms #init=ein,an,einschalten,auf,aufdrehen]
            [e#7 important = Slot Off Synonyms #init=aus,ausschalten,ab,abdrehen ]
            [e#8 option = Slot Name Value #init=brightness ]
            [e#9 option = Multiplikator #init=2.55 ]
            [e#10 option = SlotName Location #init=location_name ]

            [e#12 = Names 0 ] // hier soll eingeben werden: mia|strasse was bedeutet: room|location
            [e#13 = Names 1 ]
            [e#14 = Names 2 ]
            [e#15 = Names 3 ]
            [e#16 = Names 4 ]
            [e#17 = Names 5 ]
            [e#18 = Names 6 ]
            [e#19 = Names 7 ]
            [e#20 = Names 8 ]
            [e#21 = Names 9 ]


            [a#12 = Output 0 ]
            [a#13 = Output 1 ]
            [a#14 = Output 2 ]
            [a#15 = Output 3 ]
            [a#16 = Output 4 ]
            [a#17 = Output 5 ]
            [a#18 = Output 6 ]
            [a#19 = Output 7 ]
            [a#20 = Output 8 ]
            [a#21 = Output 9 ]

            [v#100 = 0.1 ] // Version
            [v#101 = 19100002 ] // LBS ID
            [v#102 = RhasspySpeech] // LBS name
            [v#103 = 3 ] // Loglevel
            [v#104 = 1 ] // One logfile per instance
            [v#105 = 1 ] // log ID in each line
            ###[/DEF]###


            ###[HELP]###
            ###[/HELP]###

            ###[LBS]###
            <?php
            function LB_LBSID($id) {
            if (
            $E=logic_getInputs($id)) {
            if (
            $E[2]['refresh'] == && $E[2]['value'] != "") {
            setLogicElementVar($id103$E[1]['value']); // set loglevel to #VAR 103
            LB_LBSID_logging($id"LBS: LBS started",7);
            LB_LBSID_logging($id"LBS: Payload changed to ".$E[2]['value'], 6);


            $jsonArray json_decode($E[2]['value'], true);
            if(
            json_last_error() == JSON_ERROR_NONE){


            $slotName strtolower(trim($E[4]['value']));

            $OnArray explode(",",strtolower(trim($E[6]['value'])));
            LB_LBSID_logging($id,"On Array ",8,$OnArray);
            $OffArray explode(",",strtolower(trim($E[7]['value'])));
            LB_LBSID_logging($id,"Off Array ",8,$OffArray);

            $jsonArray json_decode($E[2]['value'], true);
            if(
            json_last_error() == JSON_ERROR_NONE){

            $roomaArray explode("|",strtolower(trim($E[12]['value']))); // Eingang 12 auswerten
            LB_LBSID_logging($id,"rooma12.1 Array ",8,$roomaArray[0]);
            $locaArray explode("|",strtolower(trim($E[12]['value'])));
            LB_LBSID_logging($id,"loca12.2 Array ",8,$locaArray[1]);

            $roombArray explode("|",strtolower(trim($E[13]['value']))); // Eingang 13 auswerten
            LB_LBSID_logging($id,"roomb13.1 Array ",8,$roombArray[0]);
            $locbArray explode("|",strtolower(trim($E[13]['value'])));
            LB_LBSID_logging($id,"locb13.2 Array ",8,$locbArray[1]);
            }

            $intentName explode(":",$jsonArray["intent"]["intentName"]);
            $intentName strtolower(trim($intentName[1]));

            $pos $rooa $ent $loca ''// $loca hinzugefügt für "location"
            unset($val);
            $Name false;
            if ( 
            $intentName == strtolower(trim($E[3]['value'])) ) {
            $ent $intentName;

            foreach(
            $jsonArray['slots'] as $slots ){
            if(
            strtolower(trim($slots['slotName'])) == strtolower(trim($E[5]['value']))){
            $Name=true;
            break;
            }}

            $brightArray explode(","strtolower($E[8]['value'])); // wertet Wert aus
            LB_LBSID_logging($id,"Bright Array ",8,$brightArray);
            $switch 0;

            foreach(
            $jsonArray['slots'] as $slots ){
            if(
            strtolower(trim($slots['slotName'])) == strtolower(trim($E[8]['value']))){
            $Name=true;
            break;
            }}

            if(
            $Name){
            foreach(
            $jsonArray['slots'] as $slots ){
            if(
            in_array(strtolower(trim($slots['value']['value'])),$roomaArray)){
            if(
            strtolower(trim($slots['slotName'])) == $slotName){
            $rooa $slots['value']['value'];
            $posarray = (array_keys($roomaArraystrtolower(trim($slots['value']['value']))));
            $pos $posarray[0];
            break;
            }}}

            foreach(
            $jsonArray['slots'] as $slots ){ // bearbeitet location
            if(in_array(strtolower(trim($slots['value']['value'])),$locaArray)){
            if(
            strtolower(trim($slots['entity'])) == $entity){
            $loca $slots['value']['value'];
            $posarray = (array_keys($locaArraystrtolower(trim($slots['value']['value']))));
            $pos $posarray[0];
            break;
            }}}

            foreach(
            $jsonArray['slots'] as $slots ){
            if(
            in_array(strtolower(trim($slots['value']['value'])),$OnArray)){
            $val 1;
            LB_LBSID_logging($id,"On found $val ",8);
            $switch 1;
            break;
            }}
            foreach(
            $jsonArray['slots'] as $slots ){
            if(
            in_array(strtolower(trim($slots['value']['value'])),$OffArray)){
            $val 0;
            $switch 1;
            LB_LBSID_logging($id,"Off found $val $pos",8);
            break;
            }}

            // folgender Block wertet $brightArray aus
            if($switch != 1){
            foreach(
            $jsonArray['slots'] as $slots ){
            if(
            in_array(strtolower(trim($slots['slotName'])),$brightArray)){
            $switch 0;
            $val $slots['value']['value'];
            LB_LBSID_logging($id,"val found $val ",8);
            break;
            }}}

            if(
            $ent != ''){LB_LBSID_logging($id,"Snips IntentName found: $ent ",8);}
            if(
            $rooa != ''){LB_LBSID_logging($id,"Slot Name Room found: $rooa ",8);}else{LB_LBSID_logging($id,"Slot Name Room not found",8);} // rooma, roomb, usw noch hinzufügen
            if($loca != ''){LB_LBSID_logging($id,"Slot Name location found: $loca ",8);}else{LB_LBSID_logging($id,"Slot Name location not found",8);} // loca, locb, usw noch hinzufügen
            if($val != ''){LB_LBSID_logging($id,"Slot Name Value found: $val ",8);}else{LB_LBSID_logging($id,"Slot Name Value not found",8);}
            if(
            $pos != ''){LB_LBSID_logging($id,"Slot Name Device Key found: $pos,8);}else{LB_LBSID_logging($id,"Slot Name Device not in array",8);}
            }
            if(isset(
            $val) && $pos != ''){
            LB_LBSID_logging($id,"switch $switch"$E[9]['value'],1);
            if(
            $E[9]['value'] != '' && $switch == 0){
            $val round(($val*$E[9]['value']),0);
            LB_LBSID_logging($id,"Multiplikator erkannt ".$E[9]['value']." Neuer Wert $val,8);
            }
            logic_setOutput($id,$pos$val);
            LB_LBSID_logging($id,"Ausgang $pos auf $val gesetzt" ,8);
            }
            }else{
            LB_LBSID_logging($id,"Snips IntentName not found",8);
            }
            }else{
            if(
            phpversion() < 5.5){
            LB_LBSID_logging($id,"incorrect JSON string " ,3);
            }else {
            LB_LBSID_logging($id,"incorrect JSON string - ".json_last_error_msg() ,3);
            }}}}}

            function 
            LB_LBSID_logging($id$msg$priority$var NULL){
            $E getLogicEingangDataAll($id);
            $logLevel getLogicElementVar($id103);
            if (
            is_int($priority) && $priority <= $logLevel && $priority 0) {
            $logLevelNames = array(
            'none',
            'emerg',
            'alert',
            'crit',
            'err',
            'warning',
            'notice',
            'info',
            'debug'
            );
            $version getLogicElementVar($id100);
            $lbsNo getLogicElementVar($id101);
            $logName getLogicElementVar($id102) . "-LBS$lbsNo";
            $logName preg_replace('/ /''_'$logName);
            if (
            logic_getVar($id104))
            $logName .= "-$id";
            if (
            logic_getVar($id105) == 1)
            //$msg .= " ($id)";
            strpos($_SERVER['SCRIPT_NAME'], $lbsNo) ? $scriptname 'EXE' $lbsNo $scriptname 'LBS' $lbsNo;
            writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t" $msg);
            if (isset(
            $var)) {
            writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t================ ARRAY/OBJECT START ================");
            writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t" json_encode($var));
            writeToCustomLog($logNamestr_pad($logLevelNames[$logLevel], 7), $scriptname " [v$version]:\t================ ARRAY/OBJECT END ================");
            }}}

            ?>
            ###[/LBS]###

            ###[EXEC]###
            <?
            ?>
            ###[/EXEC]###

            Auch im LBS kütt nischt an:
            b.JPG

            Wo kann ich hier noch ansetzen?
            Denn so langsam gehen mir die Varianten aus die ich noch versuchen könnte.

            Kommentar

            Lädt...
            X