SlideShare a Scribd company logo
IOTDB.org 
• 
Control all the Things 
with Node-JS
David Janes 
@dpjanes 
davidjanes@iotdb.org 
http://iotdb.org/social/imadeit/ 
November 2014
Introduction
N.B. 
• Demo example code on github 
• dpjanes/ 
• iotdb-examples/ 
• demos/ 
• 2014-11-fsto/
What is it? 
{ 
"on" : true, 
"temperature" : 225 
}
What does each field 
mean?
Control or 
Measurement? 
• Does on mean: 
• Turn it on? or 
• Is it on? 
• Does temperature mean: 
• Set the temperature? or 
• What is the temperature?
Units 
• What does temperature refer to? 
• degrees Celsius, Fahrenheit … or Kelvin?
What does the whole 
message represent?
What are we talking 
about … or with? 
• An oven? 
• A toaster? 
• A sensor in the Large Hadron Collider?
Solve “the Basket Full 
of Remotes Apps 
Problem”
Solve the N-standards 
• Open Interconnect 
Consortium 
• Thread Group 
• AllSeen Alliance 
• HyperCat Consortium 
• Industrial Internet 
Consortium 
• IoT-GSI) from ITU-T 
• oneM2M 
• Open Mobile Alliance 
• Internet of Things (IEE) 
• IETF 
• IPSO Alliance
XKCD
IOTDB(.org)
Semantic Vocab 
• Formal definitions 
• https://iotdb.org/pub 
• JSON-LD
Models 
• https://iotdb.org/iotdb 
• https://github.com/dpjanes/iotdb-models
Node-IOTDB
IOTDB Stack 
• Client Program 
• Node-IOTDB 
• Models 
• Drivers 
• Libraries 
•simple_on.js 
•require('iotdb') 
•WeMoSwitch 
•iot-driver:upnp 
•upnplib
Client Program 
simple_red 
iot 
.connect() 
.set(':color', 'red');
require(‘iotdb’) 
• locates Models, Drivers, Stores,… 
• loads & maintains user configuration 
• connects to iotdb.org (sometimes) 
• manages Things (huge deal … too many 
things to go into in detail)
Model (I) 
• Semantic description of Things 
• (can be) written in JavaScript 
• actually compiles to JSON-LD (with some 
restrained JavaScript) 
• Node independent!
Model (II) 
iotdb.make_model('WeMoSwitch') 
.facet(":device.switch") 
.product(“http://www.belkin.com/…”) 
.name("WeMo Switch") 
.description("Belkin WeMo Switch") 
.attribute( 
iotdb.make_boolean(":on") 
.name("on / off") 
.control() 
)
Model (III) 
.driver_out(function(paramd) { 
if (paramd.thingd.on !== undefined) { 
paramd.driverd['urn:Belkin:service:basicevent:1'] = { 
'SetBinaryState' : { 
'BinaryState' : paramd.thingd.on ? 1 : 0 
} 
} 
} 
})
Drivers 
iot-driver:upnp 
• Binds Models to the code that actually 
“does the work” 
• discovery 
• static configuration 
• dynamic / environmental
Libraries 
• What developers usually program against 
• We’ve rewritten a number of libraries to 
make them more reliable
Demos
simple_on 
things = iot.connect() 
things.set(':on', true);
simple_off 
things = iot.connect() 
things.set(‘:on’, false);
simple_model 
iot 
.connect(‘HueLight') 
.set(':on', true);
Metadata
Select Things 
• select Things by (e.g.) 
• Model 
• name 
• number 
• place 
• facet
meta_dump 
var things = iot.connect(); 
iot.on_things(function() { 
console.log(things.metas()); 
});
meta_model 
iot.connect() 
.with_model("TCPConnectedLight") 
.set(':on', false)
meta_name 
iot 
.connect() 
.with_name("Hue Lamp 2") 
.set(':color', 'purple')
meta_number 
iot 
.connect() 
.with_number(3) 
.set(':color', 'cyan')
meta_place 
iot 
.connect() 
.with_room("David Bedroom") 
.with_floor("Second Floor") 
.set(':color', 'green')
meta_facet 
iot 
.connect() 
.with_facet(":device.lighting") 
.set(':on', true);
where does Metadata 
come from? 
• Metadata comes from several places 
• can be altered in code 
• can be persisted to locally / to disk 
• can be retrieved from iotdb.org 
• “inherent” in the Model / Driver
Events
two types of events 
• thing.on(key, callback) 
• thing.on_change(callback)
event_brightness 
var lights = iot.connect() 
var input = iot.connect({ 
model: "FirmataInputUnit", 
pin: 0 
}); 
input.on(":value", function(thing, attribute, value) { 
lights.set(':brightness', value); 
})
event_fob 
var things = iot.connect(); 
iot 
.connect('TIKeyFob') 
.on('left', function() { 
things.set(':on', true); 
}) 
.on('right', function() { 
things.set(':on', false); 
})
Arduino / Firmata
firmata_cycle 
var things = iot 
.connect() 
.connect({ 
model: "FirmataNeoPixel", 
pin: 6, 
n: 16 
}) 
var colors = [ "red", "green", "blue", "white", "black" ]; 
var ci = 0; 
setInterval(function() { 
things.set(":color", colors[ci++ % colors.length]); 
}, 2500)
firmata_neopixel 
var n = 16; 
var leds = iot.connect({ 
model: "FirmataNeoPixel", 
pin: 6, 
n: n 
}) 
var c = new iotdb.libs.Color() 
var ci = 0; 
var cf = 0; 
setInterval(function() { 
c.set_hsl(cf, 1, 0.5) 
cf += 0.015; 
if (cf > 1) cf = 0; 
leds 
.with_number(ci++ % n) 
.set(":color", c.get_hex()) 
; 
}, 50)
Arduino Models 
• FirmataChainableLED 
• FirmataDHT11 
• FirmataGroveThermistor 
• FirmataInputBoolean 
• FirmataInputUnit 
• FirmataLightDimmer 
• FirmataLightSensor 
• FirmataLightSimple 
• FirmataMotionSensor 
• FirmataNeoPixel 
• FirmataOn 
• FirmataOutputBoolean
Stores
Available Stores 
• dweet 
• http 
• mqtt 
• phant 
• pubnub 
• thingspeak
store_phant 
var input = iot.connect('TIKeyFob') 
var store = iot 
.store('phant') 
.track(input) 
https://data.sparkfun.com/streams/aGNjQK9RwZHgEmx089Lg
store_mqtt 
var input = iot.connect({ 
model: "FirmataInputUnit", 
pin: 0 
}); 
var store = iot 
.store('mqtt') 
.track(input) 
mqtt.iotdb.org u/dpjanes/#
Transmogrifiers
What if we have the 
wrong thing? 
• Have Celsius but want Fahrenheit 
• Want to set brightness but only have color 
• What if brightness is 0-100 on one device 
and 0-1 on another 
• Average data? Max data over time? &c…
trans_fahrenheit 
var t_c = iot.connect("FirmataDHT11") 
t_c.on('temperature', function(thing, attribute, value) { 
console.log("+ temperature (C)", value) 
}) 
var t_f = t_c.transmogrify( 
iot.transmogrifier(":imperial/fahrenheit")) 
t_f.on('temperature', function(thing, attribute, value) { 
console.log("+ temperature (F)", value) 
})
warning 
• transmogrifiers are very much a work in 
progress! 
• not even pushed to npm yet
Takeaways
IOTDB 
• Semantic description of how things work
Node-IOTDB 
• Powerful language for controlling things 
• Builds on IOTDB concepts 
• Strong alpha 
• Join! Help!
Modeling 
{ 
"@context": "./meta-iri.jsonld", 
"on": true, 
"temperature": 225 
} 
Note: @context is just one way of doing this!
N.B. 
• The data does not have to be JSON! 
• You don’t need to have IOTDB! 
• You don’t need to use IOTDB IRIs (but you 
should) 
• https://iotdb.org/pub/
Additional Resources 
• Many examples + House of Janes 
https://github.com/dpjanes/iotdb-examples 
• Getting started 
https://iotdb.org/docs/node/getting-started 
• Concepts 
https://medium.com/@dpjanes
One last point 
• Don’t be misled by the simplicity! 
• I worked backward from “what do I want 
to do” to get the code 
• Way more things than I demoed today 
• I want to work with you!
Get in touch! 
David Janes 
@dpjanes 
davidjanes@iotdb.org 
http://iotdb.org/social/imadeit/

More Related Content

Similar to Control all the Things with Node-JS

Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Frédéric Harper
 
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Frédéric Harper
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
Tony Tam
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗
Pofat Tseng
 
IL2CPP: Debugging and Profiling
IL2CPP: Debugging and ProfilingIL2CPP: Debugging and Profiling
IL2CPP: Debugging and Profiling
joncham
 
Building the IOT Platform as a Service
Building the IOT Platform as a ServiceBuilding the IOT Platform as a Service
Building the IOT Platform as a Service
Jesus Rodriguez
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
Chhom Karath
 
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Frédéric Harper
 
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Frédéric Harper
 
Polyglot
PolyglotPolyglot
Polyglot
Rory Preddy
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
Lars Marius Garshol
 
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
The Internet of Things Methodology
 
Android and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsAndroid and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout js
musart Park
 
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
Frédéric Harper
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
Serge Stinckwich
 
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
Frédéric Harper
 
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-TestingJava Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Tal Melamed
 
Reactive programming
Reactive programmingReactive programming
Reactive programming
Nick Hodge
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
Axway Appcelerator
 

Similar to Control all the Things with Node-JS (20)

Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
 
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗
 
IL2CPP: Debugging and Profiling
IL2CPP: Debugging and ProfilingIL2CPP: Debugging and Profiling
IL2CPP: Debugging and Profiling
 
Building the IOT Platform as a Service
Building the IOT Platform as a ServiceBuilding the IOT Platform as a Service
Building the IOT Platform as a Service
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
 
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
 
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
 
Polyglot
PolyglotPolyglot
Polyglot
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
 
Android and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsAndroid and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout js
 
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
 
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
 
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-TestingJava Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
 
Reactive programming
Reactive programmingReactive programming
Reactive programming
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
 

Recently uploaded

Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdfSoftware Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
kalichargn70th171
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
Anand Bagmar
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
alowpalsadig
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
Alina Yurenko
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Beginner's Guide to Observability@Devoxx PL 2024
Beginner's  Guide to Observability@Devoxx PL 2024Beginner's  Guide to Observability@Devoxx PL 2024
Beginner's Guide to Observability@Devoxx PL 2024
michniczscribd
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
Cost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App DevelopmentCost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App Development
Softradix Technologies
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 

Recently uploaded (20)

Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdfSoftware Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Beginner's Guide to Observability@Devoxx PL 2024
Beginner's  Guide to Observability@Devoxx PL 2024Beginner's  Guide to Observability@Devoxx PL 2024
Beginner's Guide to Observability@Devoxx PL 2024
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
Cost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App DevelopmentCost-Effective Strategies For iOS App Development
Cost-Effective Strategies For iOS App Development
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 

Control all the Things with Node-JS

  • 1. IOTDB.org • Control all the Things with Node-JS
  • 2. David Janes @dpjanes davidjanes@iotdb.org http://iotdb.org/social/imadeit/ November 2014
  • 4. N.B. • Demo example code on github • dpjanes/ • iotdb-examples/ • demos/ • 2014-11-fsto/
  • 5. What is it? { "on" : true, "temperature" : 225 }
  • 6. What does each field mean?
  • 7. Control or Measurement? • Does on mean: • Turn it on? or • Is it on? • Does temperature mean: • Set the temperature? or • What is the temperature?
  • 8. Units • What does temperature refer to? • degrees Celsius, Fahrenheit … or Kelvin?
  • 9. What does the whole message represent?
  • 10. What are we talking about … or with? • An oven? • A toaster? • A sensor in the Large Hadron Collider?
  • 11. Solve “the Basket Full of Remotes Apps Problem”
  • 12.
  • 13. Solve the N-standards • Open Interconnect Consortium • Thread Group • AllSeen Alliance • HyperCat Consortium • Industrial Internet Consortium • IoT-GSI) from ITU-T • oneM2M • Open Mobile Alliance • Internet of Things (IEE) • IETF • IPSO Alliance
  • 14. XKCD
  • 16. Semantic Vocab • Formal definitions • https://iotdb.org/pub • JSON-LD
  • 17. Models • https://iotdb.org/iotdb • https://github.com/dpjanes/iotdb-models
  • 19. IOTDB Stack • Client Program • Node-IOTDB • Models • Drivers • Libraries •simple_on.js •require('iotdb') •WeMoSwitch •iot-driver:upnp •upnplib
  • 20. Client Program simple_red iot .connect() .set(':color', 'red');
  • 21. require(‘iotdb’) • locates Models, Drivers, Stores,… • loads & maintains user configuration • connects to iotdb.org (sometimes) • manages Things (huge deal … too many things to go into in detail)
  • 22. Model (I) • Semantic description of Things • (can be) written in JavaScript • actually compiles to JSON-LD (with some restrained JavaScript) • Node independent!
  • 23. Model (II) iotdb.make_model('WeMoSwitch') .facet(":device.switch") .product(“http://www.belkin.com/…”) .name("WeMo Switch") .description("Belkin WeMo Switch") .attribute( iotdb.make_boolean(":on") .name("on / off") .control() )
  • 24. Model (III) .driver_out(function(paramd) { if (paramd.thingd.on !== undefined) { paramd.driverd['urn:Belkin:service:basicevent:1'] = { 'SetBinaryState' : { 'BinaryState' : paramd.thingd.on ? 1 : 0 } } } })
  • 25. Drivers iot-driver:upnp • Binds Models to the code that actually “does the work” • discovery • static configuration • dynamic / environmental
  • 26. Libraries • What developers usually program against • We’ve rewritten a number of libraries to make them more reliable
  • 27. Demos
  • 28. simple_on things = iot.connect() things.set(':on', true);
  • 29. simple_off things = iot.connect() things.set(‘:on’, false);
  • 32. Select Things • select Things by (e.g.) • Model • name • number • place • facet
  • 33. meta_dump var things = iot.connect(); iot.on_things(function() { console.log(things.metas()); });
  • 35. meta_name iot .connect() .with_name("Hue Lamp 2") .set(':color', 'purple')
  • 36. meta_number iot .connect() .with_number(3) .set(':color', 'cyan')
  • 37. meta_place iot .connect() .with_room("David Bedroom") .with_floor("Second Floor") .set(':color', 'green')
  • 38. meta_facet iot .connect() .with_facet(":device.lighting") .set(':on', true);
  • 39. where does Metadata come from? • Metadata comes from several places • can be altered in code • can be persisted to locally / to disk • can be retrieved from iotdb.org • “inherent” in the Model / Driver
  • 41. two types of events • thing.on(key, callback) • thing.on_change(callback)
  • 42. event_brightness var lights = iot.connect() var input = iot.connect({ model: "FirmataInputUnit", pin: 0 }); input.on(":value", function(thing, attribute, value) { lights.set(':brightness', value); })
  • 43. event_fob var things = iot.connect(); iot .connect('TIKeyFob') .on('left', function() { things.set(':on', true); }) .on('right', function() { things.set(':on', false); })
  • 45. firmata_cycle var things = iot .connect() .connect({ model: "FirmataNeoPixel", pin: 6, n: 16 }) var colors = [ "red", "green", "blue", "white", "black" ]; var ci = 0; setInterval(function() { things.set(":color", colors[ci++ % colors.length]); }, 2500)
  • 46. firmata_neopixel var n = 16; var leds = iot.connect({ model: "FirmataNeoPixel", pin: 6, n: n }) var c = new iotdb.libs.Color() var ci = 0; var cf = 0; setInterval(function() { c.set_hsl(cf, 1, 0.5) cf += 0.015; if (cf > 1) cf = 0; leds .with_number(ci++ % n) .set(":color", c.get_hex()) ; }, 50)
  • 47. Arduino Models • FirmataChainableLED • FirmataDHT11 • FirmataGroveThermistor • FirmataInputBoolean • FirmataInputUnit • FirmataLightDimmer • FirmataLightSensor • FirmataLightSimple • FirmataMotionSensor • FirmataNeoPixel • FirmataOn • FirmataOutputBoolean
  • 49. Available Stores • dweet • http • mqtt • phant • pubnub • thingspeak
  • 50. store_phant var input = iot.connect('TIKeyFob') var store = iot .store('phant') .track(input) https://data.sparkfun.com/streams/aGNjQK9RwZHgEmx089Lg
  • 51. store_mqtt var input = iot.connect({ model: "FirmataInputUnit", pin: 0 }); var store = iot .store('mqtt') .track(input) mqtt.iotdb.org u/dpjanes/#
  • 53.
  • 54. What if we have the wrong thing? • Have Celsius but want Fahrenheit • Want to set brightness but only have color • What if brightness is 0-100 on one device and 0-1 on another • Average data? Max data over time? &c…
  • 55. trans_fahrenheit var t_c = iot.connect("FirmataDHT11") t_c.on('temperature', function(thing, attribute, value) { console.log("+ temperature (C)", value) }) var t_f = t_c.transmogrify( iot.transmogrifier(":imperial/fahrenheit")) t_f.on('temperature', function(thing, attribute, value) { console.log("+ temperature (F)", value) })
  • 56. warning • transmogrifiers are very much a work in progress! • not even pushed to npm yet
  • 58. IOTDB • Semantic description of how things work
  • 59. Node-IOTDB • Powerful language for controlling things • Builds on IOTDB concepts • Strong alpha • Join! Help!
  • 60. Modeling { "@context": "./meta-iri.jsonld", "on": true, "temperature": 225 } Note: @context is just one way of doing this!
  • 61. N.B. • The data does not have to be JSON! • You don’t need to have IOTDB! • You don’t need to use IOTDB IRIs (but you should) • https://iotdb.org/pub/
  • 62. Additional Resources • Many examples + House of Janes https://github.com/dpjanes/iotdb-examples • Getting started https://iotdb.org/docs/node/getting-started • Concepts https://medium.com/@dpjanes
  • 63. One last point • Don’t be misled by the simplicity! • I worked backward from “what do I want to do” to get the code • Way more things than I demoed today • I want to work with you!
  • 64. Get in touch! David Janes @dpjanes davidjanes@iotdb.org http://iotdb.org/social/imadeit/