How to implement integration with Alexa door lock

#1

Hi Guys, right now I´m working node-red to integrate with amazon Echo (Alexa) and I have success to integrate Switches but I have doubts how to do it well with door lock.
I seen that the Alex Home node sending a command GetLockStateRequest and than I formatted a GetLockStateResponse with payload (Locked or unlocked) synchronous with global variable that represents the state of door lock trought Alexa home resp node. Since Alexa home node received message the Alexa App waiting a response and than show the error: "Door lock is not responding".

The function that changes lock state can be seen bellow:

var Doorlockfeedback = global.get("DoorLockFeedback");


if (Doorlockfeedback.LockCurrentState === 0) {
    console.log(`Door lockState :)` +Doorlockfeedback.LockCurrentState);
    
    var status = {payload :{lockState: "LOCKED"}};
    msg.paylaod = status;
    return msg;

    
} else if (Doorlockfeedback.LockCurrentState === 1) {
        console.log(`Door lockState :)` +Doorlockfeedback.LockCurrentState);
    
    var status = {payload :{lockState: "UNLOCKED"}};
    msg.paylaod = status;
    return msg;
}

The Msgs (Request and Response) on node-red debug can be seen bellow:

Please, can Somebody help me to solve this?

#2

There are at least two alexa nodes with home also in the title. Which one are you using?

One contains a link to a wiki that includes a list of the functionality it contains.
For the other one I’d contact the author to confirm if it can control a lock

#3

Hi ukmoose, thanks a lot for your quickly replay!
The node that I sending the GetLockStateResponse is Alexa Home Resp. As you can see bellow in the nodes:

[{"id":"3317000.46702","type":"alexa-home","z":"521c6d66.acd1f4","conf":"652b1fd7.9687d","device":"56330","acknoledge":true,"name":"Door Lock","topic":"Alexa - Door Lock","x":90,"y":900,"wires":[["364ca348.31672c"]]},{"id":"364ca348.31672c","type":"switch","z":"521c6d66.acd1f4","name":"Locker find Cmd","property":"command","propertyType":"msg","rules":[{"t":"eq","v":"GetLockStateRequest","vt":"str"},{"t":"eq","v":"SetLockState","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":900,"wires":[["100f4419.d9efbc"],["45876eea.1e39e"]]},{"id":"100f4419.d9efbc","type":"change","z":"521c6d66.acd1f4","name":"","rules":[{"t":"change","p":"command","pt":"msg","from":"GetLockStateRequest","fromt":"str","to":"GetLockStateResponse","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":870,"wires":[["9ec994f3.0e8b08"]]},{"id":"9ec994f3.0e8b08","type":"delay","z":"521c6d66.acd1f4","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":750,"y":870,"wires":[["c61b4be7.3daab8"]]},{"id":"c61b4be7.3daab8","type":"function","z":"521c6d66.acd1f4","name":"DoorLockState","func":"var Doorlockfeedback = global.get(\"DoorLockFeedback\");\n\n\nif (Doorlockfeedback.LockCurrentState === 0) {\n    console.log(`Door lockState :)` +Doorlockfeedback.LockCurrentState);\n    \n    var status = {payload :{lockState: \"LOCKED\"}};\n    msg.paylaod = status;\n    return msg;\n\n    \n} else if (Doorlockfeedback.LockCurrentState === 1) {\n        console.log(`Door lockState :)` +Doorlockfeedback.LockCurrentState);\n    \n    var status = {payload :{lockState: \"UNLOCKED\"}};\n    msg.paylaod = status;\n    return msg;\n}\n\n    \n","outputs":1,"noerr":0,"x":950,"y":900,"wires":[["df1d8656.9b9fb8","2fe9ee2e.9cc042"]]},{"id":"2fe9ee2e.9cc042","type":"debug","z":"521c6d66.acd1f4","name":"Door Lock - Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1170,"y":840,"wires":[]},{"id":"df1d8656.9b9fb8","type":"alexa-home-resp","z":"521c6d66.acd1f4","x":1180,"y":930,"wires":[]},{"id":"652b1fd7.9687d","type":"alexa-home-conf","z":"","username":"aargollo"}]

Please, let me know if I need to share more information for you!

#4

There are 15 Alexa nodes listed on flows.nodered.org
none of them are called Alexa Home Resp

See https://flows.nodered.org/?term=alexa&type=node&num_pages=1

As per my last post, if you look at the ReadMe for the node one contains a wiki of its functionality, one you will need to contact the author of the node. You can do that through the github link which should be listed on the nodes page on the flows site

#5

Hi Ukmoose, thanks.
I got success after included the parameters according alexa-home skill adivise.

msg.extra = {
    lockState: "LOCKED"
};

I used this change node to implement it:

[{"id":"100f4419.d9efbc","type":"change","z":"521c6d66.acd1f4","name":"","rules":[{"t":"change","p":"command","pt":"msg","from":"GetLockStateRequest","fromt":"str","to":"GetLockStateResponse","tot":"str"},{"t":"set","p":"extra","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":870,"wires":[["9ec994f3.0e8b08"]]}]

Thanks a lot!
Alex