Skip to content
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Logo
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Gelöst - Programm funktioniert nicht so wie's soll :(

NEWS

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.0k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    1.8k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    15
    1
    2.0k

Gelöst - Programm funktioniert nicht so wie's soll :(

Gelöst - Programm funktioniert nicht so wie's soll :(

Scheduled Pinned Locked Moved Skripten / Logik
5 Posts 2 Posters 829 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rascal
    wrote on last edited by
    #1

    Hallo,

    ich habe mir eine globale Funktion geschrieben, mit welcher ich mir über die SayIt Adapter Sachen ansage lasse.

    Ich über gebe der Funktion mit "wo" den Raumnamen, welchen ich dann mit "if" abfrage und nur dort ausgeben lasse.

    Zusätzlich habe ich noch eine if-Abfrage für "alle", wo dann natürlich auf allen Sayit angesagt werden soll.

    Das Problem das ich jetzt habe ist, dass wenn ich zb den Raumnamen "DBR" (für Dachbodenraum) übergebe, sagt er den Text in allen Räumen, nicht nur im DBR.

    Die Variablen werden richtig übergeben, er geht auch in die richtige IF Verzweigung, nur die Ansage passiert überall und nicht nur dort wo sie soll.

    habe ich was übersehen? funktioniert das über haupt so?

    Code:

    //Aufruf der Funktion mit: ansage("TestText", "Martin", Ansagelänge);
    
    function ansage(wo, text, laenge, volume)
    {
        if(volume === undefined || volume === null || volume > 100) volume = 1;
        else volume = volume/100;
        var vol;
        var vol_old;
        var vol_dp;
    
        log("---------------------ANSAGE MAIN wo: "+wo+" Text: "+text+" Länge: "+laenge+" Volume: "+volume);
    
        var tagw = tagwache();
    
        if(wo == "Martin")
        {
            var ist_da = getState("hm-rega.0.2475"/*Anwesenheit.Martin*/).val;
    
            if(ist_da)
            {
                log("----------------ANSAGE Martin: "+wo);
                wo = "sayit.0.tts.text";
                vol_dp = "sayit.0.tts.volume";
                vol_old = 100;
    
                if(tagw) vol = 85*volume;
                    else vol = 85*volume;
    
                setState(vol_dp, vol);
                setState(wo, text);
                setStateDelayed(vol_dp, vol_old, laenge);
            }
        }
        if(wo == "DBR")
        {
            log("----------------ANSAGE DBR: "+wo);
            wo = "sayit.2.tts.text";
            vol_dp = "sayit.2.tts.volume";
            vol_old = 100;
    
            if(tagw) vol = 100*volume;
                else vol = 85*volume;
    
            setState(vol_dp, vol);
            setState(wo, text);
            setStateDelayed(vol_dp, vol_old, laenge);
        }
        if(wo == "Küche")
        {
            log("----------------ANSAGE Küche: "+wo);
            wo = "sayit.3.tts.text";
            vol_dp = "sayit.3.tts.volume";
            vol_old = 100;
    
            if(tagw) vol = 100*volume;
                else vol = 85*volume;
    
            setState(vol_dp, vol);
            setState(wo, text);
            setStateDelayed(vol_dp, vol_old, laenge);
        }
        if(wo == "Badezimmer")
        {
            log("----------------ANSAGE Badezimmer: "+wo);
            wo = "sayit.1.tts.text";
            vol_dp = "sayit.1.tts.volume";
            vol_old = 85;
    
            if(tagw) vol = 85*volume;
                else vol = 75*volume;
    
            setState(vol_dp, vol);
            setState(wo, text);
            setStateDelayed(vol_dp, vol_old, laenge);
        }
         if(wo == "Schrankraum")
        {
            log("----------------ANSAGE Schrankraum: "+wo);
            wo = "sayit.7.tts.text";
            vol_dp = "sayit.7.tts.volume";
            vol_old = 80;
            var bett_1 = getState("hm-rpc.0.JEQ0156677.1.STATE"/*Sensor Bett SZ Martin.STATE*/).val;
            var bett_2 = getState("hm-rpc.0.JEQ0156677.2.STATE"/*Sensor Bett SZ Babsi.STATE*/).val;
    
            if(tagw) vol = 90*volume;
                else vol = 80*volume;
            if(!bett_1 || !bett_2) vol = 0;
    
            setState(vol_dp, vol);
            setState(wo, text);
            setStateDelayed(vol_dp, vol_old, laenge);
        }
        if(wo == "Keller")
        {
            log("----------------ANSAGE Keller: "+wo);
            wo = "sayit.6.tts.text";
            vol_dp = "sayit.6.tts.volume";
            vol_old = 85;
    
            if(tagw) vol = 85*volume;
                else vol = 75*volume;
    
            setState(vol_dp, vol);
            setState(wo, text);
            setStateDelayed(vol_dp, vol_old, laenge);
        }
        if(wo == "wc")
        {
            log("----------------ANSAGE wc: "+wo);
            wo = "sayit.5.tts.text";
            vol_dp = "sayit.5.tts.volume";
            vol_old = 85;
    
            if(tagw) vol = 85*volume;
                else vol = 75*volume;
    
            setState(vol_dp, vol);
            setState(wo, text);
            setStateDelayed(vol_dp, vol_old, laenge);
        }
        if(wo == "alle")
            log("----------------ANSAGE alle: "+wo);
            var x = 0;
            for(var i=0; i<=7; i++) //-----------------------------------ANPASSEN WENN EIN SAYIT ADAPTER DAZU KOMMT!!!!
            {
                wo = "sayit."+i+".tts.text";
                vol_dp = "sayit."+i+".tts.volume";
                if(i === 0 || i == 2 || i ==3) vol_old = 100;
                if(i == 1 || i ==5 || i == 6) vol_old = 85;
                if(i == 7) vol_old = 80;
    
                if(tagw) vol = 85*volume;
                    else vol = 75*volume;
    
                setState(vol_dp, vol);
                setState(wo, text);
                setStateDelayed(vol_dp, vol_old, laenge);
            }
    }
    

    Aufruf der Funktion:

    ansage("DBR", "Guten Morgen", 2000, 80);
    

    Log Ausgabe für Variable "wo" = "DBR":

    javascript-0	2016-10-28 11:28:30.186	info	script.js.Test3: ----------------ANSAGE DBR: DBR
    javascript-0	2016-10-28 11:28:30.185	info	script.js.Test3: ---------------------ANSAGE MAIN wo: DBR Text: Guten Morgen Länge: 2000 Volume: 0.8
    

    Wäre toll wenn mir jemand helfen könnte, danke.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rascal
      wrote on last edited by
      #2

      Ich habe die if(wo == "alle") ausgeklammert, nun sagte er mir nur mehr im richtigen Raum an… ich versteh's nicht.

      die wo Variable hat zb "DBR" und trotzdem geht das Programm in den if(wo == "alle") Zweig..... warum?!?!

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Phantomio
        wrote on last edited by
        #3

        Hey,

        ich glaube hinter if(wo == "alle) fehlt {

        und am ende halt }

        Gruß

        Phantomio

        Geräte: CCU2, RaspberryPi2,

        Adapter: email, feiertage, flot, fritzbox, history, hm-rpc.0, hm-rpc.1 (Für Homematic IP), ical, javascript, sayit, scenes, socketio, sonos, tankerkoenig, telegram, text2command, vis, web, yr

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rascal
          wrote on last edited by
          #4

          bevor ich jetzt im Boden versinke und für die kommende Woche das Programmieren ganz lasse, möchte ich mich recht herzlich bedanken… das wars :oops:

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Phantomio
            wrote on last edited by
            #5

            Kein Problem !!!

            Ich habe selber schon so viel aus dem Forum an Infos gezogen und Hilfe bekommen,

            da bin froh wenn ich auch mal helfen kann.

            Gruß

            Phantomio

            Geräte: CCU2, RaspberryPi2,

            Adapter: email, feiertage, flot, fritzbox, history, hm-rpc.0, hm-rpc.1 (Für Homematic IP), ical, javascript, sayit, scenes, socketio, sonos, tankerkoenig, telegram, text2command, vis, web, yr

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            Support us

            ioBroker
            Community Adapters
            Donate

            477

            Online

            32.4k

            Users

            81.3k

            Topics

            1.3m

            Posts
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
            ioBroker Community 2014-2025
            logo
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Unread 0
            • Categories
            • Unreplied
            • Popular
            • GitHub
            • Docu
            • Hilfe