Nuki Card with Callback support (supports both Lock & Opener, it replaces the official integration)

Si infatti le icone sono tutte corrette appunto, volevo semplicemente che sulla destra venisse fuori anche lo stato del blocco, invece che solo chiuso, Chiuso e Bloccato o Chiuso e Sbloccato

Lo stato del blocco è binario. Chiuso/Aperto.

Tu vuoi un unico sensore che racchiuda lo stato di due sensori: la porta e la serratura. Devi fare un template sensor, e nel codice controlli lo stato dei due sensori (porta e lock), in base al loro stato, configuri lo stato del sensore template.

Puoi prendere spunto dal codice che uso per l’icona della porta:

      nuki_door_state:
        unique_id: nuki_door_state
        device_class: door
        friendly_name: "Nuki Door State"
        icon_template: >
          {% set door_icon = states('input_number.nuki_bridge_door_state_id') | int %}
          {% set lock_icon = states('input_number.nuki_bridge_lock_state_id') | int %}
          {% if door_icon == 2 and lock_icon == 3 %}
            mdi:door-closed
          {% elif door_icon == 2 and lock_icon == 1 %}
            mdi:door-closed-lock
          {% elif door_icon == 3 %}
            mdi:door-open
          {% endif %}

Ottimo grazie!!

Intanto posto qui il codice della card:

type: custom:vertical-stack-in-card
cards:
  - type: custom:banner-card
    heading:
      - Nuki
  - type: horizontal-stack
    cards:
      - type: button
        tap_action:
          action: more-info
        entity: script.nuki_lock
        show_state: false
        hold_action:
          action: toggle
      - type: button
        tap_action:
          action: more-info
        entity: script.nuki_unlock
        hold_action:
          action: toggle
      - type: button
        tap_action:
          action: more-info
        entity: script.nuki_open
        hold_action:
          action: toggle
  - type: entities
    entities:
      - entity: sensor.nuki_lock_last_update
        name: Ultima Attività
      - entity: binary_sensor.nuki_door_state
        name: Stato (callback)
        secondary_info: last-changed
    state_color: true
  - type: glance
    entities:
      - entity: binary_sensor.nuki_door_state
        name: Porta
      - entity: lock.porta_di_casa
        name: Serratura
      - entity: binary_sensor.nuki_door_state
        name: Stato (polling)
    show_icon: false
    columns: 3
  - type: glance
    entities:
      - entity: binary_sensor.nuki_bridge_callback
        name: Bluetooth
      - entity: sensor.nuki_lock_bridge_bt_rssi
        name: Wifi
      - entity: binary_sensor.nuki_bridge_wifi_connected
        name: Wlan
      - entity: binary_sensor.nuki_bridge_cloud_connected
        name: Cloud
      - entity: sensor.nuki_lock_fw_version
        name: F.Serratura
      - entity: sensor.nuki_bridge_fw_version
        name: F.Bridge
      - entity: sensor.nuki_bridge_wifi_fw_version
        name: F.Bridge Wifi
    show_icon: false
    columns: 4
    state_color: true
  - type: custom:bar-card
    entities:
      - entity: sensor.nuki_lock_battery_level
        name: Batteria
        direction: right
        positions:
          icon: outside
          indicator: inside
          name: inside
          minmax: 'off'
          value: inside
        severity:
          - from: '0'
            to: '50'
            color: red
          - from: '51'
            to: '80'
            color: orange
          - from: '81'
            to: '100'
            color: green
        animation:
          state: 'on'
          speed: '5'
  - type: entities
    entities:
      - entity: binary_sensor.nuki_lock_battery_critical_state
        name: Batteria Critica Serratura

Se usi il custom component nuki_ng, è stato implementato un sensore che fa quel che volevi tu:

Se magari passi a quello, e rifai la card basandoti su quel componente, sarebbe utile. :slight_smile:

