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

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 

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