Dreame Vacuum Control

Flow to control Dreame vacuum using Home Assistant services via Node-RED.

[
    {
        "id": "inject_clean_salon",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Clean Salon",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 80,
        "wires": [
            [
                "service_clean_salon"
            ]
        ]
    },
    {
        "id": "service_clean_salon",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Clean Salon (Segment 2)",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "dreame_vacuum",
        "service": "vacuum_clean_segment",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "{\"segments\": [2]}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 350,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "inject_clean_kitchen",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Clean Kitchen",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 140,
        "wires": [
            [
                "service_clean_kitchen"
            ]
        ]
    },
    {
        "id": "service_clean_kitchen",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Clean Kitchen (Segment 3)",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "dreame_vacuum",
        "service": "vacuum_clean_segment",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "{\"segments\": [3]}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 350,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "inject_clean_adele",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Clean Adele Room",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 200,
        "wires": [
            [
                "service_clean_adele"
            ]
        ]
    },
    {
        "id": "service_clean_adele",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Clean Adele Room (Segment 4)",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "dreame_vacuum",
        "service": "vacuum_clean_segment",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "{\"segments\": [4]}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 350,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "inject_clean_parents",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Clean Parents Room",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 260,
        "wires": [
            [
                "service_clean_parents"
            ]
        ]
    },
    {
        "id": "service_clean_parents",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Clean Parents Room (Segment 5)",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "dreame_vacuum",
        "service": "vacuum_clean_segment",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "{\"segments\": [5]}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 350,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "inject_clean_kids",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Clean Kids Room",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 320,
        "wires": [
            [
                "service_clean_kids"
            ]
        ]
    },
    {
        "id": "service_clean_kids",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Clean Kids Room (Segment 6)",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "dreame_vacuum",
        "service": "vacuum_clean_segment",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "{\"segments\": [6]}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 350,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "inject_return_dock",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Return to Dock",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 380,
        "wires": [
            [
                "service_return_dock"
            ]
        ]
    },
    {
        "id": "service_return_dock",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Return Vacuum to Dock",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "vacuum",
        "service": "return_to_base",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 350,
        "y": 380,
        "wires": [
            []
        ]
    },
    {
        "id": "ed2902816199dda2",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Start Cleaning - Selected Rooms",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 170,
        "y": 500,
        "wires": [
            [
                "67d2fd40583eb859"
            ]
        ]
    },
    {
        "id": "67d2fd40583eb859",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Clean Selected Segments",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "dreame_vacuum",
        "service": "vacuum_clean_segment",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "{\"segments\": [1]}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 450,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "dde13d0a785534f1",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Stop Cleaning",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 110,
        "y": 440,
        "wires": [
            [
                "acfea6821532c0da"
            ]
        ]
    },
    {
        "id": "acfea6821532c0da",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Stop Vacuum",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "vacuum",
        "service": "stop",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 310,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "038543b58117a198",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Check Vacuum State",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 560,
        "wires": [
            [
                "146b2438f7949644"
            ]
        ]
    },
    {
        "id": "146b2438f7949644",
        "type": "api-current-state",
        "z": "room_cleaning_tab",
        "name": "Get Vacuum State",
        "server": "",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "vacuum.max",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 350,
        "y": 560,
        "wires": [
            [
                "bd7c6e1e994865c3"
            ]
        ]
    },
    {
        "id": "bd7c6e1e994865c3",
        "type": "debug",
        "z": "room_cleaning_tab",
        "name": "Vacuum Attributes",
        "active": true,
        "tosidebar": true,
        "console": false,
        "complete": "true",
        "statusVal": "",
        "statusType": "auto",
        "x": 590,
        "y": 560,
        "wires": []
    },
    {
        "id": "37a94c86606247f2",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Get Vacuum Capabilities",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 150,
        "y": 700,
        "wires": [
            [
                "27f6374436b575b8"
            ]
        ]
    },
    {
        "id": "27f6374436b575b8",
        "type": "api-current-state",
        "z": "room_cleaning_tab",
        "name": "Get Vacuum State",
        "server": "",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "vacuum.max",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 390,
        "y": 700,
        "wires": [
            [
                "b810369d3d906858"
            ]
        ]
    },
    {
        "id": "b810369d3d906858",
        "type": "function",
        "z": "room_cleaning_tab",
        "name": "Extract Capabilities",
        "func": "var attributes = msg.data.attributes;\n\nif (attributes && attributes.capabilities) {\n    // Create a string listing all supported functions\n    msg.payload = \"Supported Functions: \" + attributes.capabilities.join(\", \");\n    // Optionally, store the raw array in msg.capabilities\n    msg.capabilities = attributes.capabilities;\n} else {\n    msg.payload = \"No capabilities found.\";\n}\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 700,
        "wires": [
            [
                "08705c4e4deeb0d9"
            ]
        ]
    },
    {
        "id": "08705c4e4deeb0d9",
        "type": "debug",
        "z": "room_cleaning_tab",
        "name": "Vacuum Capabilities",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 860,
        "y": 700,
        "wires": []
    },
    {
        "id": "82cedc6c8725aee2",
        "type": "inject",
        "z": "room_cleaning_tab",
        "name": "Set Cleaning Route to 'Deep'",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 160,
        "y": 620,
        "wires": [
            [
                "84525739ec1fc50a"
            ]
        ]
    },
    {
        "id": "84525739ec1fc50a",
        "type": "api-call-service",
        "z": "room_cleaning_tab",
        "name": "Set Cleaning Route",
        "server": "",
        "version": 5,
        "debugenabled": false,
        "domain": "dreame_vacuum",
        "service": "set_cleaning_route",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "vacuum.max"
        ],
        "data": "{\"cleaning_route\": \"Deep\"}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "output_location": "",
        "output_location_type": "none",
        "x": 410,
        "y": 620,
        "wires": [
            [
                "e74f73ba8c04db26"
            ]
        ]
    },
    {
        "id": "e74f73ba8c04db26",
        "type": "debug",
        "z": "room_cleaning_tab",
        "name": "Vacuum Capabilities",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 660,
        "y": 620,
        "wires": []
    }
]

I bought the 40X, I’m trying to work with it with the help of Node Red - unfortunately I haven’t found many people who work in this way with X40, so I’m sharing the things in the environments that I was able to do - maybe something if a better experience than mine can help and make smarter processes - — If there is something the process exists, I would appreciate sharing - good luck to us