Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Xiaomi Roborock S55 in Gekko einbinden Node Red
#1
!!! AKTUELLE VERSION WEITER UNTEN !!!


Ich arbeite eine Weile daran meinen Xiaomi Roborock S55 Saugstaubroboter in myGekko einzubinden. 

Als erstes benötigt man den Token des Saugers, damit eine Kommunikation überhaupt möglich ist. Da ich auch nicht mehr wollte das er mit den chinesischen Server kommuniziert habe ich eine CoustomFirmeware aufgespielt. 
Eine Anleitung dazu findet ihr zu Beispiel >>>>hier<<<.

Nachdem die IP und der Token nun bekannt waren ging es relativ "schnell". 

Vielen Dank an dieser Stella an SaschaD und Bluscreen. Ohne euch wüsste ich nicht mal wie man Node-Red schreibt  Wink

Manueller Start über's Gekko:

Im Gekko habe ich eine Aktion angelegt "Robert starten". Anmerkung meine Sauger heißt Robert, halt wie Roboter ...

Diese ruft sich rekursiv, nach 1 Stunde, selber auf und stoppt. Das ist notwendig, da eine Aktion mit mindestens einer Aufgabe hinterlegt sein muss, damit sie nicht sofort wieder stoppt. Die Stunde ist somit die maximale Zeit des Saugers die Bude sauber zu machen. Damit hätten wir den händischen Start abgehakt. Ebenfalls ist es möglich, die Aktion jetzt mit einer Uhr im Gekko zu nutzen. In meinem speziellen Fall muss diese dann aber eine Sperrbedingung erhalten und zwar die "Abwesenheit", um nicht mit der zweiten Startmöglichkeit zu kollidieren.

[Bild: emrzzcxd.png]


Automatischer Start über Abwesenheit.

Ich habe bereits zwei weitere Aktion im Gekko, womit ich Abwesenheit und Anwesenheit steuere. Die Aktion sperren sich gegenseitig. s.H. Bin ich abwesend kann ich bei meiner Wiederkehr nur die Aktion "Kommen" auslösen, welche sich anschließend sperrt und die Aktion "Gehen" freischaltet und umgekehrt. Das war nötig, da ich diese über einen einzelnen Taster im Eingangsbereich auslöse und das Gekko ja sonst nicht weis ob ich gerade gehe oder zurückkomme. 
Wichtig für das Verständnis ist hier folgendes: Im Node-Red prüfe ich den Sperrstatus von der Aktion "Kommen". 
Zu prüfen ob die Aktion läuft oder nicht wäre (für mich) hier nicht zielführend, da sie ja nach ihren Aufgaben stoppt und somit die Bedingung nicht mehr erfüllt wäre. Wird hingegen "Kommen" freigeschalten bedeutet dies sinngemäß mein Verlassen/Abwesenheit. Wird "Kommen" gesperrt, bedeutet dies meine Rückkehr und somit Anwesenheit.

[Bild: a8htymce.png]


Ziel ist es den Sauger 15 Minuten nach verlassen des Hausen zu starten und bei Rückkehr die Reinigung zu beenden. Kommt man innerhalb der 15 Minuten wieder nach Hause wird die Reinigung gar nicht erst gestartet.


Eine Unterbrechung erfolgt so das der Roboter erst den "Stop"-Befehl erhält und 3 Sekunden den "laden"-Befehl erhält.


[Bild: ntc5axwa.png]


Nach jedem Start speichere ich die Zeit der letzten Reinigung. Ich wollte das der Sauger prüft ob diese mindestens x Stunden zurückliegt, um somit unnötiges saugen zu unterbinden. Ich weis aber nicht wie ich diese Werte sinnvoll miteinander vergleich kann. Wenn mir da jemand auf die Sprünge helfen könnte wäre ich dankbar.
Falls ihr komischen Quellcode in den Funktionen entdeckt, liegt es daran das ich zu wenig Ahnung habe. Bitte nicht schlagen  Tongue

Node Platten die ich verwende:

node-red-contrib-mygekko
node-red-contrib-miio-roborock
node-red-contrib-simpletime




