Nuki lock setup
Moderator: leecollings
Re: Nuki lock setup
Hello,
the "old" script doorlock_change.sh runs now if i start the script via terminal.
I get the following return
{
"status" : "ERR"
}
In the syslog stand this
Sep 20 16:25:59 raspberrypi pi: Doorlock change Received message POST /nuki HTTP/1.0#015 User-Agent: NukiBridge_++++#015 Host: 192.168.1.4#015 Connection: Close#015 Content-Type: application/json;charset=utf-8#015 Content-Length: 81#015 #015 {"nukiId": +++++, "state": 1, "stateName": "locked", "batteryCritical": false}
Sep 20 16:25:59 raspberrypi logger: handle_doorlock_event: received {"nukiId": ++++, "state": 1, "stateName": "locked", "batteryCritical": false}
Sep 20 16:25:59 raspberrypi logger: handle_doorlock_event: got locked for ++++++
Sep 20 16:25:59 raspberrypi logger: handle_doorlock_event: setting mode to OFF for ++++++
If i change in the second script $[idx] to 887 (this is the ID in Domoticz) than this script change on or off in domoticz.
curl -s "http://192.168.1.4:8080/json.htm?type=c ... e}&svalue="
Whats wrong?
I think i am short before it works correct.
Thanks
Martin
the "old" script doorlock_change.sh runs now if i start the script via terminal.
I get the following return
{
"status" : "ERR"
}
In the syslog stand this
Sep 20 16:25:59 raspberrypi pi: Doorlock change Received message POST /nuki HTTP/1.0#015 User-Agent: NukiBridge_++++#015 Host: 192.168.1.4#015 Connection: Close#015 Content-Type: application/json;charset=utf-8#015 Content-Length: 81#015 #015 {"nukiId": +++++, "state": 1, "stateName": "locked", "batteryCritical": false}
Sep 20 16:25:59 raspberrypi logger: handle_doorlock_event: received {"nukiId": ++++, "state": 1, "stateName": "locked", "batteryCritical": false}
Sep 20 16:25:59 raspberrypi logger: handle_doorlock_event: got locked for ++++++
Sep 20 16:25:59 raspberrypi logger: handle_doorlock_event: setting mode to OFF for ++++++
If i change in the second script $[idx] to 887 (this is the ID in Domoticz) than this script change on or off in domoticz.
curl -s "http://192.168.1.4:8080/json.htm?type=c ... e}&svalue="
Whats wrong?
I think i am short before it works correct.
Thanks
Martin
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
The good news is that it receives message from the lock. The bad news is that domoticz complains about the device. If you only have 1 lock then fine to replace idx with your device id. It seems that ${idx} is not expanded correctly. It should say idx=887 at the beginning of that script.
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Re: Nuki lock setup
Hello,
I have 2 nuki device.
What is the best way to implement this Script to start at boot.
Do you know an workaround regarding my 2 device?
Thanks
Martin
Gesendet von meinem MHA-L29 mit Tapatalk
I have 2 nuki device.
What is the best way to implement this Script to start at boot.
Do you know an workaround regarding my 2 device?
Thanks
Martin
Gesendet von meinem MHA-L29 mit Tapatalk
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
Do you have 1 or 2 bridges?
Start at boot is easiest through cron. It supports @boot at the start of the file.
Start at boot is easiest through cron. It supports @boot at the start of the file.
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Re: Nuki lock setup
I have two Bridge and two nuki look.
How does it work with cron?
Thanks
Martin
How does it work with cron?
Thanks
Martin
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
Ok then the handle doorlock script should work as is as that is what I have. I'll post the cron entry when I am at my computer.
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
Here's the cron entry to start at boot:
@reboot /usr/local/bin/doorlock_change.sh > /tmp/doorlock_change.txt
put this at the start of the cron (crontab -e) before the entries that need to start on a timed basis.
In terms of the multiple bridges, that is the setup I have as well. Since both bridges should have a callback configured for the lock, they both send their status changes to the same ip/port (ie your domoticz system IP and port 15003 in this case). The handle_doorlock_event.sh script only needs to check which lock it is and then switch the right switch in domoticz. this is done in the case statement as follows:
So you need to make sure that the idx's of your 2 domoticz devices are filled in correctly. Since you got the { "ERR" } resonse, I suspect something is not correct here since you could replace ${idx} in the curl statement with the domoticz id and it did work.
If you want, post (or pm) the script and i'll take a look.
Good news is that everything seems to be close to working.
@reboot /usr/local/bin/doorlock_change.sh > /tmp/doorlock_change.txt
put this at the start of the cron (crontab -e) before the entries that need to start on a timed basis.
In terms of the multiple bridges, that is the setup I have as well. Since both bridges should have a callback configured for the lock, they both send their status changes to the same ip/port (ie your domoticz system IP and port 15003 in this case). The handle_doorlock_event.sh script only needs to check which lock it is and then switch the right switch in domoticz. this is done in the case statement as follows:
Code: Select all
case "${nukiId}" in
"id of you first lock")
idx=domoticz id of the respective decice in domoticz
;;
"id of the second lock")
idx=domoticx id of the other lock device in domoticz
;;
esac
If you want, post (or pm) the script and i'll take a look.
Good news is that everything seems to be close to working.
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Re: Nuki lock setup
Hello,
thanks for your greate support script 1 and 2 now works. Also start script 1 via boot works with cron.
Now i start with the 3 script. Why is this so complex?
Would it also work only with the lock command from nuki for on and off instead of your script?
Regards
Martin
Gesendet von meinem MHA-L29 mit Tapatalk
thanks for your greate support script 1 and 2 now works. Also start script 1 via boot works with cron.
Now i start with the 3 script. Why is this so complex?
Would it also work only with the lock command from nuki for on and off instead of your script?
Regards
Martin
Gesendet von meinem MHA-L29 mit Tapatalk
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
Not sure I understand. Why so complex? Because I am not a domoticz developer and just hacked together a couple of scripts to integrate the locks. As mentioned, polling kills battery life so is not an option. The callback hook is quite nice but, with 2 locks, you run the risk of multiple messages at once hence splitting the reception and handling into 2 scripts. These are just my 2 scripts for anyone who has an interest. Feel free to change.
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Re: Nuki lock setup
Sorry i do not mean script 1 and 2, i mean the script 3 where you lock and unlock the door in domoticz.
Script 3 is also for 2 nuki Switch/bridge? Because in the script there stand only 1 nuki ID but 2 token and 2 idx in the beginning of the Script.
if [ $lock = [NUKI ID of the lock] ] then idx=[domoticz idx of the lock] token=[API TOKEN] ip=[BRIDGE ip OF THE NUKI BRIDGE] else idx=[OTHER IDX OF OTHER LOCK] token=[other api token in case of another bridge] ip=[IP of the other bridge] fi
Can you help me again to become running Script 3?
Thanks
Martin
Gesendet von meinem MHA-L29 mit Tapatalk
Script 3 is also for 2 nuki Switch/bridge? Because in the script there stand only 1 nuki ID but 2 token and 2 idx in the beginning of the Script.
if [ $lock = [NUKI ID of the lock] ] then idx=[domoticz idx of the lock] token=[API TOKEN] ip=[BRIDGE ip OF THE NUKI BRIDGE] else idx=[OTHER IDX OF OTHER LOCK] token=[other api token in case of another bridge] ip=[IP of the other bridge] fi
Can you help me again to become running Script 3?
Thanks
Martin
Gesendet von meinem MHA-L29 mit Tapatalk
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
Ah, ok, understand now. Sure, no problem. Not at my computer until later today so will assist when I get home. Script 3 is what I use so it will work with multiple bridges. I should really clean up the scripts but I have too many other priorities. That said, script 3 operates the locks based on the nuki switches in domoticz which is different from updating domoticz based on lock actions. You could integrate in one big script but that makes it less maintainable IMO.
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 10
- Joined: Monday 12 September 2016 14:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Nuki lock setup
First of all, excuse me for my bad English.
My situation: 2 locks, 1 bridge
After a lot of trying, I do not get this working.
I have working script 1 (version 2).
I sent it to handle_doorlock_event.sh, but it stops there.
Sending to Domoticz gives problems, when I manually enter the IDX it goes well.
When I let this through the script, I get an error, just like above.
I enter the IDX manually in the handle_doorlock_event.sh in the curl part, but it works for one lock, not for both.
Somebody might have an idea?
My situation: 2 locks, 1 bridge
After a lot of trying, I do not get this working.
I have working script 1 (version 2).
I sent it to handle_doorlock_event.sh, but it stops there.
Sending to Domoticz gives problems, when I manually enter the IDX it goes well.
When I let this through the script, I get an error, just like above.
I enter the IDX manually in the handle_doorlock_event.sh in the curl part, but it works for one lock, not for both.
Somebody might have an idea?
-
- Posts: 1
- Joined: Monday 02 April 2018 10:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Nuki lock setup
case "${stateName}" in
"unlocked")
logger "handle_doorlock_event: setting mode to ON for ${nukiId}"
mode="1"
"locked")
logger "handle_doorlock_event: setting mode to OFF for ${nukiId}"
mode="0"
Could it be that you've mixed up the mode's in your script "handle_doorlock_event.sh" (see above)?
Should it not be:
Case Unlocked -> mode to OFF -> mode="0"
and
Case Locked -> mode ON -> mode="1"
Anyway, great scripting!!
"unlocked")
logger "handle_doorlock_event: setting mode to ON for ${nukiId}"
mode="1"
"locked")
logger "handle_doorlock_event: setting mode to OFF for ${nukiId}"
mode="0"
Could it be that you've mixed up the mode's in your script "handle_doorlock_event.sh" (see above)?
Should it not be:
Case Unlocked -> mode to OFF -> mode="0"
and
Case Locked -> mode ON -> mode="1"
Anyway, great scripting!!
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
I have just released a python nuki lock plugin that replaces all the scripts. Couple of comments:
https://github.com/heggink/domoticz-nuki
- Only tested for raspberry pi
- A recent bug fix in domoticz requires you to be an a very recent beta as otherwise domoticz will crash.
- it should work with multiple locks on 1 bridge but I cannot test that (I have one lock per bridge)
- it's BETA until multiple locks on 1 bridge has been tested
- it automatically installs the callbacks in the bridge BUT IT WON'T DELETE EXISTING so if you install on the same box where the scripts are then USE OTHER PORTS or things will get messy
- deleting callbacks from the bridge needs to be done manually
- the script creates LOCK devices instead of standard switches. You can still use dzvents switchOn/Off but you need to test Locked and Unlocked instead of On/Off. Also, a LOCK device does not have a timer (unfortunately) so I created a "Lock Schedule" switch manually with timers and a dzv-script in order to lock the locks at night.
https://github.com/heggink/domoticz-nuki
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 187
- Joined: Tuesday 07 March 2017 21:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Germany
- Contact:
Re: Nuki lock setup
Hi, I have a question:
Is it possible to open and close Nuki Castle via Domoticz?
Is it possible to open and close Nuki Castle via Domoticz?
-
- Posts: 187
- Joined: Tuesday 07 March 2017 21:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Germany
- Contact:
Re: Nuki lock setup
nobody an answer for me?
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
What is Nuki Castle? My plugin let's you open and close the lock...salopette wrote:Hi, I have a question:
Is it possible to open and close Nuki Castle via Domoticz?
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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 187
- Joined: Tuesday 07 March 2017 21:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Germany
- Contact:
Re: Nuki lock setup
Sorry, google translated the lock into Castle!
Of course I mean the Nuki door lock!
Of course I mean the Nuki door lock!
- heggink
- Posts: 980
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Nuki lock setup
Ah
. So yes, you can open/close from Domoticz.
Sent from phone.

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 :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 187
- Joined: Tuesday 07 March 2017 21:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Germany
- Contact:
Re: Nuki lock setup
Can you help me?
I have entered everything necessary, but it comes to mistakes
2019-10-12 09:32:18.947 (Nuki) Nuki plugin started on IP 192.168.178.37 and port 8008
2019-10-12 09:32:18.313 Status: (Nuki) Stop directive received.
2019-10-12 09:32:18.313 Status: (Nuki) Exiting work loop.
2019-10-12 09:32:18.513 Status: (Nuki) Stopping threads.
2019-10-12 09:32:18.513 Status: (Nuki) Stopped.
2019-10-12 09:32:18.513 Status: (Nuki) Started.
2019-10-12 09:32:18.908 Status: (Nuki) Initialized version 1.0.5, author 'heggink'
2019-10-12 09:32:18.908 Status: (Nuki) Entering work loop.
2019-10-12 09:32:19.067 Error: (Nuki) NUKI HTTPError code: 403
I have entered everything necessary, but it comes to mistakes
2019-10-12 09:32:18.947 (Nuki) Nuki plugin started on IP 192.168.178.37 and port 8008
2019-10-12 09:32:18.313 Status: (Nuki) Stop directive received.
2019-10-12 09:32:18.313 Status: (Nuki) Exiting work loop.
2019-10-12 09:32:18.513 Status: (Nuki) Stopping threads.
2019-10-12 09:32:18.513 Status: (Nuki) Stopped.
2019-10-12 09:32:18.513 Status: (Nuki) Started.
2019-10-12 09:32:18.908 Status: (Nuki) Initialized version 1.0.5, author 'heggink'
2019-10-12 09:32:18.908 Status: (Nuki) Entering work loop.
2019-10-12 09:32:19.067 Error: (Nuki) NUKI HTTPError code: 403
Who is online
Users browsing this forum: No registered users and 1 guest