Integrate with Domoticz

Below we explain how to add the Loqed Smart Lock to your Domoticz installation by using standard Domoticz functionality. You will end up with two switches: one will show the status, and one will allow you to control the lock. With native Domoticz functionality, it it currently not possible to have both in the same switch (do no try to: it will create an endless loop of door openings).

Create the control switch

1 Create dummy hardware device

Go to  Setup -> Hardware. Add a new dummy device.

2 Create virtual sensor

On the same page as above, click on Create Virtual Sensors.

Call the new sensor ‘Loqed Actions’ and choose ‘Selector Switch’ as type.

3. Create API URLs

Go to https://webhooks.loqed.com and login with your administrator account and create an API Key. You should end up with an entry similar as below. Leave this page open, we need the three URLs in the next step.

4 Add URLs to sensor

Go to ‘Switches’ and click on the edit button of the ‘Loqed Actions’ switch. We are now going to ensure the switch has three selector levels: ‘Open’, ‘Day lock’, and ‘Night lock’. Each level will call the correct URL for the lock action.

Don’t forget to save the switch. The first part is done, you now have a switch that you can use to control your Loqed Smart Lock! Note that if the lock status is changed from within the Loqed app, Domoticz will not show the correct lock status. This is unfortunately not easy to solve. However, we can show the lock status also in Domoticz by making just another virtual switch. This allows you to still performs actions with Domoticz if the lock status is changed.

Create the lock status switch

This switch will not be used for switching really, but just to see the current lock status.

1 Create another virtual sensor

Go to Setup -> Hardware, and click again on the Create Virtual Sensors button. Name the sensor ‘Loqed Status’ and choose again the ‘Selector Switch’ type. Click save.

2 Set selector levels

Go to ‘Switches’ and click on the edit button of the ‘Loqed Status’ switch. This time, ensure there are only two selector levels: ‘Day lock’, and ‘Night lock’ (open is only reached by the lock for a second, thus it doesn’t make sense to show it here). Do NOT add any URL’s.

Before saving the switch, look at the URL in your browser, and write down the Switch ID (it is numeric). Also, write down the Selector level number for ‘Day lock’ and ‘Night lock’.

https://www.mywebsite.org/#/Devices/IDX/LightEdit

3 Create and test URLs to change the status of the ‘Loqed Status’ switch

We are now going to format an URL that the Loqed Backend can call to let Domoticz know the Loqed Status has changed. The URL looks like this, but certain parts need to be changed:

https://www.mywebsite.org/json.htm?username=[USERNAME]&password=[PASSWORD|&type=command&param=switchlight&idx=[IDX]&switchcmd=Set%20Level&level=[LEVEL]

  • [USERNAME]: Enter your username here in BASE64 format. You can convert your username to this format by using (for example)  https://codebeautify.org/base64-encode
  • [PASSWORD]: Enter your password here in BASE64 format. You can convert your username to this format by using (for example)  https://codebeautify.org/base64-encode
  • [IDX]: enter the IDX of the switch ID (which you wrote down in the previous step)
  • [LEVEL]: enter the ‘Day Lock’ selector level (which you wrote down in the previous step)

When you are finished, enter this URL in your browser, and verify that the ‘Loqed Status’ switch changes status to the status you requested! Then, create a second URL for the other selector level ‘Night Lock’ (only the [LEVEL] part of the URL will be different).

4 Enter the URLs in the Loqed system

Go to https://webhooks.loqed.com and login with your administrator account. Click on ‘Add new webhook’. Ensure to select only the ‘Day lock’ checkbox, and copy-paste the URL of ‘Day lock’ status here. Save. Add another webhook, now only select the ‘Night lock’ checkbox, and copy-paste the other URL of step 3 here. Save as well.

Now you’re all set! Once the lock changes status, the new status will be send to Domoticz.

Once again: you cannot use one switch to combine actions and status in Domoticz using this method. Do not try to: it will create an endless loop of openings or closings.