Hi all
I am trying to toogle a value too control my light. I have a payload with a value 0-100, and I want a button(Ikea) to toogle the value if it over 0, then set it to 0, and if it is 0 then set it to 40.
If I push the button, it always give me a "0"
[
{
"id": "f15e9b1906385ff2",
"type": "function",
"z": "72a01dcd34706a98",
"name": "Toggle Brightness",
"func": "var Value = msg.payload;\nvar Button = msg.payload.buttonevent;\nif (Button === 1002) {\n if (Value === 0) {\n Value = 40;\n } else {\n Value = 0;\n }\n}\nmsg.payload = Value;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 550,
"y": 600,
"wires": [
[
"d273438d6b622696"
]
]
},
{
"id": "d273438d6b622696",
"type": "debug",
"z": "72a01dcd34706a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 830,
"y": 600,
"wires": []
},
{
"id": "58ea0f732023cf3c",
"type": "deconz-input",
"z": "72a01dcd34706a98",
"name": "",
"topic": "",
"config_version": 2,
"server": "4b1fba61.3934e4",
"statustext": "",
"statustext_type": "default",
"search_type": "device",
"device_list": [
"sensors/uniqueid/0c:43:14:ff:fe:41:7e:94-01-1000"
],
"device_name": "",
"query": "{}",
"outputs": 1,
"output_rules": [
{
"type": "state",
"format": "single",
"output": "onupdate",
"onstart": false,
"payload": [
"__complete__"
],
"uniqueId": "ui-id-6"
}
],
"x": 170,
"y": 880,
"wires": [
[
"f15e9b1906385ff2"
]
]
},
{
"id": "5753bff37f112f1b",
"type": "inject",
"z": "72a01dcd34706a98",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "0",
"payloadType": "num",
"x": 190,
"y": 600,
"wires": [
[
"f15e9b1906385ff2"
]
]
},
{
"id": "80f5cd71a5f0c35c",
"type": "inject",
"z": "72a01dcd34706a98",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "50",
"payloadType": "num",
"x": 190,
"y": 680,
"wires": [
[
"f15e9b1906385ff2"
]
]
},
{
"id": "85474c477996a68e",
"type": "inject",
"z": "72a01dcd34706a98",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "100",
"payloadType": "num",
"x": 190,
"y": 760,
"wires": [
[
"f15e9b1906385ff2"
]
]
},
{
"id": "4b1fba61.3934e4",
"type": "deconz-server",
"name": "Phoscon-GW",
"config_version": 1,
"ip": "192.168.0.44",
"port": "8080",
"ws_port": "443",
"secure": false,
"polling": "3"
}
]