LightwaveRF Raspberry Pi

In my last couple of posts I had LightwaveRF working on an Ardunio UNO. This was great but I already have a Raspberry Pi that I keep permanently powered to receive data from my tinytx nodes  so I wanted to run my lightwaverf receiver from this too. Hence my raspberry pi port of Lawrie Griffiths arduino library was born.

First of all let me say thanks to Lawrie for doing all of the hard work. The port would not have been possible without his hard work in the beginning. Secondly the port is still in the early stages of development. I’m planning to make it a proper c library and to expand the example programs and instructions.

For now to get this working you will need a cheap 433 Mhz transceiver pair connected to the Pi, the wiring pi library and a checkout of the code from my github page. Once you have this all compiled you can use the sample send and receive programs to control lightwave devices.

The next project for me is finishing this off and then integrating this into my nodeRED installation for which im planning to use the MQTT transport. Watch this space for more on that over the next week.

Advertisements
Posted in home automation | Tagged , , , | Leave a comment

LightwaveRF into NodeRED

couldn’t resist doing a bit more playing so I had a go at modifying the simple arduino sketch that can sent lightwave commands and modified it so that it can send command on up to 16 channels:

#include <LightwaveRF.h>

byte on[] = {0xf6,0xf6,0xf6,0xee,0x6f,0xed,0xbb,0xdb,0x7b,0xee};
byte off[] = {0xf6,0xf6,0xf6,0xf6,0x6f,0xed,0xbb,0xdb,0x7b,0xee};

static byte nibbles[] = {0xF6,0xEE,0xED,0xEB,0xDE,0xDD,0xDB,0xBE,
                     0xBD,0xBB,0xB7,0x7E,0x7D,0x7B,0x77,0x6F};

void setup() {
  Serial.begin(57600);
  lw_setup();
}

String readString, channelStr, valueStr;

void loop() {
   while (Serial.available()) {
    delay(3);  //delay to allow buffer to fill
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    }
   }

    if (readString.length() >0) {
      Serial.println(readString); //see what was received

      channelStr = readString.substring(0, 1); //get the first four characters
      valueStr = readString.substring(1, 2); //get the next four characters

      Serial.println(channelStr);  //print to serial monitor to see parsed results
      Serial.println(valueStr);

      int channel = channelStr.toInt();
      int value = valueStr.toInt();

      if(value == 1){
       turnOn(channel);
      }else if(value == 0){
        turnOff(channel);
      }

      readString="";
    }
}

void turnOn(int channel) {
  Serial.println("Turning on");
  on[2]=nibbles[channel];
  lw_send(on);
}

void turnOff(int channel) {
  Serial.println("Turning off");
  off[2]=nibbles[channel];
  lw_send(off);
}

this works by using the code defined for your remote at the top and modifying the 3rd set of bytes that denote the channel number. As a result if you connect your arduino to a pc and send down the serial port <0 or 1> it will send an off/on signal to the devices configured against that channel on your remote. The remote has 16 channels and hence the ardunio does too.

Once this is in place connecting it to node red becomes very simple. Just add a serial output block with the port of the arduino and then send 00, or 01 to it via an inject block and like magic you have nodered controlling lightwaverf devices.

[{"id":"6b75c3f3.948a3c","type":"serial-port","serialport":"/dev/ttyACM0","serialbaud":"57600","newline":"\\n","addchar":"false"},{"id":"622ff413.9dd00c","type":"serial out","name":"arduino","serial":"6b75c3f3.948a3c","x":627,"y":734,"z":"7ea6e1a3.81592","wires":[]},{"id":"41a93d2e.be56c4","type":"inject","name":"On at 17:30","topic":"","payload":"01","repeat":"","crontab":"30 17 * * *","once":false,"x":217.50000381469727,"y":719.0000114440918,"z":"7ea6e1a3.81592","wires":[["622ff413.9dd00c"]]},{"id":"4626d189.b9d93","type":"inject","name":"","topic":"","payload":"00","repeat":"","crontab":"","once":false,"x":287.5,"y":655,"z":"7ea6e1a3.81592","wires":[["622ff413.9dd00c"]]}]
Posted in Uncategorized | Tagged , , | Leave a comment

LightwaveRF

