# How to implement integration with Alexa door lock

**URL:** <https://discourse.nodered.org/t/how-to-implement-integration-with-alexa-door-lock/10042>\
**Category:** General\
**Created:** [11 April 2019 22:04 UTC](https://discourse.nodered.org/t/how-to-implement-integration-with-alexa-door-lock/10042 "2019-04-11T22:04:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aargollo](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@aargollo](https://discourse.nodered.org/u/aargollo)\
**Post date:** [11 April 2019 22:04 UTC](https://discourse.nodered.org/t/how-to-implement-integration-with-alexa-door-lock/10042/1 "2019-04-11T22:04:52Z")

</div>

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:

```auto
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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e8b2ec21583d782f99e65c78d380c093f5dafe30.png)

Please, can Somebody help me to solve this?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [12 April 2019 06:27 UTC](https://discourse.nodered.org/t/how-to-implement-integration-with-alexa-door-lock/10042/2 "2019-04-12T06:27:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aargollo](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@aargollo](https://discourse.nodered.org/u/aargollo)\
**Post date:** [13 April 2019 01:28 UTC](https://discourse.nodered.org/t/how-to-implement-integration-with-alexa-door-lock/10042/3 "2019-04-13T01:28:02Z")

</div>

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:

```auto
[{"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!

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [13 April 2019 06:13 UTC](https://discourse.nodered.org/t/how-to-implement-integration-with-alexa-door-lock/10042/4 "2019-04-13T06:13:02Z")

</div>

There are 15 Alexa nodes listed on [flows.nodered.org](http://flows.nodered.org)  
none of them are called Alexa Home Resp

See [https://flows.nodered.org/?term=alexa&type=node&num\_pages=1](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

---

<div class="post-metadata">

**Author:** ![aargollo](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@aargollo](https://discourse.nodered.org/u/aargollo)\
**Post date:** [13 April 2019 12:58 UTC](https://discourse.nodered.org/t/how-to-implement-integration-with-alexa-door-lock/10042/5 "2019-04-13T12:58:11Z")

</div>

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

> **[node-red-contrib-alexa-home-skill](https://flows.nodered.org/node/node-red-contrib-alexa-home-skill)**
>
> This node allows you to hook up Node-RED to react to your Amazon Echo.

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

```

I used this change node to implement it:

```auto
[{"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
