I am pretty new in Node-Red, I'm driven here because Home Assistant's automation is slow.
I made my first flow! and want to make sure I didn't ignore some basics of Node Red and didn't overcomplicate
Scenario:
I have an Aeotec nanomote. This is a 4 keys button switch. I want to enable with One switch to toggle some devices (without using Zwave associatons).
Nanomote uses Central Scenes. When you press a button the MQTT payload receives for one second the Value "Pressed" and after a bit Updates the topic with value "Inactive"
This is my Trigger state
I want to achieve the following:
- If bulb which is another MQTT device is on, turn it off...
- If bulb is off, turn it on.
My flow is not EndState one, I miss sending the state update to the MQTT Topic. But I do debug it using this way.
My flow:
[
{
"id": "74fe1247.6a93cc",
"type": "switch",
"z": "6f8f89ff.9374a8",
"name": "",
"property": "payload.value",
"propertyType": "jsonata",
"rules": [
{
"t": "eq",
"v": "Pressed",
"vt": "str"
}
],
"checkall": "true",
"repair": true,
"outputs": 1,
"x": 570,
"y": 180,
"wires": [
[
"c0d20793.f78738"
]
]
},
{
"id": "c0d20793.f78738",
"type": "switch",
"z": "6f8f89ff.9374a8",
"name": "",
"property": "lightState",
"propertyType": "flow",
"rules": [
{
"t": "eq",
"v": "Off",
"vt": "str"
},
{
"t": "eq",
"v": "On",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 750,
"y": 180,
"wires": [
[
"c6b492d.4d5a57"
],
[
"416e38dc.c14b18"
]
]
},
{
"id": "cd33b334.98644",
"type": "debug",
"z": "6f8f89ff.9374a8",
"name": "Debug end state",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 1270,
"y": 180,
"wires": []
},
{
"id": "c6b492d.4d5a57",
"type": "change",
"z": "6f8f89ff.9374a8",
"name": "Is OFF set ON",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Is OFF, set ON",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 940,
"y": 140,
"wires": [
[
"cd33b334.98644",
"6dd10397.87ef5c"
]
]
},
{
"id": "416e38dc.c14b18",
"type": "change",
"z": "6f8f89ff.9374a8",
"name": "Is On, Set OFF",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Is ON, Set to OFF",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 940,
"y": 220,
"wires": [
[
"cd33b334.98644",
"f97ecdbc.71d4a"
]
]
},
{
"id": "95676085.92d26",
"type": "mqtt in",
"z": "6f8f89ff.9374a8",
"name": "",
"topic": "zwave2mqtt/MasterBedroom/VassilisSwitch/91/1/4",
"qos": "2",
"datatype": "json",
"broker": "96bab34d.d97b5",
"x": 270,
"y": 180,
"wires": [
[
"74fe1247.6a93cc"
]
]
},
{
"id": "e0e11546.5730d8",
"type": "inject",
"z": "6f8f89ff.9374a8",
"name": "send Pressed State",
"topic": "",
"payload": "{\"value_id\":\"60-91-1-1\",\"node_id\":60,\"class_id\":91,\"type\":\"list\",\"genre\":\"user\",\"instance\":1,\"index\":1,\"label\":\"Scene 1\",\"units\":\"\",\"help\":\"\",\"read_only\":true,\"write_only\":false,\"min\":0,\"max\":0,\"is_polled\":false,\"values\":[\"Inactive\",\"Pressed 1 Time\",\"Key Released\",\"Key Held down\"],\"value\":\"Pressed\",\"lastUpdate\":1583079850053}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 370,
"y": 260,
"wires": [
[
"74fe1247.6a93cc"
]
]
},
{
"id": "6dd10397.87ef5c",
"type": "change",
"z": "6f8f89ff.9374a8",
"name": "Set flow.state",
"rules": [
{
"t": "set",
"p": "lightState",
"pt": "flow",
"to": "On",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1180,
"y": 120,
"wires": [
[]
]
},
{
"id": "f97ecdbc.71d4a",
"type": "change",
"z": "6f8f89ff.9374a8",
"name": "Set flow.state",
"rules": [
{
"t": "set",
"p": "lightState",
"pt": "flow",
"to": "Off",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1180,
"y": 260,
"wires": [
[]
]
},
{
"id": "96bab34d.d97b5",
"type": "mqtt-broker",
"z": "",
"name": "Main MQTT",
"broker": "mqtt",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
I will in the end replace the end flow state with the MQTT Target.
I also have another Flow which updates flow.lightState using an mqtt subscription on the Bulb Endpoint.
Thanks,
V