So....thanks to the shitty weather over the weekend...for those of you who want to play with it...:
I took the sample websocket python program from the Gardena site, fixed a few bugs and stitched it together with MQTT.
the program does create a websocket connection and then will transmit all 'realtime' data to MQTT with the out-topic 'Gardena/out'
You also can send commands to your device(s) using 'Gardena/in'.
Part of an command request is the 'service ID', that will be appended to the service url.
This appears to be device dependend of dynamic, so you will need to send it as the request ID in every command (see my Node-Red example).
Code: Select all
[{"id":"9fe51f8d.af06c","type":"tab","label":"Flow 8","disabled":false,"info":""},{"id":"d80688e4.be1028","type":"mqtt in","z":"9fe51f8d.af06c","name":"","topic":"Gardena/out","qos":"2","datatype":"auto","broker":"5660e74b.bef428","x":150,"y":80,"wires":[["e9116af1.fea438"]]},{"id":"14841d3d.db0c23","type":"debug","z":"9fe51f8d.af06c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":80,"wires":[]},{"id":"e9116af1.fea438","type":"json","z":"9fe51f8d.af06c","name":"","property":"payload","action":"obj","pretty":false,"x":330,"y":80,"wires":[["14841d3d.db0c23","74ea86d5.089a08","d4b23963.da0cc8"]]},{"id":"8c262953.b12308","type":"mqtt out","z":"9fe51f8d.af06c","name":"","topic":"Gardena/in","qos":"","retain":"","broker":"5660e74b.bef428","x":1190,"y":440,"wires":[]},{"id":"b6745cd8.5ecb4","type":"inject","z":"9fe51f8d.af06c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":440,"wires":[["295ebdb4.1a8662"]]},{"id":"295ebdb4.1a8662","type":"function","z":"9fe51f8d.af06c","name":"Park until further notice","func":"\nvar id = flow.get(\"SERVICE_ID\")\nmsg.payload = {\n \"data\":{\n \"type\": \"MOWER_CONTROL\", \n \"id\": id, \n \"attributes\": {\n \"command\": \"PARK_UNTIL_FURTHER_NOTICE\",\n \"seconds\": 60\n }\n}}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":380,"wires":[["8c262953.b12308","7347f335.0d26dc"]]},{"id":"ac15ac94.147ec","type":"function","z":"9fe51f8d.af06c","name":"Resume operation","func":"var id = flow.get(\"SERVICE_ID\")\nmsg.payload = {\n \"data\":{\n \"type\": \"MOWER_CONTROL\", \n \"id\": id, \n \"attributes\": {\n \"command\": \"START_DONT_OVERRIDE\",\n \"seconds\": 60\n }\n}\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":480,"wires":[["8c262953.b12308","3fa17324.9b990c"]]},{"id":"874637d4.05ad08","type":"inject","z":"9fe51f8d.af06c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":500,"wires":[["ac15ac94.147ec"]]},{"id":"9d4c3f71.21ff9","type":"mqtt in","z":"9fe51f8d.af06c","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"54505e91.d17d1","x":100,"y":580,"wires":[["2445fe7d.7bb1f2"]]},{"id":"2445fe7d.7bb1f2","type":"json","z":"9fe51f8d.af06c","name":"","property":"payload","action":"obj","pretty":false,"x":270,"y":580,"wires":[["abcddc25.dcb56","65e59f6a.7dc0f"]]},{"id":"abcddc25.dcb56","type":"function","z":"9fe51f8d.af06c","name":"Rain sensor","func":"var enabled = flow.get(\"ENABLED\")\nif (msg.payload.idx == \"14\" && enabled === 1)\n{\n\n\n\nvar rain = parseInt(msg.payload.svalue1)\n\nif (rain > 40)\n{msg.payload = \"true\" }\nif (rain < 10)\n{msg.payload = \"false\" }\n\nreturn msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":580,"wires":[["402589a0.1bb2c8"]]},{"id":"402589a0.1bb2c8","type":"rbe","z":"9fe51f8d.af06c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":580,"y":580,"wires":[["87d8725c.19f35"]]},{"id":"87d8725c.19f35","type":"switch","z":"9fe51f8d.af06c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":700,"y":580,"wires":[["295ebdb4.1a8662"],["f5382574.cbcec8"]]},{"id":"f5382574.cbcec8","type":"delay","z":"9fe51f8d.af06c","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":880,"y":580,"wires":[["ac15ac94.147ec"]]},{"id":"7347f335.0d26dc","type":"function","z":"9fe51f8d.af06c","name":"message parking","func":" msg.payload = \n {\"command\": \"sendnotification\",\n \"subject\": \"C3PO\",\n \"body\": \"Robot is parking until next schedule\",\n \"priority\": 0}\nreturn msg;","outputs":1,"noerr":0,"x":890,"y":320,"wires":[["217538dc.05c828"]]},{"id":"3fa17324.9b990c","type":"function","z":"9fe51f8d.af06c","name":"message resuming","func":" msg.payload = \n {\"command\": \"sendnotification\",\n \"subject\": \"C3PO\",\n \"body\": \"Robot is resuming schedule\",\n \"priority\": 0}\nreturn msg;","outputs":1,"noerr":0,"x":890,"y":360,"wires":[["217538dc.05c828"]]},{"id":"217538dc.05c828","type":"mqtt out","z":"9fe51f8d.af06c","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"1afefb3e.65c825","x":1210,"y":340,"wires":[]},{"id":"74ea86d5.089a08","type":"function","z":"9fe51f8d.af06c","name":"Extract Service ID","func":"\n//Service.Id\nif (msg.payload.type == \"DEVICE\")\n\nflow.set(\"SERVICE_ID\", msg.payload.relationships.services.data[1].id)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":160,"wires":[[]]},{"id":"65e59f6a.7dc0f","type":"function","z":"9fe51f8d.af06c","name":"Main Switch","func":"if (msg.payload.idx == 464)\n{\n flow.set(\"ENABLED\", msg.payload.nvalue)\nreturn msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":640,"wires":[["fd6d3be9.b6e2f8"]]},{"id":"1815d8e3.802f87","type":"switch","z":"9fe51f8d.af06c","name":"","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":710,"y":640,"wires":[["ac15ac94.147ec"],["295ebdb4.1a8662"]]},{"id":"fd6d3be9.b6e2f8","type":"rbe","z":"9fe51f8d.af06c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":590,"y":640,"wires":[["1815d8e3.802f87"]]},{"id":"d4b23963.da0cc8","type":"function","z":"9fe51f8d.af06c","name":"Parse Battery level and mower status","func":"var newmsg = {headers: \"\", payload:\"\", topic:\"\"}\nif (msg.payload.type == \"COMMON\")\n{\n\nnewmsg.payload = { \n \"command\": \"udevice\",\n \"idx\" :389,\n \"nvalue\" :msg.payload.attributes.batteryLevel.value,\n \"svalue\" :msg.payload.attributes.batteryLevel.value.toString()}\n\nreturn newmsg;\n}\nif (msg.payload.type == \"MOWER\")\n{\n \n newmsg.payload = { \n \"command\": \"udevice\",\n \"idx\" :393,\n \"nvalue\" :0,\n \"svalue\" :msg.payload.attributes.activity.value.toString()\n}\n return newmsg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":220,"wires":[["217538dc.05c828"]]},{"id":"5660e74b.bef428","type":"mqtt-broker","z":"","name":"Controlberry","broker":"192.168.2.40","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"54505e91.d17d1","type":"mqtt-broker","name":"Controlberry","broker":"192.168.2.40","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"1afefb3e.65c825","type":"mqtt-broker","name":"Controlberry","broker":"192.168.2.40","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
I'm running this for a few days now and so far it works as expected.
if this turns out to be a usable thing, maybe some real developer can make a plugin out of it.
I can only test it with my mower, but it should work with irrigation too.
unfortunately, the API documentation is the same kind of crappy as the API itself.