Nuki Smart Lock 2.0 - support all available API actions (i.e. add lock/unlock)

Yes Iā€™m still in the modifying phase, I will update that test.

I also tried with 1 == 1. Same thing. Try it yourself. :slight_smile:

Did you try to trigger homeassistant_start event manually (via Developer Tool) after the card fulfilled (except the two first fields) ?

When this is triggered by Reload Template Entities:

- trigger:
    - platform: event
      event_type: event_template_reloaded
    - platform: homeassistant
      event: start
    - platform: webhook
      webhook_id: !secret nuki_bridge_webhook
  binary_sensor:
    - name: "Nuki Door State"
      unique_id: nuki_door_state
      device_class: door
      state: >
        {% if trigger.platform == 'webhook' %}
          {{ trigger.json.doorsensorState == 3 }}
        {% else %}
          {{ is_state('sensor.nuki_door_sensor_state', 'open') }}
        {% endif %}

it will evaluate this template:

          {{ is_state('sensor.nuki_door_sensor_state', 'open') }}

If sensor.nuki_door_sensor_state is unavailable, or even if it doesnā€™t exist, that template will return false. On other words, the binary_sensorā€™s state is off.

HOWEVER, the sensorā€™s configuration also has an availability template and so this will be evaluated as well:

          {{ (states('sensor.nuki_door_sensor_state') >= 1) and (states('sensor.nuki_door_sensor_state') <= 5) }}

Now we have a problem and thatā€™s because the template is incorrect (which is the source of the Unavailable state).

This returns a string:

states('sensor.nuki_door_sensor_state')

but the template compares a string to an integer and thatā€™s invalid. You must convert the string to an integer using the int filter.

          {{ (states('sensor.nuki_door_sensor_state') | int >= 1) and (states('sensor.nuki_door_sensor_state') | int <= 5) }}

Hereā€™s a shorter way of writing the same expression:

          {{ 1 <= states('sensor.nuki_door_sensor_state') | int <= 5 }}
1 Like

Again, the sensor above returns a word (see dict), so the availability test will always fail (not an integer) and the sensor will appear as unavailable, until the first webhook triggers.
@alexdelprete, try with the availability section of the sensor nuki_door_state entirely removed.

I tried first with this:

      availability: >
        {% if trigger.platform == 'webhook' %}
          {{ trigger.json.doorsensorState != None }}
        {% else %}
          {{ (states('sensor.nuki_door_sensor_state') == 'open' or states('sensor.nuki_door_sensor_state') == 'closed') }}
        {% endif %}

And it didnā€™t work. Then I tried removing the availability section. And it still didnā€™t work:

image

Iā€™m releasing the card as it is in a separate thread, even with this small problem, so you can try the code and do any test directly.

I released v4.0 of the card in a separate thread. :slight_smile:

We can continue the discussion over there. If someone can test the version there, Iā€™d appreciate a feedback, because the instructions for the configuration have changed.

Thanks,

Alessandro

When you say ā€œit didnā€™t workā€, what did the sensor report as its state? As mentioned in my previous post, the state template is incapable of reporting unavailable. This template will report false (i.e. state will be off) even if the sensor.nuki_door_sensor_state doesnā€™t exist).

          {{ is_state('sensor.nuki_door_sensor_state', 'open') }}

FWIW, itā€™s important to sort out the basics, namely the state, before progressing to availability, icon, etc; it simplifies troubleshooting.

I replied in the other thread.

Hi I instaled a Smart LOck wth Bridge and all works well. Try to integrate in HASS but recieve

Failed to connect

I changed the token in the Android app at the section of the bridge, with a different simple token, but still failed to connect

Any hint?

Hey,

Iā€™m hoping that is the correct thread to post my question. Iā€™m using Nuki Smart Lock 2.0 since a few months now, with the official Integration - very stable, no dramas.

Today, I had an internet outage and boom, my Nuki didnt open the door, despite I have an automation for that with the Nuki integration.

Also, when I tried to unlock the Nuki on the touchpanel in Lovelace, there was an error.

Officially, the Nuki integration IoT class is local polling, however I found it only working with Internet connection?!

Can somebody confirm it works without internet and if so, how have you configured other than the description in the official integration? (Nuki - Home Assistant)

Hi, my understanding is that it should work without internet connection but there have been severall issues with older FW (see the annotation for FW 2.51).
Check what FM is running on your bridge and update.

I remember a couple of months ago, all of a sudden, my Nuki was newly recognised - dont know why (FW update?)

Anyway, I checked the logs and I got an 401 Client Error: Unauthorized for url - turns out the wrong Nuki ID was there. I removed the Nuki integration, restarted HA, added Nuki again, restarted HA - now its all good, it works now with local polling :slight_smile:

Thanks!

Fine.
Maybe you are interesting in another integration which uses callback instead of polling, the official integration is not needed:

Thanks Joerg, I might give it a crack :slight_smile:

There is a new, much improved integration, that also uses local push and not just polling. It integrates with both, the bridge and the web API.

1 Like

got invalid repository when try to add it on HACS
https://github.com/kvj/hass_nuki_ng

do youā€™ve follow the instructions here : GitHub - kvj/hass_nuki_ng: Better support for Nuki devices in the Home Assistant ?

I just tried it now, and no problem

I got my 2nd smartlock today. My old 1st gen Nuki works fine with HA. But my new one is not available in HA.
I already reinstalled the nuki integration, but it had no effect. Could it be, that the Nuki integration can currently handle just one lock?

Hi,

To get the Web API, is it the red colored button that I need to use to generate the key ? Or the one of the top ? Everything I try, when entering in the Integration, after submitting, it freezes and the integration is not completeā€¦ Please advise

Integration page:

Itā€™s stuck like more than 15 min

Kr,

Bart

Try this new integration : GitHub - kvj/hass_nuki_ng: Better support for Nuki devices in the Home Assistant

1 Like