To install the script with HACS Phyton scripts for HomeAssistant must be activated, see: Repository can currently not be integrated via HACS · Issue #1 · MattDog06/Nuki-MQTT-auto.-Discovery · GitHub
@fireballrs I posted my configuration in the topic about Home Assistant autodiscovery implementation specifications to avoid polluting this post which is specifically about the script made by @MattDog_06
Hey Patrick,
thank you for sharing me the link to your config. Got it working but so far i never get live values and i can’t lock / unlock the door. So i think i need a bit more testing with the mqtt connection.
greetings
dominik
Hi all,
I’ve forked this script from @MattDog_06 to make it more complient to Home Assistant best practices for MQTT auto discovery.
Differences with original script
- The smartlock ID is used for entity unique IDs instead of the name which could be changed
Using this method, if the smartlock is renamed in the Nuki app, the existing entities will be updated instead of create new entities (not visible actually but would be an issue when the smartlock will manage MQTT) - Node ID is not used anymore for MQTT topics
- MQTT abbreviations are used
- Locking, unlocking and jammed states are implemented. This change should be visible from Home Assistant 2023.2
- Open and opening states are removed, these don’t exist in Home Assistant for lock entities
- Apply conventional namming for entities, for example the door sensor of the smartlock Front door will be named Front door Door sensor instead of Front door Door Sensor
- In the rot of the repository, there is now a script to remove original device and entities.
It uses the same parameters you used to add the smartlock entities,nuki_remove_old
has to be used instead ofnuki_mqtt_discovery
when calling the service, you must place thepython_scripts/nuki_remove_old.py
to thepython_script
subdirectory of your Home Assistant configuration directory
I would recommand to use this implementation, particularly because the original one did not implement real unique IDs, in the case it would be used officially you would have two smartlock if renamming the old one.
Do not esitate if you need some help and if some idea about facilitating old MQTT topics removal.
I would honestly have prefered these modification to be implemented in the original repository but I unfortunately had no answer when I made pull requests.
@mattdog_06 if you read it and are OK to discus about updating your script I would be glad if we could share our competences
Link to the fork:
Hi @Nardol,
Thanks for your work! Unfortunately I can’t install it correcty. Only the file python_scripts/nuki_remove_old.py
ist there after installing with HACS as described. The other one is missing. There is also no error in the log. Do you have any idea why this could Happen?
Any advice would be appreciated!
Hi @Grawper
The reason looks being between my chair and my keyboard please test 2.0.1 and tel me if you still encounter any issue.
If it is the case I will create separate repository for the removal script.
In this release I also removed all unlatch related state to return unlocked, I think I made things to much complicated by doing this, lock should stay in unlocked state with previous information returned by the smartlock.
The Installation with HACS is working fine now, thanks! I already tried to set it all up but so far the Lock is shown as unavailable in HA. I did not really find a guide how to set it up so I did the following:
- Installed Beta Firmware 3.5.6 on lock
- Enabled debug mode
- set up a user called nuki with password SHA256 of WiFi PW in mosquitto in HA (I use the mosquitto addon). I have read this in the mqtt API Specification
- restarted lock by removing battery Back
However it is still not working and I did not yet find a possibility to debug this. In the Specification it says you can check the mqtt connection in the App but I did not find it there.
Is there anything I missed or some general guide how to set it up? And is there any possibility to debug this on my side?
Thanks in advance for any help
Edit: I have read through some other posts and I guess I have found a possibe issue. The lock cannot find my mqtt Server because it is execting it at mqtt.local. So I guess I have to set up some local DNS server for this. I will try to do it in the next days. And I also found out that I can’t find anything in the App due to the beta status.
Yes, your MQTT server must be accessible at mqtt.local (MDNS) or mqtt (using local DNS).
I use Home Assistant core so I was able to set a service adding mqtt.local using a MDNS alias which I believe is not possible with HA OS or HA supervised, the only solution is to set a local DNS on your network which would be set to all your machins using DHCP or using another machine always online on your local network to set a MDNS alias.
I published the last version: 2.1.
A new parameter remove_lock
is added to remove all created MQTT topics, which will remove device and associated entities.
To use it you also have to specify other usual parameters.
And if you want to apply the last version, this parameter must be used firstly because now really all unique IDs are prefixed with nuki_
to be sur of their uniqueness.
Do not esitate to make some feedback if I made a mistake or if you have some question.
I am aware I make too much changes but I want to be sure all is at least near perfect for Home Assistant integration.
That’s why I don’t want to touch anything else from now except if there is a bug somewhere.
Hi all,
in case anyone stumbles across this post (as this ist also in the release now): I installed the addon dnsmasq for home assistant to resolve the address. It worked perfectly.
Hi and thanks for the hint. I’m googling a while now and are not able to find out if dnsmasq supports mDNS. How is your config? Did you announce the DNS server through DHCP to all devices in the network or do you configure dnsmasq to announce the host mqtt.local via mDNS? Last option I would prefer if possible…
Hi there, I found a solution. If you have another machine in the local network it is quite easy:
If you want to publish .local domains for other computers / devices, which are not capable of publishing them for themselves, you can also do this with Avahi.
nano /etc/avahi/hosts
Add a line for each device, e.g.
192.168.1.XXX mqtt.local
Save the file. Reload the avahi daemon (the reload may not actually even be necessary)
service avahi-daemon restart
source: Avahi how to assign several .local names to same IP - pi3g.com
This did the job for me, the lock does find the mqtt server which is mosquitto in home assistant.
Hi All,
Thanks for all the wonderful work, getting Homeasistant (OS), MQTT and NUKI 3.0 Pro working together.
As the direct Homekit connection via Bluetooth to NUKI 3.0 Pro is still unreliable (device unresponsive, device taking long time to respond, NUKI 3.0 Pro 1,5m far from Homepod mini, also with Beta FW 3.6.5) I decided I would try connecting The NUKI 3.0 Pro via MQTT (over WIFI, not Bluetooth) to Homeassistant (let’s call this step 1), and then from Homeassistant expose the NUKI to Homekit (step 2).
Step 1 went fairly simple out of the box. I used this guide:
The result is a nice dashboard in Homeassitant. All actions are lightning fast. As soon as you press lock/unloack/unlock the NUKI 3.0 Pro reacts in micro seconds. Fantastic!
Step 2, exposing the MQTT connected NUKI 3.0 pro to Homekit (and Siri) also works and is SUPER FAST, never unresponsive. Even from Apple Watch with Siri. But I have one problem that I don’t know how to solve. I have asked on the Homeassistant forum, but have not got any usable answers.
The problem:
I have a fixed door knob on the outside of the door.
Homekit by default locks and unlocks the door, but does not unlatch/open the door when unlocking (which IS the behaviour of NUKI 3.0 Pro, when connected directly via Bluetooth to Homekit).
The $1M Question:
Does anybody know how I can make Homekit open the door (in stead of just unlocking) with my setup (Nuki <> MQTT <> Hass <> Homekit)?
I’m thinking of some way to map/expose the Homeassitant Unlatch/Open function to Homekit Unlock function.
I’m hoping somebody here with more Homeassiatant knowledge has already bumped into this issue and can explain what I need to add to configuration.yaml to fix this.
THANKS!