For a while I have been using ZWave to control my lighting from a PC. Recently this has been more unreliable and the modules are expensive so i have decided to give one of tha alternatives a go. LightwaveRF produce a huge range of relatively low-cost modules that can be bought from B&Q and Screwfix. They look pretty nice and have reasonable reviews.

The more technical comparison between lightwave and zwave are that zwave uses a bi-directional protocol with acknowledged packets where as lightwave is fire and forget. lightwave also runs on 433.92MHz where as ZWave runs at 868MHz.

So not wanting to spend too much on lightwave to try it out i went to my local B&Q and picked up a set of these for £19.99

lightwaveplugs

Once you get past the indestructible plastic packaging they are actually pretty nice. Well built and slimmer than previous modules I have used before. Using the included remote they worked flawlessly.

Now for these to be useful to me I need to be able to control them from some sort of computer.  Lightwave do make something called the WifILink (badly named as it doesn’t actually have WiFi!) but this is £70 and seems somewhat unfinished software wise. Taking a look online i found this arduino library

Plugging in my Arduino UNO with a cheap 433MHz module I had allowed me to capture my remote controls on and off codes

F6 F6 F6 EE 6F ED BB DB 7B EE on
F6 F6 F6 F6 6F ED BB DB 7B EE off

putting this into the send example and connecting the transmitter allowed me to control the sockets. Even without an aerial connected to the transmitter it was working perfectly from about 5m away. Heres my ardunio send sketch:

#include <LightwaveRF.h>

byte on[] = {0xf6,0xf6,0xf6,0xee,0x6f,0xed,0xbb,0xdb,0x7b,0xee};
byte off[] = {0xf6,0xf6,0xf6,0xf6,0x6f,0xed,0xbb,0xdb,0x7b,0xee};

void setup() {
  Serial.begin(57600);
  lw_setup();
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();

    if (c == '1') turnOn();
    else if (c == '0') turnOff();
  }
}

void turnOn() {
  Serial.println("Turning on");
  lw_send(on);
}

void turnOff() {
  Serial.println("Turning off");
  lw_send(off);
}

All in all this was pretty easy to get going. There still a bit of work to be done but so far i’ve been very impressed with the simplicity and reliability of the lightwave protocol. Watch this space for more posts about this, i’m sure this wont be the last!

Posted in home automation | Tagged , | Leave a comment

Node Red ZWave

Continuing my productive weekend I had a go at integrating nodered with my zwave network. It’s still a work in progress but there is a version on my github page.

To use it node-openzwave must be installed and then the 99-zwave* files need to be copied into the nodered/nodes directory.

At the moment this can only do outputs and is probably full of bugs (I only wrote my first nodejs code yesterday!) so any suggestions or bug reports are more than welcome.

At the moment I have it controlling a wired in dimmer and a plug switch, scheduled to turn on at 17:30 every day. Was definitely surprised how easy it was to write a new node for nodered. I expect I shall be writing more.

Posted in home automation | Tagged , , , | Leave a comment

Node Red

I’ve been thinking about investigating node red for a while after it was suggested to me by a colleague at work so this weekend i had a go and I’m pleased to say that i really like it.

So what is node red? Well its advertised a being a tool for wiring the internet of things but for me it seems like an orchestration / workflow tools a bit like camel of mule but with a simpler graphical user interface.

I started of by installing nodered on my HP microserver. This didn’t go entirely to plan as the version of node and npm that i got from the ububtu repository didn’t seem to play nicely with the requirements for node red. eventually i got it working after messing around with a few versions of things:

sudo apt-get install nodejs
sudo apt-get install npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
npm config set registry http://registry.npmjs.org/

This will install the version of node and npm from the ubuntu repository then upgrade it to the latest version. the npm registry settings were needed to avoid a problem with it not being able to download a dependency using a https repository.

Now we can install nodered:

wget https://github.com/node-red/node-red/archive/0.5.0.zip
unzip 0.5.0.zip
cd node-red-0.5.0/
sudo npm install --production

Now it depends what you want to do with nodered but there are a number of optional dependencies that enable extra features. Seeing as I was playing I installed quite a few

sudo npm install nodemailer
sudo npm install redis
sudo npm install mongodb
sudo npm install serialport
sudo npm install fs.notify
sudo npm install xml2js

