I’m trying to build a widget for my Nuki locks, showing lock and battery status and also allowing to lock/unlock the doors. I had everything working already using a Switch item for the lock but then decided to change to a Contact item instead, and i cant get it to work.
this is my items file:
Number EGFrontdoorLockStatus { http="<[http://EGTec1NukiBridge:8080/list?token=xxx:30000:JSONPATH($[0].lastKnownState.state)]"}
Contact EGFrontdoorLock <lock> { http=">[CLOSE:GET:http://EGTec1NukiBridge:8080/lockaction?token=xxx&nukiid=yyy&action=2] >[OPEN:GET:http://EGTec1NukiBridge:8080/lockaction?token=xxx&nukiid=yyy&action=1]"}
String EGFrontdoorLockBatteryCritical { http="<[http://EGTec1NukiBridge:8080/list?token=xxx:30000:JSONPATH($[0].lastKnownState.batteryCritical)]"
and this is the rules file:
rule "Nuki EGFrontdoorLock"
when
Item EGFrontdoorLockStatus changed
then
if (EGFrontdoorLockStatus.state == 1) {
EGFrontdoorLock.postUpdate(CLOSED)
} else {
EGFrontdoorLock.postUpdate(OPEN)
}
end
This part is working fine - So when i lock/unlock the door using the Nuki app, the EGFrontdoorLockStatus is set to either 1 or 3, after a while the rule is triggered and the EGFrontdoorLock changes to CLOSED or OPEN.
this is the part of the widget which is supposed to build the button and trigger action:
<div ng-if="itemValue(config.ITEM_ID) =='CLOSED'">
<button class="btn btn-lg" style="background: transparent; color: white"
ng-click="sendCmd(config.ITEM_ID, 'OPEN')">
locked
</button>
</div>
<div ng-if="itemValue(config.ITEM_ID) =='OPEN'">
<button class="btn btn-lg" style="background: red; color: white"
ng-click="sendCmd(config.ITEM_ID, 'CLOSE')">
unlocked
</button>
</div>
it is shown nice & correct in my habpanel
but when I trigger the button I get the following messages in openhab.log:
16:31:42.681 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/EGFrontdoorLock' with an invalid status value 'CLOSE'.
16:32:24.273 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/EGFrontdoorLock' with an invalid status value 'OPEN'.
To me this seems as if Contacts are not supposed to receive commands ? Or am I doing something wrong here ? I’ve tried CLOSED, OPENCLOSE, several other things with slightly different behaviour, but at the end none of them works…