Created
December 14, 2020 21:39
-
-
Save nayelyzarazua-bluetrail/5570a0782c7b349c5921c725a81ce23b to your computer and use it in GitHub Desktop.
iconAlternativesChange
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
//definition | |
{ | |
"id": "xxxx.customlock", | |
"version": 1, | |
"status": "proposed", | |
"name": "customlock", | |
"attributes": { | |
"lockstate": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"value": { | |
"type": "string" | |
} | |
}, | |
"additionalProperties": false, | |
"required": [ | |
"value" | |
] | |
}, | |
"setter": "setLockstate", | |
"enumCommands": [] | |
} | |
}, | |
"commands": { | |
"setLockstate": { | |
"name": "setLockstate", | |
"arguments": [ | |
{ | |
"name": "value", | |
"optional": false, | |
"schema": { | |
"type": "string" | |
} | |
} | |
] | |
} | |
} | |
} | |
//presentation | |
{ | |
"dashboard": { | |
"states": [ | |
{ | |
"label": "{{lockstate.value}}", | |
"alternatives": [ | |
{ | |
"key": "disarmed", | |
"value": "Disarmed", | |
"type": "active" | |
}, | |
{ | |
"key": "armed", | |
"value": "Armed", | |
"type": "inactive" | |
} | |
] | |
} | |
], | |
"actions": [], | |
"basicPlus": [] | |
}, | |
"detailView": [ | |
{ | |
"label": "Security State", | |
"displayType": "state", | |
"state": { | |
"label": "{{lockstate.value}}", | |
"alternatives": [ | |
{ | |
"key": "disarmed", | |
"value": "Disarmed", | |
"type": "active" | |
}, | |
{ | |
"key": "armed", | |
"value": "Armed", | |
"type": "inactive" | |
} | |
] | |
} | |
} | |
], | |
"id": "xxxx.customlock", | |
"version": 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* DTH to show the icon change according to the alternatives | |
*/ | |
metadata { | |
definition (name: "iconAlternativeChange", author:"nayely",ocfDeviceType:"oic.d.smartlock", deviceTypeId: "SmartLock", vid:"bc7b9b6c-1a3c-3408-87e1-fddf61ce8d01", mnmn: "SmartThingsCommunity") { | |
capability "xxxx.customlock" | |
capability "lock" | |
} | |
simulator {} | |
tiles {} | |
} | |
def installed() { | |
log.trace "Executing 'installed'" | |
initialize() | |
} | |
def updated() { | |
log.trace "Executing 'updated'" | |
} | |
def lock(){ | |
sendEvent(name: "lock", value: "locked") | |
sendEvent(name: "lockstate", value: "armed") | |
} | |
def unlock(){ | |
sendEvent(name: "lock", value: "unlocked") | |
sendEvent(name: "lockstate", value: "disarmed") | |
} | |
private initialize() { | |
log.trace "Executing 'initialize'" | |
sendEvent(name: "lock", value: "unlocked") | |
sendEvent(name: "lockstate", value: "disarmed") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment