Trying to set a lock code remotely - can someone point me in a direction on how to do this?

Hello,

I’m new to Hass.io. Currently running on a Raspberry Pi 3 and an Aeotec Z-stick Gen5. So far I’ve successfully added a Kwikset 910 lock to my z-wave network using this method. I can go under Developer Tools > Services and set the code(s) for the lock. That’s all working great. I’ve also set up ssh and can poke around the files, view the “help” documentation, etc., while on my local network.

Now, the next step is: I want to set a lock code remotely and integrate this control into my own website/GUI. I was hoping there would be an easy way to do an HTTP POST to perform a service call. Does some method for this exist?

Do I have to use the Hass.io GUI, or is there some way I can write a script to accept HTTP requests? I know there’s a RESTful API, but I don’t immediately see a way to use it to run a “service”.

I just need to know if this is possible, what direction to look into, what keywords to look up. Any & all guidance would be much appreciated. Thanks in advance.

You could use the Home Assistant API. From your remote location you’d HTTP POST something like

http(s)://IPADDRESS:PORT/api/services/lock/set_usercode?api_password=YOUR_PASSWORD

Then in the body of the POST you’d want the following JSON

{"node_id":YOUR_LOCK_NODE_NUMBER,"code_slot":YOUR_SLOT_NUMBER,"user_code":"YOUR_CODE"}

Note that in the JSON all of the value NAMES are in quotes, but of the actual VALUES, only the user_code VALUE is in quotes.

2 Likes

thanks so much! this is exactly the kind of info i was looking for.