Python Plugin: NUKI locks

Python and python framework

Moderator: leecollings

User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: NUKI locks

Post by heggink »

Also just noticed that giejay forked the plugin with a bunch of fixes. Adopted these just now. Still rather new to this whole github thing so bear with me ;-).
Hope it's all OK now.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Bidibulle
Posts: 7
Joined: Wednesday 22 May 2019 22:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11361
Location: Paris
Contact:

Re: Python Plugin: NUKI locks

Post by Bidibulle »

Hi

it's Ok with last update :D

Merci ;) :mrgreen:
User avatar
BartdaMan
Posts: 20
Joined: Sunday 22 May 2016 22:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Amersfoort
Contact:

Re: Python Plugin: NUKI locks

Post by BartdaMan »

Well, in my case I can unlock via Domoticz fine, but locking gives an error.
User avatar
BartdaMan
Posts: 20
Joined: Sunday 22 May 2016 22:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Amersfoort
Contact:

Re: Python Plugin: NUKI locks

Post by BartdaMan »

Well, it only gives an error if you switch the lock again within ±20 s after the previous switch action. And that normally does not happen. So for me this version is fine now! Thanks a lot, Herman! :D
StephaneM60
Posts: 12
Joined: Saturday 10 November 2018 12:47
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: NUKI locks

Post by StephaneM60 »

Hi,

I'm having one issue with this plugin : it fails at some time and never recover.

Here is the type of error I receive :
2019-09-01 12:05:36.961 Error: (Nuki) 'onStart' failed 'RemoteDisconnected'.
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 345 in 'C:\Program Files (x86)\Domoticz\plugins\domoticz-nuki\plugin.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 161 in 'C:\Program Files (x86)\Domoticz\plugins\domoticz-nuki\plugin.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 222 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 525 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 543 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 503 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 1345 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 1323 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-01 12:05:36.961 Error: (Nuki) ----> Line 1353 in 'C:\Program Files (x86)\Python37-32\Lib\http\client.py'
2019-09-01 12:05:36.965 Error: (Nuki) ----> Line 306 in 'C:\Program Files (x86)\Python37-32\Lib\http\client.py'
2019-09-01 12:05:36.965 Error: (Nuki) ----> Line 275 in 'C:\Program Files (x86)\Python37-32\Lib\http\client.py'

It seems the error occurs when the plugin hit the refresh interval (60 min for me) though I'm not sure. It may be because the plugin fail to contact the bridge (like a temporary network error).

I'm currently running Domoticz on a Windows 10 PC.

Otherwise the plugin works fine : it does see the brige, the lock, update the lock status and can lock / unlock the lock.

I turned debug to see if I can pinpoint the moment it fails, will let you know if I notice something obvious.
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: NUKI locks

Post by heggink »

Please do. I can't test under Windows as I only run on rpi and have no spare locks to test.


Sent from phone.

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
StephaneM60
Posts: 12
Joined: Saturday 10 November 2018 12:47
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: NUKI locks

Post by StephaneM60 »

It does have failed this night, same error.

2019-09-02 02:49:52.288 Error: Nuki hardware (18) thread seems to have ended unexpectedly
2019-09-02 02:50:06.742 Error: Nuki hardware (18) thread seems to have ended unexpectedly
2019-09-02 02:50:12.092 Error: (Nuki) 'onHeartbeat' failed 'RemoteDisconnected'.
2019-09-02 02:50:12.092 Error: (Nuki) ----> Line 368 in 'C:\Program Files (x86)\Domoticz\plugins\domoticz-nuki\plugin.py'
2019-09-02 02:50:12.092 Error: (Nuki) ----> Line 308 in 'C:\Program Files (x86)\Domoticz\plugins\domoticz-nuki\plugin.py'
2019-09-02 02:50:12.092 Error: (Nuki) ----> Line 222 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-02 02:50:12.092 Error: (Nuki) ----> Line 525 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-02 02:50:12.092 Error: (Nuki) ----> Line 543 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-02 02:50:12.096 Error: (Nuki) ----> Line 503 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-02 02:50:12.096 Error: (Nuki) ----> Line 1345 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-02 02:50:12.096 Error: (Nuki) ----> Line 1323 in 'C:\Program Files (x86)\Python37-32\Lib\urllib\request.py'
2019-09-02 02:50:12.096 Error: (Nuki) ----> Line 1353 in 'C:\Program Files (x86)\Python37-32\Lib\http\client.py'
2019-09-02 02:50:12.096 Error: (Nuki) ----> Line 306 in 'C:\Program Files (x86)\Python37-32\Lib\http\client.py'
2019-09-02 02:50:12.096 Error: (Nuki) ----> Line 275 in 'C:\Program Files (x86)\Python37-32\Lib\http\client.py'
2019-09-02 02:50:20.849 Error: Nuki hardware (18) thread seems to have ended unexpectedly

