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 / app.js
Last active January 7, 2023 00:25
GoogleSheetLogger
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const SmartApp = require('@smartthings/smartapp');
const axios = require('axios');
require('dotenv').config();
const server = module.exports = express();
server.use(bodyParser.json());
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / command_handlers.lua
Created December 7, 2022 23:17
createChildDevice_afterMain
local log = require "log"
local capabilities = require "st.capabilities"
local utils= require "st.utils"
local command_handlers = {}
-- callback to handle an `on` capability command
function command_handlers.switch_on(driver, device, command)
log.debug(string.format("[%s] calling set_power(on)", device.device_network_id))
device:emit_event(capabilities.switch.switch.on())
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / messageHandler.lua
Created April 7, 2022 23:24
WriteAttributeCommand-Zigbee
local read_attribute = require "st.zigbee.zcl.global_commands.read_attribute"
local write_attribute = require "st.zigbee.zcl.global_commands.write_attribute"
local messages = require "st.zigbee.messages"
local zb_const = require "st.zigbee.constants"
local zcl_messages = require "st.zigbee.zcl"
local data_types = require "st.zigbee.data_types"
local messageHandler = {}
messageHandler.build_zcl_message = function(device,cluster_id,zclh,body_message,mfg_specific_code)
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / init.lua
Created October 8, 2021 18:39
Hello_World_customCapabilities
-- require st provided libraries
local capabilities = require "st.capabilities"
local Driver = require "st.driver"
local log = require "log"
-- require custom handlers from driver package
local discovery = require "discovery"
--construct the custom capability to use it in the driver
--This is the result of the command >> smartthings capabilities namespace.oneiteminlist -j
local oneiteminlist = capabilities.build_cap_from_json_string([[
local caps = require "st.capabilities"
local zcl_clusters = require "st.zigbee.zcl.clusters"
local ZigbeeDriver = require "st.zigbee"
local constants = require "st.zigbee.constants"
local defaults = require "st.zigbee.defaults"
local contact_sensor_defaults = require "st.zigbee.defaults.contactSensor_defaults"
local data_types = require "st.zigbee.data_types"
local fancy_switch_def = [[{
"id": "commonsmall09402.copySwitch",
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / init(main).lua
Last active December 23, 2022 18:01
EdgeDrivers_change defaults
local capabilities = require "st.capabilities"
local zcl_clusters = require "st.zigbee.zcl.clusters"
local ZigbeeDriver = require "st.zigbee"
local constants = require "st.zigbee.constants"
local defaults = require "st.zigbee.defaults"
local contact_sensor_defaults = require "st.zigbee.defaults.contactSensor_defaults"
local data_types = require "st.zigbee.data_types"
local common = require("common")
local function acceleration_handler(driver, device, value, zb_rx)
@nayelyzarazua-bluetrail
nayelyzarazua-bluetrail / presentation.json
Created August 11, 2021 21:18
Tasmota_DTH_presentation
{
"dashboard": {
"states": [
{
"component": "main",
"capability": "switch",
"version": 1,
"values": []
}
],
@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':