now this is done we can go ahead and fire up nodered:

sudo node red.js

This will start-up the server-side and the GUI can now be accessed at http://127.0.0.1:1880

You should see something that looks a bit like this:

nodered

Now its time to get building! The basic approach is that you are building a pipeline of commands. You have a number of different inputs, such as http, tcp, mqqt etc, some processing blocks that can execute custom JavaScript and some output blocks. To get you started there is a short tutorial on the nodered site. The most common error i made was forgetting to press the deploy button in the top right and wondering why things hadn’t changed!

In my setup i currently have a number of different input sending data to the great emoncms for graphing and data analysis. This is currently done by a number of small scripts that i have written/borrowed so the obvious thing for me is to build this all into nodered.

TinyTX Sensors

I currently have one (more being built soon) tinytx sensors that monitor light level, temperature and movement via PIR sensor. These communicate with a raspberry pi using an RFM12b radio module. I have written some code (available here on github) that receives this data and uploads it to emon CMS via a HTTP GET. I didn’t want to change this too much so i modified it so that you can customise the URL it sends data to. This was then coupled with a nodered config to expose a HTTP endpoint that the rfmrec code and send data too.

I used the HTTP input, some JavaScript processing and then an http output to upload this to emoncms.

Heres the code for the sensors:

[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"19cecd48.e63133","type":"http in","name":"","url":"/sensor","method":"get","x":90.83339945475268,"y":181.0833295186361,"z":"7ea6e1a3.81592","wires":[["75660596.8a99fc","92fca16c.6d036","b849177e.47b6e8"]]},{"id":"75660596.8a99fc","type":"switch","name":"","property":"payload.type","rules":[{"t":"eq","v":"pir"}],"checkall":"true","outputs":1,"x":271.91667556762695,"y":253.2499876022339,"z":"7ea6e1a3.81592","wires":[["7acbc320.85343c"]]},{"id":"7acbc320.85343c","type":"function","name":"store pir","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\noldValue = context.pir\ncontext.pir = msg.payload.value\nif(context.pir != oldValue){\n\treturn msg;\n} else {\n\treturn null;\n}\n\n","outputs":1,"x":418.91668701171875,"y":252.9166340827942,"z":"7ea6e1a3.81592","wires":[[]]},{"id":"92fca16c.6d036","type":"mqtt out","name":"output to emon","topic":"emon","broker":"ba386057.845d3","x":292.6190528869629,"y":135.05953407287598,"z":"7ea6e1a3.81592","wires":[]},{"id":"b849177e.47b6e8","type":"http response","name":"respond to http","x":287.32142857142856,"y":195.17857142857142,"z":"7ea6e1a3.81592","wires":[]}]

if you want to import this go to the menu on the top right and import from clipboard. Makes it very easy to share code!

Current Cost

I have a current cost power monitor (it also has a temperature sensor) which can be connected to a PC. It just shows up as a USB serial adapter and outputs XML every 10 seconds or so. I previously had a perl script capturing this data but luckily nodered has a direct serial input.

I used the serial input to read in the data. This was as simple as dragging in a serial input block, double clicking and setting the port and baud rate. This then spits out a string to the next block. Nodered also has an XML processing node called node2js, this takes the output from the serial block and then turns it into a javascript xml structure that is very simple to use.

Here are the contents of my function block for this flow (there are 2, one for power and one for temp):

var parsedXml = msg.payload;
msg.payload={};
msg.payload.type="power";
msg.payload.value = parsedXml['msg']['ch1'][0]['watts'][0];
return msg;

Heres the complete code for my current cost flow:

