Why can't open the magnetic successfully, just can lock

this is the full flow

[{"id":"2f0108b5.890318","type":"tab","label":"VAES_Project","disabled":false,"info":""},{"id":"e0ae3ada.3b0f48","type":"function","z":"2f0108b5.890318","name":"Generate History INSERT SQL","func":"//generate the SQL insert\nmsg.topic = `INSERT INTO HISTORY (NAME)   \n            VALUES( '${msg.result.NAME}' )`;\n\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":400,"wires":[["22bec2b4.2184de","50bc03ce.52717c"]]},{"id":"9a158a05.d25df8","type":"debug","z":"2f0108b5.890318","name":"History Insert Result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":840,"y":360,"wires":[]},{"id":"738f0443.2ae92c","type":"change","z":"2f0108b5.890318","name":"set welcome sound","rules":[{"t":"set","p":"payload","pt":"msg","to":"welcome","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":500,"wires":[["89fc085b.968e58","a29324e5.f81ec8"]]},{"id":"aa649507.390908","type":"change","z":"2f0108b5.890318","name":"set access denied sound","rules":[{"t":"set","p":"payload","pt":"msg","to":"access denied","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":540,"wires":[["89fc085b.968e58","a29324e5.f81ec8"]]},{"id":"41920331.b26b4c","type":"watson-speech-to-text","z":"2f0108b5.890318","name":"","alternatives":1,"speakerlabels":true,"smartformatting":true,"lang":"en-US","langhidden":"en-US","langcustom":"NoCustomisationSetting","langcustomhidden":"","custom-weight":"0.5","band":"NarrowbandModel","bandhidden":"NarrowbandModel","keywords":"","keywords-threshold":"0.5","word-confidence":true,"password":"","apikey":"aEfplzvlM_B8MA01nsDy3fj6b3CnG6dOQEGISr2gHxxk","payload-response":true,"streaming-mode":false,"streaming-mute":false,"auto-connect":false,"discard-listening":false,"disable-precheck":false,"service-endpoint":"https://api.us-south.speech-to-text.watson.cloud.ibm.com/instances/4ec7115d-1cbf-4ac7-b141-9c9a675fbdac","x":320,"y":260,"wires":[["96f196fa.d30768"]]},{"id":"96f196fa.d30768","type":"function","z":"2f0108b5.890318","name":"Generate SQL SELECT","func":"//first check payload is a string with something in it\nif(!msg.payload || typeof msg.payload != \"string\"){\n    node.warn(\"msg.payload is empty\");\n    return null;//halt the flow\n}\n\n//Next, trim spoken text & store it in the msg for later use\nmsg.spokenAsText = msg.payload.trim();\n\n//now generate the SQL insert\nmsg.topic = `SELECT * FROM USER \n            WHERE VOICE = '${msg.spokenAsText}' \n            AND VERIFY = 1 \n            LIMIT 1`;\n\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":260,"wires":[["3f2d63ca.637b7c","a3762ed.feadbd"]]},{"id":"9b417c9a.800dd","type":"debug","z":"2f0108b5.890318","name":"SELECT Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":820,"y":220,"wires":[]},{"id":"3f2d63ca.637b7c","type":"debug","z":"2f0108b5.890318","name":"SELECT SQL","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":580,"y":220,"wires":[]},{"id":"89fc085b.968e58","type":"play audio","z":"2f0108b5.890318","name":"","voice":"4","x":800,"y":540,"wires":[]},{"id":"f2e0d688.70ebc8","type":"function","z":"2f0108b5.890318","name":"Verify data","func":"//if payload is empty send it out of output 2\nif(!msg.payload){\n    node.warn(\"payload is null\");\n    return [null, msg];//send msg to output 2\n}\n\n//if payload is NOT an array  send it out of output 2\nif(Array.isArray(msg.payload) === false){\n    node.warn(\"payload array is NOT an array\");\n    return [null, msg];//send msg to output 2\n}\n\n//payload IS an array BUT has < 1, send it out of output 2\nif(msg.payload.length < 1){\n    node.warn(\"payload array is empty\");\n    return [null, msg];//send msg to output 2\n}\n\n/**********  ADD THE LINE BELOW ******************/\nmsg.result = msg.payload[0]; //SAVE the DB SELECT Result for later use\n\n//All checks have passed (data is good!) - send message to output 1\nreturn [msg,null];","outputs":2,"noerr":0,"x":170,"y":400,"wires":[["e0ae3ada.3b0f48","738f0443.2ae92c","d4434a09.afd108"],["aa649507.390908"]],"outputLabels":["Good","Bad"]},{"id":"22bec2b4.2184de","type":"debug","z":"2f0108b5.890318","name":"INSERT SQL","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":510,"y":360,"wires":[]},{"id":"a29324e5.f81ec8","type":"debug","z":"2f0108b5.890318","name":"Play Sound Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":830,"y":500,"wires":[]},{"id":"7af061f6.409ed","type":"inject","z":"2f0108b5.890318","name":"TEST hello hello hello","topic":"","payload":"hello hello hello","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":140,"wires":[["96f196fa.d30768"]]},{"id":"a3762ed.feadbd","type":"mysql","z":"2f0108b5.890318","mydb":"7c738c44.e9a364","name":"DB_MYSQL","x":830,"y":260,"wires":[["9b417c9a.800dd","f2e0d688.70ebc8"]]},{"id":"50bc03ce.52717c","type":"mysql","z":"2f0108b5.890318","mydb":"7c738c44.e9a364","name":"DB_MYSQL","x":830,"y":400,"wires":[["9a158a05.d25df8"]]},{"id":"d6308704.2240c8","type":"rpi-gpio out","z":"2f0108b5.890318","name":"Magnetic lock","pin":"40","set":"","level":"0","freq":"","out":"out","x":880,"y":440,"wires":[]},{"id":"c564cc8c.cdb66","type":"microphone","z":"2f0108b5.890318","name":"","x":110,"y":260,"wires":[["41920331.b26b4c"]]},{"id":"8cabca28.898928","type":"change","z":"2f0108b5.890318","name":"change 0 to 1","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":440,"wires":[["d6308704.2240c8"]]},{"id":"d4434a09.afd108","type":"change","z":"2f0108b5.890318","name":"set msg to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":440,"wires":[["8cabca28.898928"]]},{"id":"7c738c44.e9a364","type":"MySQLdatabase","z":"","host":"165.22.51.44","port":"3306","db":"hireelec_vaes","tz":""}]

this project is using voice to open the door... when it have same voice, the lock will unlock....but it cant unlock the lock .... is that any setting error (red part)

it sometime when start, it will lock first until end ...cant open
somestime when start , it will unlock first (wrong result) then lock...
it make me unclear

and magnetic lock node show 1 already at finally...why still cant open?

In the first picture you set payload to a string "0". In the second node you look for a number 0.
Maybe that's already the error!??

i change alrady... but still error

If you just take a gpio node and connect two inject nodes where one is set to inject zero and the other to inject one does your lock work than? Just to rule out it’s a hardware problem in your wiring or something.
I often find its easier to debug such problems when breaking them down into such small peace’s as it limits the number of possible errors at any time when you have a complex flow like above.

i have try... it always lock ...cant unlock

but when start (if havent lock), it can lock if i press lock node
but after it lock..it cant unlock if pressunlock node

Well than it’s probably a hardware problem and outside the scope of nodered and this forum.
We don’t know which hardware this is and probably nobody here has the same hardware so it will be very hard for anybody to help you with it.
Just out of interest, have you checked things like that your lock is actually running on the same voltage as the gpios of the pi? Have you checked all your wiring? What kind of lock is this?

1 Like

but when start (if havent lock), it can lock if i press lock node
but after it lock..it cant unlock if press unlock node

it only can unlock when i press the deploy....

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