How to Wake Up Like a God? LYO.

by yoav.bermand in Craft > Art

605 Views, 1 Favorites, 0 Comments

How to Wake Up Like a God? LYO.

LYO 3

Created by: Lidor Cohen, Yoav Bermand, Atabek Sherman

It's that time of the day (or night), in which you are, again, needing to leap out of your comfortable bed and start your active part of the day; saggy, tired and probably extremely unhappy.

We know your struggle too well, as undergrad students. This couldn't be an utter truth - there has to be a way in which we could simply wake up, and feel... chill.

Therefore, we decided to take on an adventure and build a remote system that will do exactly that, from anywhere in the world, as part of our university IoT class.

Without any further adieu - introducing LYO!

What's involved?

  • Automatic monitor control to kick off your morning routine with your favorite sceneries, shows or just a cute rabbit picture screened.
  • Automatic shutters control so that your eyes start adjusting to the colors of the outside world!
  • Automatic air conditioning control if you don't fancy snuggling your blanket in the bathroom
  • Automatic lights control if the sun isn't enough
  • Automatic speakers control because it's never too late to decide: Britney or Beyoncé?

Supplies

  • 1 x Raspberry Pie 4 Model B (or less)
  • 2 x Wemos D1 Mini with WiFi ESP8266
  • 1 x IR Remote Led
  • 1 x DHT Shield for the Wemos above
  • 1 x BC547B Transistor
  • 1 x Diks-on-key
  • 1 x Micro SD Card (8GB or more)
  • 1 x 5V battery
  • 1 x 1 Channel 5V Relay Module for Arduino
  • 1 x DC Motor
  • 1 x Arduino Motion Sensor

Before we send you away to build such a system on your own, we would like to thank our awesome IoT professor Zvika Markfeld!

Now all you have to do is to fasten your seatbelts and enjoy the ride!

Our Flow

WhatsApp Image 2020-08-30 at 21.43.33.jpeg

Our system is comprised of 3 separate units, each functions and operates different units of our system.

The first, is our Raspberry Pie board. This board operates as a service which enables communication from the outer world, as well as control over things like playing music using Spotify through the speakers using WiFi. This board is the "brain", the bread and butter of the system. It also decides which actions will be executed.

It also controls our other 2 units -

The one we use in order to control the shutters, which is the D1 unit, and another one, the DHT, which we use in order to indicate climate levels to accommodate and "normalise" it according to our preferences, as well as controlling the lights, the air-conditioning, and television.

Prepare Your Raspberry Pie

flow-node-red.png

1. Firstly, install the 'Home Assistant' system from the following link:

https://www.home-assistant.io/hassio/installation/ (follow the installation instructions from there)

2. In the disk-on-key, create a new folder named 'network'. Inside it, create another folder and name it 'my- 'network.txt' with the following text inside it:

[connection]
id=my-network
uuid=d55162b4-6152-4310-9312-8f4c54d86afa
type=802-3-ethernet

[ipv4]
method=manual
address=192.168.1.111/24;192.168.1.1
dns=8.8.8.8;8.8.4.4;<br>

Note: make sure to switch between the 'address' given in our example, to your IPV4/default gateway.

3. Connect your disk-on-key into your Raspberry Pie board, and connect it to the Ethernet cable.

4. Go to the following URL:

http://homeassistant.local:8123/ (if that doesn't work, try with the IPV4 internal Raspberry address with port 8123)

5. After the page was redirected, click on the 'Supervisor' button, then 'Add on store', and install:

  • Duck DNS - lets you be connected with a URL instead of an IP (sign-up to the website duckdns.org and edit your add-ons where you must define your access token).
  • Mosquito Broker - lets you control and communicate with the other boards, and your phone.
  • NodeRed - flow-based programming for the IoT (used to code the way we manage the system)
  • Spotify Connect - lets the Raspberry control the Spotify

6. Go to the left menu on the NodeRed page, and this is where you build all of your actions needed in order to communicate and control the whole system (you can use MQTT-out server nodes to listen or write signals, as they are the building blocks needed to create pulls).

Our example code flow - Node Red(for importing):

