Support for Loqed Lock

Hi,
Is there any interest to implement alternative smart locks similar like Nuki.
I‘m quite satisfied with and have brought the Loqed as exchange to the nuki lock. What is much more robust and with nice use cases. The current HA implementation is so far working (except the status change, maybe I did something wrong…) but it would be nice to have a full/better integration.

Considering this lock as well +1 Bought it

+1, also installed one for testing. HA integration is a pain having the same status update issue

Hopefully Loqed will get their HA integration ready soon

I have integrated the lock with my Grandstream GDS3710 access system. Bit of programming but when now somebody rings at the frontdoor I get a HA notification with picture asking me if I want to open the door :yum:

Real pain in the ass to configure this. Can’t get it to work.

plus one for me, great lock like to see intergration for it, no idea how to add it otherwise

Thanks!

1 Like

HA integration would be great, i hope this comes soon. Great product

Just got the feedback from the devs of Loqed - they are already working on an implementation. Estimated release is around end of September 2021.

So there is hope to get a smooth solution soon :tada:

5 Likes

Did someone get an update from Loqed as the September timelines seems to have slipped?

And can someone who got this to work post details? I can’t get the status Webhooks to work via Nabu Casa.

I’ve contacted Loqed last month to ask about the release of the integration. They said it has been postponed for undetermined time. It appears that the integration is more complicated than thought…

So I went on trying to figure out how to use the proposed solution from their website.

Their instructions are not 100% accurate so here is the content of my (working) loqed.yaml

automation:
    - alias: Loqed Smart Lock status change
      trigger:
        platform: webhook
        webhook_id: !secret LOQED_WEBHOOK # http://your-home-assistant:8123/api/webhook/<webhook_id>
      action:
        service: rest_command.update_sensor
        data_template:
          entity_id: lock.Loqed_Smart_Lock
          lock_state: >
            {% if (trigger.json.requested_state == 'NIGHT_LOCK') %}
              locked
            {% elif (trigger.json.requested_state == 'DAY_LOCK') %}
              unlocked
            {% elif (trigger.json.requested_state == 'OPEN') %}
              open
            {% else %}
              UNKNOWN
            {% endif %}

rest_command:
  loqed_action:
    url: !secret LOQED_API_URL
    method: GET
    verify_ssl: true

  update_sensor:
    # If you are using HTTPS, ensure to put HTTPS below instead of HTTP
    url: !secret LOQED_SENSOR_URL
    method: POST
    headers:
      authorization: !secret LOQED_AUTH_KEY
      accept: "application/json, text/html"
#      user-agent: 'Mozilla/5.0 {{ useragent }}'
    payload: '{"state":"{{ lock_state }}"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false

# Make a lock that supports OPEN and LOCKED. While the Loqed Smart Lock supports UNLOCKED as well, the lock template does not have support for a third state.
lock:
  - platform: template
    name: Loqed_Smart_Lock
    value_template: "{{ true }}" # todo: get the value by using a API call to Loqed server (not available yet)
    optimistic: false
    lock:
      service: rest_command.loqed_action
      data:
        lock_state: "NIGHT_LOCK"
    unlock:
      service: rest_command.loqed_action
      data:
        lock_state: "OPEN" # You could put "DAY_LOCK" here as well, the lock will not fully open then.

I made some mistakes with some of the !secret data so below my "edited !secret content.

# ------------------------------------------------------------------------------
# Loqed:
# ------------------------------------------------------------------------------
LOQED_WEBHOOK: 'loqed_status'
LOQED_API_URL: 'https://production.loqed.com:8080/v1/locks/5641/state?lock_api_key=pDY%3D&api_token=Ao--------------------e6VioU--------------------------DoY%3D&lock_state={{ lock_state }}&local_key_id=2'

LOQED_SENSOR_URL: 'https://<mydomain.com>/api/states/{{entity_id}}'
LOQED_AUTH_KEY: 'Bearer u2DFKwpoyJ0eXAiOiJKYz---------------------------YxTQ4OTc4OTc---------------------------FDJekjI'

Pay special attention to include Bearerand also make sure you edit the API URL (that you created on their website) to include the HASIO variable {{ lock_state }}

