SlideShare a Scribd company logo
1 of 31
Download to read offline
Programming Your SmartThings 
Janet Huang 
janetyc@gmail.com 
2014.10.22 @ NTU CSIE
Outline 
• Introduction 
• Conceptual Architecture 
• SmartThings Architecture 
• How to Program SmartThings 
• Build a SmartApp 
• Build a Device Type
Important Concepts 
Image 
Capture 
Lock 
Contact 
Sensor 
Switch Music Player 
Temperature 
Measurement
Conceptual Architecture
SmartThings Architecture
SmartApps 
SmartDevices 
SmartThings Shield 
Customized Smart Device 
Arduino-compatible board 
(Uno, Mega, Duemilanove, and Leonardo) 
+ 
Sensor, Actuator 
= 
1 
2 
3 ZigBee or ZigWave Device
SmartApp 
Event Handler SmartApps 
Subscribe events and call a handler 
method 
Solution Module SmartApps 
Built-in apps in dashboard 
Service Manager SmartApps 
Be used to connect to your external 
devices 
Device Type 
Hub Connected Devices 
ZigBee Home Automation Devices 
Z-Wave Devices 
Cloud Connected Devices 
Authenticate via a standard OAuth2 flow 
Communicate via HTTP-based APIs 
LAN-Connected Devices 
Communicate via REST or with SOAP 
requests using UPnP (Universal Plug 
and Play)
Device Type Handler
SmartApp Execution 
1. Event Subscription 
attribute changes -> creates an event (triggers 
a subscription, calls a handler method) 
2. Scheduled Events 
call a method at a particular time, e.g. runIn() 
3. Endpoint Triggers 
create an endpoint accessible over the web that calls a 
method within your SmartApp
Capabilities 
device state action 
https://graph.api.smartthings.com/ide/doc/capabilities
Your First SmartApp
SmartApp Empty Template 
define input 
install setting 
update setting
https://graph.api.smartthings.com
Create an Empty SmartApp
SmartThings IDE
Choose SmartApp Examples
Example 1a: Lights Off, When Closed (Built-in example) 
app setting 
define input 
subscribe event 
define action
Example 1b: Lights On/Off, When Opened/Closed 
https://gist.github.com/janetyc/22c0ecf586f1550669b5
check the state of the door 
https://gist.github.com/janetyc/22c0ecf586f1550669b5
1 
Select location 
2 
Select testing devices 
4 Testing on real devices 
3 Testing on simulator
Your First Device Type
Create an Empty SmartDevice
profile 
select capabilities
Device Type Empty Template 
define capability, command 
define UI 
parse events 
commands
Tile Definitions 
standardTile() 
valueTile() 
controlTile() 
Tile Layouts 
valueTile("temperature", 
"device.temperature", 
width: 
2, 
height: 
2) 
main 
"temperature" 
details(["temperature", 
“mode", 
…])
https://gist.github.com/janetyc/34c1642f8eaa3e4299da 
metadata 
{ 
definition 
(name: 
"On/Off 
Shield 
(Janet)", 
namespace: 
"janetyc", 
author: 
"Janet 
Huang") 
{ 
capability 
"Switch" 
capability 
"Sensor" 
command 
"hello" 
} 
simulator 
{ 
// 
TODO: 
define 
status 
and 
reply 
messages 
here 
status 
"on": 
"catchall: 
0104 
0000 
01 
01 
0040 
00 
0A21 
00 
00 
0000 
0A 
00 
0A6F6E" 
status 
"off": 
"catchall: 
0104 
0000 
01 
01 
0040 
00 
0A21 
00 
00 
0000 
0A 
00 
0A6F6666" 
// 
reply 
messages 
reply 
"raw 
0x0 
{ 
00 
00 
0a 
0a 
6f 
6e 
}": 
"catchall: 
0104 
0000 
01 
01 
0040 
00 
0A21 
00 
00 
0000 
0A 
00 
0A6F6E" 
reply 
"raw 
0x0 
{ 
00 
00 
0a 
0a 
6f 
66 
66 
}": 
"catchall: 
0104 
0000 
01 
01 
0040 
00 
0A21 
00 
00 
0000 
0A 
00 
0A6F6666" 
} 
tiles 
{ 
// 
TODO: 
define 
your 
main 
and 
details 
tiles 
here 
standardTile("switch", 
"device.switch", 
width: 
2, 
height: 
2, 
canChangeIcon: 
true, 
canChangeBackground: 
true) 
{ 
state 
"on", 
label: 
'${name}', 
action: 
"switch.off", 
icon: 
"st.shields.shields.arduino", 
backgroundColor: 
"#79b821" 
state 
"off", 
label: 
'${name}', 
action: 
"switch.on", 
icon: 
"st.shields.shields.arduino", 
backgroundColor: 
"#ffffff" 
} 
standardTile("greeting", 
"device.greeting", 
width: 
1, 
height: 
1, 
canChangeIcon: 
true, 
canChangeBackground: 
true) 
{ 
state 
"greeting", 
label: 
'hello', 
action: 
"hello", 
icon: 
"st.switches.switch.off", 
backgroundColor: 
"#ccccff" 
} 
valueTile("message", 
"device.message", 
inactiveLabel: 
false) 
{ 
state 
"message", 
label:'${currentValue}', 
unit:"" 
} 
valueTile("sensorValue", 
"device.sensorValue", 
){ 
state 
"sensorValue", 
label:'${currentValue}', 
inactiveLabel: 
false, 
backgroundColors:[ 
[value: 
31, 
color: 
"#153591"], 
[value: 
44, 
color: 
"#1e9cbb"], 
[value: 
59, 
color: 
"#90d2a7"], 
[value: 
74, 
color: 
"#44b621"], 
[value: 
84, 
color: 
"#f1d801"], 
[value: 
120, 
color: 
"#d04e00"], 
[value: 
195, 
color: 
"#bc2323"] 
] 
} 
main 
"switch" 
details(["switch","greeting","message","sensorValue"]) 
} 
}
// 
parse 
events 
into 
attributes 
def 
parse(String 
description) 
{ 
log.debug 
"raw: 
${description}” 
! 
def 
value 
= 
zigbee.parse(description)?.text 
def 
linkText 
= 
getLinkText(device) 
def 
descriptionText 
= 
getDescriptionText(description, 
linkText, 
value) 
def 
handlerName 
= 
value 
def 
isStateChange 
= 
value 
!= 
"ping" 
def 
displayed 
= 
value 
&& 
isStateChange 
def 
name 
= 
"null" 
if 
(value?.startsWith("lightValue: 
")) 
{ 
value 
= 
value 
-­‐ 
"lightValue: 
" 
name 
= 
"sensorValue" 
value 
= 
Integer.parseInt(value) 
}else 
if 
(value?.startsWith("irValue: 
")) 
{ 
value 
= 
value 
-­‐ 
"irValue: 
" 
name 
= 
"irValue" 
value 
= 
Integer.parseInt(value) 
}else 
{ 
name 
= 
value 
in 
["on","off"] 
? 
"switch" 
: 
(value 
&& 
value 
!= 
"ping" 
? 
"message" 
: 
"null") 
value 
= 
value 
} 
def 
result 
= 
[ 
value: 
value, 
name: 
name, 
handlerName: 
handlerName, 
linkText: 
linkText, 
descriptionText: 
descriptionText, 
isStateChange: 
isStateChange, 
displayed: 
displayed 
] 
result 
} 
debug log 
parse zigbee message 
attribute name 
https://gist.github.com/janetyc/34c1642f8eaa3e4299da
// 
handle 
commands 
def 
on() 
{ 
log.debug 
"Executing 
'on'" 
zigbee.smartShield(text: 
"on").format() 
//send 
'on' 
to 
device 
} 
def 
off() 
{ 
log.debug 
"Executing 
'off'" 
zigbee.smartShield(text: 
"off").format() 
//send 
'off' 
to 
device 
} 
//customized 
commands 
def 
hello() 
{ 
log.debug 
"Executing 
'hello'" 
zigbee.smartShield(text: 
"hello").format() 
//send 
'hello' 
to 
device 
} 
https://gist.github.com/janetyc/34c1642f8eaa3e4299da
It’s Your Turn!! 
Build Your SmartApp & SmartDevice

More Related Content

Viewers also liked

Internet of Things and its applications
Internet of Things and its applicationsInternet of Things and its applications
Internet of Things and its applicationsPasquale Puzio
 
Itsm group15 project
Itsm group15 projectItsm group15 project
Itsm group15 projectJugal Shah
 
Samsung ARTIK Cloud and Genuino MKR100
Samsung ARTIK Cloud and Genuino MKR100Samsung ARTIK Cloud and Genuino MKR100
Samsung ARTIK Cloud and Genuino MKR100SAMSUNG ARTIK Cloud
 
PCCW Teleservics Overview
PCCW Teleservics OverviewPCCW Teleservics Overview
PCCW Teleservics OverviewTony Zubek
 
Modern vs. Traditional SIEM
Modern vs. Traditional SIEM Modern vs. Traditional SIEM
Modern vs. Traditional SIEM Alert Logic
 
SIEM 101: Get a Clue About IT Security Analysis
SIEM 101: Get a Clue About IT Security Analysis SIEM 101: Get a Clue About IT Security Analysis
SIEM 101: Get a Clue About IT Security Analysis AlienVault
 
Track 3 session 1 - st dev con 2016 -ieee- iot standards adn open source
Track 3   session 1 - st dev con 2016 -ieee- iot standards adn open sourceTrack 3   session 1 - st dev con 2016 -ieee- iot standards adn open source
Track 3 session 1 - st dev con 2016 -ieee- iot standards adn open sourceST_World
 
Five Best and Five Worst Practices for SIEM by Dr. Anton Chuvakin
Five Best and Five Worst Practices for SIEM by Dr. Anton ChuvakinFive Best and Five Worst Practices for SIEM by Dr. Anton Chuvakin
Five Best and Five Worst Practices for SIEM by Dr. Anton ChuvakinAnton Chuvakin
 
Golden Mean in Design
Golden Mean in DesignGolden Mean in Design
Golden Mean in DesignArtik Design
 
The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...
The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...
The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...Paul Brody
 
IoT Platform Meetup - HP Enterprise
IoT Platform Meetup - HP EnterpriseIoT Platform Meetup - HP Enterprise
IoT Platform Meetup - HP EnterpriseFilip Kolář
 
IoT Platform Meetup - IBM
IoT Platform Meetup - IBMIoT Platform Meetup - IBM
IoT Platform Meetup - IBMFilip Kolář
 
NISTs Cybersecurity Framework -- Comparison with Best Practice
NISTs Cybersecurity Framework -- Comparison with Best PracticeNISTs Cybersecurity Framework -- Comparison with Best Practice
NISTs Cybersecurity Framework -- Comparison with Best PracticeDavid Ochel
 
Samsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoTSamsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoTRyo Jin
 

Viewers also liked (20)

Smartthings
SmartthingsSmartthings
Smartthings
 
Understanding Samsung SmartThings from Patents
Understanding Samsung SmartThings from PatentsUnderstanding Samsung SmartThings from Patents
Understanding Samsung SmartThings from Patents
 
Internet of Things and its applications
Internet of Things and its applicationsInternet of Things and its applications
Internet of Things and its applications
 
Itsm group15 project
Itsm group15 projectItsm group15 project
Itsm group15 project
 
Facebook facts and figures 2016
Facebook facts and figures 2016Facebook facts and figures 2016
Facebook facts and figures 2016
 
M health ppt 모바일 시스템
M health ppt 모바일 시스템M health ppt 모바일 시스템
M health ppt 모바일 시스템
 
Samsung ARTIK Cloud and Genuino MKR100
Samsung ARTIK Cloud and Genuino MKR100Samsung ARTIK Cloud and Genuino MKR100
Samsung ARTIK Cloud and Genuino MKR100
 
PCCW Teleservics Overview
PCCW Teleservics OverviewPCCW Teleservics Overview
PCCW Teleservics Overview
 
Modern vs. Traditional SIEM
Modern vs. Traditional SIEM Modern vs. Traditional SIEM
Modern vs. Traditional SIEM
 
SIEM 101: Get a Clue About IT Security Analysis
SIEM 101: Get a Clue About IT Security Analysis SIEM 101: Get a Clue About IT Security Analysis
SIEM 101: Get a Clue About IT Security Analysis
 
SIEM evolution
SIEM evolutionSIEM evolution
SIEM evolution
 
Leap motion
Leap motionLeap motion
Leap motion
 
Track 3 session 1 - st dev con 2016 -ieee- iot standards adn open source
Track 3   session 1 - st dev con 2016 -ieee- iot standards adn open sourceTrack 3   session 1 - st dev con 2016 -ieee- iot standards adn open source
Track 3 session 1 - st dev con 2016 -ieee- iot standards adn open source
 
Five Best and Five Worst Practices for SIEM by Dr. Anton Chuvakin
Five Best and Five Worst Practices for SIEM by Dr. Anton ChuvakinFive Best and Five Worst Practices for SIEM by Dr. Anton Chuvakin
Five Best and Five Worst Practices for SIEM by Dr. Anton Chuvakin
 
Golden Mean in Design
Golden Mean in DesignGolden Mean in Design
Golden Mean in Design
 
The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...
The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...
The Golden Age of Wearables:
 Personal Networks, Smart Things & Intimate Know...
 
IoT Platform Meetup - HP Enterprise
IoT Platform Meetup - HP EnterpriseIoT Platform Meetup - HP Enterprise
IoT Platform Meetup - HP Enterprise
 
IoT Platform Meetup - IBM
IoT Platform Meetup - IBMIoT Platform Meetup - IBM
IoT Platform Meetup - IBM
 
NISTs Cybersecurity Framework -- Comparison with Best Practice
NISTs Cybersecurity Framework -- Comparison with Best PracticeNISTs Cybersecurity Framework -- Comparison with Best Practice
NISTs Cybersecurity Framework -- Comparison with Best Practice
 
Samsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoTSamsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoT
 

Similar to How to Program SmartThings

Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid FoundationsPaul Blundell
 
Da Arduino ad Android_ illumina il Natale con il BLE
Da Arduino ad Android_ illumina il Natale con il BLEDa Arduino ad Android_ illumina il Natale con il BLE
Da Arduino ad Android_ illumina il Natale con il BLEinfogdgmi
 
Android Things in action
Android Things in actionAndroid Things in action
Android Things in actionStefano Sanna
 
Iot for smart agriculture
Iot for smart agricultureIot for smart agriculture
Iot for smart agricultureAtit Patumvan
 
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】tsuchimon
 
Arduino and the real time web
Arduino and the real time webArduino and the real time web
Arduino and the real time webAndrew Fisher
 
IoT on Raspberry PI v1.2
IoT on Raspberry PI v1.2IoT on Raspberry PI v1.2
IoT on Raspberry PI v1.2John Staveley
 
Scaling Application in Node.js.pdf
Scaling Application in Node.js.pdfScaling Application in Node.js.pdf
Scaling Application in Node.js.pdfSudhanshiBakre1
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
What's Coming Next in Sencha Frameworks
What's Coming Next in Sencha FrameworksWhat's Coming Next in Sencha Frameworks
What's Coming Next in Sencha FrameworksGrgur Grisogono
 
Distributed Stream Processing with WSO2 Stream Processor
Distributed Stream Processing with WSO2 Stream ProcessorDistributed Stream Processing with WSO2 Stream Processor
Distributed Stream Processing with WSO2 Stream ProcessorWSO2
 
Architecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour versionArchitecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour versionAlon Fliess
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019Jong-Hyun Kim
 
Designing an API for the Internet of Things
Designing an API for the Internet of ThingsDesigning an API for the Internet of Things
Designing an API for the Internet of ThingsKevin Swiber
 

Similar to How to Program SmartThings (20)

Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid Foundations
 
Da Arduino ad Android_ illumina il Natale con il BLE
Da Arduino ad Android_ illumina il Natale con il BLEDa Arduino ad Android_ illumina il Natale con il BLE
Da Arduino ad Android_ illumina il Natale con il BLE
 
Android Things in action
Android Things in actionAndroid Things in action
Android Things in action
 
Iot for smart agriculture
Iot for smart agricultureIot for smart agriculture
Iot for smart agriculture
 
MouthMouse
MouthMouseMouthMouse
MouthMouse
 
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
 
Arduino and the real time web
Arduino and the real time webArduino and the real time web
Arduino and the real time web
 
IoT on Raspberry Pi
IoT on Raspberry PiIoT on Raspberry Pi
IoT on Raspberry Pi
 
IoT on Raspberry PI v1.2
IoT on Raspberry PI v1.2IoT on Raspberry PI v1.2
IoT on Raspberry PI v1.2
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
SRV408 Deep Dive on AWS IoT
SRV408 Deep Dive on AWS IoTSRV408 Deep Dive on AWS IoT
SRV408 Deep Dive on AWS IoT
 
dSS API by example
dSS API by exampledSS API by example
dSS API by example
 
Scaling Application in Node.js.pdf
Scaling Application in Node.js.pdfScaling Application in Node.js.pdf
Scaling Application in Node.js.pdf
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
What's Coming Next in Sencha Frameworks
What's Coming Next in Sencha FrameworksWhat's Coming Next in Sencha Frameworks
What's Coming Next in Sencha Frameworks
 
Distributed Stream Processing with WSO2 Stream Processor
Distributed Stream Processing with WSO2 Stream ProcessorDistributed Stream Processing with WSO2 Stream Processor
Distributed Stream Processing with WSO2 Stream Processor
 
Architecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour versionArchitecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour version
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019
 
Designing an API for the Internet of Things
Designing an API for the Internet of ThingsDesigning an API for the Internet of Things
Designing an API for the Internet of Things
 

More from Janet Huang

Transferring Sensing to a Mixed Virtual and Physical Experience
Transferring Sensing to a Mixed Virtual and Physical ExperienceTransferring Sensing to a Mixed Virtual and Physical Experience
Transferring Sensing to a Mixed Virtual and Physical ExperienceJanet Huang
 
Collecting a Image Label from Crowds Using Amazon Mechanical Turk
Collecting a Image Label from Crowds Using Amazon Mechanical TurkCollecting a Image Label from Crowds Using Amazon Mechanical Turk
Collecting a Image Label from Crowds Using Amazon Mechanical TurkJanet Huang
 
Art in the Crowd
Art in the CrowdArt in the Crowd
Art in the CrowdJanet Huang
 
Designing physical and digital experience in social web
Designing physical and digital experience in social webDesigning physical and digital experience in social web
Designing physical and digital experience in social webJanet Huang
 
The power of example
The power of exampleThe power of example
The power of exampleJanet Huang
 
Responsive web design
Responsive web designResponsive web design
Responsive web designJanet Huang
 
Openframworks x Mobile
Openframworks x MobileOpenframworks x Mobile
Openframworks x MobileJanet Huang
 

More from Janet Huang (13)

Transferring Sensing to a Mixed Virtual and Physical Experience
Transferring Sensing to a Mixed Virtual and Physical ExperienceTransferring Sensing to a Mixed Virtual and Physical Experience
Transferring Sensing to a Mixed Virtual and Physical Experience
 
Collecting a Image Label from Crowds Using Amazon Mechanical Turk
Collecting a Image Label from Crowds Using Amazon Mechanical TurkCollecting a Image Label from Crowds Using Amazon Mechanical Turk
Collecting a Image Label from Crowds Using Amazon Mechanical Turk
 
Art in the Crowd
Art in the CrowdArt in the Crowd
Art in the Crowd
 
Designing physical and digital experience in social web
Designing physical and digital experience in social webDesigning physical and digital experience in social web
Designing physical and digital experience in social web
 
Of class3
Of class3Of class3
Of class3
 
Of class2
Of class2Of class2
Of class2
 
Of class1
Of class1Of class1
Of class1
 
Iphone course 3
Iphone course 3Iphone course 3
Iphone course 3
 
Iphone course 2
Iphone course 2Iphone course 2
Iphone course 2
 
Iphone course 1
Iphone course 1Iphone course 1
Iphone course 1
 
The power of example
The power of exampleThe power of example
The power of example
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
Openframworks x Mobile
Openframworks x MobileOpenframworks x Mobile
Openframworks x Mobile
 

Recently uploaded

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

How to Program SmartThings

  • 1. Programming Your SmartThings Janet Huang janetyc@gmail.com 2014.10.22 @ NTU CSIE
  • 2.
  • 3. Outline • Introduction • Conceptual Architecture • SmartThings Architecture • How to Program SmartThings • Build a SmartApp • Build a Device Type
  • 4. Important Concepts Image Capture Lock Contact Sensor Switch Music Player Temperature Measurement
  • 7. SmartApps SmartDevices SmartThings Shield Customized Smart Device Arduino-compatible board (Uno, Mega, Duemilanove, and Leonardo) + Sensor, Actuator = 1 2 3 ZigBee or ZigWave Device
  • 8. SmartApp Event Handler SmartApps Subscribe events and call a handler method Solution Module SmartApps Built-in apps in dashboard Service Manager SmartApps Be used to connect to your external devices Device Type Hub Connected Devices ZigBee Home Automation Devices Z-Wave Devices Cloud Connected Devices Authenticate via a standard OAuth2 flow Communicate via HTTP-based APIs LAN-Connected Devices Communicate via REST or with SOAP requests using UPnP (Universal Plug and Play)
  • 10. SmartApp Execution 1. Event Subscription attribute changes -> creates an event (triggers a subscription, calls a handler method) 2. Scheduled Events call a method at a particular time, e.g. runIn() 3. Endpoint Triggers create an endpoint accessible over the web that calls a method within your SmartApp
  • 11. Capabilities device state action https://graph.api.smartthings.com/ide/doc/capabilities
  • 13. SmartApp Empty Template define input install setting update setting
  • 15. Create an Empty SmartApp
  • 18.
  • 19. Example 1a: Lights Off, When Closed (Built-in example) app setting define input subscribe event define action
  • 20. Example 1b: Lights On/Off, When Opened/Closed https://gist.github.com/janetyc/22c0ecf586f1550669b5
  • 21. check the state of the door https://gist.github.com/janetyc/22c0ecf586f1550669b5
  • 22. 1 Select location 2 Select testing devices 4 Testing on real devices 3 Testing on simulator
  • 24. Create an Empty SmartDevice
  • 26. Device Type Empty Template define capability, command define UI parse events commands
  • 27. Tile Definitions standardTile() valueTile() controlTile() Tile Layouts valueTile("temperature", "device.temperature", width: 2, height: 2) main "temperature" details(["temperature", “mode", …])
  • 28. https://gist.github.com/janetyc/34c1642f8eaa3e4299da metadata { definition (name: "On/Off Shield (Janet)", namespace: "janetyc", author: "Janet Huang") { capability "Switch" capability "Sensor" command "hello" } simulator { // TODO: define status and reply messages here status "on": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E" status "off": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666" // reply messages reply "raw 0x0 { 00 00 0a 0a 6f 6e }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E" reply "raw 0x0 { 00 00 0a 0a 6f 66 66 }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666" } tiles { // TODO: define your main and details tiles here standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) { state "on", label: '${name}', action: "switch.off", icon: "st.shields.shields.arduino", backgroundColor: "#79b821" state "off", label: '${name}', action: "switch.on", icon: "st.shields.shields.arduino", backgroundColor: "#ffffff" } standardTile("greeting", "device.greeting", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { state "greeting", label: 'hello', action: "hello", icon: "st.switches.switch.off", backgroundColor: "#ccccff" } valueTile("message", "device.message", inactiveLabel: false) { state "message", label:'${currentValue}', unit:"" } valueTile("sensorValue", "device.sensorValue", ){ state "sensorValue", label:'${currentValue}', inactiveLabel: false, backgroundColors:[ [value: 31, color: "#153591"], [value: 44, color: "#1e9cbb"], [value: 59, color: "#90d2a7"], [value: 74, color: "#44b621"], [value: 84, color: "#f1d801"], [value: 120, color: "#d04e00"], [value: 195, color: "#bc2323"] ] } main "switch" details(["switch","greeting","message","sensorValue"]) } }
  • 29. // parse events into attributes def parse(String description) { log.debug "raw: ${description}” ! def value = zigbee.parse(description)?.text def linkText = getLinkText(device) def descriptionText = getDescriptionText(description, linkText, value) def handlerName = value def isStateChange = value != "ping" def displayed = value && isStateChange def name = "null" if (value?.startsWith("lightValue: ")) { value = value -­‐ "lightValue: " name = "sensorValue" value = Integer.parseInt(value) }else if (value?.startsWith("irValue: ")) { value = value -­‐ "irValue: " name = "irValue" value = Integer.parseInt(value) }else { name = value in ["on","off"] ? "switch" : (value && value != "ping" ? "message" : "null") value = value } def result = [ value: value, name: name, handlerName: handlerName, linkText: linkText, descriptionText: descriptionText, isStateChange: isStateChange, displayed: displayed ] result } debug log parse zigbee message attribute name https://gist.github.com/janetyc/34c1642f8eaa3e4299da
  • 30. // handle commands def on() { log.debug "Executing 'on'" zigbee.smartShield(text: "on").format() //send 'on' to device } def off() { log.debug "Executing 'off'" zigbee.smartShield(text: "off").format() //send 'off' to device } //customized commands def hello() { log.debug "Executing 'hello'" zigbee.smartShield(text: "hello").format() //send 'hello' to device } https://gist.github.com/janetyc/34c1642f8eaa3e4299da
  • 31. It’s Your Turn!! Build Your SmartApp & SmartDevice