View single post by cab123
 Posted: Saturday Feb 13th, 2016 05:58 am
 PM  Quote  Reply  Full Topic 
cab123

 

Joined: Saturday Oct 3rd, 2009
Location: Coimbra, Portugal
Posts: 25
Status: 
Offline

  back to top

So the next step after having a MQTT broker interacting with comfort is to install NodeRED
http://nodered.org/

It is really easy to set up stuff in logical blocks, however some javascript is needed for the functions.
This is my processing of comfort stuff:


The first "flow" updates comfort's time periodically. Every 10 minutes a timestamp is generated, passed through the "Build Date Command" and sent to the MQTT topic comfort is listening to. The function is something like this:



At the bottom of the first image, every group of received messages from Comfort are handled. For instance, i have temperature sensors, one KNX and another from a SCS that are transformed to MQTT also and sent to the broker. This way i can later read the sensors and display them on openHab. 

The "split function is configured as shown:



and the Sensor function decodes comfort sensor messages like this:
var string = msg.payload;
var re = /^s[r\?](..)(..)(..)/; // regex to extract LSB, MSB
var sensor = msg.payload.replace(re, "$1"); //get sensor id
var hex = msg.payload.replace(re, "$3$2"); //Store MSB LSB
var dec = parseInt(hex,16); // convert to Decimal

if ((dec & 0x8000) > 0) { // handle negative numbers   
  dec = dec - 0x10000;
}
switch(sensor) {   
  case "00":       
    msg.topic = "house/floor2/livingroom/temperature";       
    break;   
  case "09":       
    msg.topic = "house/floor2/bedroom/temperature";       
    break;   
  default:       
    msg.topic = "unspecified";
}

msg.payload = dec;return msg;


All processing can be done here. Imagination is the limit, everything can be done with small bits of code and simple "flows".

Later i will try to show some of my OpenHab setup that takes advantage of all this data.

Fell free to ask any questions.


 Close Window