Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Iobroker <> Domoticz

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Iobroker <> Domoticz

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

      2742_2017.05.21-22.01.55.png Hallo liebe Gemeinde,

      gestartet vor einem Jhr mit Domoticz, hat sich hier inzwischen ein tolles Sammelsurium an ESP's, 433MHz, z-Wave und diversen spezialteilen mit http-Interface angesammelt.

      Das klappt auch alles ganz gut, möchte aber jetzt, nachdem ich bei einem Freund ioBorker sah, auf diesen softmigrieren. Soweit der Wunsch…..

      Ich habe mir also das mqtt-Servermodul auf den iobroker gezogen und domoticz sendet nun seine Stati dahin.

      ch kann auch gut verfolgen wie alle messages ankommen , hier im Bild mit Domoticz out.

      iobroker legt dafür aber keine Devices an, da mache doch garantiert ich was total falsch, kann mir bitte jemand einen Tip geben?

      Danke

      elRedeo

      1 Reply Last reply Reply Quote 0
      • Dutchman
        Dutchman Developer Most Active Administrators last edited by

        @elRedeo:

        2017.05.21-22.01.55.pngHallo liebe Gemeinde,

        gestartet vor einem Jhr mit Domoticz, hat sich hier inzwischen ein tolles Sammelsurium an ESP's, 433MHz, z-Wave und diversen spezialteilen mit http-Interface angesammelt.

        Das klappt auch alles ganz gut, möchte aber jetzt, nachdem ich bei einem Freund ioBorker sah, auf diesen softmigrieren. Soweit der Wunsch…..

        Ich habe mir also das mqtt-Servermodul auf den iobroker gezogen und domoticz sendet nun seine Stati dahin.

        ch kann auch gut verfolgen wie alle messages ankommen , hier im Bild mit Domoticz out.

        iobroker legt dafür aber keine Devices an, da mache doch garantiert ich was total falsch, kann mir bitte jemand einen Tip geben?

        Danke

        elRedeo `

        So einfach geht das nicht, MQTT ist nur ein reader/message broker.

        Ich habe für domoticz ein script geschrieben in kombination von MQTT & Javascript, das kann ich demnäst posten um weiter zu helfen.

        Mein script erstellt die werten en schiest änderungen der werte per URL (domoticz API) zurück nach domoticz.

        Greetzz,

        Dutch

        1 Reply Last reply Reply Quote 0
        • E
          elRedeo last edited by

          Hallo Dutch,

          ja, das wäre toll wenn Du das mal posten könntest, ich bin im Bereich MQTT sehr unerfahren und taste mich gerade rest langsam ran.

          Gruß

          elRedeo

          1 Reply Last reply Reply Quote 0
          • Dutchman
            Dutchman Developer Most Active Administrators last edited by

            @elRedeo:

            Hallo Dutch,

            ja, das wäre toll wenn Du das mal posten könntest, ich bin im Bereich MQTT sehr unerfahren und taste mich gerade rest langsam ran.

            Gruß

            elRedeo `

            Na dan probiern wiers mal :), das script hat nog so einige schoenheitsfehler und ist mehr "bastler" arbeit aber es geht :mrgreen:

            Als erste erstellen wir uns die objecte, dazu per script die API auslesen von domoticz. Im script IP adress aendern, es werde nicht alle geraete ausgelesen.

            Siehe commentar "// Only create states for supported switchtypes ", den filter kannst du ausschalten oder erweitern.

            `var objekt, results, count_import;
            // Connect to Domoticz API interface and list all devices
            try {
                require("request")('http://xxx.xxx.x.xxx:8080/json.htm?type=devices', function (error, response, results) {
                objekt = JSON.parse(results);
            
                log ("ServerTime:"+ objekt.ServerTime);
                log ("Reading Domoticz device list : " + objekt.status);
                log("Total amount of Devices found: " + objekt.result.length);
            
                var i,j;
                for (i = 0; i < objekt.result.length; i++) {
                    // If received value is On/Off translate to boolean, otherwise use received value
                    if ( objekt.result[i].Data == 'On') {
                        state = true;
                    } else if ( objekt.result[i].Data == 'Off' ) {
                        state = false;
                    } else {
                        state = objekt.result[i].Data;
                    }
                // Only create states for supported switchtypes 
                if(objekt.result[i].SwitchType == "Push On Button" || objekt.result[i].SwitchType == "Doorbell" || objekt.result[i].SwitchType == "On/Off"){
            
                    //Create States for each device
                    createState("domoticz.Devices." + objekt.result[i].Name + '.STATE', {
                        name: objekt.result[i].Name,
                        type: 'boolean',
                        role: 'switch',
                        def: 'false',
                        idx: objekt.result[i].idx,
                        SwitchType: objekt.result[i].SwitchType
                    });
                } else {
                    // Error logging for unsupported devices
                    log("Device creation failed not supported yet! DeviceName : " + objekt.result[i].Name + " | SwitchType : " + objekt.result[i].SwitchType
                        + " | Subtype : " + objekt.result[i].SubType);
                }
            }});
            } catch (e) { console.error(e); }` 
            
            Damit sind die objecte erstellt und koennen die states abgefragt werden, dazu muss man aber immer das script neu starten das ist bloed.
            
            Aenderungen auf domitcz hohle ich mir per MQTT ein. Dazu iObroker als MQTT server einrichten und domoticz mit iObroker verbinden.
            
            {habe keine andere loesung gefunden um updates zu ueberwachen....}
            
            Dieses script uerbwacht den MQTT kanal von domoticz. Die daten kommen in JSON format, werden ausgelesen und objecte (vorher mit anderem script ersellt) 
            
            kriegen ihre updates:
            
            `~~[code]~~on({id: 'mqtt.0.domoticz.out', change: "any"}, function (obj) {
                try {
                    obj = JSON.parse(getState('mqtt.0.domoticz.out').val);
                    } catch (e) {
                        console.error('Cannot parse: ' + getState('mqtt.0.domoticz.out').val);
                        return;
                    }
                    var state = obj.nvalue;
                    // Translate number to boolean
                    if ( obj.nvalue == '1' ) {
                    state = true;
                    } else if ( obj.nvalue == '0' ) {
                        state = false;
                    }
                    setState('domoticz.Devices.' + obj.name + '.STATE', state);
                    log('Device : "' + obj.name + '" value updated to : ' + state );
                }
            );
            [/code]`
            
            Damit haben wir domticz > Iobroker fertig, jetzt noch iObroker > Domoticz  8-) 
            
            Dieses script ueberwacht alle domoticz states, bei aenderungen schikt er diese per HTTP API zu domoticz.
            
            Im moment aber nur TRUE/FALSE kommandos, fuer dimmer muesste dies noch angepasst werden. Ich wollte dazu den type afragen um damit das richtige commando zu erstellen aber durch OpenHab adapter brauch ich dieses script nicht mehr :)
            
            Eine function verhindert das ein update per MQTT (weil domoticz schaltet) den befehl nochmal schikt (loop protection), diese ist auf 2 sekunden eingestellt:
            
            `~~[code]~~//Configure IP & Port of domoticz
            var IP = 'xxx.xxx.x.xxx';
            var port = '8080';
            
            // Trigger on state within domotics devices    
            on({id: /^javascript.0.domoticz.Devices\./ , change: "any"}, function (obj) {
            
                var apiLink = '/json.htm?type=command¶m=switchlight&idx=';
                var switchvalue;
                var device = obj.common.idx;
                var switchcmd = '&switchcmd=';
                var httpcommand = "http://" + IP  + ':' + port + apiLink + device + switchcmd ;
            
                if (obj.state.val === true || obj.state.val == '1') {
                    switchvalue = 'On';
                    RFX_Command(httpcommand,switchvalue);
                } else {
                    switchvalue = 'Off';
                    RFX_Command(httpcommand,switchvalue);
                }
            });
            
            // Send switch command by HTTP to Domoticz API, avoid double commando within 2 seconds
            var previouscommand;
            function RFX_Command(httpcommand,switchvalue){
                if (previouscommand !== httpcommand + switchvalue) {
                    try {
                        require("request")(httpcommand + switchvalue);
                    } catch (e) { console.error(e); }
                    console.log("request: " + httpcommand + switchvalue);    
                    previouscommand = httpcommand + switchvalue;
                }
                // Clean previouscommand
                timeout = setTimeout(function () {
                previouscommand = "";
                }, 2000);
            }
            
            [/code]`
            
            Das ist meine loesung zur Domoticz integration, read all devices, get updates, sent updates.
            
            Ist zwar noch ne baustelle und nicht optimal, aber bin ja auch kein pro hauptsache es laeuft  :mrgreen:  :mrgreen:  :mrgreen: 
            
            ~Dutch[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
            
            1 Reply Last reply Reply Quote 0
            • E
              elRedeo last edited by

              Hi dutch,

              klasse, das ist ein Ansatz an dem ich mich entlang hangeln kann.

              Vielen Dank dafür

              elRedeo

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              Support us

              ioBroker
              Community Adapters
              Donate
              FAQ Cloud / IOT
              HowTo: Node.js-Update
              HowTo: Backup/Restore
              Downloads
              BLOG

              904
              Online

              31.7k
              Users

              79.8k
              Topics

              1.3m
              Posts

              2
              5
              4019
              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