Okay, you’ve moved on quickly with that one.
Try dropping an openHAB2-get node between function and the switch.
Then set the switch to compare msg.payload.state
which will contain the value for the brightness (or whatever state the item has)
( FYI, all the Previous payload, as it was before it hit the Get node, is moved to msg.payload_in
)
[
{
"id": "a2f09dd.58e4b6",
"type": "function",
"z": "d055bce9.0a808",
"name": "",
"func": "\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 540,
"y": 520,
"wires": [
[
"79deec4d.6ec694"
]
]
},
{
"id": "79deec4d.6ec694",
"type": "openhab2-get",
"z": "d055bce9.0a808",
"name": "",
"controller": "",
"itemname": "",
"x": 740,
"y": 520,
"wires": [
[
"8be75d4f.ec97e"
]
]
},
{
"id": "8be75d4f.ec97e",
"type": "switch",
"z": "d055bce9.0a808",
"name": "State of brightness",
"property": "payload.state",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "num"
},
{
"t": "eq",
"v": "0",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 970,
"y": 520,
"wires": [
[
"ad9ff65c.1bffd8",
"6eaf08e.eeec9f8"
],
[
"663f5db.07179a4",
"88d9a911.187e58"
]
]
},
{
"id": "ad9ff65c.1bffd8",
"type": "openhab2-out",
"z": "d055bce9.0a808",
"name": "",
"controller": "",
"itemname": "",
"topic": "",
"payload": "",
"x": 1270,
"y": 400,
"wires": [
[]
]
},
{
"id": "6eaf08e.eeec9f8",
"type": "openhab2-out",
"z": "d055bce9.0a808",
"name": "",
"controller": "",
"itemname": "",
"topic": "",
"payload": "",
"x": 1280,
"y": 440,
"wires": [
[]
]
},
{
"id": "663f5db.07179a4",
"type": "openhab2-out",
"z": "d055bce9.0a808",
"name": "",
"controller": "",
"itemname": "",
"topic": "",
"payload": "",
"x": 1280,
"y": 600,
"wires": [
[]
]
},
{
"id": "88d9a911.187e58",
"type": "openhab2-out",
"z": "d055bce9.0a808",
"name": "",
"controller": "",
"itemname": "",
"topic": "",
"payload": "",
"x": 1280,
"y": 640,
"wires": [
[]
]
},
{
"id": "cebcafa8.dd76f",
"type": "comment",
"z": "d055bce9.0a808",
"name": "If brightness is >0",
"info": "",
"x": 1260,
"y": 340,
"wires": []
},
{
"id": "8f1a739d.a8492",
"type": "comment",
"z": "d055bce9.0a808",
"name": "If brightness is == 0",
"info": "",
"x": 1270,
"y": 560,
"wires": []
},
{
"id": "611fd2b9.46262c",
"type": "openhab2-events",
"z": "d055bce9.0a808",
"name": "",
"controller": "",
"itemname": "",
"x": 330,
"y": 520,
"wires": [
[
"a2f09dd.58e4b6"
]
]
}
]