Outils pour utilisateurs

Outils du site


Panneau latéral

Accueil

Select other language :


Apprentissage

Enseignements

Enseignements Département Informatique SI5 et Master IFI

Enseignements Département Bâtiment Polytech'Nice

Autres Formations française et étrangère

Activités administratives, Ingénierie et Innovation Pédagogiques

Apprentissage Département Informatique SI5/Master 2 ingénierie informatique EUR DS4H


Recherche

Valorisation de la Recherche

Dépôts Logiciels à l’Agence de Protection des Programme (APP)

Valorisation des résultats de recherche et transfert

Diffusion de la Culture scientifique et Technologique

Communications de presse

Séminaire ENSI Tunis

Pédagogie Innovante

Relations industrielles et socio-économique

Organisation de Manifestations

  • Conférence sur les FabLabs, Alexandre Schneider, Professeur Agrégé en Génie Mécanique, Université de Reims Champagne-Ardenne Web
  • Journées UbiMob'14 Site Web

Animation de la Recherche

U-Santé

Privé

Outils

Sources d'Informations

cours:ds4hiot:correcions
Web Services Accesses

be careful, if you want to use Web Services to access to ThingSpeak first you must create channels to publish data and get the corresponding keys

  • Dataflow that publishes/displays a changing data in ThingSpeak, using timer

This example uses a key of the 275 public channel : https://sparks-vm24.i3s.unice.fr/channels/275

[{"id":"b6ba693.b940298","type":"inject","z":"2ce2a219.894e3e","name":"Inject data","topic":"","payload":"-5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":580,"wires":[["d23c2100.93cbc"]]},{"id":"9dde6e7f.3cd66","type":"delay","z":"2ce2a219.894e3e","name":"delai repet","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":390,"y":660,"wires":[["7db93689.4f46c8"]]},{"id":"a61123ff.96303","type":"http request","z":"2ce2a219.894e3e","name":"","method":"GET","ret":"txt","url":"https://sparks-vm24.i3s.unice.fr/update?key=F5OBSRU54WPK0XSA&field1={{{field1}}}&field2={{{field2}}}&field3={{{field3}}}&field4={{{field4}}}","tls":"","x":620,"y":580,"wires":[[]]},{"id":"d23c2100.93cbc","type":"function","z":"2ce2a219.894e3e","name":"set fields","func":"msg.field1 = msg.payload;\nmsg.field2 = msg.payload + 1;\nmsg.field3 = msg.payload - 1;\nmsg.field4 = msg.payload * 2;\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":580,"wires":[["9dde6e7f.3cd66","a61123ff.96303"]]},{"id":"7db93689.4f46c8","type":"function","z":"2ce2a219.894e3e","name":"increment","func":"msg.payload++;\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":720,"wires":[["d23c2100.93cbc"]]}]
  
* Dataflow that gets weather information on OpenWeatherMap Web Service (here, students can use my API key but without any guarantee). In case of problem, get your own API key after free registration.
 [{"id":"452441aa.07cbd","type":"inject","z":"2ce2a219.894e3e","name":"","topic":"","payload":"Biot,FR","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":810,"y":400,"wires":[["abb00141.4754c"]]},{"id":"65daee20.15c48","type":"inject","z":"2ce2a219.894e3e","name":"","topic":"","payload":"Moscow,RU","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":830,"y":460,"wires":[["abb00141.4754c"]]},{"id":"abb00141.4754c","type":"http request","z":"2ce2a219.894e3e","name":"OpenWeatherMap Request","method":"GET","ret":"txt","url":"http://api.openweathermap.org/data/2.5/weather?q={{{payload}}}&appid=8e35e9a5638ee0540022a6b38d9ea89c","tls":"","x":1040,"y":380,"wires":[["10bf958d.e421aa"]]},{"id":"fc448289.27d86","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1250,"y":440,"wires":[]},{"id":"10bf958d.e421aa","type":"function","z":"2ce2a219.894e3e","name":"parse and format","func":"var obj = JSON.parse(msg.payload);\nmsg.payload = obj.name + \":\" + obj.weather[0].main;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":480,"wires":[["fc448289.27d86"]]}]