[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"6b75c3f3.948a3c","type":"serial-port","serialport":"/dev/ttyUSB1","serialbaud":"57600","newline":"\\n","addchar":"false"},{"id":"16d7c405.e9283c","type":"serial in","name":"current cost","serial":"6b75c3f3.948a3c","x":82.25000381469727,"y":29.500001907348633,"z":"7ea6e1a3.81592","wires":[["f63e199f.09c1e8"]]},{"id":"f63e199f.09c1e8","type":"xml2js","useEyes":false,"name":"","x":259.00000381469727,"y":29.500003814697266,"z":"7ea6e1a3.81592","wires":[["c93a21c3.36c5e","9243576f.6dbca8"]]},{"id":"c93a21c3.36c5e","type":"function","name":"Extract Temp","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar parsedXml = msg.payload;\nmsg.payload={};\nmsg.payload.type=\"temp2\";\nmsg.payload.value = parsedXml['msg']['tmpr'][0];\n\n\nreturn msg;","outputs":1,"x":517.2499923706055,"y":30.08335304260254,"z":"7ea6e1a3.81592","wires":[["4f074d5f.b0f8b4"]]},{"id":"9243576f.6dbca8","type":"function","name":"Extract Power","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar parsedXml = msg.payload;\nmsg.payload={};\nmsg.payload.type=\"power\";\nmsg.payload.value = parsedXml['msg']['ch1'][0]['watts'][0];\n\n\nreturn msg;","outputs":1,"x":517.1666641235352,"y":92.16667366027832,"z":"7ea6e1a3.81592","wires":[["4f074d5f.b0f8b4"]]},{"id":"4f074d5f.b0f8b4","type":"mqtt out","name":"output to emon","topic":"emon","broker":"ba386057.845d3","x":738.3332977294922,"y":56.666666984558105,"z":"7ea6e1a3.81592","wires":[]}]

Weather

For purposes of data comparison I also have local weather data uploaded to emoncms. For this I used forecast.io and its very easy to use developer API. It’s free as long as you don’t do more than 1000 requests per day. i signed up for a free account and got my API key.

The inject input is useful for debugging but it also has another use. It can be used to schedule jobs:

inject node

the payload is set to my location in lat long and this is fed directly into a http request node doing a GET to https://api.forecast.io/forecast// the output of this is some JSON in the form:

{"latitude":37.8267,"longitude":-122.423,"timezone":"America/Los_Angeles","offset":-8,"currently":{"time":1392498332,"summary":"Overcast","icon":"cloudy","nearestStormDistance":21,"nearestStormBearing":57,"precipIntensity":0,"precipProbability":0,"temperature":13.29,"apparentTemperature":13.29,"dewPoint":10.58,"humidity":0.84,"windSpeed":7.67,"windBearing":251,"visibility":11.94,"cloudCover":1,"pressure":1015.84,"ozone":305.25},"minutely":{"summary":"Overcast for the hour.","icon":"cloudy","data":[{"time":1392498300,"precipIntensity":0,"precipProbability":0},{"time":1392498360,"precipIntensity":0,"precipProbability":0},{"time":1392498420,"precipIntensity":0,"precipProbability":0},{"time":1392498480,"precipIntensity":0,"precipProbability":0},{"time":1392498540,"precipIntensity":0,"precipProbability":0},{"time":1392498600,"precipIntensity":0,"precipProbability":0},{"time":1392498660,"precipIntensity":0,"precipProbability":0},{"time":1392498720,"precipIntensity":0,"precipProbability":0},{ ....

As an aside debug nodes are invaluable not just for when things go wrong but also when developing. You can intercept things at anytime and see exactly whats going on.

I then fed the JSON output into a number of different functions to extract out temperature, humidity, wind speed and pressure which would then get uploaded to emoncms.

var weather = JSON.parse(msg.payload);
msg.payload={};
msg.payload.type="outsidetemp";
msg.payload.value=weather.currently.temperature;
return msg;

Heres the code for my weather flow (don’t forget to replace you API key):

[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"cd51dad7.32ae28","type":"inject","name":"Home","topic":"Home","payload":"52.067774,1.191117","repeat":"","crontab":"*/30 * * * *","once":true,"x":126.33335304260254,"y":323.91669178009033,"z":"7ea6e1a3.81592","wires":[["c102ef76.3efd1"]]},{"id":"c102ef76.3efd1","type":"httpget","name":"get forecast.io","baseurl":"https://api.forecast.io/forecast//","append":"?units=uk","x":288.3332767486572,"y":324.91677379608154,"z":"7ea6e1a3.81592","wires":[["bd22c285.42dd4","e6b4a5e8.194b58","187f71ae.e7808e","eb51ddf4.14ae2"]]},{"id":"bd22c285.42dd4","type":"function","name":"extract temp","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"outsidetemp\";\nmsg.payload.value=weather.currently.temperature;\n\nreturn msg;","outputs":1,"x":488.333345413208,"y":325.0595293045044,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"e6b4a5e8.194b58","type":"function","name":"extract wind","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"wind\";\nmsg.payload.value=weather.currently.windSpeed;\n\nreturn msg;","outputs":1,"x":484.0476760864258,"y":375.9523983001709,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"187f71ae.e7808e","type":"function","name":"extract pressure","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"pressure\";\nmsg.payload.value=weather.currently.pressure;\n\nreturn msg;","outputs":1,"x":496.54764556884766,"y":425.9523992538452,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"eb51ddf4.14ae2","type":"function","name":"extract humidity","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"humidity\";\nmsg.payload.value=weather.currently.humidity;\n\nreturn msg;","outputs":1,"x":495.47620391845703,"y":472.38098907470703,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"b8be7d9a.47418","type":"mqtt out","name":"output to emon","topic":"emon","broker":"ba386057.845d3","x":743.333350499471,"y":406.250012397766,"z":"7ea6e1a3.81592","wires":[]}]

Upload to emon

all 3 of the above flows end in a publish to an MQTT queue called emon. This queue is then picked up by a publish to emon flow looking like this:

emon flow

The function block in this flow takes a payload with two properties type and value, constructs an emon url and then feeds this into a http request node to perform the GET on emon:

var data = JSON.parse(msg.payload);
msg.url="http://emoncms.org/input/post.json?json={"+data.type+":"+data.value+"}&amp;apikey="
return msg;

Originally I didn’t have the MQTT queue but it is a good way of reusing functionality without having hundreds of links in nodered.

The complete picture

So here it is all put together:

complete flow

And the complete code:

[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"6b75c3f3.948a3c","type":"serial-port","serialport":"/dev/ttyUSB1","serialbaud":"57600","newline":"\\n","addchar":"false"},{"id":"1608dfa.fe9f72","type":"http request","name":"Upload to Emon","method":"GET","url":"","x":467.58336893717455,"y":550.1666825612386,"z":"7ea6e1a3.81592","wires":[[]]},{"id":"53cc86bc.ac3378","type":"function","name":"Create Emon URL","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar data = JSON.parse(msg.payload);\n\nmsg.url=\"http://emoncms.org/input/post.json?json={\"+data.type+\":\"+data.value+\"}&amp;apikey=\"\n\nreturn msg;","outputs":1,"x":272.58336893717455,"y":550.1666825612386,"z":"7ea6e1a3.81592","wires":[["1608dfa.fe9f72"]]},{"id":"19cecd48.e63133","type":"http in","name":"","url":"/sensor","method":"get","x":90.83339945475268,"y":181.0833295186361,"z":"7ea6e1a3.81592","wires":[["75660596.8a99fc","92fca16c.6d036","b849177e.47b6e8"]]},{"id":"75660596.8a99fc","type":"switch","name":"","property":"payload.type","rules":[{"t":"eq","v":"pir"}],"checkall":"true","outputs":1,"x":271.91667556762695,"y":253.2499876022339,"z":"7ea6e1a3.81592","wires":[["7acbc320.85343c"]]},{"id":"7acbc320.85343c","type":"function","name":"store pir","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\noldValue = context.pir\ncontext.pir = msg.payload.value\nif(context.pir != oldValue){\n\treturn msg;\n} else {\n\treturn null;\n}\n\n","outputs":1,"x":418.91668701171875,"y":252.9166340827942,"z":"7ea6e1a3.81592","wires":[[]]},{"id":"16d7c405.e9283c","type":"serial in","name":"current cost","serial":"6b75c3f3.948a3c","x":82.25000381469727,"y":29.500001907348633,"z":"7ea6e1a3.81592","wires":[["f63e199f.09c1e8"]]},{"id":"f63e199f.09c1e8","type":"xml2js","useEyes":false,"name":"","x":259.00000381469727,"y":29.500003814697266,"z":"7ea6e1a3.81592","wires":[["c93a21c3.36c5e","9243576f.6dbca8"]]},{"id":"c93a21c3.36c5e","type":"function","name":"Extract Temp","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar parsedXml = msg.payload;\nmsg.payload={};\nmsg.payload.type=\"temp2\";\nmsg.payload.value = parsedXml['msg']['tmpr'][0];\n\n\nreturn msg;","outputs":1,"x":517.2499923706055,"y":30.08335304260254,"z":"7ea6e1a3.81592","wires":[["4f074d5f.b0f8b4"]]},{"id":"9243576f.6dbca8","type":"function","name":"Extract Power","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar parsedXml = msg.payload;\nmsg.payload={};\nmsg.payload.type=\"power\";\nmsg.payload.value = parsedXml['msg']['ch1'][0]['watts'][0];\n\n\nreturn msg;","outputs":1,"x":517.1666641235352,"y":92.16667366027832,"z":"7ea6e1a3.81592","wires":[["4f074d5f.b0f8b4"]]},{"id":"cd51dad7.32ae28","type":"inject","name":"Home","topic":"Home","payload":"52.067774,1.191117","repeat":"","crontab":"*/30 * * * *","once":true,"x":126.33335304260254,"y":323.91669178009033,"z":"7ea6e1a3.81592","wires":[["c102ef76.3efd1"]]},{"id":"c102ef76.3efd1","type":"httpget","name":"get forecast.io","baseurl":"https://api.forecast.io/forecast//","append":"?units=uk","x":288.3332767486572,"y":324.91677379608154,"z":"7ea6e1a3.81592","wires":[["bd22c285.42dd4","e6b4a5e8.194b58","187f71ae.e7808e","eb51ddf4.14ae2"]]},{"id":"bd22c285.42dd4","type":"function","name":"extract temp","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"outsidetemp\";\nmsg.payload.value=weather.currently.temperature;\n\nreturn msg;","outputs":1,"x":488.333345413208,"y":325.0595293045044,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"e6b4a5e8.194b58","type":"function","name":"extract wind","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"wind\";\nmsg.payload.value=weather.currently.windSpeed;\n\nreturn msg;","outputs":1,"x":484.0476760864258,"y":375.9523983001709,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"187f71ae.e7808e","type":"function","name":"extract pressure","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"pressure\";\nmsg.payload.value=weather.currently.pressure;\n\nreturn msg;","outputs":1,"x":496.54764556884766,"y":425.9523992538452,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"eb51ddf4.14ae2","type":"function","name":"extract humidity","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nvar weather = JSON.parse(msg.payload); \n\nmsg.payload={};\nmsg.payload.type=\"humidity\";\nmsg.payload.value=weather.currently.humidity;\n\nreturn msg;","outputs":1,"x":495.47620391845703,"y":472.38098907470703,"z":"7ea6e1a3.81592","wires":[["b8be7d9a.47418"]]},{"id":"70d63d9d.8f29c4","type":"mqtt in","name":"emon topic","topic":"emon","broker":"ba386057.845d3","x":93.33337847391772,"y":550.0000222524008,"z":"7ea6e1a3.81592","wires":[["53cc86bc.ac3378"]]},{"id":"4f074d5f.b0f8b4","type":"mqtt out","name":"output to emon","topic":"emon","broker":"ba386057.845d3","x":738.3332977294922,"y":56.666666984558105,"z":"7ea6e1a3.81592","wires":[]},{"id":"92fca16c.6d036","type":"mqtt out","name":"output to emon","topic":"emon","broker":"ba386057.845d3","x":292.6190528869629,"y":135.05953407287598,"z":"7ea6e1a3.81592","wires":[]},{"id":"b8be7d9a.47418","type":"mqtt out","name":"output to emon","topic":"emon","broker":"ba386057.845d3","x":743.333350499471,"y":406.250012397766,"z":"7ea6e1a3.81592","wires":[]},{"id":"b849177e.47b6e8","type":"http response","name":"respond to http","x":287.32142857142856,"y":195.17857142857142,"z":"7ea6e1a3.81592","wires":[]}]
Posted in home automation | Tagged , , , , , | 1 Comment

First post

This blog is intended to be a record of some of the things I play around with. These range from technology, diy, home automation to other random things. I’m storing them here for my own benefit and in the hope that they might help others.

I often find other blogs tone really helpful when I’m trying to do something so I thought that I would try and contribute back to the community

 

Posted in Uncategorized | Leave a comment