Code:
[{"id":"4a16f2bb.735c4c","type":"tab","label":"Xiaomi Sauger","disabled":false,"info":""},{"id":"595df213.d8817c","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"starten","server":"48fc5ed6.f0e03","command_name":"► Start","command":"app_start","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"60","voice_pack":null,"homekit_stop_to_dock":true,"x":1230,"y":440,"wires":[["cc773250.f370f"]]},{"id":"87502f6b.cee01","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"stoppen","server":"48fc5ed6.f0e03","command_name":"◼ Stop","command":"app_stop","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"50","voice_pack":null,"homekit_stop_to_dock":false,"x":1240,"y":500,"wires":[["60e69f82.33658"]]},{"id":"5852b65a.7eeef8","type":"delay","z":"4a16f2bb.735c4c","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1260,"y":560,"wires":[["991af6c8.69d7f8"]]},{"id":"991af6c8.69d7f8","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"laden","server":"48fc5ed6.f0e03","command_name":"Dock","command":"app_charge","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"50","voice_pack":null,"homekit_stop_to_dock":false,"x":1410,"y":560,"wires":[[]]},{"id":"4b0c8a3f.5d2664","type":"function","z":"4a16f2bb.735c4c","name":"Change Var","func":"var x = msg.payload;\n \nif (x ==\"1\"){\n  var msg_o = {payload : \"app_start\"} \n  return [msg_o, null]}\nelse if (x ==\"0\"){\n  var msg_o = {payload : \"app_stop\"} \n  return [null, msg_o]}","outputs":2,"noerr":0,"x":1010,"y":440,"wires":[["595df213.d8817c"],["5852b65a.7eeef8","87502f6b.cee01"]]},{"id":"8f2c37b0.fe73e8","type":"mqtt in","z":"4a16f2bb.735c4c","name":"actions17.state","topic":"actions17.state","qos":"1","datatype":"auto","broker":"7438383a.9fc788","x":120,"y":440,"wires":[["4b0c8a3f.5d2664"]]},{"id":"ab65b9fc.9d0e08","type":"mqtt in","z":"4a16f2bb.735c4c","name":"anwesend.state","topic":"anwesend.state","qos":"1","datatype":"auto","broker":"7438383a.9fc788","x":120,"y":560,"wires":[["854dd390.77af1"]]},{"id":"93a3b33a.e0b38","type":"delay","z":"4a16f2bb.735c4c","name":"Zeitverzögerung 10 min","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":690,"y":500,"wires":[["49973a37.3365b4"]]},{"id":"49973a37.3365b4","type":"join","z":"4a16f2bb.735c4c","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"1","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":870,"y":560,"wires":[["e9f169be.1623d8"]]},{"id":"e9f169be.1623d8","type":"function","z":"4a16f2bb.735c4c","name":"Change Var","func":"var x = msg.payload;\n \nif (x ==\"111\"){\n  var msg_o = {payload : \"app_start\"} \n  return [msg_o, null]}\nelse {\n  var msg_o = {payload : \"app_stop\"} \n  return [null, msg_o]}","outputs":2,"noerr":0,"x":1010,"y":560,"wires":[["595df213.d8817c"],["87502f6b.cee01","5852b65a.7eeef8"]]},{"id":"d89ea21f.f29fa","type":"function","z":"4a16f2bb.735c4c","name":"Stop nach Rückkehr","func":"var x = msg.payload;\n \nif (x ==\"1\"){\n  var msg_o = {payload : \"1\"} \n  return [msg_o, null]}\nelse {\n  var msg_o = {payload : \"0\"} \n  return [null, msg_o]}","outputs":2,"noerr":0,"x":460,"y":520,"wires":[["93a3b33a.e0b38"],["49973a37.3365b4"]]},{"id":"854dd390.77af1","type":"rbe","z":"4a16f2bb.735c4c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":270,"y":560,"wires":[["d89ea21f.f29fa","49973a37.3365b4"]]},{"id":"cc773250.f370f","type":"simpletime","z":"4a16f2bb.735c4c","name":"","x":1380,"y":440,"wires":[["8f34617c.d4bc9"]]},{"id":"8f34617c.d4bc9","type":"mqtt out","z":"4a16f2bb.735c4c","name":"LetzteReinigung","topic":"LetzteReinigung","qos":"0","retain":"","broker":"b9224abc.983868","x":1560,"y":440,"wires":[]},{"id":"aba07a95.35fa48","type":"mygekko_action","z":"4a16f2bb.735c4c","name":"Robert starten","itemid":"item17","server":"130dec2b.1ee7a4","x":1560,"y":500,"wires":[[]]},{"id":"60e69f82.33658","type":"function","z":"4a16f2bb.735c4c","name":"Change Var","func":"msg = false;\nreturn {\"state\" :msg};","outputs":1,"noerr":0,"x":1390,"y":500,"wires":[["aba07a95.35fa48"]]},{"id":"32d791f8.047c9e","type":"mygekko_universal","z":"4a16f2bb.735c4c","name":"myGekkoMsg","server":"130dec2b.1ee7a4","x":150,"y":160,"wires":[["32de38e.dd654c8","6fde94bc.da1ddc"]]},{"id":"32de38e.dd654c8","type":"function","z":"4a16f2bb.735c4c","name":"Aktion: Robert starten","func":"var str = msg.payload.queryapi.actions.item17.sumstate.value;\nvar res = str.split(\";\");\n\n\nvar msg0= { payload: res[0]}; //???\nvar msg1= { payload: res[1]}; //???\nvar msg2= { payload: res[2]}; // SOLL Temp Pufferspeicher\n\nreturn [msg0, msg1, msg2];\n\n","outputs":3,"noerr":0,"x":400,"y":140,"wires":[["5bf6e22b.fe4b6c"],[],[]]},{"id":"6fde94bc.da1ddc","type":"function","z":"4a16f2bb.735c4c","name":"action 30 --- Kommen","func":"var str = msg.payload.queryapi.actions.item30.sumstate.value;\nvar res = str.split(\";\");\n\n\nvar msg0= { payload: res[0]}; //Aktiv\nvar msg1= { payload: res[1]}; //Freigegeben\nvar msg2= { payload: res[2]}; //SumState[0=Ok|1=ManualOff|2=ManualOn|3=Locked|4=Alarm]\n\nreturn [msg0, msg1, msg2];\n\n","outputs":3,"noerr":0,"x":400,"y":200,"wires":[[],["2185709b.cade2"],[]]},{"id":"2185709b.cade2","type":"rbe","z":"4a16f2bb.735c4c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":650,"y":200,"wires":[["cf3f4028.2dc09","e875150e.869308"]]},{"id":"5bf6e22b.fe4b6c","type":"rbe","z":"4a16f2bb.735c4c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":650,"y":140,"wires":[["34b4449e.5b21bc"]]},{"id":"34b4449e.5b21bc","type":"mqtt out","z":"4a16f2bb.735c4c","name":"actions17.state","topic":"actions17.state","qos":"1","retain":"false","broker":"7438383a.9fc788","x":820,"y":140,"wires":[]},{"id":"e875150e.869308","type":"mqtt out","z":"4a16f2bb.735c4c","name":"anwesend.state","topic":"anwesend.state","qos":"","retain":"","broker":"7438383a.9fc788","x":820,"y":200,"wires":[]},{"id":"cf3f4028.2dc09","type":"debug","z":"4a16f2bb.735c4c","name":"Satus Kommen von Gekko","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":860,"y":260,"wires":[]},{"id":"63646831.91d988","type":"comment","z":"4a16f2bb.735c4c","name":"Manueller Start","info":"","x":120,"y":400,"wires":[]},{"id":"6e50a8e2.5e1e48","type":"comment","z":"4a16f2bb.735c4c","name":"Abwesenheitsgesteuert","info":"","x":140,"y":520,"wires":[]},{"id":"9f5ba77d.8e2c18","type":"comment","z":"4a16f2bb.735c4c","name":"Input","info":"","x":130,"y":120,"wires":[]},{"id":"48fc5ed6.f0e03","type":"miio-roborock-server","z":"","name":"Robert","ip":"192.168.1.21","token":"6e76774c4e6f3132734f33744e395336","polling":"5"},{"id":"7438383a.9fc788","type":"mqtt-broker","z":"","name":"MQTT Broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b9224abc.983868","type":"mqtt-broker","z":"","name":"MQTT Broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"130dec2b.1ee7a4","type":"mygekko_server","z":"","active":true,"api":"local","host":"192.168.1.100","interval":"5"}]
#2
Hallo Strabbit,

super Arbeit, Danke für die sehr detaillierte Erklärung hier. Das wird sicher vielen helfen. DANKE ...
Viele Grüße

Francisco Santos

myGekko im Einfamilienhaus  Tongue
#3
-Update-


Bitte das Grundfunktionsprinzip beachten. Steht im ersten Post. 
Da ich schon einige eMails erhalten habe, witzig das hier keiner schreibt Huh ,werde ich mal die Weiterentwicklung posten.


Nachdem ich die erste Version im heimischen Heim umgesetzt hatte kam mir ein wesentlicher Gedanke. Wenn der Sauger jetzt schön selbständig arbeitet, sobald wir weg sind, wer denk denn eigentlich daran den Behälter mal zu leeren?  Dodgy
Aus Erfahrung weis ich das eine Leerung spätestens nach 3 Reinigungen erfolgen sollte.
Meine Lösung:
Im Flow wurde ein Counter integriert. Er wird nach jedem "start"-Befehl hochgesetzt und zählt bis 3. Dann erhält der "Robert" den Befehl zu einer bestimmten Koordinate zu fahren. Bei mir ist das in der Küche vor einem Mülleimer. Man fällt also fast drüber und kann die Leerung nicht vergessen  Big Grin  Dort leert man ihn und drück einmal die Steckdosentaste, sodass er wieder in der Basis auf seinen nächsten Auftrag warte. Fertig ... 




Um eure eigenen Koordinaten herauszufinden nutzt das hier. Sobald ihr sie habt, müsst ihr sie in die Funktion "Was soll ich tun..." übertragen.

[Bild: M-ll.png]


Am besten auf einem zweiten Bildschirm "Valtudo" im Map-Bildschirm laufen lassen. Da sieht man wo der Sauger hin will und kann sich rantasten, bis der grüne Punkt dort ist wo er sein soll. Das ging bei mir ziemlich schnell.
Informativ: Die Koordinaten sind abhängig von der Ladestation, s.h. verlegt ihr die Station, müsst ihr auch die Koordinate anpassen.

[Bild: valetudo.png]



Mit den Zeitproblem, das zwischen den automatischen Reinigungen mindestens 12 Stunden liegen sollen, bin ich jetzt soweit, dass ich die zeitliche Differenz errechnet wird. 
Ich weis aber noch nicht so richtig, wie ich eine Bedingung einbau die prüft ob die zeitliche Differenz gegeben ist und ein automatischer start erfolgen soll. Im Flow ist das dargestellt mit "hier fehlt noch was". Gedacht hatte ich mir das so. Ein "Baustein" mit zwei Eingängen, welcher unter korrekten Bedingungen zum "start"-Befehl geht.

[Bild: fehlt.png]

Wenn da jemand eine Idee hat ... würde mich echt riesig freuen. Ist eigentlich auch das letzte was auf dieser Projekt-To-Do-Liste steht.




Node Platten die ich verwende:

node-red-contrib-mygekko
node-red-contrib-miio-roborock
- node-red-contrib-simpletime    (entfernt)



Code:
[{"id":"4a16f2bb.735c4c","type":"tab","label":"Xiaomi Sauger","disabled":false,"info":""},{"id":"595df213.d8817c","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"starten","server":"9b76a5c3.ab64a8","command_name":"► Start","command":"app_start","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"60","voice_pack":null,"homekit_stop_to_dock":true,"x":1260,"y":280,"wires":[["956165c6.e7b8f8","ef873e75.e5ed3","de58a69b.e40af8"]]},{"id":"87502f6b.cee01","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"stoppen","server":"9b76a5c3.ab64a8","command_name":"◼ Stop","command":"app_stop","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"50","voice_pack":null,"homekit_stop_to_dock":false,"x":1280,"y":340,"wires":[["60e69f82.33658","5852b65a.7eeef8"]]},{"id":"5852b65a.7eeef8","type":"delay","z":"4a16f2bb.735c4c","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1400,"y":380,"wires":[["991af6c8.69d7f8"]]},{"id":"991af6c8.69d7f8","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"laden","server":"9b76a5c3.ab64a8","command_name":"Dock","command":"app_charge","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"50","voice_pack":null,"homekit_stop_to_dock":false,"x":1570,"y":380,"wires":[[]]},{"id":"4b0c8a3f.5d2664","type":"function","z":"4a16f2bb.735c4c","name":"händisch ausgelöst?","func":"var x = msg.payload;\n \nif (x ==\"1\"){\n  var msg_o = {payload : \"app_start\"} \n  return [msg_o, null]}\nelse if (x ==\"0\"){\n  var msg_o = {payload : \"app_stop\"} \n  return [null, msg_o]}","outputs":2,"noerr":0,"x":980,"y":280,"wires":[["595df213.d8817c"],["87502f6b.cee01"]]},{"id":"8f2c37b0.fe73e8","type":"mqtt in","z":"4a16f2bb.735c4c","name":"actions17.state","topic":"actions17.state","qos":"1","datatype":"auto","broker":"7438383a.9fc788","x":120,"y":280,"wires":[["4b0c8a3f.5d2664"]]},{"id":"ab65b9fc.9d0e08","type":"mqtt in","z":"4a16f2bb.735c4c","name":"anwesend.state","topic":"anwesend.state","qos":"1","datatype":"auto","broker":"7438383a.9fc788","x":120,"y":380,"wires":[["854dd390.77af1"]]},{"id":"93a3b33a.e0b38","type":"delay","z":"4a16f2bb.735c4c","name":"Zeitverzögerung 15 min","pauseType":"delay","timeout":"15","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":670,"y":320,"wires":[["49973a37.3365b4"]]},{"id":"49973a37.3365b4","type":"join","z":"4a16f2bb.735c4c","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"1","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":830,"y":380,"wires":[["ec75c575.36e898"]]},{"id":"d89ea21f.f29fa","type":"function","z":"4a16f2bb.735c4c","name":"Stop nach Rückkehr","func":"var x = msg.payload;\n \nif (x ==\"1\"){\n  var msg_o = {payload : \"1\"} \n  return [msg_o, null]}\nelse {\n  var msg_o = {payload : \"0\"} \n  return [null, msg_o]}","outputs":2,"noerr":0,"x":440,"y":340,"wires":[["93a3b33a.e0b38"],["49973a37.3365b4"]]},{"id":"854dd390.77af1","type":"rbe","z":"4a16f2bb.735c4c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":270,"y":380,"wires":[["d89ea21f.f29fa","49973a37.3365b4"]]},{"id":"8f34617c.d4bc9","type":"mqtt out","z":"4a16f2bb.735c4c","name":"Letzte Reinigung","topic":"LetzteReinigung","qos":"0","retain":"","broker":"b9224abc.983868","x":2470,"y":300,"wires":[]},{"id":"aba07a95.35fa48","type":"mygekko_action","z":"4a16f2bb.735c4c","name":"Robert starten","itemid":"item17","server":"130dec2b.1ee7a4","x":2460,"y":440,"wires":[[]]},{"id":"60e69f82.33658","type":"function","z":"4a16f2bb.735c4c","name":"aktion stoppen","func":"msg = false;\nreturn {\"state\" :msg};","outputs":1,"noerr":0,"x":2240,"y":340,"wires":[["aba07a95.35fa48"]]},{"id":"63646831.91d988","type":"comment","z":"4a16f2bb.735c4c","name":"Manueller Start über Gekko Aktion","info":"","x":180,"y":240,"wires":[]},{"id":"6e50a8e2.5e1e48","type":"comment","z":"4a16f2bb.735c4c","name":"Abwesenheitsgesteuert","info":"","x":140,"y":340,"wires":[]},{"id":"e4873788.c75e18","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"fahre zum Mülleimer","server":"9b76a5c3.ab64a8","command_name":"Send to coordinates","command":"app_goto_target","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"[\n   [26234,26042,27284,26642,1],\n   [26234,26042,27284,26642,1]\n]","fan_speed":"","homekit_stop_to_dock":true,"x":1620,"y":440,"wires":[["b4d135b6.925318"]]},{"id":"ef60ff2f.c34b3","type":"mqtt out","z":"4a16f2bb.735c4c","name":"Anzahl Reinigung","topic":"AnzahlReinigung","qos":"","retain":"","broker":"7438383a.9fc788","x":2470,"y":240,"wires":[]},{"id":"227eb646.106fea","type":"rbe","z":"4a16f2bb.735c4c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":2270,"y":240,"wires":[["ef60ff2f.c34b3"]]},{"id":"3fdf8850.1fcb08","type":"mqtt in","z":"4a16f2bb.735c4c","name":"Anzahl Reinigung","topic":"AnzahlReinigung","qos":"2","datatype":"auto","broker":"7438383a.9fc788","x":300,"y":500,"wires":[["46034324.e87bec","7254c75e.806b38"]]},{"id":"ec75c575.36e898","type":"function","z":"4a16f2bb.735c4c","name":"Was soll ich tun ...","func":"var x = msg.payload;\n\nif (x == 111 || x == \"app_start\")\n    {\n    msg.payload=\"1\";\n    return [msg,null,null]\n    }\n    \nif (x == 3)\n    {\n    msg.payload=[21400,25600];\n    return [null,null,msg];\n    }\n\nif (x !=111 && x !=3)\n    {\n    msg.payload=\"1\";\n    return [null,msg,null];\n    }\n\n    if (x == \"app_stop\")\n    {\n    msg.payload=\"1\";\n    return [null,msg,null];\n    }\n\n    ","outputs":3,"noerr":0,"x":1030,"y":380,"wires":[["595df213.d8817c"],["87502f6b.cee01"],["4a06fcbb.4cddc4","d0cedb25.22be58"]]},{"id":"b4d135b6.925318","type":"function","z":"4a16f2bb.735c4c","name":"zurücksetzen Zähler","func":"msg.reset = true;\nmsg2 = 0;\n\nreturn [msg,{\"state\" :msg2}];\n","outputs":2,"noerr":0,"x":1840,"y":440,"wires":[["ef873e75.e5ed3"],["aba07a95.35fa48"]]},{"id":"c76748fb.cad828","type":"inject","z":"4a16f2bb.735c4c","name":"","topic":"","payload":"[21400,25600]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":960,"wires":[["8b5e566f.6546c8","700ad906.752e88"]]},{"id":"a7bfbe0.952854","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"stoppen","server":"9b76a5c3.ab64a8","command_name":"◼ Stop","command":"app_stop","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"50","voice_pack":null,"homekit_stop_to_dock":false,"x":1160,"y":520,"wires":[[]]},{"id":"4854c18d.f8006","type":"comment","z":"4a16f2bb.735c4c","name":"beendet die Aktion im Gekko","info":"dient der Fehlervermeidung","x":2500,"y":400,"wires":[]},{"id":"295e9c43.8bbef4","type":"comment","z":"4a16f2bb.735c4c","name":"Nach jeder 3ten Reinigung fahrt zum Mülleimer","info":"Sobald der Roboter seine 3 Reinigung absolviert hat begibt er sich zum Mülleimer.\nDort muss er händisch entleert werden und kann anschließend wieder zum Dock geschickt werden.\n\nDer Zähler setzt sich nach der Fahrt zum Mülleimer zurück.","x":400,"y":460,"wires":[]},{"id":"f33e4b31.9226e8","type":"inject","z":"4a16f2bb.735c4c","name":"laden","topic":"","payload":"101","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":840,"wires":[["ec75c575.36e898"]]},{"id":"8b5e566f.6546c8","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"stoppen","server":"9b76a5c3.ab64a8","command_name":"◼ Stop","command":"app_stop","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"50","voice_pack":null,"homekit_stop_to_dock":false,"x":740,"y":1000,"wires":[[]]},{"id":"700ad906.752e88","type":"delay","z":"4a16f2bb.735c4c","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":960,"wires":[["e4873788.c75e18"]]},{"id":"8e8b6169.f4c23","type":"inject","z":"4a16f2bb.735c4c","name":"starten","topic":"","payload":"app_start","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":800,"wires":[["ec75c575.36e898"]]},{"id":"81341f99.1dde4","type":"comment","z":"4a16f2bb.735c4c","name":"Manuelle Kontrolle","info":"","x":150,"y":760,"wires":[]},{"id":"ea4609f9.200fb8","type":"inject","z":"4a16f2bb.735c4c","name":"Flüstern 1%","topic":"","payload":"[1]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":1040,"wires":[["4e5b306b.6703f"]]},{"id":"2cec25e.1542ada","type":"inject","z":"4a16f2bb.735c4c","name":"Leise 40%","topic":"","payload":"[40]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":1080,"wires":[["4e5b306b.6703f"]]},{"id":"ed3fdcd.a7b052","type":"inject","z":"4a16f2bb.735c4c","name":"Balanced 60%","topic":"","payload":"[60]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":1120,"wires":[["4e5b306b.6703f"]]},{"id":"c65a6b94.c849a8","type":"inject","z":"4a16f2bb.735c4c","name":"Turbo 80%","topic":"","payload":"[80]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":1160,"wires":[["4e5b306b.6703f"]]},{"id":"dfbf242e.8decd8","type":"inject","z":"4a16f2bb.735c4c","name":"Maximal 100%","topic":"","payload":"[100]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":500,"y":1200,"wires":[["4e5b306b.6703f"]]},{"id":"4e5b306b.6703f","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"Saubstufe","server":"9b76a5c3.ab64a8","command_name":"⚙ Fan Power","command":"set_custom_mode","commandType":"vacuum_cmd","payload":"payload","payloadType":"msg","coordinates":"","fan_speed":"","voice_pack":null,"homekit_stop_to_dock":false,"x":740,"y":1120,"wires":[[]]},{"id":"bbf77634.e146b8","type":"comment","z":"4a16f2bb.735c4c","name":"zum Herrrausfinden des Müllplatzes","info":"erster Wert x Achse \nzweiter Wert y Achse\n\n\n\ndie herrausgefunden Koordinaten müssen anschließend in der Funktion \"Was soll ich tun ...\" noch eingeben werden","x":200,"y":960,"wires":[]},{"id":"96fd5f6.f4319a","type":"comment","z":"4a16f2bb.735c4c","name":"starten und stoppen","info":"","x":250,"y":840,"wires":[]},{"id":"90c52c45.2ae86","type":"comment","z":"4a16f2bb.735c4c","name":"Einstellen der Lüfterstärke","info":"","x":230,"y":1120,"wires":[]},{"id":"d0cedb25.22be58","type":"delay","z":"4a16f2bb.735c4c","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1400,"y":440,"wires":[["e4873788.c75e18"]]},{"id":"189de1c1.4104fe","type":"delay","z":"4a16f2bb.735c4c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":620,"y":500,"wires":[["ec75c575.36e898"]]},{"id":"ef873e75.e5ed3","type":"counter","z":"4a16f2bb.735c4c","name":"Reinigungszähler","init":"0","step":1,"lower":"","upper":"3","mode":"increment","outputs":2,"x":2090,"y":280,"wires":[["227eb646.106fea"],["ab15ea5.c844018"]]},{"id":"269de64c.93993a","type":"inject","z":"4a16f2bb.735c4c","name":"stoppen","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":880,"wires":[["4a06fcbb.4cddc4"]]},{"id":"46034324.e87bec","type":"switch","z":"4a16f2bb.735c4c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"3","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":500,"wires":[["189de1c1.4104fe"]]},{"id":"4a06fcbb.4cddc4","type":"miio-roborock-command","z":"4a16f2bb.735c4c","name":"pause","server":"9b76a5c3.ab64a8","command_name":"❙❙ Pause","command":"app_pause","commandType":"vacuum_cmd","payload":"arguments","payloadType":"vacuum_payload","coordinates":"","fan_speed":"50","voice_pack":null,"homekit_stop_to_dock":false,"x":1010,"y":460,"wires":[["4189f232.a3096c"]]},{"id":"4189f232.a3096c","type":"delay","z":"4a16f2bb.735c4c","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1160,"y":460,"wires":[["a7bfbe0.952854"]]},{"id":"8d3b1ea7.205d","type":"mqtt in","z":"4a16f2bb.735c4c","name":"Letzte Reinigung","topic":"LetzteReinigung","qos":"2","datatype":"auto","broker":"7438383a.9fc788","x":1440,"y":180,"wires":[["806920aa.82955"]]},{"id":"254d9f95.7eada","type":"function","z":"4a16f2bb.735c4c","name":"zähler vergleichen","func":"var math = Number(msg.payload[1]) - Number(msg.payload[0]); //millisekunden\n\n//man hätte das auch in einem Schritt machen können\n// war so aber besser für mein Verständnis und ich kann\n// auf Sekunden reduzieren zum testen\n\n\nmath = math / 1000; //Sekunden\nmath = math / 60;  //Minuten\nmath = math / 60;  //Stunden\n\n\nmsg.payload = math;\nreturn msg;","outputs":1,"noerr":0,"x":1770,"y":180,"wires":[["eae483ca.bd1e"]]},{"id":"ab15ea5.c844018","type":"change","z":"4a16f2bb.735c4c","name":"aktuelle zeit","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":2290,"y":300,"wires":[["8f34617c.d4bc9"]]},{"id":"806920aa.82955","type":"join","z":"4a16f2bb.735c4c","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"1","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":1610,"y":180,"wires":[["254d9f95.7eada"]]},{"id":"eae483ca.bd1e","type":"mqtt out","z":"4a16f2bb.735c4c","name":"Verstrichene Zeit seit letzten Reinigung","topic":"VerstricheneZeitReinigung","qos":"","retain":"","broker":"7438383a.9fc788","x":2310,"y":180,"wires":[]},{"id":"956165c6.e7b8f8","type":"change","z":"4a16f2bb.735c4c","name":"aktuelle zeit","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":1430,"y":240,"wires":[["806920aa.82955"]]},{"id":"86ee89f5.89a2c8","type":"comment","z":"4a16f2bb.735c4c","name":"ausrechnen des aktuellen Starts mit der letzten Reinigung","info":"","x":1570,"y":140,"wires":[]},{"id":"d077007a.b0c8b","type":"comment","z":"4a16f2bb.735c4c","name":"hier fehlt was","info":"Vor Start muss eine Sperre geschaffen werden das er erst nach 12 Stunden wider reinigen kann.\n\nAUSNAHME: Manueller Start über Gekko","x":1070,"y":100,"wires":[]},{"id":"b0b3915a.58e65","type":"mqtt in","z":"4a16f2bb.735c4c","name":"VerstricheneZeitReinigung","topic":"VerstricheneZeitReinigung","qos":"2","datatype":"auto","broker":"7438383a.9fc788","x":630,"y":100,"wires":[["d9d0857b.f9fab8"]]},{"id":"d9d0857b.f9fab8","type":"switch","z":"4a16f2bb.735c4c","name":"mehr als 12h verstrichen","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"12","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":100,"wires":[[]]},{"id":"7254c75e.806b38","type":"debug","z":"4a16f2bb.735c4c","name":"Anzahl Reinigung","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":520,"y":600,"wires":[]},{"id":"de58a69b.e40af8","type":"debug","z":"4a16f2bb.735c4c","name":"nach start","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1420,"y":300,"wires":[]},{"id":"aca80eb6.8bec6","type":"mygekko_universal","z":"4a16f2bb.735c4c","name":"myGekkoMsg","server":"130dec2b.1ee7a4","x":1590,"y":840,"wires":[["f7b03d05.0af23","51970215.cca11c"]]},{"id":"f7b03d05.0af23","type":"function","z":"4a16f2bb.735c4c","name":"action 17","func":"var str = msg.payload.queryapi.actions.item17.sumstate.value;\nvar res = str.split(\";\");\n\n\nvar msg0= { payload: res[0]}; //???\nvar msg1= { payload: res[1]}; //???\nvar msg2= { payload: res[2]}; // SOLL Temp Pufferspeicher\n\nreturn [msg0, msg1, msg2];\n\n","outputs":3,"noerr":0,"x":1780,"y":840,"wires":[["e176048e.c15b28"],[],[]]},{"id":"51970215.cca11c","type":"function","z":"4a16f2bb.735c4c","name":"action 30 --- Kommen","func":"var str = msg.payload.queryapi.actions.item30.sumstate.value;\nvar res = str.split(\";\");\n\n\nvar msg0= { payload: res[0]}; //Aktiv\nvar msg1= { payload: res[1]}; //Freigegeben\nvar msg2= { payload: res[2]}; //SumState[0=Ok|1=ManualOff|2=ManualOn|3=Locked|4=Alarm]\n\nreturn [msg0, msg1, msg2];\n\n","outputs":3,"noerr":0,"x":1820,"y":900,"wires":[[],["bf391e1f.f1487"],[]]},{"id":"e176048e.c15b28","type":"rbe","z":"4a16f2bb.735c4c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":2070,"y":840,"wires":[["7105985f.2455e8"]]},{"id":"bf391e1f.f1487","type":"rbe","z":"4a16f2bb.735c4c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":2070,"y":900,"wires":[["dea3aa16.6fc148"]]},{"id":"7105985f.2455e8","type":"mqtt out","z":"4a16f2bb.735c4c","name":"actions17.state","topic":"actions17.state","qos":"1","retain":"false","broker":"7438383a.9fc788","x":2240,"y":840,"wires":[]},{"id":"dea3aa16.6fc148","type":"mqtt out","z":"4a16f2bb.735c4c","name":"anwesend.state","topic":"anwesend.state","qos":"","retain":"","broker":"7438383a.9fc788","x":2240,"y":900,"wires":[]},{"id":"a39bc53a.cd5ea8","type":"comment","z":"4a16f2bb.735c4c","name":"my Gekko-Input","info":"","x":1590,"y":780,"wires":[]},{"id":"9b76a5c3.ab64a8","type":"miio-roborock-server","z":"","name":"Robert","ip":"192.168.1.21","token":"6e76774c4e6f3132734f33744e395336","polling":"5"},{"id":"7438383a.9fc788","type":"mqtt-broker","z":"","name":"MQTT Broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b9224abc.983868","type":"mqtt-broker","z":"","name":"MQTT Broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"130dec2b.1ee7a4","type":"mygekko_server","z":"","active":true,"api":"local","host":"192.168.1.100","interval":"5"}]


Angehängte Dateien Thumbnail(s)
   
#4
-Aktuellste Version-


Es ist (glaube ich) geschafft und läuft stabil :-)

[Bild: papzd9o7.png]

Der Flow wurde aufgeräumt und entschlackt. Ich habe zu besseren Übersicht "Link in" und "Link out" verwendet. Um den Pfad zu sehen, einfach anklicken und der gestrichelten Linie folgen.
Die zeitliche Sperre, Standartmäsig 12 Stunden, wurde eingebaut und funktioniert. Die Anzahl bis zur Entleerung wurde auf 4 erhöht, bis er zur Müllfahrt ansetzt.

Der Abschnitt Manuelle Steuerung wurde um einen Entwicklungsbereich ergänzt. In diesen kann man unteranderen die Koordinaten, mit etwas Geduld, zur Müllfahrt ermitteln. Koordinaten sind abhängig von der Ladestation. Kommentar beachten. Ebenfalls lässt sich die Anwesenheit simulieren und die Sperre zurücksetzen.

[Bild: ekbcvzb4.png]


Kurze Zusammenfassung.

Der Sauger kann entweder händisch über die Aktion "Robert starten" oder automatisch über An- und Abwesenheit gestartet werden. Genauere Erklärungen im 1. Post. Nach einer Reinigung wird die Zeit gespeichert. Bei einem erneuten Reinigung über den automatischen Start wird geprüft ob eine Sperrzeit überschritten wurde. Somit soll mehrmaliges saugen in zu kurzen Zeitabständen verhindert werden. Der händische Start wird hiervon nicht beeinträchtigt und funktioniert immer. Setzt aber am Ende ebenfalls eine Zeit der letzten Reinigung.
Nach 4 Saugvorgängen fährt das Gerät zu einer vorgegebenen Koordinate und warte auf Entleerung.



Was Ihr braucht:


  1. Token und IP des Saugers (1ster Post beachten)
  2. MQTT Server
  3. NodeRed Server mit folgenden Nodes:
    - node-red-contrib-mygekko
         - node-red-contrib-miio-roborock (optional könnte hier 

         - node-red-contrib-counter



Was Ihr ändern müsst:



  1. Zugangsdaten für Gekko, Xiaomi-Node, MQTT
  2. Die item Nummer eurer Aktionen
  3. Die Koordinaten für die Müllfahrt  in der Funktion "Was soll ich tun ..."   msg.payload=[21400,25600];


Was Ihr anpassen könnt:



  1. Die Sperrzeit in der Funktion "Was soll ich tun ... "     if (verstrichenenZeit >= 12)   --- Angabe in Stunden
  2. Die Anzahl der Saugvorgänge bis Müllfahrt. Folgende Anpassungen nötig:
    - Funktion "Was soll ich tun ..."    if (x == 4)    und weiter unten    if (x !=111 && x !=4)
    - Switch "Reinigungen bis Leerung" den Wert 4 ändern- Counter "Reinigungszähler" das Upper Limit anpassen
  3. Verzögerter Start bei automatischen Start im Delay "Zeitverzögerung 15 min" nach belieben ändern


Anmerkung: 

Der Export als Code führt bei mir mittlerweile zu einem Absturz des Forums, beziehungsweise muss ich mich mit weiteren Eingaben, nachdem einfügen, sehr sehr gedulden. Deswegen ist dieser als JSON Datei gezipt im Anhang angefügt.


Wer noch Anmerkungen, Anregungen, Wünsche, Kritik oder Lob hat kann dies gern hier machen ...


Angehängte Dateien Thumbnail(s)
       

.zip   Xiaomi_Sauger_09.01.20.zip (Größe: 5,83 KB / Downloads: 0)


Möglicherweise verwandte Themen...
Thema Verfasser Antworten Ansichten Letzter Beitrag
  Eigener MyGekko-Node für Node-Red Bluescreen 68 10.324 23.01.2020, 19:03
Letzter Beitrag: Strabbit

Gehe zu:


Benutzer, die gerade dieses Thema anschauen:
1 Gast/Gäste