support for API 1.5, 2 new set commands (factoryReset, unpair)

This commit is contained in:
Marko Oldenburg 2017-01-19 21:07:38 +01:00
parent 8cb3f21115
commit 9db1e49fc8
5 changed files with 28 additions and 8 deletions

Binary file not shown.

View File

@ -46,7 +46,8 @@ use JSON;
use HttpUtils;
my $version = "0.4.7";
my $version = "0.5.99";
my $bridgeapi = "1.5";
@ -135,6 +136,7 @@ sub NUKIBridge_Define($$) {
$hash->{PORT} = $port;
$hash->{TOKEN} = $token;
$hash->{VERSION} = $version;
$hash->{BRIDGEAPI} = $bridgeapi;
$hash->{helper}{aliveCount} = 0;
@ -245,6 +247,11 @@ sub NUKIBridge_Set($@) {
NUKIBridge_CallBlocking($hash,"clearlog",undef) if( !IsDisabled($name) );
} elsif($cmd eq 'factoryReset') {
return "usage: clearLog" if( @args != 0 );
NUKIBridge_CallBlocking($hash,"factoryReset",undef) if( !IsDisabled($name) );
} elsif($cmd eq 'callbackRemove') {
return "usage: callbackRemove" if( @args != 1 );
my $id = "id=" . join( " ", @args );
@ -259,7 +266,7 @@ sub NUKIBridge_Set($@) {
} else {
my $list = "";
$list .= "info:noArg autocreate:noArg callbackRemove:0,1,2 ";
$list .= "clearLog:noArg fwUpdate:noArg reboot:noArg" if( ReadingsVal($name,'bridgeType','Software') eq 'Hardware' );
$list .= "clearLog:noArg fwUpdate:noArg reboot:noArg factoryReset:noArg" if( ReadingsVal($name,'bridgeType','Software') eq 'Hardware' );
return "Unknown argument $cmd, choose one of $list";
}
}
@ -439,7 +446,7 @@ sub NUKIBridge_Distribution($$$) {
# zum testen da ich kein Nuki Smartlock habe
#$json = '[{"nukiId": 1,"name": "Home","lastKnownState": {"state": 1,"stateName": "locked","batteryCritical": false,"timestamp": "2016-10-03T06:49:00+00:00"}},{"nukiId": 2,"name": "Grandma","lastKnownState": {"state": 3,"stateName": "unlocked","batteryCritical": false,"timestamp": "2016-10-03T06:49:00+00:00"}}]' if( $param->{endpoint} eq "list" );
#$json= '{"bridgeType":2,"ids":{"serverId":142667440},"versions":{"appVersion":"0.2.14"},"uptime":1527,"currentTime":"2017-01-17T04:55:58Z","serverConnected":true,"scanResults":[{"nukiId": 1,"name": "Home","rssi": -87,"paired": true},{"nukiId": 2,"name": "Grandma","rssi": -93,"paired": false}]}';
#$json= '{"bridgeType":2,"ids":{"serverId":142667440},"versions":{"appVersion":"0.2.14"},"uptime":1527,"currentTime":"2017-01-17T04:55:58Z","serverConnected":true,"scanResults":[{"nukiId": 1,"name": "Home","rssi": -87,"paired": true},{"nukiId": 2,"name": "Grandma","rssi": -93,"paired": false}]}' if( $param->{endpoint} eq "info" );
NUKIBridge_ResponseProcessing($hash,$json,$param->{endpoint});
@ -809,10 +816,11 @@ sub NUKIBridge_CallBlocking($$$) {
<ul>
<li>autocreate - Prompts to re-read all Smartlocks from the bridge and if not already present in FHEM, create the autimatic.</li>
<li>callbackRemove - Removes a previously added callback</li>
<li>clearLog - Clears the log of the Bridge</li>
<li>fwUpdate - Immediately checks for a new firmware update and installs it</li>
<li>clearLog - Clears the log of the Bridge (only hardwarebridge)</li>
<li>factoryReset - Performs a factory reset (only hardwarebridge)</li>
<li>fwUpdate - Immediately checks for a new firmware update and installs it (only hardwarebridge)</li>
<li>info - Returns all Smart Locks in range and some device information of the bridge itself</li>
<li>reboot - reboots the bridge</li>
<li>reboot - reboots the bridge (only hardwarebridge)</li>
<br>
</ul>
<br><br>

View File

@ -33,7 +33,7 @@ use warnings;
use JSON;
my $version = "0.4.7";
my $version = "0.5.99";
@ -306,9 +306,13 @@ sub NUKIDevice_Set($$@) {
} elsif( $cmd eq 'locknGoWithUnlatch' ) {
$lockAction = $cmd;
} elsif( $cmd eq 'unpair' ) {
NUKIDevice_ReadFromNUKIBridge($hash,"$cmd",undef,$hash->{NUKIID} ) if( !IsDisabled($name) );
return undef;
} else {
my $list = "statusRequest:noArg unlock:noArg lock:noArg unlatch:noArg locknGo:noArg locknGoWithUnlatch:noArg";
my $list = "statusRequest:noArg unlock:noArg lock:noArg unlatch:noArg locknGo:noArg locknGoWithUnlatch:noArg unpair:noArg";
return "Unknown argument $cmd, choose one of $list";
}
@ -601,6 +605,9 @@ sub NUKIDevice_CGI() {
<ul>
<li>state - Status of the Smartlock or error message if any error.</li>
<li>lockState - current lock status uncalibrated, locked, unlocked, unlocked (lock n go), unlatched, locking, unlocking, unlatching, motor blocked, undefined.</li>
<li>name - name of the device</li>
<li>paired - paired information false/true</li>
<li>rssi - value of rssi</li>
<li>succes - true, false Returns the status of the last closing command. Ok or not Ok.</li>
<li>batteryCritical - Is the battery in a critical state? True, false</li>
<li>battery - battery status, ok / low</li>
@ -613,6 +620,7 @@ sub NUKIDevice_CGI() {
<li>lock - lock</li>
<li>unlock - unlock</li>
<li>unlatch - unlock / open Door</li>
<li>unpair - Removes the pairing with a given Smart Lock</li>
<li>locknGo - lock when gone</li>
<li>locknGoWithUnlatch - lock after the door has been opened</li>
<br>
@ -658,6 +666,9 @@ sub NUKIDevice_CGI() {
<ul>
<li>state - Status des Smartlock bzw. Fehlermeldung von Fehler vorhanden.</li>
<li>lockState - aktueller Schlie&szlig;status uncalibrated, locked, unlocked, unlocked (lock n go), unlatched, locking, unlocking, unlatching, motor blocked, undefined.</li>
<li>name - Name des Smart Locks</li>
<li>paired - pairing Status des Smart Locks</li>
<li>rssi - rssi Wert des Smart Locks</li>
<li>succes - true, false Gibt des Status des letzten Schlie&szlig;befehles wieder. Geklappt oder nicht geklappt.</li>
<li>batteryCritical - Ist die Batterie in einem kritischen Zustand? true, false</li>
<li>battery - Status der Batterie, ok/low</li>
@ -670,6 +681,7 @@ sub NUKIDevice_CGI() {
<li>lock - verschlie&szlig;en</li>
<li>unlock - aufschlie&szlig;en</li>
<li>unlatch - entriegeln/Falle &ouml;ffnen.</li>
<li>unpair - entfernt das pairing mit dem Smart Lock</li>
<li>locknGo - verschlie&szlig;en wenn gegangen</li>
<li>locknGoWithUnlatch - verschlie&szlig;en nach dem die Falle ge&ouml;ffnet wurde.</li>
<br>

Binary file not shown.

BIN
Bridge-API-v1.5.pdf Normal file

Binary file not shown.