Scripts for my smart home setup.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

400 lines
12 KiB

[
{
"id": "46b0845e.b35b04",
"type": "tab",
"label": "Valetudo-Domoticz Interface",
"disabled": false,
"info": ""
},
{
"id": "2aaf4883.4c134",
"type": "mqtt in",
"z": "46b0845e.b35b04",
"name": "",
"topic": "domoticz/out",
"qos": "0",
"datatype": "auto",
"broker": "e0bf1c2a.932a88",
"x": 130,
"y": 460,
"wires": [
[
"1fb9589d.5ca7af"
]
]
},
{
"id": "65c71638.c1a1a",
"type": "mqtt out",
"z": "46b0845e.b35b04",
"name": "",
"topic": "",
"qos": "",
"retain": "",
"broker": "e0bf1c2a.932a88",
"x": 950,
"y": 460,
"wires": []
},
{
"id": "fd20492b.8c25e8",
"type": "debug",
"z": "46b0845e.b35b04",
"name": "valetudo_in",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 970,
"y": 540,
"wires": []
},
{
"id": "96d8f1a3.fb866",
"type": "function",
"z": "46b0845e.b35b04",
"name": "valetudo_control_msg",
"func": "var payload = msg.payload;\n\n//Domoticz control device Idx.\nvar domo_controldev_id = 105\n\nif (payload.idx == domo_controldev_id)\n{\n if (payload.svalue1 == 10){\n msg.topic = \"valetudo/rockrobo/command\";\n msg.payload = \"start\";\n return msg;\n }\n if (payload.svalue1 == 20){\n msg.topic = \"valetudo/rockrobo/command\";\n msg.payload = \"stop\";\n return msg;\n }\n if (payload.svalue1 == 30){\n msg.topic = \"valetudo/rockrobo/custom_command\";\n msg.payload = {\"command\": \"zoned_cleanup\", \"zone_ids\": [\"Living\", \"Kitchen\", \"Hall\"]};\n return msg;\n }\n if (payload.svalue1 == 40){\n msg.topic = \"valetudo/rockrobo/command\";\n msg.payload = \"return_to_base\";\n return msg;\n }\n if (payload.svalue1 == 50){\n msg.topic = \"valetudo/rockrobo/command\";\n msg.payload = \"pause\";\n return msg;\n }\n if (payload.svalue1 == 60){\n msg.topic = \"valetudo/rockrobo/command\";\n msg.payload = \"locate\";\n return msg;\n }\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 560,
"y": 460,
"wires": [
[
"65c71638.c1a1a",
"fd20492b.8c25e8"
]
]
},
{
"id": "1fb9589d.5ca7af",
"type": "json",
"z": "46b0845e.b35b04",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 370,
"y": 460,
"wires": [
[
"96d8f1a3.fb866",
"5d798cd4.06f91c"
]
]
},
{
"id": "b8165e42.22f308",
"type": "mqtt in",
"z": "46b0845e.b35b04",
"name": "",
"topic": "valetudo/rockrobo/attributes",
"qos": "0",
"datatype": "auto",
"broker": "e0bf1c2a.932a88",
"x": 180,
"y": 220,
"wires": [
[
"ca89f757.e149c8"
]
]
},
{
"id": "ca89f757.e149c8",
"type": "json",
"z": "46b0845e.b35b04",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 370,
"y": 220,
"wires": [
[
"324cea32.09bfae",
"c2839d66.4924b8",
"ad2cadb5.a6c52",
"3734419b.fb287e",
"d29c28af.cbbf8",
"7b60159e.81518c"
]
]
},
{
"id": "324cea32.09bfae",
"type": "debug",
"z": "46b0845e.b35b04",
"name": "valetudo_attr",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 610,
"y": 60,
"wires": []
},
{
"id": "c2839d66.4924b8",
"type": "function",
"z": "46b0845e.b35b04",
"name": "valetudo_care",
"func": "var payload = msg.payload;\n\nif (payload.mainBrush == \"0.0\")\n flow.set(\"care\", 1);\nelse if (payload.sideBrush == \"0.0\")\n flow.set(\"care\", 1);\nelse if (payload.filter == \"0.0\")\n flow.set(\"care\", 1);\nelse if (payload.sensor == \"0.0\")\n flow.set(\"care\", 1);\nelse\n flow.set(\"care\", 0);\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 620,
"y": 100,
"wires": [
[]
]
},
{
"id": "77924c57.51034c",
"type": "mqtt in",
"z": "46b0845e.b35b04",
"name": "",
"topic": "valetudo/rockrobo/#",
"qos": "0",
"datatype": "auto",
"broker": "e0bf1c2a.932a88",
"x": 150,
"y": 640,
"wires": [
[
"4a8036b3.f5b92"
]
]
},
{
"id": "144fe2f2.c55afd",
"type": "debug",
"z": "46b0845e.b35b04",
"name": "valetudo_all",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 590,
"y": 640,
"wires": []
},
{
"id": "4a8036b3.f5b92",
"type": "json",
"z": "46b0845e.b35b04",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 410,
"y": 640,
"wires": [
[
"144fe2f2.c55afd"
]
]
},
{
"id": "ad2cadb5.a6c52",
"type": "moment",
"z": "46b0845e.b35b04",
"name": "",
"topic": "",
"input": "payload.last_run_stats.startTime",
"inputType": "msg",
"inTz": "Europe/Berlin",
"adjAmount": "0",
"adjType": "hours",
"adjDir": "add",
"format": "YYYY-MM-DD kk:mm:ss",
"locale": "de_DE",
"output": "lastcleaning",
"outputType": "flow",
"outTz": "Europe/Berlin",
"x": 640,
"y": 140,
"wires": [
[]
]
},
{
"id": "cce4dc63.137028",
"type": "mqtt out",
"z": "46b0845e.b35b04",
"name": "",
"topic": "",
"qos": "",
"retain": "",
"broker": "e0bf1c2a.932a88",
"x": 1170,
"y": 220,
"wires": []
},
{
"id": "be9c673b.59651",
"type": "debug",
"z": "46b0845e.b35b04",
"name": "domoticz_in",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1190,
"y": 320,
"wires": []
},
{
"id": "3734419b.fb287e",
"type": "function",
"z": "46b0845e.b35b04",
"name": "valetudo_state_for_domoticz",
"func": "var payload = msg.payload;\n\n//Domoticz state device Idx.\nvar domo_statedev_id = 111;\n\nvar state = payload.valetudo_state.name;\nvar carestate = flow.get(\"care\") || 0;\n\nmsg.topic = \"domoticz/in\"\n\nif (carestate){\n msg.payload = \"{\\\"command\\\": \\\"udevice\\\", \\\"idx\\\": \" + domo_statedev_id + \", \\\"svalue\\\": \\\"Care\\\"}\";\n return msg;\n}\n\nmsg.payload = \"{\\\"command\\\": \\\"udevice\\\", \\\"idx\\\": \" + domo_statedev_id + \", \\\"svalue\\\": \\\"\" + state + \"\\\"}\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 660,
"y": 220,
"wires": [
[
"57658e77.c385d"
]
]
},
{
"id": "57658e77.c385d",
"type": "json",
"z": "46b0845e.b35b04",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 890,
"y": 220,
"wires": [
[
"cce4dc63.137028",
"be9c673b.59651"
]
]
},
{
"id": "d29c28af.cbbf8",
"type": "function",
"z": "46b0845e.b35b04",
"name": "lastcleaning",
"func": "var payload = msg.payload;\nvar lastcleaning = flow.get(\"lastcleaning\") || 0;\n\n//Domoticz date device Idx.\nvar domo_datedev_id = 112;\n\nmsg.topic = \"domoticz/in\";\n\nif (payload.last_run_stats.finishedFlag){\n msg.payload = \"{\\\"command\\\": \\\"udevice\\\", \\\"idx\\\": \" + domo_datedev_id + \", \\\"svalue\\\": \\\"\" + lastcleaning.toString() + \"\\\"}\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 610,
"y": 300,
"wires": [
[
"b8795702.267f18"
]
]
},
{
"id": "b8795702.267f18",
"type": "json",
"z": "46b0845e.b35b04",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 890,
"y": 300,
"wires": [
[
"cce4dc63.137028",
"be9c673b.59651"
]
]
},
{
"id": "7b60159e.81518c",
"type": "function",
"z": "46b0845e.b35b04",
"name": "lastcleaning_duration",
"func": "var payload = msg.payload;\nvar lastcleaning_duration = 0;\n\n//Domoticz duration device Idx.\nvar domo_durationdev_id = 113;\n\nmsg.topic = \"domoticz/in\";\n\nif (payload.last_run_stats.finishedFlag){\n lastcleaning_duration = Math.ceil(payload.last_run_stats.duration/60);\n msg.payload = \"{\\\"command\\\": \\\"udevice\\\", \\\"idx\\\": \" + domo_durationdev_id + \", \\\"svalue\\\": \\\"\" + lastcleaning_duration.toString() + \"\\\"}\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 640,
"y": 380,
"wires": [
[
"47e1c933.1e9268"
]
]
},
{
"id": "47e1c933.1e9268",
"type": "json",
"z": "46b0845e.b35b04",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 890,
"y": 380,
"wires": [
[
"cce4dc63.137028",
"be9c673b.59651"
]
]
},
{
"id": "5d798cd4.06f91c",
"type": "debug",
"z": "46b0845e.b35b04",
"name": "domoticz_out",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 540,
"y": 520,
"wires": []
},
{
"id": "e0bf1c2a.932a88",
"type": "mqtt-broker",
"z": "",
"name": "Mosquitto",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]