Skip to content

Instantly share code, notes, and snippets.

View nayelyzarazua-bluetrail's full-sized avatar

Nayely Zarazua nayelyzarazua-bluetrail

View GitHub Profile
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / dthFunctions.groovy
Last active July 1, 2021 23:57
modifyConfigParamsSmartApp
//Function called when the command of the Custom Capability is executed (from the app, API or SmartApp)
def setAttr(String arg){
log.trace("attr ${arg}")
sendEvent(name:"attr",value:arg)
state.configValue = 0
switch(arg){
case 'option1':
state.configValue= 20
break;
case 'option2':
{
"name": "Sample for precondition",
"actions": [
{
"if":{
"equals": {
"left":{
"string": "pushed"
},
"right":{
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / smartapp.js
Created April 30, 2021 14:23
Lambda-SmartAppConnector
const SmartApp = require('@smartthings/smartapp');
const deviceStates = {switch: 'off'}//1-10
module.exports = new SmartApp()
.appId('smartApp connector')
.disableCustomDisplayName(true)
.permissions(['w:devices:*', 'r:locations:*','x:devices:*', 'i:deviceprofiles:*', 'r:devices:*'])
.page('mainPage', (ctx, page, configData) => {
page.section('Device label:', section => {
const express = require('express');
const bodyParser = require('body-parser');
const SmartApp = require('@smartthings/smartapp');
const { json } = require('body-parser');
require('dotenv').config();
const server = module.exports = express();
server.use(bodyParser.json());
const app = new SmartApp()
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / server.js
Last active April 1, 2021 18:23
SmartAppConnector-sample
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const SmartApp = require('@smartthings/smartapp');
require('dotenv').config();
const server = module.exports = express();
server.use(bodyParser.json());
const deviceStates = {switch: 'off'}//1-10
/**
* Test DTH for custom capabilities >>>> waterFlowHighestRate
*/
metadata {
definition (name: "testwaterFlowHighestRate2", vid:"4a5086e4-393f-39e1-9d28-1ca0df09729b", mnmn: "SmartThingsCommunity", author: "Nayely") {
capability "schoolwater29967.waterFlowHighestRate"
}
simulator {}
/**
* Test DTH for pushButton display of a custom capability.
*/
metadata {
definition (name: "startButton", author:"nayely", vid:"c1d85a31-6661-341c-94fb-9ddd42420392", mnmn: "SmartThingsCommunity") {
capability "schoolwater29967.startbutton"
}
simulator {}
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / DynamicInputsDelete.js
Created March 2, 2021 21:28
SmartApp_DynamicInputsDelete
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const SmartApp = require('@smartthings/smartapp');
require('dotenv').config();
const server = module.exports = express();
server.use(bodyParser.json());
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / smartapp.js
Created February 25, 2021 01:34
SmartApp_DynamicInputsPersistance
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const SmartApp = require('@smartthings/smartapp');
require('dotenv').config();
const server = module.exports = express();
server.use(bodyParser.json());
/**
* Z-Wave Lock
*
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*