[{"id":"d6e0df6.12d3f2","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5fa86ccd.869264","type":"server","z":"","name":"Home Assistant","addon":true},{"id":"dde7e643.e8ebf8","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"200","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"f506d055.9b50b","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false},{"id":"e1486445.adcb18","type":"ui_group","z":"","name":"Default","tab":"f506d055.9b50b","order":1,"disp":true,"width":"6","collapse":false},{"id":"989c332b.71e4d","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"60bdb1b5.02d8d","type":"shared-state","z":"","name":"AlarmOn","historyCount":"2"},{"id":"9f679da5.035dd","type":"shared-state","z":"","name":"AlarmOff","historyCount":"2"},{"id":"f9e2ad7a.c77d2","type":"spotify-auth","z":"","name":"Spotify OAuth2","scope":"ugc-image-upload\nuser-read-playback-state\nuser-modify-playback-state\nuser-read-currently-playing\nstreaming\napp-remote-control\nuser-read-email\nuser-read-private\nplaylist-read-collaborative\nplaylist-modify-public\nplaylist-read-private\nplaylist-modify-private\nuser-library-modify\nuser-library-read\nuser-top-read\nuser-read-playback-position\nuser-read-recently-played\nuser-follow-read\nuser-follow-modify"},{"id":"b55d259e.1f1708","type":"ha-entity","z":"d6e0df6.12d3f2","name":"Movment Sensor","server":"5fa86ccd.869264","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"MovmentSensor"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":570,"y":120,"wires":[[]]},{"id":"eeaf1312.d1881","type":"function","z":"d6e0df6.12d3f2","name":"","func":"\nflow.set('movment',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":120,"wires":[[]]},{"id":"54d755b6.507c7c","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"alarmTemp","qos":"2","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":360,"wires":[["3cda910a.54ce5e"]]},{"id":"cc4c22f6.8e7d3","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"alarmStatus","qos":"1","datatype":"auto","broker":"dde7e643.e8ebf8","x":150,"y":840,"wires":[["42e26142.fe228"]]},{"id":"3cda910a.54ce5e","type":"function","z":"d6e0df6.12d3f2","name":"","func":"flow.set('alarmTemp',msg.payload);","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":360,"wires":[[]]},{"id":"42e26142.fe228","type":"function","z":"d6e0df6.12d3f2","name":"","func":"flow.set('alarmStatus',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":840,"wires":[[]]},{"id":"f176b812.4a7098","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"inputTemp","qos":"2","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":420,"wires":[["e6a0282b.ef0c38","759ca436.c4bb0c"]]},{"id":"e6a0282b.ef0c38","type":"function","z":"d6e0df6.12d3f2","name":"COOLIX PROTOCOL","func":"var a= [{\"mqtt_dashboard\":{\"mode\":\"cool\",\"setpoint\":24.5}}];\na= [JSON.parse(msg.payload)];\n\nif(a[0].mqtt_dashboard.mode===\"off\"){\n    msg.payload=0xB27BE0;\n    return msg;  \n}else{\n    //console.log(a[0].mqtt_dashboard.mode);\n    var mode = {\"cool\": 0b00, \"auto\" : 0b10, \"heat\" : 0b11};\n\n    //console.log(mode.cool)\n    \n     \n    var temp = {\n      \"n17\": 0b0000, \"n18\" : 0b0001, \"n19\" : 0b0011, \"n20\": 0b0010, \n      \"n21\" : 0b0110, \"n22\" : 0b0111, \"n23\": 0b0101, \"n24\" : 0b0100, \n      \"n25\" : 0b1100, \"n26\": 0b1101, \"n27\" : 0b1001, \"n28\" : 0b1000, \n      \"n29\": 0b1010, \"n30\" : 0b1011}\n    //alert(setpoint[0].((int)a[0].mqtt_dashboard.setpoint));\n    var res = 0b1011001000011111;\n    \n    //console.log(temp.n30);\n    if(a[0].hasOwnProperty('mqtt_dashboard')){\n        var fixed = \"n\" + parseInt(a[0]['mqtt_dashboard']['setpoint'])\n        \n        //console.log(a[0].mqtt_dashboard.mode);\n        \n        \n        //temp:\n        res = res << 4;\n        res = res | temp[fixed]\n        //console.log(res.toString(2));\n        \n        \n        //mode:\n        res = res << 2;\n        res = res | mode[a[0].mqtt_dashboard.mode]\n        //console.log(res.toString(2));\n        \n        \n        //last parameter:\n        res = res <<2;\n        \n       \n      \n    msg.payload=res;\n    }\n    return msg;   \n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":420,"wires":[["67550c8f.f905e4"]]},{"id":"67550c8f.f905e4","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"sendCoolixIR","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":590,"y":420,"wires":[]},{"id":"b4e70241.84fe9","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"TVswitch","qos":"2","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":480,"wires":[["1021854.1634e7b","886ec7d3.c24118"]]},{"id":"813fda55.05c2e8","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"sendSamsungIR","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":590,"y":480,"wires":[]},{"id":"1021854.1634e7b","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload=Number(\"0x\"+msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":480,"wires":[["813fda55.05c2e8"]]},{"id":"2aa5ec11.9f3d54","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"temp","qos":"1","datatype":"auto","broker":"dde7e643.e8ebf8","x":130,"y":240,"wires":[["33da0892.4fac38"]]},{"id":"4d7fb1fd.2ab8f","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"humidity","qos":"1","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":180,"wires":[["d7a4a832.ca8e48"]]},{"id":"c7378713.51aa18","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"movment","qos":"1","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":120,"wires":[["eeaf1312.d1881"]]},{"id":"ba296687.15efe8","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"alarmTime","qos":"2","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":300,"wires":[["387a34d5.f3f4fc","759ca436.c4bb0c"]]},{"id":"387a34d5.f3f4fc","type":"function","z":"d6e0df6.12d3f2","name":"","func":"flow.set('AlarmTime',msg.payload);\nflow.set('SpotifyFire',false);\nflow.set('SpotifyStopFire',true);\nmsg.payload=\"On\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":300,"wires":[["511c97bb.4abb08"]]},{"id":"eedd0e82.b9688","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"TempList","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":580,"y":240,"wires":[]},{"id":"33da0892.4fac38","type":"function","z":"d6e0df6.12d3f2","name":"","func":"let TempList;\nif(!flow.get('TempList')){\n    TempList = ['0'];\n    flow.set('TempList', TempList);\n}else{\n    TempList = flow.get('TempList', TempList);\n}\n\nTempList.push(msg.payload);\n\nif(TempList.length>20)\n    TempList.shift();\nmsg.payload = TempList;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":240,"wires":[["eedd0e82.b9688"]]},{"id":"d7a4a832.ca8e48","type":"function","z":"d6e0df6.12d3f2","name":"","func":"let HumidityList;\nif(!flow.get('HumidityList')){\n    HumidityList = ['0'];\n    flow.set('HumidityList', HumidityList);\n}else{\n    HumidityList = flow.get('HumidityList', HumidityList);\n}\n\nHumidityList.push(msg.payload);\n\nif(HumidityList.length>20)\n    HumidityList.shift();\nmsg.payload = HumidityList;\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":180,"wires":[["17368647.ae64aa"]]},{"id":"17368647.ae64aa","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"HumidityList","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":590,"y":180,"wires":[]},{"id":"511c97bb.4abb08","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"alarmStatus","qos":"2","retain":"","broker":"dde7e643.e8ebf8","x":590,"y":300,"wires":[]},{"id":"759ca436.c4bb0c","type":"debug","z":"d6e0df6.12d3f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":330,"y":60,"wires":[]},{"id":"3ff79c05.539df4","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"moveList","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":540,"y":920,"wires":[]},{"id":"88cda12a.ecdf2","type":"function","z":"d6e0df6.12d3f2","name":"","func":"let MoveList;\nlet i=0;\nif(!flow.get('MoveList')){\n    MoveList = ['0'];\n    flow.set('MoveList', MoveList);\n}else{\n    MoveList = flow.get('MoveList', MoveList);\n}\n\nif((i%15)===0){\n    MoveList.push(msg.payload);\n}\ni++;\nif(MoveList.length>20)\n    MoveList.shift();\nmsg.payload = MoveList;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":920,"wires":[["3ff79c05.539df4"]]},{"id":"5815f3f0.c4b52c","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"movment","qos":"1","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":920,"wires":[["88cda12a.ecdf2"]]},{"id":"23d301c6.b0b6be","type":"function","z":"d6e0df6.12d3f2","name":"","func":"var currentdate = new Date();\nvar datetime = currentdate.getHours() + \":\" + currentdate.getMinutes();\nmsg.payload = datetime;\nflow.set('datetime',datetime);\n\nif(((flow.get('datetime') || 0)==(flow.get('AlarmTime')||0)))\n{\n    if(flow.get('alarmStatus')==\"On\"){\n        msg.payload=flow.get('alarmTemp',msg.payload);\n        return msg;\n    }\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":1080,"wires":[["3482a35e.68237c"]]},{"id":"b34b8581.98fa38","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"sendSamsungIR","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":1110,"y":1380,"wires":[]},{"id":"b72a1de2.72123","type":"http request","z":"d6e0df6.12d3f2","name":"Spotify token","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://accounts.spotify.com/api/token","tls":"","persist":false,"proxy":"","authType":"","x":830,"y":1520,"wires":[["1954526d.244f6e","e3421e34.c2a35"]]},{"id":"41234c5e.920f04","type":"function","z":"d6e0df6.12d3f2","name":"headers","func":"    msg.headers = {};\n    msg.headers['Accept'] = 'application/json'\n    msg.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'\n    msg.headers['Authorization'] = 'Bearer {change me}';\n    \n    msg.payload=\"grant_type=client_credentials\";\n    return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":1520,"wires":[["b72a1de2.72123"]]},{"id":"1bae56f8.8fa1d9","type":"debug","z":"d6e0df6.12d3f2","name":"http debug","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1850,"y":1400,"wires":[]},{"id":"1954526d.244f6e","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload = JSON.parse(msg.payload).access_token;\nflow.set('SpotifyToken',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":1080,"y":1460,"wires":[["e93f2ec6.4dce4","3d27c4e4.09029c"]]},{"id":"1c1992a2.858e5d","type":"http request","z":"d6e0df6.12d3f2","name":"Spotify Play","method":"PUT","ret":"txt","paytoqs":"ignore","url":"https://api.spotify.com/v1/me/player/play?device_id={change to your device}","tls":"","persist":false,"proxy":"","authType":"","x":1610,"y":1340,"wires":[["1bae56f8.8fa1d9","574bdb12.10d7b4"]]},{"id":"e93f2ec6.4dce4","type":"function","z":"d6e0df6.12d3f2","name":"headers","func":"\n    flow.set('SpotifyFire',true);\n    flow.set('SpotifyStopFire',false);\n    msg.payload = \"{\\\"context_uri\\\":\\\"spotify:playlist:0JkOlVGtLNcRgGACwOjvsQ\\\",\\\"position_ms\\\":0}\"\n    msg.headers = {};\n    msg.headers['Accept'] = 'application/json'\n    msg.headers['Content-Type'] = 'application/json'\n   msg.headers['Authorization'] = 'Bearer {change your}';\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":1340,"wires":[["1c1992a2.858e5d"]]},{"id":"4101a69b.d361d8","type":"http request","z":"d6e0df6.12d3f2","name":"Spotify Volume","method":"PUT","ret":"txt","paytoqs":"ignore","url":"https://api.spotify.com/v1/me/player/volume?volume_percent=100","tls":"","persist":false,"proxy":"","authType":"","x":1620,"y":1400,"wires":[["1bae56f8.8fa1d9"]]},{"id":"3d27c4e4.09029c","type":"function","z":"d6e0df6.12d3f2","name":"headers","func":"\n    flow.set('SpotifyFire',true);\n    flow.set('SpotifyStopFire',false);\n    msg.payload = \"{\\\"context_uri\\\":\\\"spotify:playlist:0JkOlVGtLNcRgGACwOjvsQ\\\",\\\"position_ms\\\":0}\"\n    msg.headers = {};\n    msg.headers['Accept'] = 'application/json'\n    msg.headers['Content-Type'] = 'application/json'\n   msg.headers['Authorization'] = 'Bearer '+flow.get('SpotifyToken');\n   \n  msg.headers['Authorization'] = 'Bearer BQANTh3VEi9FrF5z9z1gbkRa-aKT5OLBOkDdWoDDWir5MTgvmp-seaeWz32YBiCn-URI_BTERKbWpg3Sc2SpDq5LKCFadFkOAU7QrNEWSBYmkJARdqXckEJw5JyUtTKcHM38kb4v0wiThX9k09t5ikVSRt9uMRSLGW9zxk5pnpiVBwYkFQEb8zvs70rt6vCtKXbE0t9qwLzl6qBs3G8bfs1KhnoYsaRf0ASgwTbxlYg9tQBbRcc_WPFmD0vjaQOqsjo9DYrYduHndUw';\n   return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":1400,"wires":[["4101a69b.d361d8"]]},{"id":"3bc3a71f.bcbf88","type":"inject","z":"d6e0df6.12d3f2","name":"","props":[{"p":"payload"}],"repeat":"60","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":460,"y":1080,"wires":[["23d301c6.b0b6be"]]},{"id":"6733c0d6.fe00c","type":"inject","z":"d6e0df6.12d3f2","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":480,"y":1520,"wires":[["41234c5e.920f04"]]},{"id":"56111257.9cebcc","type":"function","z":"d6e0df6.12d3f2","name":"הדלקת טלויזיה","func":"msg.payload = 0x40BF;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":1280,"wires":[["b34b8581.98fa38","e93f2ec6.4dce4","3d27c4e4.09029c","9ccfcaa4.801c18"]]},{"id":"f2c11562.16e668","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"alarmStatus","qos":"2","retain":"","broker":"dde7e643.e8ebf8","x":2170,"y":1340,"wires":[]},{"id":"2d3eb04d.66866","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload = \"Off\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2000,"y":1340,"wires":[["f2c11562.16e668"]]},{"id":"574bdb12.10d7b4","type":"delay","z":"d6e0df6.12d3f2","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1820,"y":1340,"wires":[["2d3eb04d.66866"]]},{"id":"7ee356e2.ce3458","type":"function","z":"d6e0df6.12d3f2","name":"אישור","func":"msg.payload = 0x16E9;\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":1380,"wires":[["b34b8581.98fa38"]]},{"id":"9ccfcaa4.801c18","type":"delay","z":"d6e0df6.12d3f2","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":640,"y":1380,"wires":[["7ee356e2.ce3458"]]},{"id":"3482a35e.68237c","type":"function","z":"d6e0df6.12d3f2","name":"COOLIX PROTOCOL","func":"var a= [{\"mqtt_dashboard\":{\"mode\":\"cool\",\"setpoint\":24.5}}];\na= [JSON.parse(msg.payload)];\n\nif(a[0].mqtt_dashboard.mode==\"off\"){\n    msg.payload=0xB27BE0;\n    return msg;  \n}else{\n    //console.log(a[0].mqtt_dashboard.mode);\n    var mode = {\"cool\": 0b00, \"auto\" : 0b10, \"heat\" : 0b11};\n\n    //console.log(mode.cool)\n    \n     \n     var temp = {\n      \"n17\": 0b0000, \"n18\" : 0b0001, \"n19\" : 0b0011, \"n20\": 0b0010, \n      \"n21\" : 0b0110, \"n22\" : 0b0111, \"n23\": 0b0101, \"n24\" : 0b0100, \n      \"n25\" : 0b1100, \"n26\": 0b1101, \"n27\" : 0b1001, \"n28\" : 0b1000, \n      \"n29\": 0b1010, \"n30\" : 0b1011}\n    //alert(setpoint[0].((int)a[0].mqtt_dashboard.setpoint));\n    var res = 0b1011001000011111;\n    \n    //console.log(temp.n30);\n    if(a[0].hasOwnProperty('mqtt_dashboard')){\n        var fixed = \"n\" + parseInt(a[0]['mqtt_dashboard']['setpoint'])\n        \n        //console.log(a[0].mqtt_dashboard.mode);\n        \n        \n        //temp:\n        res = res << 4;\n        res = res | temp[fixed]\n        //console.log(res.toString(2));\n        \n        \n        //mode:\n        res = res << 2;\n        res = res | mode[a[0].mqtt_dashboard.mode]\n        //console.log(res.toString(2));\n        \n        \n        //last parameter:\n        res = res <<2;\n        \n       \n      \n    msg.payload=res;\n    }\n    return msg;   \n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":1080,"wires":[["3f42361b.48b4ca","5e9e760c.2ed478"]]},{"id":"3f42361b.48b4ca","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"sendCoolixIR","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":1100,"y":1080,"wires":[]},{"id":"5e9e760c.2ed478","type":"delay","z":"d6e0df6.12d3f2","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":650,"y":1160,"wires":[["7eff6ec2.5fb7e","e72e9202.d595f"]]},{"id":"7eff6ec2.5fb7e","type":"function","z":"d6e0df6.12d3f2","name":"turnON","func":"msg.payload = 0xF7C03F;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":830,"y":1160,"wires":[["71a9556e.5c591c","ee8accb7.6d658","fafc66b5.027608"]]},{"id":"5097e1db.e5d46","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload=0xF700FF;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":1240,"wires":[["71a9556e.5c591c"]]},{"id":"71a9556e.5c591c","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"sendNECIR","qos":"1","retain":"","broker":"dde7e643.e8ebf8","x":1650,"y":1160,"wires":[]},{"id":"e72e9202.d595f","type":"delay","z":"d6e0df6.12d3f2","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":650,"y":1280,"wires":[["56111257.9cebcc"]]},{"id":"c3f3e78f.9f6af8","type":"looptimer","z":"d6e0df6.12d3f2","duration":"0.5","units":"Second","maxloops":"30","maxtimeout":"30","maxtimeoutunits":"Second","name":"","x":1270,"y":1240,"wires":[["5097e1db.e5d46"],[]]},{"id":"ee8accb7.6d658","type":"delay","z":"d6e0df6.12d3f2","name":"","pauseType":"delay","timeout":"0.6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1070,"y":1240,"wires":[["c3f3e78f.9f6af8"]]},{"id":"e3421e34.c2a35","type":"debug","z":"d6e0df6.12d3f2","name":"http debug","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1070,"y":1520,"wires":[]},{"id":"a0b4a065.b5fe8","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"LEDcolor","qos":"2","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":540,"wires":[["65e69199.50fbb"]]},{"id":"6bea9281.a2d03c","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload=0xF700FF;\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":700,"wires":[["18dcf9ab.ce0ca6"]]},{"id":"2f67af50.ba87c","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload=0xF7807F;\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":760,"wires":[["e6d8963b.7689e8"]]},{"id":"b4eb286c.975c48","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"LEDlighter","qos":"2","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":700,"wires":[["6bea9281.a2d03c"]]},{"id":"da29cdd2.c2d14","type":"mqtt in","z":"d6e0df6.12d3f2","name":"","topic":"LEDdarker","qos":"2","datatype":"auto","broker":"dde7e643.e8ebf8","x":140,"y":760,"wires":[["2f67af50.ba87c"]]},{"id":"18dcf9ab.ce0ca6","type":"looptimer","z":"d6e0df6.12d3f2","duration":"0.5","units":"Second","maxloops":"5","maxtimeout":"5","maxtimeoutunits":"Second","name":"","x":570,"y":700,"wires":[["12e34ca9.d2cf13"],[]]},{"id":"e6d8963b.7689e8","type":"looptimer","z":"d6e0df6.12d3f2","duration":"0.5","units":"Second","maxloops":"5","maxtimeout":"5","maxtimeoutunits":"Second","name":"","x":570,"y":760,"wires":[["12e34ca9.d2cf13"],[]]},{"id":"a2f83888.8c3f08","type":"function","z":"d6e0df6.12d3f2","name":"turnON","func":"msg.payload = 0xF7C03F;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":600,"wires":[["12e34ca9.d2cf13"]]},{"id":"ca9da1d5.15826","type":"function","z":"d6e0df6.12d3f2","name":"turnOFF","func":"msg.payload = 0xF740BF;\nreturn msg;","outputs":1,"noerr":0,"x":560,"y":640,"wires":[["12e34ca9.d2cf13"]]},{"id":"b2950d11.566b6","type":"switch","z":"d6e0df6.12d3f2","name":"on or off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"On","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":320,"y":620,"wires":[["a2f83888.8c3f08"],["ca9da1d5.15826"]]},{"id":"886ec7d3.c24118","type":"debug","z":"d6e0df6.12d3f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":540,"wires":[]},{"id":"229077c4.f97788","type":"delay","z":"d6e0df6.12d3f2","name":"","pauseType":"delay","timeout":"0.3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1070,"y":1180,"wires":[["78f0e81c.679b18"]]},{"id":"78f0e81c.679b18","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload=0xF7E01F;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1280,"y":1180,"wires":[["71a9556e.5c591c"]]},{"id":"54c94bc6.6b8b74","type":"mqtt in","z":"d6e0df6.12d3f2","name":"led","topic":"led","qos":"2","datatype":"utf8","broker":"dde7e643.e8ebf8","x":130,"y":600,"wires":[["886ec7d3.c24118","b2950d11.566b6"]]},{"id":"12e34ca9.d2cf13","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"sendNECIR","qos":"2","retain":"","broker":"dde7e643.e8ebf8","x":950,"y":620,"wires":[]},{"id":"65e69199.50fbb","type":"function","z":"d6e0df6.12d3f2","name":"ColorChecker","func":"var color=Number(\"0x\"+(msg.payload.substr(1,6)));\nvar blue = (color & 0xff);\nvar green = (color>>8) & 0xff;\nvar red = (color>>16) & 0xff;\nvar colors = [\n    {'r':0x00, 'g':0xff, 'b':0x00, 'ir':0xF7609F },\n    {'r':0x00, 'g':0xff, 'b':0x99, 'ir': 0xF750AF},\n    {'r':0x00, 'g':0xff, 'b':0xcc, 'ir':0xF7708F },\n    {'r':0x33, 'g':0xcc, 'b':0xcc, 'ir':0xF748B7 },\n    {'r':0x00, 'g':0xcc, 'b':0xff, 'ir':0xF76897 },\n    {'r':0xff, 'g':0x33, 'b':0x00, 'ir':0xF7A05F },\n    {'r':0xff, 'g':0xcc, 'b':0x66, 'ir':0xF7906F },\n    {'r':0xff, 'g':0xff, 'b':0x66, 'ir':0xF7B04F },\n    {'r':0x99, 'g':0xff, 'b':0x33, 'ir':0xF7A857 },\n    {'r':0x00, 'g':0x66, 'b':0xff, 'ir': 0xF720DF},\n    {'r':0x66, 'g':0x66, 'b':0xff, 'ir': 0xF710EF},\n    {'r':0x99, 'g':0x33, 'b':0xff, 'ir':0xF730CF },\n    {'r':0xcc, 'g':0x33, 'b':0xff, 'ir':0xF708F7 },\n    {'r':0xff, 'g':0x66, 'b':0xcc, 'ir': 0xF728D7},\n    {'r':0xff, 'g':0xff, 'b':0xff, 'ir': 0xF7E01F}\n    ];\nvar diff=new Array(16), min=0xFFFFFF, colorIndex;\nfor (i=0; i<colors.length; i++){\n    diff[i]=Math.abs(red-colors[i].r)+Math.abs(green-colors[i].g)+Math.abs(blue-colors[i].b);\n    if(diff[i]<min){\n        min=diff[i];\n        colorIndex=i;\n    }\n}\n\nmsg.payload=colors[colorIndex].ir;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":540,"wires":[["12e34ca9.d2cf13"]]},{"id":"fafc66b5.027608","type":"function","z":"d6e0df6.12d3f2","name":"","func":"msg.payload=0xffffff;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1350,"y":1020,"wires":[["157b7388.0755bc"]]},{"id":"157b7388.0755bc","type":"mqtt out","z":"d6e0df6.12d3f2","name":"","topic":"LEDcolor","qos":"2","retain":"","broker":"dde7e643.e8ebf8","x":1560,"y":1020,"wires":[]}]<br>

Setting Up the Applications

WhatsApp Image 2020-08-31 at 00.17.26.jpeg

1. Download the MQTT dashboard app

2. Inside the app, add your MQTT broker (the one you have installed)

Note - you have to insert an address: tcp://(and right after insert your Duck DNS domain address)

Note 2.0 - don't forget to open the relevant ports in your router (8123 for the Home Assistant, 1883 for the MQTT broker!)

3. After connecting to the MQTT broker, feel free to add any elements should you need.

Note - make sure you define every element if it's a receiver or a giver type of an element.

Note 2.0 - the selected topic is the one you choose for the MQTT in/out.

Play Hard With Your Wemos D1 Mini PART A

lidor.gif
WhatsApp Image 2020-09-14 at 14.19.40.jpeg

The D1 Mini unit is responsible for connections between itself and the Raspberry Pie using the internet. It's able to listen to signals from the Raspberry Pie unit (MQTT broker), which makes it versatile for whichever usage you might need it for. Although, in our case, we created 2 units:

Window opener - comprised of one unit of Wemos D1 Mini, 5V battery, 1 Channel 5V Relay Model, DC Motor. Listens on a specified topic, and by which it knows when to open/close a circle which connects between the DC motor, and the 5V battery. The motor then pulls a string which is connected to the shutters and closes/opens them. Example code:

#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <Adafruit_Sensor.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.
const char* ssid = "WiFiName";
const char* password = "WiFiPW";
const char* mqtt_server = ".duckdns.org";
const char* mqttUser = "YourMqttUser";
const char* mqttPassword = "YourMqttUserPassword";

WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE  (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;

void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  randomSeed(micros());

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  
  if(strcmp (topic,"alarmStatus") == 0){ 
    for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
    if(payload[0]=='1'){
      digitalWrite(D0, HIGH);  // turn on LED with voltage HIGH
      delay(1000);                      // wait one second
      digitalWrite(D0, LOW);   // turn off LED with voltage LOW
      delay(1000); 
    }
  }
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect("ESP8266Client2", mqttUser, mqttPassword)) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.subscribe("alarmStatus");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
  pinMode(D0, OUTPUT);
}

void loop() {
  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  unsigned long now = millis();
  sensors_event_t event;
  if (now - lastMsg > 2000) {
    lastMsg = now;
  }
}

Downloads

Play Hard With Your Wemos D1 Mini PART B

lidor2.gif
WhatsApp Image 2020-09-14 at 14.19.55.jpeg

Temperature, movement, humidity indicator & TV and AC controller - comprised of a Wemos D1 Mini, IR Remote led, DHT Shield, transistor, Arduino motion sensor. Each one of these units is connected to a certain topic, both as a receiver or a giver; for temperature, it publishes a certain topic on the MQTT along with the temperature data. This data flows into the Raspberry board, on which the application is connected and renders this information. And on the other way around, the application sends MQTT publishes certain topics, which is being received by the Raspberry (MQTT broker which is identified by the NodeRed), and that data is being transmitted to the Wemos unit. The unit then decides upon the action that needs to be executed amid the topic that is being listened to.

Example code:

#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.
const char* ssid = "WiFiName";
const char* password = "WiFiPW";
const char* mqtt_server = ".duckdns.org";
const char* mqttUser = "YourMqttUser";
const char* mqttPassword = "YourMqttUserPassword";

int pirPin = D7;
#define DHTPIN 2     // Digital pin connected to the DHT sensor 
#define DHTTYPE    DHT22     // DHT 22 (AM2302)
DHT_Unified dht(DHTPIN, DHTTYPE);

WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
unsigned long lastTempMsg = 0;
unsigned long lastMoveMsg = 0;
#define MSG_BUFFER_SIZE  (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;
const uint16_t kIrLed = 4;  // ESP8266 GPIO pin to use. Recommended: 4 (D2).
IRsend irsend(kIrLed);

void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  randomSeed(micros());

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  //Serial.print("Message arrived [");
  //Serial.print(topic);
  //Serial.print("] ");
  long a=0;
  for (int i = 0; i < length; i++) {
    a+=((int)payload[i]-48)*(pow(10,(length-1-i)));
  }
  //Serial.println(a,HEX);
  if(strcmp (topic,"sendCoolixIR") == 0){
    //Serial.println("sendCoolixIR");
    irsend.sendCOOLIX(a);
  }else if(strcmp (topic,"sendSamsungIR") == 0){
    //Serial.println("sendSamsungIR");
    long b = (0xE0E0 << 16) | a;
    irsend.sendSAMSUNG(b);
  }else if(strcmp (topic,"sendNECIR") == 0){
    //Serial.println("sendNECIR");
    irsend.sendNEC(a);
  }
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect("ESP8266Client", mqttUser, mqttPassword)) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("outTopic", "hello world");
      // ... and resubscribe
      client.subscribe("sendCoolixIR");
      client.subscribe("sendSamsungIR");
      client.subscribe("sendNECIR");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
  irsend.begin();
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);

  dht.begin();
  sensor_t sensor;
  dht.temperature().getSensor(&sensor);
  dht.humidity().getSensor(&sensor);
}

void loop() {
  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  unsigned long now = millis();
  sensors_event_t event;
  if (now - lastTempMsg > 300000) {
    lastTempMsg = now;
    
    dht.temperature().getEvent(&event);
    if (isnan(event.temperature)) {
      //Serial.println(F("Error reading temperature!"));
    } else {
      snprintf (msg, MSG_BUFFER_SIZE, "%.2f", event.temperature);
      client.publish("temp", msg);
      //Serial.print(msg);
      //Serial.println(F("°C"));
    }
    
    // Get humidity event and print its value.
    dht.humidity().getEvent(&event);
    if (isnan(event.relative_humidity)) {
      //Serial.println(F("Error reading humidity!"));
    }
    else {
      snprintf (msg, MSG_BUFFER_SIZE, "%.2f", event.relative_humidity);
      client.publish("humidity", msg);
      //Serial.print(msg);
      //Serial.println(F("%"));
    }
}
  
  if (now - lastMoveMsg > 5000) {
    lastMoveMsg = now;
    if (digitalRead(pirPin) == LOW)
    {
      client.publish("movment", "0");
     // Serial.println("No motion");
    }
    else
    {
      client.publish("movment", "1");
      //Serial.println("Motion detected  ALARM");
    }
  }
}

Note - we used the Coolix protocol, in order to communicate with the AC.

Example Code for the NodeRed which is getting the information from the AC, and outputs the signal needed for the AC using the Coolix protocol:

var a= [{"mqtt_dashboard":{"mode":"cool","setpoint":24.5}}];
a= [JSON.parse(msg.payload)];
var mode = {"cool": 0b00, "auto" : 0b10, "heat" : 0b11};

var temp = {
  "n17": 0b0000, "n18" : 0b0001, "n19" : 0b0011, "n20": 0b0010, 
  "n21" : 0b0001, "n22" : 0b0011, "n23": 0b0101, "n24" : 0b0100, 
  "n25" : 0b1100, "n26": 0b1101, "n27" : 0b1001, "n28" : 0b1000, 
  "n29": 0b1010, "n30" : 0b1011}
var res = 0b1011001000011111;

if(a[0].hasOwnProperty('mqtt_dashboard')){
    var fixed = "n" + parseInt(a[0]['mqtt_dashboard']['setpoint'])
    res = res << 4;
    res = res | temp[fixed]
    
    //mode:
    res = res << 2;
    res = res | mode[a[0].mqtt_dashboard.mode]   
    res = res <<2;
    msg.payload=res;
    return msg;   
}

Assembling the Puzzle Pieces

26fc5eafe724598026e6d6702ce369bd.jpg

Our systems units are ready to roll! One thing for sure, after you assemble the pieces together - our raspberry server unit, as well as the other 2 independent units, which can listen and operate according to our requirements! Our system is designed in order to provide us with the mornings we have always dreamed of - waking up, slowly, comfortably, with all the essential morning elements - shutters that open and grant us natural sun-light, Spotify playing exactly the music we need in order to orchestrate with the birds' chirps, let alone that perfect AC temperature which will give us that slight kick out of our bed, but not too stiff. And if the natural sun-light isn't enough, we have our lights light together with it.

So, you made it THIS far.

By now, we ushered you the important skills needed in order to assemble the parts into one fascinating system! As you know, we prioritised chilled mornings, but you certainly can go ahead and use it for whichever needs you have.

We hope you enjoyed our journey together up until now, we hope you will take up this adventure as far as your imagination lets you.

Thank you!