2 Likes

Thanks @erje for sharing your solution. Any idea why I would get this error?: Package loqed setup failed. Component rest_command has duplicate key 'url'

Hi Sorry for the late reply. Did you manage to fix it?

It sounds like you got a syntax error in your yaml. Very often caused by wrong line alignments.

My stupid mistake was that I left some old code in the configuration.yaml and tried to use yours as a package and so they collided.
So it works, but only as well as before, i.e. no status updates :man_shrugging:

I’m still waiting for the official support. As soon as it’s available, I’ll buy two.
The Loqed website still states ‘soon’.

They said the same to me somewhere on Facebook that they will release an app voor HA but there is still none. Have someone asked them the last weeks about the status of it?
I can’t get the solution erje says to work and i want to use an official app if there is one :slight_smile:

At the end of your post you write that the API URL on the Loqed website should include the HASIO variable.

On webhooks, in the webhook that will be called field I have: ‘domain api webhook loqed_status’. I had to remove the link here, could’nt do more then 2 links in the post. It’s over a secure channel, rest with backslashes in between.

My api key and api token (not url encoded) from de webhooks site, are both ending with an = sign. Do I delete this in the secrets file?

You talk about the loqed.yaml file. Where did you link to this file (and how)?

When I check the url section on the webhooks website, it shows this:
status: ‘https://app.loqed.com/API/lock_status.php?api_token=token_removed%3D&lock_id=full_lock_id_not_key_id

For night lock it shows: ‘https://gateway.production.loqed.com/v1/locks/lock_id/state?lock_api_key=key_removed%3D&api_token=token_removed%3D&lock_state=NIGHT_LOCK&local_key_id=_number

So, is the LOQED_API_URL right?

I can’t figure it out, if someone could help, that would be great, thanks!

Kind regards,
Ray

You don’t have to use a loged.yaml file. You can just include the code in the configuration.yaml But separating the configuration code has it’s advantages.

You find a detailed explanation here

But in short: At the top of my configuration.yaml:

default_config:
logger:
  default: info
homeassistant:
  packages:
    pack_1: !include packages/01.cameras.yaml
    pack_2: !include packages/02.lights.yaml
    pack_3: !include packages/03.loqed.yaml
    pack_4: !include packages/04.telegram.yaml
    pack_5: !include packages/05.water_irrigation.yaml
    pack_6: !include packages/06.security.yaml

I posted the content of my loqed.yaml in a previous post.

Your outgoing webhook should contain the URL from your local HAS installation e.g.

You don’t need the API Key or token, use the webhook URL instead. This contains all the info you need for your setup and just need a small adjustment.

You should note that 3 webhooks are almost identical accept for the lock_state=DAY_LOCK&local_key_id=2

This is the part you need to change in HAS into a variable. From my !secret.yaml:

LOQED_API_URL: 'https://production.loqed.com:8080/v1/locks/5641/state?lock_api_key=pDY%3D&api_token=Ao--------------------e6VioU--------------------------DoY%3D&lock_state={{ lock_state }}&local_key_id=2'

{{ lock_state }}

Some more explaination about my !secret.yaml:

LOQED_WEBHOOK:  # The HAS webhook that will be listening for your lock. (the full URL will be http://your-home-assistant:8123/api/webhook/loqed_status but you ONLY put the webhook here, not the full URL
LOQED_API_URL: # This is the complete API URLs (URL encoded) from the Loqed webhook website (right column) Take any of the three (not status) and change the lock_state into a variable at the end of the line (see above)
LOQED_SENSOR_URL: # https://your.HAS.domain.com/api/states/{{entity_id}}
LOQED_AUTH_KEY: # Bearer the Long-Lived Access Token you generated in your profile page in HAS

image

ps I noticed the webhook URL has changed from https://production.loqed.com:8080 to https://gateway.production.loqed.com The old URL is still working for me but I will update that in my setup. Don’t get confused by this.

Thank you so much, works now!

I can lock/unlock the door from Home Assistant but it doesn’t update the status.
My webhook is ‘domainname.com/api/webhook/loqed_status’ without the https:// is that correct?

Thanks