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 / server.js
Created July 7, 2021 16:41
Hub_Health_SmartApp
'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 / rule.json
Created July 6, 2021 22:55
Rule_conditions_noDepth
{
"name": "Rule with several conditions but no depth",
"actions": [
{
"if": {
"equals": {
"right": {
"device": {
"devices": [
"Dimmer1-ID"
@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()
/**
* 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 / 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 {}
@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());