type: custom:vertical-stack-in-card
cards:
  - type: custom:banner-card
    heading:
      - Nuki
  - type: horizontal-stack
    cards:
      - type: button
        tap_action:
          action: more-info
        entity: script.nuki_lock
        show_state: false
        hold_action:
          action: toggle
      - type: button
        tap_action:
          action: more-info
        entity: script.nuki_unlock
        hold_action:
          action: toggle
      - type: button
        tap_action:
          action: more-info
        entity: script.nuki_open
        hold_action:
          action: toggle
  - type: entities
    entities:
      - entity: sensor.nuki_lock_last_update
        name: Ultima Attività
      - entity: sensor.nuki_porta_di_casa_door_security_state
        name: Stato (callback)
        secondary_info: last-changed
    state_color: true
  - type: glance
    entities:
      - entity: binary_sensor.nuki_door_state
        name: Porta
      - entity: binary_sensor.nuki_porta_di_casa_locked
        name: Serratura
      - entity: sensor.nuki_porta_di_casa_door_security_state
        name: Stato (polling)
    show_icon: false
    columns: 3
  - type: glance
    entities:
      - entity: binary_sensor.nuki_bridge_callback
        name: Bluetooth
      - entity: sensor.nuki_lock_bridge_bt_rssi
        name: Wifi
      - entity: binary_sensor.nuki_bridge_wifi_connected
        name: Wlan
      - entity: binary_sensor.nuki_bridge_cloud_connected
        name: Cloud
      - entity: sensor.nuki_lock_fw_version
        name: F.Serratura
      - entity: sensor.nuki_bridge_fw_version
        name: F.Bridge
      - entity: sensor.nuki_bridge_wifi_fw_version
        name: F.Bridge Wifi
    show_icon: false
    columns: 4
    state_color: true
  - type: custom:bar-card
    entities:
      - entity: sensor.nuki_lock_battery_level
        name: Batteria
        direction: right
        positions:
          icon: outside
          indicator: inside
          name: inside
          minmax: 'off'
          value: inside
        severity:
          - from: '0'
            to: '50'
            color: red
          - from: '51'
            to: '80'
            color: orange
          - from: '81'
            to: '100'
            color: green
        animation:
          state: 'on'
          speed: '5'
  - type: entities
    entities:
      - entity: binary_sensor.nuki_lock_battery_critical_state
        name: Batteria Critica Serratura

qui gli script:

nuki_open:
  alias: Apri Porta
  sequence:
  - service: rest_command.nuki_lock_action
    data:
      dev_type: '{{ state_attr(''sensor.nuki_bridge_endpoint_list_lock'',''deviceType'')
        }}

        '
      nuki_id: '{{ state_attr(''sensor.nuki_bridge_endpoint_list_lock'',''nukiId'')
        }}

        '
      action: 3
  mode: single
  icon: mdi:door-open
nuki_lock:
  alias: Blocca Porta
  sequence:
  - service: rest_command.nuki_lock_action
    data:
      dev_type: '{{ state_attr(''sensor.nuki_bridge_endpoint_list_lock'',''deviceType'')
        }}

        '
      nuki_id: '{{ state_attr(''sensor.nuki_bridge_endpoint_list_lock'',''nukiId'')
        }}

        '
      action: 2
  mode: single
  icon: mdi:door-closed-lock
nuki_unlock:
  alias: Sblocca Porta
  sequence:
  - service: rest_command.nuki_lock_action
    data:
      dev_type: '{{ state_attr(''sensor.nuki_bridge_endpoint_list_lock'',''deviceType'')
        }}

        '
      nuki_id: '{{ state_attr(''sensor.nuki_bridge_endpoint_list_lock'',''nukiId'')
        }}

        '
      action: 1
  mode: single
  icon: mdi:door-closed

@alexdelprete
Thanks for this great integration. I moved from the official integration to this once because I was sick fo the 30 seconds that it takes until the statechange is reflected on my dashboard. I’m now down to 5 seconds as soon as there is a state change thanks to your integration.
Specific question: is it somehow possible to further reduce the time of a state change?

Thanks

Thanks for your kind words.

What are you referring to, the lock/unlock or door sensor? The lock/unlock callback is done by the bridge at the end of the mechanical action, and that takes 3s more or less, so it’s not possible to optimize it further. For the door sensor, I receive the callback and the sensor update in 1s.

If it takes 5s for you to see door sensor changes, there’s something not working fine.

Let me know…

I’m referring the lock/unlock, so that is state of the art then :slight_smile:
Ok got it - thanks for your quick reply

Unfortunately the callback is sent by the bridge only at the end of the action. Your lock takes 3-4s to do its thing. :slight_smile:

How long does the door sensor take to update?

Too bad it takes that long :smiley: I dont use the door sensor as I dont have a need for it. Its still in the box :joy:

You don’t have the need to know if the door’s open? Strange. :slight_smile:

Well are doing well without the sensor. Of course it would be a nice addon - but tell that the offspring - eagerly waiting for sticky-taped things to pull down :joy: so for now, the sensor stays in the box for the next couple of years… :wink:

You put it on the inside of the door, not on the outside…It has been offspring also here a couple of times…but the darn thing is still sticked there tightly, on the inside of the door. 3M does very sticky things. :rofl:

Any news on this?

You can already install the component, it’s working fine.

Thanks for your Feedback! Is there any disadvantage using it instead of your card?

No, only advantages. :slight_smile:

1 Like

Yeah, feel free to give it a try: GitHub - kvj/hass_nuki_ng: Better support for Nuki devices in the Home Assistant

It’s HACS ready now and pretty stable

1 Like

what’s the difference between the 4 door states and what values can they have?