Need help with huemagic

so here i am again
most posible asking you guys aa easy quistion
i have trouble setting up somthing that recieves a singnal of my hue dot and do somthing with it i got

[{"id":"79f1f61985718e40","type":"debug","z":"d5d4a606.0f05","name":"Information","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload.action","targetType":"msg","statusVal":"payload","statusType":"auto","x":760,"y":140,"wires":[],"icon":"font-awesome/fa-info-circle"},{"id":"74f3cdad2b625d5c","type":"inject","z":"d5d4a606.0f05","name":"Status","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"status\":true}","payloadType":"json","x":110,"y":160,"wires":[["664e68b0b62d7e4e"]],"icon":"node-red/alert.svg"},{"id":"664e68b0b62d7e4e","type":"hue-buttons","z":"d5d4a606.0f05","name":"Dot Light Switch Desk","bridge":"6465e98b22084718","sensorid":"455397cf-1fab-4eb6-98ae-05aaf4110dc1","skipevents":false,"initevents":true,"x":480,"y":160,"wires":[["7acc494c2cf71b83","79f1f61985718e40","b2ff50f06ff3cc76"]]},{"id":"b2ff50f06ff3cc76","type":"debug","z":"d5d4a606.0f05","name":"Information","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload.button","targetType":"msg","statusVal":"payload","statusType":"auto","x":760,"y":80,"wires":[],"icon":"font-awesome/fa-info-circle"},{"id":"25ca7b9c17693660","type":"switch","z":"d5d4a606.0f05","name":"","property":"payload.result","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":200,"wires":[["dc80c78f8055effe"]]},{"id":"dc80c78f8055effe","type":"wled2","z":"d5d4a606.0f05","address":"192.168.1.190","brightness":128,"delay":0,"color1":"#ffffff","color2":"#ffffff","color3":"#ffffff","effect":0,"effectIntensity":128,"effectSpeed":128,"name":"","palette":"0","preset":0,"state":"toggle","x":950,"y":200,"wires":[[]]},{"id":"bcac79974de13aa4","type":"debug","z":"d5d4a606.0f05","name":"Information function","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"msg.payload.result","targetType":"msg","statusVal":"payload","statusType":"auto","x":780,"y":260,"wires":[],"icon":"font-awesome/fa-info-circle"},{"id":"7acc494c2cf71b83","type":"function","z":"d5d4a606.0f05","name":"function 1","func":"// Initialize a variable to track the state\ncontext.toggleState = context.toggleState || false;\n\n// Check if msg.payload.button is a number and msg.payload.action is a string with the specified value\nif (\n    msg.payload &&\n    typeof msg.payload.button === 'number' &&\n    msg.payload.button === 3 &&\n    typeof msg.payload.action === 'string' &&\n    msg.payload.action === 'initial_press'\n) {\n    // Toggle the state\n    context.toggleState = !context.toggleState;\n}\n\n// Set msg.payload.result based on the state\nmsg.payload.result = context.toggleState;\n\n// Return the modified message object\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":200,"wires":[["25ca7b9c17693660","bcac79974de13aa4"]]},{"id":"6465e98b22084718","type":"hue-bridge","name":"Hue Bridge (Aredhone)","bridge":"xxx.xxx,x.xx","key":"xaaMhr4WOurTpaoriPyDffAX59V23PhyvLIll4Fw","worker":"10","autoupdates":true,"disableupdates":false}]

see updates in function node

// Initialize a variable to track the state
var toggleState = context.get("toggleState") || false;

// Check if msg.payload.button is a number and msg.payload.action is a string with the specified value
if (
    msg.payload &&
    typeof msg.payload.button === 'number' &&
    msg.payload.button === 3 &&
    typeof msg.payload.action === 'string' &&
    msg.payload.action === 'initial_press'
) {
    // Toggle the state
    toggleState = !context.toggleState;
    // save state
    context.set("toggleState", toggleState)
}

// Set msg.payload.result based on the state
msg.payload.result = toggleState;

// Return the modified message object
return msg;

i have the same problem with this no mather witch button i press on the hue tap it toggles the light i only want it to toggle when i press button 3

Please share the incoming msg , then i can help, of al 3 buttons pressed

i hope this helps

4/30/2024, 7:46:21 PMnode: Complete msg
msg : Object
{ payload: object, info: object, updated: object, lastState: object, command: object … }
4/30/2024, 7:46:21 PMnode: Information function
msg.msg.payload.result : boolean
true
4/30/2024, 7:46:22 PMnode: Complete msg
msg : Object
{ payload: object, info: object, updated: object, lastState: object, command: object … }
4/30/2024, 7:46:22 PMnode: Information function
msg.msg.payload.result : boolean
true
4/30/2024, 7:46:28 PMnode: Complete msg
msg : Object
{ payload: object, info: object, updated: object, lastState: object, command: object … }
4/30/2024, 7:46:28 PMnode: Information function
msg.msg.payload.result : boolean
true
4/30/2024, 7:46:29 PMnode: Complete msg
msg : Object
{ payload: object, info: object, updated: object, lastState: object, command: object … }
4/30/2024, 7:46:29 PMnode: Information function
msg.msg.payload.result : boolean
true

nope cant see what this contains
payload: object, info: object, updated: object

Thanks for your efford but i found another way how to do it through devices and functions lessen for me not all extensions make life easier
Well thanks for all the help all

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.