There is one thing taht I fail to understand, the way I see it, it does fail trying to open the bridge URL urlib.request.urlopen(req).read(), but the log file locate the error in the catch block for URLError in Domoticz.Error('NUKI HTTPError code:' + str(e.reason)). So it means that the real URLError is masked by the RemoteDisconnected in the Domoticz.Error function...?
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: Python Plugin: NUKI locks

Post by Antori91 »

Hello Heggink,

I'm currently looking for a door smart lock. I've just found this Nuki Smart Lock product and your plugin.
I've a simple question. Is there any way to connect this Nuki Smart Lock product to a home automation system like Domoticz without using the Nuki Cloud, I mean Domoticz talking directly to the Nuki bridge.
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: NUKI locks

Post by heggink »

Hi Antori91,
This is exactly what the plugin does. It uses the published http api to communicate directly to the bridge. It does not need an internet connection. Please note that connecting the locks to Domoticz is always a security risk so make sure your system is well protected.
Herman

Sent from phone.

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: Python Plugin: NUKI locks

Post by Antori91 »

By the way about security, how secure is this HTTP NUKI Bridge API? Is it plain HTTP or HTTPS with client authentication?
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: NUKI locks

Post by heggink »

It's simple http calls but since it's inside my network, I don't mind. I use MAC authentication for wireless access so someone would have to gain access through my internet connection. External access is through VPN.

Just google for nuki bridge http api and you can find it.

Sent from phone.

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: Python Plugin: NUKI locks

Post by Antori91 »

Hello Heggink,

I've downloaded the Nuki Web API V1.3.0 whitepaper. The chapter 1.Introduction mentions:
The Nuki Web API offers various ways to interact with a Nuki Smart Lock. The API transmits all commands directly through a permanent HTTPS/TLS connection to the corresponding Nuki bridge, which forwards it via Bluetooth to the Smart Lock for execution. Responses are directly fed back into Nuki Web.All commands are performed with the server-stored Nuki Web Authentication Key which was created when Nuki Web has been initially activated by the Smart Lock administrator. Because of having its own Authentication Key, Nuki Web acts independently of other clients (e.g. Nuki iOS or Android App).
???

Anyway, I don't go further with NUKI because my door lock is not compatible.
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: NUKI locks

Post by heggink »

That's the web api that uses the nuki cloud. I use the local bridge api. Different one. I don't like all those web services. When the internet is down, nothing works...

Sent from phone.

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: Python Plugin: NUKI locks

Post by Antori91 »

heggink wrote: Tuesday 05 May 2020 9:13 That's the web api that uses the nuki cloud. I use the local bridge api. Different one. I don't like all those web services. When the internet is down, nothing works...
Ah OK, I see. I will not like too using the cloud to open my main door (it was my first question) !
Thank you for your answers. Have a nice day
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: NUKI locks

Post by heggink »

There is a new (testing) version of the plugin adding support for the door sensor for the V2 lock (thanks to StephaneM60). Please note that the device numbers in domoticz have been renumbered so installing this will create new devices and you need to delete the old ones. In order to test, you need to switch to the feature-unlatch branch on github.

At some point, I will move that to master.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Plugin: NUKI locks

Post by salopette »

Thank you very much! It all seems to be working!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest