SlideShare a Scribd company logo
1 of 33
dS S A PI by example
Patrick S tählin, futureLA B A G
pstaehlin@futurelab.ch
Demo setup




       dSS     Serial                 dSID
                        dSM   230V
     MacBook   RS485                 Device
Demo
Include model.js




 [...]
 <script src="js/model.js" language="JavaScript" type="text/javascript">
 </script>
 [...]
S etup js functions




 [...]
 function turnOn() {
   (new Device("3F...")).turnOn();
 }
 [...]
 function turnOff() {
   (new Device("3F...")).turnOff();
 }
Hook it up




 [...]
 <a href="javascript:turnOn()">Turn on</a>
 <a href="javascript:turnOff()">Turn off</a>
 [...]
Recap

●   Put .html into webroot of dSS
●   Include /js/model.js
●   Code! ;-)
Avoid code like that




 [...]
 function turnOn() {
   (new Device("3F...1")).turnOn();
   (new Device("3F...2")).turnOn();
   (new Device("3F...3")).turnOn();
 }
 [...]
 function turnOff() {
   (new Device("3F...1")).turnOff();
   (new Device("3F...2")).turnOff();
   (new Device("3F...3")).turnOff();
 }
Use sets




 [...]
 function turnOn() {
   (new Set(".addDevices(3F...1, 3F...2, 3F...3)")).turnOn();
 }
 [...]
 function turnOff() {
   (new Set(".addDevices(3F...1, 3F...2, 3F...3)")).turnOff();
 }
S ets

●   Arbitrary list of devices
●   Optimized bus use
●   Possibility to persist (to be implemented)
S et syntax

●   '.' starts at the root (all Devices)
●   .name restricts to a group/zone/device with that name
●   Special functions
    ●   .dsid()
    ●   .fd()
    ●   .group()
    ●   .zone()
S et syntax cont.

●   Set operations
    ●   .add(set)
    ●   .remove(set)
●   .empty()
●   .addDevices(3f..., 'dev1 ...)
                           ',
Examples

●   All devices
    . (< dot)
       -
●   All yellow (light emitting) devices
    .yellow
●   All yellow devices and media devices (magenta)
    .yellow.add(.magenta)
●   All yellow device in zone 3
    .zone(3).yellow
Events




 [...]
 function turnOn() {
   (new HEvent('arriving', '.addDevices(3F...)')).raise();
 }
 [...]
 function turnOff() {
   (new HEvent('leaving', '.addDevices(3F...)')).raise();
 }
 [...]
Event

●   Name
●   Context (Source)
●   Location (Target)
●   Parameter
S ubscriptions

●   Filter
●   Action
●   Loaded from data/subscriptions.xml
Subscriptions
       dS-Bus                        Subscriptions
                                      Subscriptions



                                                      calls handleEvent()
                                                      on every matching
                                                      Subscription


          Event           Queue   Interpreter




SOAP        Web (J SON)
Internaly raised events

●   „callScene“ translates into:
    ●   „bell“ as in door-bell
    ●   „alarm“
    ●   „panic“
●   „model_ready“
●   „modulator_ready“
●   More to come, check the wiki
subscriptions.xml




 [...]
   <subscription event-name="call" handler-name="raise_event">
     <parameter>
       <parameter name="event_name">sendBell</parameter>
     </parameter>
     <flter match="all">
       <property-flter type="matches" value="0797428986" property="source" />
     </flter>
   </subscription>
 [...]
Default handler

●   „raise_event“ raises a new event when
●   „bus_handler“ do stuf on the dS bus (like turnOn/turnOf)
●   „javascript“ call a script
Subscriptions               J avaScript
J avaScript           dS-Bus             Subscriptions
                                          Subscriptions


                                                          calls handleEvent()
                                                          on every matching
                                                          Subscription


              Event            Queue      Interpreter




  SOAP          Web (J SON)
S cripting inside the dS S

●   SpiderMonkey
●   Access to all objects inside the dSS
    ●   Device
    ●   Group
    ●   Zone
    ●   Set
    ●   Event
    ●   Subscription
●   Access to the property tree
Property tree

●   Tree
●   Strings, Ints and booleans (extensible)
●   Changes can be observed (register listeners)
●   Accessible from SOAP, J SON
●   Partially persistent
Property node changes

●   Call code (C+ ) inside the dSS
                  +
●   Call script callback inside the dSS
How to use properties

●   Save the states between diferent runs
●   External inputs (e.g. outside temperature from WebService)
●   Automatic unit conversion
S ave the state between runs




 var count = getProperty('/test/counter'):
 if(count === null) {
   count = 0;
 }
 count++;
 setProperty('/test/counter', count);
Count number of visitors



initialize.js:

var s = subscription('bell', 'javascript', {'flename': 'counter.js'});
s.subscribe();
Count number of visitors



initialize.js:

var s = subscription('bell', 'javascript', {'flename': 'counter.js'});
s.subscribe();



counter.js:

var count = getProperty('/test/counter'):
if(count === null) {
  count = 0;
}
count++;
setProperty('/test/counter', count);
Converting values




 setListener('/temperature/outside-celsius',
  function(prop) {
     setProperty('/temperature/outside-fahrenheit',
       (9/5) * getValue(prop) + 32);
  }
 );
External inputs




 setListener('/temperature/outside-celsius',
  function(prop) {
     setProperty('/heater/histeresis',
       (50 - (getValue(prop))/10);
  }
 );
Further uses

●   Create a proxy device in J S to integrate your gadgets
●   Samples in the wiki
Questions?

pstaehlin@futurelab.ch
Thank you!

More Related Content

What's hot

JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervosoLuis Vendrame
 
Bangun datar dan bangun ruang
Bangun datar dan bangun ruangBangun datar dan bangun ruang
Bangun datar dan bangun ruangSanSan Yagyoo
 
Introduction to Service Workers | Matteo Manchi
Introduction to Service Workers | Matteo ManchiIntroduction to Service Workers | Matteo Manchi
Introduction to Service Workers | Matteo ManchiCodemotion
 
Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftRodrigo Leite
 
Minion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejsMinion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejsMarcelo Gornstein
 
The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196Mahmoud Samir Fayed
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandraKazutaka Tomita
 
Javascript this keyword
Javascript this keywordJavascript this keyword
Javascript this keywordPham Huy Tung
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascriptPavel Volokitin
 
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context LibraryExotel
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsTimur Shemsedinov
 
Java with a Clojure mindset
Java with a Clojure mindsetJava with a Clojure mindset
Java with a Clojure mindsetDaniel Lebrero
 
Paris Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with KafkaParis Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with KafkaFlorian Hussonnois
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)Darwin Durand
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017名辰 洪
 
From Node.js to Design Patterns
From Node.js to Design Patterns From Node.js to Design Patterns
From Node.js to Design Patterns Luciano Mammino
 

What's hot (20)

ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
Angular2 rxjs
Angular2 rxjsAngular2 rxjs
Angular2 rxjs
 
Bangun datar dan bangun ruang
Bangun datar dan bangun ruangBangun datar dan bangun ruang
Bangun datar dan bangun ruang
 
Introduction to Service Workers | Matteo Manchi
Introduction to Service Workers | Matteo ManchiIntroduction to Service Workers | Matteo Manchi
Introduction to Service Workers | Matteo Manchi
 
Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwift
 
Minion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejsMinion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejs
 
The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
 
Javascript this keyword
Javascript this keywordJavascript this keyword
Javascript this keyword
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
 
The jsdom
The jsdomThe jsdom
The jsdom
 
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.js
 
Java with a Clojure mindset
Java with a Clojure mindsetJava with a Clojure mindset
Java with a Clojure mindset
 
Paris Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with KafkaParis Kafka Meetup - How to develop with Kafka
Paris Kafka Meetup - How to develop with Kafka
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017
 
From Node.js to Design Patterns
From Node.js to Design Patterns From Node.js to Design Patterns
From Node.js to Design Patterns
 

Viewers also liked

Zero to Nova: A VMware Admin's Month of Openstack
Zero to Nova: A VMware Admin's Month of OpenstackZero to Nova: A VMware Admin's Month of Openstack
Zero to Nova: A VMware Admin's Month of OpenstackThom Greene
 
Biodiversity and trade promoting sustainable use through business engagement
Biodiversity and trade promoting sustainable use through business engagementBiodiversity and trade promoting sustainable use through business engagement
Biodiversity and trade promoting sustainable use through business engagementIra Kristina Lumban Tobing
 
Cii Event report
Cii Event reportCii Event report
Cii Event reportvinay kumar
 
Property Management Recommendation
Property Management RecommendationProperty Management Recommendation
Property Management RecommendationHaley Saalsaa
 
CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)
CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)
CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)Takako Miyagawa
 
7º año video guía de trabajo y evaluación copia
7º año  video  guía de trabajo y evaluación  copia7º año  video  guía de trabajo y evaluación  copia
7º año video guía de trabajo y evaluación copiaprofesoraudp
 
presentation Martin de Bree
presentation Martin de Breepresentation Martin de Bree
presentation Martin de BreeECR2015
 
presentation Jean Michel Crandal
presentation Jean Michel Crandalpresentation Jean Michel Crandal
presentation Jean Michel CrandalECR2015
 
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt II
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt IIdigitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt II
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt IIdigitalSTROM.org
 

Viewers also liked (13)

Zero to Nova: A VMware Admin's Month of Openstack
Zero to Nova: A VMware Admin's Month of OpenstackZero to Nova: A VMware Admin's Month of Openstack
Zero to Nova: A VMware Admin's Month of Openstack
 
Biodiversity and trade promoting sustainable use through business engagement
Biodiversity and trade promoting sustainable use through business engagementBiodiversity and trade promoting sustainable use through business engagement
Biodiversity and trade promoting sustainable use through business engagement
 
Cii Event report
Cii Event reportCii Event report
Cii Event report
 
Terugblik op 2015
Terugblik op 2015Terugblik op 2015
Terugblik op 2015
 
X39731287 activitat6
X39731287 activitat6X39731287 activitat6
X39731287 activitat6
 
Property Management Recommendation
Property Management RecommendationProperty Management Recommendation
Property Management Recommendation
 
Ict lesson
Ict lessonIct lesson
Ict lesson
 
CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)
CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)
CodeIgniter4 (PHPカンファレンス関西2016 懇親会LT)
 
7º año video guía de trabajo y evaluación copia
7º año  video  guía de trabajo y evaluación  copia7º año  video  guía de trabajo y evaluación  copia
7º año video guía de trabajo y evaluación copia
 
Integrated Compliance
Integrated ComplianceIntegrated Compliance
Integrated Compliance
 
presentation Martin de Bree
presentation Martin de Breepresentation Martin de Bree
presentation Martin de Bree
 
presentation Jean Michel Crandal
presentation Jean Michel Crandalpresentation Jean Michel Crandal
presentation Jean Michel Crandal
 
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt II
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt IIdigitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt II
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt II
 

Similar to dSS API by example

Introducing the WSO2 Complex Event Processor
Introducing the WSO2 Complex Event ProcessorIntroducing the WSO2 Complex Event Processor
Introducing the WSO2 Complex Event ProcessorWSO2
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Event sourcing in the functional world (22 07-2021)
Event sourcing in the functional world (22 07-2021)Event sourcing in the functional world (22 07-2021)
Event sourcing in the functional world (22 07-2021)Vitaly Brusentsev
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
 
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...GITS Indonesia
 
EventBus for Android
EventBus for AndroidEventBus for Android
EventBus for Androidgreenrobot
 
Event Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BEEvent Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BEAndrzej Ludwikowski
 
Event Sourcing - what could go wrong - Jfokus 2022
Event Sourcing - what could go wrong - Jfokus 2022Event Sourcing - what could go wrong - Jfokus 2022
Event Sourcing - what could go wrong - Jfokus 2022Andrzej Ludwikowski
 
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"Fwdays
 
Event sourcing - what could possibly go wrong ? Devoxx PL 2021
Event sourcing  - what could possibly go wrong ? Devoxx PL 2021Event sourcing  - what could possibly go wrong ? Devoxx PL 2021
Event sourcing - what could possibly go wrong ? Devoxx PL 2021Andrzej Ludwikowski
 
Monitoring with Syslog and EventMachine (RailswayConf 2012)
Monitoring  with  Syslog and EventMachine (RailswayConf 2012)Monitoring  with  Syslog and EventMachine (RailswayConf 2012)
Monitoring with Syslog and EventMachine (RailswayConf 2012)Wooga
 
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor WSO2
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwrdeimos
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Paco de la Cruz
 
IPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curseIPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curseYonatan Levin
 

Similar to dSS API by example (20)

Introducing the WSO2 Complex Event Processor
Introducing the WSO2 Complex Event ProcessorIntroducing the WSO2 Complex Event Processor
Introducing the WSO2 Complex Event Processor
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Event sourcing in the functional world (22 07-2021)
Event sourcing in the functional world (22 07-2021)Event sourcing in the functional world (22 07-2021)
Event sourcing in the functional world (22 07-2021)
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
 
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
 
EventBus for Android
EventBus for AndroidEventBus for Android
EventBus for Android
 
Day 1
Day 1Day 1
Day 1
 
Event Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BEEvent Sourcing - what could go wrong - Devoxx BE
Event Sourcing - what could go wrong - Devoxx BE
 
Event Sourcing - what could go wrong - Jfokus 2022
Event Sourcing - what could go wrong - Jfokus 2022Event Sourcing - what could go wrong - Jfokus 2022
Event Sourcing - what could go wrong - Jfokus 2022
 
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
 
Clojure@Nuday
Clojure@NudayClojure@Nuday
Clojure@Nuday
 
Event sourcing - what could possibly go wrong ? Devoxx PL 2021
Event sourcing  - what could possibly go wrong ? Devoxx PL 2021Event sourcing  - what could possibly go wrong ? Devoxx PL 2021
Event sourcing - what could possibly go wrong ? Devoxx PL 2021
 
Monitoring with Syslog and EventMachine (RailswayConf 2012)
Monitoring  with  Syslog and EventMachine (RailswayConf 2012)Monitoring  with  Syslog and EventMachine (RailswayConf 2012)
Monitoring with Syslog and EventMachine (RailswayConf 2012)
 
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
I phone 12
I phone 12I phone 12
I phone 12
 
IPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curseIPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curse
 

More from digitalSTROM.org

digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt I
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt IdigitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt I
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt IdigitalSTROM.org
 
digitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-AppsdigitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-AppsdigitalSTROM.org
 
digitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-AppsdigitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-AppsdigitalSTROM.org
 
digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...
digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...
digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...digitalSTROM.org
 
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...digitalSTROM.org
 
digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...
digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...
digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...digitalSTROM.org
 
digitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-Server
digitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-ServerdigitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-Server
digitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-ServerdigitalSTROM.org
 
digitalSTROM Developer Day 2011: Referat Ludger Hovestadt
digitalSTROM Developer Day 2011: Referat Ludger HovestadtdigitalSTROM Developer Day 2011: Referat Ludger Hovestadt
digitalSTROM Developer Day 2011: Referat Ludger HovestadtdigitalSTROM.org
 
digitalSTROM Interaction Design Concepts
digitalSTROM Interaction Design ConceptsdigitalSTROM Interaction Design Concepts
digitalSTROM Interaction Design ConceptsdigitalSTROM.org
 
digitalSTROM Server Development
digitalSTROM Server DevelopmentdigitalSTROM Server Development
digitalSTROM Server DevelopmentdigitalSTROM.org
 
Contributing to dSS development
Contributing to dSS developmentContributing to dSS development
Contributing to dSS developmentdigitalSTROM.org
 

More from digitalSTROM.org (12)

digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt I
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt IdigitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt I
digitalSTROM Developer Day 2011: Wie digitalSTROM auf das iPhone kommt I
 
digitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-AppsdigitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
 
digitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-AppsdigitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
digitalSTROM Developer Day 2011: digitalSTROM-Server-Apps
 
digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...
digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...
digitalSTROM Developer Day 2011: Wie Heimelektronik und digitalSTROM zusammen...
 
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
digitalSTROM Developer Day 2011: digitalSTROM bindet auch externe Komponenten...
 
digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...
digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...
digitalSTROM Developer Day 2011: Jump Start in die digitalSTROM-Server Entwic...
 
digitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-Server
digitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-ServerdigitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-Server
digitalSTROM Developer Day 2011: Neue Möglichkeiten mit dem digitalSTROM-Server
 
digitalSTROM Developer Day 2011: Referat Ludger Hovestadt
digitalSTROM Developer Day 2011: Referat Ludger HovestadtdigitalSTROM Developer Day 2011: Referat Ludger Hovestadt
digitalSTROM Developer Day 2011: Referat Ludger Hovestadt
 
digitalSTROM Interaction Design Concepts
digitalSTROM Interaction Design ConceptsdigitalSTROM Interaction Design Concepts
digitalSTROM Interaction Design Concepts
 
digitalSTROM Server Development
digitalSTROM Server DevelopmentdigitalSTROM Server Development
digitalSTROM Server Development
 
UPnP and digitalSTROM
UPnP and digitalSTROMUPnP and digitalSTROM
UPnP and digitalSTROM
 
Contributing to dSS development
Contributing to dSS developmentContributing to dSS development
Contributing to dSS development
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

