Hello,
I have this flow. It switches a socket on and off based on the power consumption.
I would now like to implement a possibility with the help of which I can operate this socket permanently off, permanently on or in automatic mode (as at the moment) via an mqtt message.
For example, if I send the message “auto”, then the flow should run as before, with “off” the socket should definitely remain off and with “on” it should be switched on accordingly.
How can I do this? I'm not very good at programming. Maybe someone can show me an example or - if necessary - a script.
Thank you very much
Flow:
[
{
"id": "7b3908c5.c15588",
"type": "tab",
"label": "Huawei on/off",
"disabled": false,
"info": ""
},
{
"id": "80866fdc06e127fe",
"type": "mqtt in",
"z": "7b3908c5.c15588",
"name": "electricity meter",
"topic": "evcc/site/gridPower",
"qos": "0",
"datatype": "json",
"broker": "f839540e.7b7858",
"nl": false,
"rap": false,
"inputs": 0,
"x": 200,
"y": 280,
"wires": [
[
"0f1e33ad983e4cb2"
]
]
},
{
"id": "f57d7408525a979f",
"type": "mqtt out",
"z": "7b3908c5.c15588",
"name": "on",
"topic": "cmnd/tas02/Power",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f839540e.7b7858",
"x": 1190,
"y": 180,
"wires": []
},
{
"id": "c66c54b6929cb23f",
"type": "debug",
"z": "7b3908c5.c15588",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1210,
"y": 300,
"wires": []
},
{
"id": "0f1e33ad983e4cb2",
"type": "rbe",
"z": "7b3908c5.c15588",
"name": "define value change",
"func": "deadband",
"gap": "300",
"start": "",
"inout": "out",
"septopics": false,
"property": "payload",
"topi": "topic",
"x": 440,
"y": 280,
"wires": [
[
"ad86aeb9a9907ae6",
"e75866d60570482a"
]
]
},
{
"id": "ad86aeb9a9907ae6",
"type": "switch",
"z": "7b3908c5.c15588",
"name": "payload <= -800",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lte",
"v": "-800",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 660,
"y": 240,
"wires": [
[
"c66c54b6929cb23f",
"a184949a27cd7bc5"
]
]
},
{
"id": "e75866d60570482a",
"type": "switch",
"z": "7b3908c5.c15588",
"name": "payload >= 300",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "gte",
"v": "300",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 660,
"y": 340,
"wires": [
[
"c66c54b6929cb23f",
"8e193c8e87b44819"
]
]
},
{
"id": "ce5f38eb6f387c05",
"type": "mqtt out",
"z": "7b3908c5.c15588",
"name": "off",
"topic": "cmnd/tas02/Power",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f839540e.7b7858",
"x": 1190,
"y": 400,
"wires": []
},
{
"id": "a184949a27cd7bc5",
"type": "change",
"z": "7b3908c5.c15588",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "on",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 950,
"y": 240,
"wires": [
[
"f57d7408525a979f",
"c66c54b6929cb23f"
]
]
},
{
"id": "8e193c8e87b44819",
"type": "change",
"z": "7b3908c5.c15588",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "off",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 950,
"y": 340,
"wires": [
[
"ce5f38eb6f387c05",
"c66c54b6929cb23f"
]
]
},
{
"id": "a201873577991e29",
"type": "mqtt in",
"z": "7b3908c5.c15588",
"name": "Mode",
"topic": "akku/mode",
"qos": "0",
"datatype": "utf8",
"broker": "f839540e.7b7858",
"nl": false,
"rap": false,
"inputs": 0,
"x": 190,
"y": 360,
"wires": [
[]
]
},
{
"id": "f839540e.7b7858",
"type": "mqtt-broker",
"name": "",
"broker": "192.168.178.44",
"port": "1883",
"clientid": "clientid",
"autoConnect": true,
"usetls": false,
"compatmode": false,
"protocolVersion": 4,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]