Dataflow that gets information from OpenHAB
  • using a OpenHab MQTT flow
         [{"id":"7e96c990.582bf8","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"openhab/#","qos":"2","broker":"aa872460.7dff18","x":120,"y":160,"wires":[["e6cd4834.c78e68"]]},{"id":"e6cd4834.c78e68","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":390,"y":160,"wires":[]},{"id":"420c7771.ed7e08","type":"mqtt out","z":"2ce2a219.894e3e","name":"","topic":"openhab/zwave_device_1b2be295_node4_switch_binary/commandssub","qos":"","retain":"","broker":"aa872460.7dff18","x":1000,"y":160,"wires":[]},{"id":"2bfce164.02ee0e","type":"inject","z":"2ce2a219.894e3e","name":"Prise ON","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":620,"y":140,"wires":[["420c7771.ed7e08"]]},{"id":"1165f273.5a523e","type":"inject","z":"2ce2a219.894e3e","name":"Prise OFF","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":620,"y":180,"wires":[["420c7771.ed7e08"]]},{"id":"aa872460.7dff18","type":"mqtt-broker","z":"","name":"192.168.137.93","broker":"192.168.137.93","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
  • using the OpenHab REST API
[{"id":"b72e122c.7d834","type":"inject","z":"2ce2a219.894e3e","name":"Prise ON","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":840,"y":580,"wires":[["ba7d98c.9efac68"]]},{"id":"5bf29976.e28098","type":"inject","z":"2ce2a219.894e3e","name":"Prise OFF","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":840,"y":620,"wires":[["ba7d98c.9efac68"]]},{"id":"ba7d98c.9efac68","type":"http request","z":"2ce2a219.894e3e","name":"OpenHAB Node4","method":"POST","ret":"txt","url":"http://192.168.137.93:8080/rest/items/zwave_device_1b2be295_node4_switch_binary","tls":"","x":1050,"y":600,"wires":[["96d0f087.426fa"]]},{"id":"96d0f087.426fa","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1260,"y":600,"wires":[]}]
Loop to read OpenHab sensor value
[{"id":"5e2906c6.ff0a28","type":"http request","z":"a1550bd9.1468c8","name":"","method":"GET","ret":"txt","url":"http://192.168.1.134:8080/rest/items/zwave_device_1b2be295_node10_sensor_temperature/state","tls":"","x":406.10003662109375,"y":180.1999969482422,"wires":[["abf47735.d71a28"]]},{"id":"61272c17.7ce984","type":"inject","z":"a1550bd9.1468c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":272.1000061035156,"y":73,"wires":[["5e2906c6.ff0a28"]]},{"id":"abf47735.d71a28","type":"debug","z":"a1550bd9.1468c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":624.1000366210938,"y":180.40000915527344,"wires":[]}]
[{"id":"a1550bd9.1468c8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"5e2906c6.ff0a28","type":"http request","z":"a1550bd9.1468c8","name":"","method":"GET","ret":"txt","url":"http://192.168.1.134:8080/rest/items/zwave_device_1b2be295_node10_sensor_luminance/state","tls":"","x":406.10003662109375,"y":180.1999969482422,"wires":[["abf47735.d71a28","89172555.a47bc8"]]},{"id":"61272c17.7ce984","type":"inject","z":"a1550bd9.1468c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":272.1000061035156,"y":73,"wires":[["5e2906c6.ff0a28"]]},{"id":"abf47735.d71a28","type":"debug","z":"a1550bd9.1468c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":624.1000366210938,"y":180.40000915527344,"wires":[]},{"id":"89172555.a47bc8","type":"http request","z":"a1550bd9.1468c8","name":"","method":"GET","ret":"txt","url":"https://sparks-vm24.i3s.unice.fr/update?key=F5OBSRU54WPK0XSA&field1={{{payload}}}","tls":"","x":519.1000366210938,"y":276,"wires":[[]]}]--
Correction for optionnal Home IO manipulations

Find in the Home I/O installation directory, a zip/csv file that gives the sensors list with prefixes A,B,C …

  • Dataflow that get boolean sensors information in room A
[{"id":"72ccc74c.836b88","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Input/bool/#","qos":"2","broker":"53b33537.72499c","x":200,"y":360,"wires":[["7f13ecda.da48c4"]]},{"id":"7f13ecda.da48c4","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":460,"y":360,"wires":[]},{"id":"53b33537.72499c","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"",
        "closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
  • Dataflow that controls lights in room A
[{"id":"18542933.86d2c7","type":"mqtt out","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Output/bool/Lights","qos":"","retain":"","broker":"53b33537.72499c","x":540,"y":460,"wires":[]},{"id":"3b14a0e3.3cf4c","type":"inject","z":"2ce2a219.894e3e","name":"Lampes ON","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":440,"wires":[["18542933.86d2c7"]]},{"id":"9cc3ec49.cc846","type":"inject","z":"2ce2a219.894e3e","name":"Lampes OFF","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":480,"wires":[["18542933.86d2c7"]]},{"id":"53b33537.72499c","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Link one Home IO virtual switch to a real light in OpenHab

[{"id":"63cba22a.43de3c","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Input/bool/Up-Down_Switch_1_(Up)","qos":"2","broker":"53b33537.72499c","x":310,"y":960,"wires":[["88c2d0ba.4c8b9"]]},{"id":"779f82d3.a80d4c","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Input/bool/Up-Down_Switch_1_(Down)","qos":"2","broker":"53b33537.72499c","x":320,"y":1020,"wires":[["e44a55cd.753418"]]},{"id":"88c2d0ba.4c8b9","type":"switch","z":"2ce2a219.894e3e","name":"filter true","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":960,"wires":[["529f2ff8.62271"]]},{"id":"e44a55cd.753418","type":"switch","z":"2ce2a219.894e3e","name":"filter true","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":1020,"wires":[["63d5e341.6a145c"]]},{"id":"529f2ff8.62271","type":"change","z":"2ce2a219.894e3e","name":"convert payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":960,"wires":[["37074f0a.af995"]]},{"id":"63d5e341.6a145c","type":"change","z":"2ce2a219.894e3e","name":"convert payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":1020,"wires":[["37074f0a.af995"]]},{"id":"37074f0a.af995","type":"mqtt out","z":"2ce2a219.894e3e","name":"","topic":"openhab/zwave_device_1b2be295_node4_switch_binary/commandssub","qos":"","retain":"","broker":"aa872460.7dff18","x":1230,"y":1000,"wires":[]},{"id":"53b33537.72499c","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"aa872460.7dff18","type":"mqtt-broker","z":"","name":"192.168.137.93","broker":"192.168.137.93","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
cours/ds4hiot/correcions.txt · Dernière modification: 2018/10/19 07:46 par tigli