dSS API by example

  • 1. dS S A PI by example Patrick S tählin, futureLA B A G pstaehlin@futurelab.ch
  • 2. Demo setup dSS Serial dSID dSM 230V MacBook RS485 Device
  • 4. Include model.js [...] <script src="js/model.js" language="JavaScript" type="text/javascript"> </script> [...]
  • 5. S etup js functions [...] function turnOn() { (new Device("3F...")).turnOn(); } [...] function turnOff() { (new Device("3F...")).turnOff(); }
  • 6. Hook it up [...] <a href="javascript:turnOn()">Turn on</a> <a href="javascript:turnOff()">Turn off</a> [...]
  • 7. Recap ● Put .html into webroot of dSS ● Include /js/model.js ● Code! ;-)
  • 8. Avoid code like that [...] function turnOn() { (new Device("3F...1")).turnOn(); (new Device("3F...2")).turnOn(); (new Device("3F...3")).turnOn(); } [...] function turnOff() { (new Device("3F...1")).turnOff(); (new Device("3F...2")).turnOff(); (new Device("3F...3")).turnOff(); }
  • 9. Use sets [...] function turnOn() { (new Set(".addDevices(3F...1, 3F...2, 3F...3)")).turnOn(); } [...] function turnOff() { (new Set(".addDevices(3F...1, 3F...2, 3F...3)")).turnOff(); }
  • 10. S ets ● Arbitrary list of devices ● Optimized bus use ● Possibility to persist (to be implemented)
  • 11. S et syntax ● '.' starts at the root (all Devices) ● .name restricts to a group/zone/device with that name ● Special functions ● .dsid() ● .fd() ● .group() ● .zone()
  • 12. S et syntax cont. ● Set operations ● .add(set) ● .remove(set) ● .empty() ● .addDevices(3f..., 'dev1 ...) ',
  • 13. Examples ● All devices . (< dot) - ● All yellow (light emitting) devices .yellow ● All yellow devices and media devices (magenta) .yellow.add(.magenta) ● All yellow device in zone 3 .zone(3).yellow
  • 14. Events [...] function turnOn() { (new HEvent('arriving', '.addDevices(3F...)')).raise(); } [...] function turnOff() { (new HEvent('leaving', '.addDevices(3F...)')).raise(); } [...]
  • 15. Event ● Name ● Context (Source) ● Location (Target) ● Parameter
  • 16. S ubscriptions ● Filter ● Action ● Loaded from data/subscriptions.xml
  • 17. Subscriptions dS-Bus Subscriptions Subscriptions calls handleEvent() on every matching Subscription Event Queue Interpreter SOAP Web (J SON)
  • 18. Internaly raised events ● „callScene“ translates into: ● „bell“ as in door-bell ● „alarm“ ● „panic“ ● „model_ready“ ● „modulator_ready“ ● More to come, check the wiki
  • 19. subscriptions.xml [...] <subscription event-name="call" handler-name="raise_event"> <parameter> <parameter name="event_name">sendBell</parameter> </parameter> <flter match="all"> <property-flter type="matches" value="0797428986" property="source" /> </flter> </subscription> [...]
  • 20. Default handler ● „raise_event“ raises a new event when ● „bus_handler“ do stuf on the dS bus (like turnOn/turnOf) ● „javascript“ call a script
  • 21. Subscriptions J avaScript J avaScript dS-Bus Subscriptions Subscriptions calls handleEvent() on every matching Subscription Event Queue Interpreter SOAP Web (J SON)
  • 22. S cripting inside the dS S ● SpiderMonkey ● Access to all objects inside the dSS ● Device ● Group ● Zone ● Set ● Event ● Subscription ● Access to the property tree
  • 23. Property tree ● Tree ● Strings, Ints and booleans (extensible) ● Changes can be observed (register listeners) ● Accessible from SOAP, J SON ● Partially persistent
  • 24. Property node changes ● Call code (C+ ) inside the dSS + ● Call script callback inside the dSS
  • 25. How to use properties ● Save the states between diferent runs ● External inputs (e.g. outside temperature from WebService) ● Automatic unit conversion
  • 26. S ave the state between runs var count = getProperty('/test/counter'): if(count === null) { count = 0; } count++; setProperty('/test/counter', count);
  • 27. Count number of visitors initialize.js: var s = subscription('bell', 'javascript', {'flename': 'counter.js'}); s.subscribe();
  • 28. Count number of visitors initialize.js: var s = subscription('bell', 'javascript', {'flename': 'counter.js'}); s.subscribe(); counter.js: var count = getProperty('/test/counter'): if(count === null) { count = 0; } count++; setProperty('/test/counter', count);
  • 29. Converting values setListener('/temperature/outside-celsius', function(prop) { setProperty('/temperature/outside-fahrenheit', (9/5) * getValue(prop) + 32); } );
  • 30. External inputs setListener('/temperature/outside-celsius', function(prop) { setProperty('/heater/histeresis', (50 - (getValue(prop))/10); } );
  • 31. Further uses ● Create a proxy device in J S to integrate your gadgets ● Samples in the wiki