ImpirihomeImperihome is a well-developed App (Android and IOS) for controlling gadgets (there are some IOS limits). It supports a wide range of systems and has a good range of controls and graphs.

Problem is… I don’t want to control any of these – Node-Red is doing a fine job of that right now.  I’m using Blynk and node-red-contrib-UI for visuals along, of course with Nextion displays (more on the latter soon).

The Blynk is fine but it has some really dumb restrictions (one page per project – and as some of the widgets are very large that makes it useless for some applications) – also it remains to be seen how quickly we’ll get new widgets when they go commercial this month and I’m not really that happy about an on-going payment. Blynk could do well or flop due to lack of support when they ask for money – and how quickly new controls emerge – who knows.

The node-red-contrib-UI program development for now at least APPEARS to have stopped – hoping that will change. Both of these incidentally work very reliably in their latest incarnation but Blynk has an inexplicable “ON” or “OFF” message on buttons which just seems rather limiting to me – what if you want to use the buttons for “up” and “down”. I’m told this will be fixed… but no timescale for when.  I’ve also been pressing for multiple pages per projects for some time – that also has still not arrived.

ImperihomeAnd so we have this lovely looking Imperihome App which reader Gregg brought to my attention. Now I have to say that I am able to write this now only because of some sterling weekend work by others who’s comments you should read. AT FIRST GLANCE this would appear to blow the pants off either of the previously mentioned UI systems.

A quick browse through the web showed NOTHING on the subject of Imperihome and Node-Red – but we’re fixing that right here – this APP is meant to work with commercial off the shelf units and I’m sure it will do that well – look at the comments on their site – mostly positive or even glowing – but I’m not interested in any of that – I have a working setup to control lots of devices via Node-Red and I’m happy with that  - what I want is a pretty and well-functional display for my phone – and it might just be that this is it. Now that Node-Red is standard on one of the world’s most popular SBCs (the Raspberry Pi – just recently given a major upgrade to RPi3) – I see Node-Red really going places hence sticking with it as my main control hub.

So – Imperihome - multiple pages – SURE – now, not later.  Decent RGB controls – YES – and they don’t take up half the screen.  Loads of devices including heating systems, RGB lights etc, yes. Multiple screen layouts – yes – again – now not later.

And now – Node-RED. Adding new devices is a matter of adding a couple of lines to the code that Steven Daglish has provided in the comments below (note his example mentions a lightswitch – just not implemented so don’t panic when you can’t see the light.

Note the pictgures here – this is just a TINY glimpse at what you can do with this app - you really need to go look at the site – the App is £4 but there’s a free demo – I lasted 20 seconds before I had to go buy the full App – it is WELL worth it.

You can see a bunch of controls – or have widgets with options for each widget – you can have variable numbers of widgets on a page so you might have large widgets on a phone or loads of little ones on a tablet – this is just WAY more advanced than anything else out there.

Oh, oh!! And it has speech recognition “turn off boiler” works no problem – sadly you seem to have to press a button to start it off – “ok google” takes you to the normal search.

This just keeps getting better – I just added one of my EASY-N cameras in Spain – and it works.

Note this blog entry is a re-write of the original article from earlier this week in the light of new knowledge. Expect to see LOTS more about this in here soon as I get my head around this and thanks to the guys who’ve contributed – keep it coming  - we’re onto a winner here I think. See the comments.


65 thoughts on “Imperihome

  1. I've had a quick look and there's a REST API available, which you can use to create your own "devices". I've yet to check in any details, but it should be possible to use Node-Red to communicate with Imperihome using this.

    I hope to have a look into this over the weekend.

    There's more details here:

    1. They make a lot of assumptions - like you know how to use a rest api - would be nice if they'd given an example - (they've still not responded to my direct questions) there seems to be enough info in the link you've given to pass info back and forth... if someone can start the job off with one example with Node-Red it should be easy to handle the other devices they show. If you do get a chance over the weekend would be much appreciated by me and I'm sure others as this would give us a another option.

  2. One day soon, everything you want in a system will just be another downloadable app.
    However before that happens, like early American settlers pushing out West, all of us can enjoy the technical exploration journey - before it all becomes mainstream and normal 🙁

    1. Absolutely - just like the wild west... still fun before between the security guys, the standards guys and politicians and their regulations make the whole thing utterly boring.

      I'm loving it right now.

  3. It seems to me that some combination of the info Steven has given us in the comments above.. ( and this post:

    Should be enough to get a simple demo going of Node-Red talking to the App - but I'm unclear about the basic mechanics here -API key etc. Anyone able to create a really simple demo of getting data from a test in Node-Red and maybe outputting a value to Node-Red ???

  4. This pushs TTS from node red to the phone - but I think you want the other direction?

    [{"id":"2b16b5e1.793b22","type":"inject","z":"d2c5762d.790988","name":"Phone IP address ","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":147,"y":136.5,"wires":[["4b32a77d.bdf52"]]},{"id":"c1f526c3.8d4fc","type":"debug","z":"d2c5762d.790988","name":"","active":true,"console":"false","complete":"payload","x":627,"y":264,"wires":[]},{"id":"302b7af0.f64a3e","type":"comment","z":"d2c5762d.790988","name":"instructions (see body)","info":"1) Put the IP address of your android phone in the inject box\n\n2) install the IMPERIHOME app on your phone and run it\n\n3) Press the inject box and your phone should say \"Hello\"","x":242,"y":59.5,"wires":[]},{"id":"4b32a77d.bdf52","type":"function","z":"d2c5762d.790988","name":"Create URL","func":"msg.url = \"http://\"+msg.payload+\":8080/api/rest/speech/tts?text=hello&times=1&vol=100\";\nreturn msg;","outputs":1,"noerr":0,"x":349,"y":136.5,"wires":[["2afe4c05.680bd4"]]},{"id":"2afe4c05.680bd4","type":"http request","z":"d2c5762d.790988","name":"REST Api to Android phone","method":"POST","ret":"txt","url":"","x":586,"y":135.5,"wires":[["c1f526c3.8d4fc"]]}]

  5. I'm guessing that the next stage is to set up (GET?) nodes in Node red along the lines that Steven says above
    - Maybe making the node-red server replicate an ISS (Imperihome Standard System)

  6. OK, I've managed to add a system as follows
    1) Setup this node red flow
    [{"id":"50df2cb.4da0ed4","type":"template","z":"d2c5762d.790988","name":"","field":"","fieldType":"msg","template":"{\n \"id\" : \"99:02:03:04:05:06\",\n \"apiversion\" : 1\n}","x":345,"y":630,"wires":[["49193a34.ce9d5c"]]},{"id":"49193a34.ce9d5c","type":"http response","z":"d2c5762d.790988","name":"","x":506,"y":630,"wires":[]},{"id":"e8291541.799cb8","type":"http in","z":"d2c5762d.790988","name":"","url":"/system","method":"get","swaggerDoc":"","x":147,"y":630,"wires":[["50df2cb.4da0ed4"]]}]

    2) Set up your Imperihome App
    - execute Imperihome App on your phone and go theought the following
    - Press Settings (3 dots top right)
    - Press "Settings"
    - Press "My Systems"
    - Press "Add a new system"
    - Press "ImperiHome StandardSystem"
    - Enter the following in the "local API Base URL" http://192.168.x.x:1880,
    - Click Finish

    So, the way to do this - is to create flows for each device - will see how I go

  7. OK - sorry in advance of the mess but this is for "system, "rooms and "devices".
    Once you put this in node-red, you can go back to "imperihome" and create new "imperihome" pages with the devices listed in the 2 rooms

    [{"id":"50df2cb.4da0ed4","type":"template","z":"d2c5762d.790988","name":"Node Red Imperihome SYSTEM","field":"","fieldType":"msg","template":"{\n \"id\" : \"99:02:03:04:05:06\",\n \"apiversion\" : 1\n}","x":401,"y":623,"wires":[["49193a34.ce9d5c"]]},{"id":"49193a34.ce9d5c","type":"http response","z":"d2c5762d.790988","name":"","x":636,"y":624,"wires":[]},{"id":"e8291541.799cb8","type":"http in","z":"d2c5762d.790988","name":"","url":"/system","method":"get","swaggerDoc":"","x":123,"y":623,"wires":[["50df2cb.4da0ed4"]]},{"id":"17558075.c013b","type":"template","z":"d2c5762d.790988","name":"Node Red Imperihome ROOMS","field":"","fieldType":"msg","template":"{\n \"rooms\": [\n {\n \"id\": \"roomID1\",\n \"name\": \"Pete's Living Room\"\n },\n {\n \"id\": \"roomID2\",\n \"name\": \"Pete's Kitchen\"\n }\n ]\n}","x":386,"y":720,"wires":[["18bb6348.97d435"]]},{"id":"18bb6348.97d435","type":"http response","z":"d2c5762d.790988","name":"","x":621,"y":721,"wires":[]},{"id":"d5674a4e.6f6d3","type":"http in","z":"d2c5762d.790988","name":"","url":"/rooms","method":"get","swaggerDoc":"","x":108,"y":720,"wires":[["17558075.c013b"]]},{"id":"c850787.42bec88","type":"template","z":"d2c5762d.790988","name":"Node Red Imperihome DEVICES","field":"","fieldType":"msg","template":"{\n \"devices\": [\n {\n \"id\": \"dev01\",\n \"name\": \"My Lamp\",\n \"type\": \"DevDimmer\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Level\",\n \"value\": \"75\"\n },\n {\n \"key\": \"Status\",\n \"value\": \"1\"\n }\n ]\n },\n {\n \"id\": \"dev02\",\n \"name\": \"Kitchen Light\",\n \"type\": \"DevSwitch\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"pulseable\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Status\",\n \"value\": \"0\"\n }\n ]\n },\n {\n \"id\": \"dev03\",\n \"name\": \"Temperature Sensor\",\n \"type\": \"DevTemperature\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"21.5\",\n \"unit\": \"°C\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev04\",\n \"name\": \"My Camera\",\n \"type\": \"DevCamera\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"localjpegurl\",\n \"value\": \"\"\n },\n {\n \"key\": \"remotejpegurl\",\n \"value\": \"\"\n },\n {\n \"key\": \"localmjpegurl\",\n \"value\": \"\"\n },\n {\n \"key\": \"remotemjpegurl\",\n \"value\": \"\"\n }\n ]\n },\n {\n \"id\": \"dev05\",\n \"name\": \"Diox sensor\",\n \"type\": \"DevCO2\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"528\",\n \"unit\": \"ppm\"\n }\n ]\n },\n {\n \"id\": \"dev07\",\n \"name\": \"Window shutter 1\",\n \"type\": \"DevShutter\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Level\",\n \"value\": \"75\"\n },\n {\n \"key\": \"stopable\",\n \"value\": \"1\"\n }\n ]\n },\n {\n \"id\": \"dev08\",\n \"name\": \"Door sensor\",\n \"type\": \"DevDoor\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"armable\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Armed\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Tripped\",\n \"value\": \"0\"\n },\n {\n \"key\": \"lasttrip\",\n \"value\": 1404762161000\n }\n ]\n },\n {\n \"id\": \"dev09\",\n \"name\": \"My Flood sensor\",\n \"type\": \"DevFlood\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"ackable\",\n \"value\": \"1\"\n },\n {\n \"key\": \"armable\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Armed\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Tripped\",\n \"value\": \"1\"\n },\n {\n \"key\": \"lasttrip\",\n \"value\": 1404762161000\n }\n ]\n },\n {\n \"id\": \"dev10\",\n \"name\": \"Motion sensor\",\n \"type\": \"DevMotion\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Armed\",\n \"value\": \"0\"\n },\n {\n \"key\": \"Tripped\",\n \"value\": \"1\"\n },\n {\n \"key\": \"lasttrip\",\n \"value\": 1404762161000\n }\n ]\n },\n {\n \"id\": \"dev11\",\n \"name\": \"Smoke sensor\",\n \"type\": \"DevSmoke\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Armed\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Tripped\",\n \"value\": \"0\"\n }\n ]\n },\n {\n \"id\": \"dev12\",\n \"name\": \"Electricity conso\",\n \"type\": \"DevElectricity\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Watts\",\n \"value\": \"620\",\n \"unit\": \"W\",\n \"graphable\": true\n },\n {\n \"key\": \"ConsoTotal\",\n \"value\": \"983\",\n \"unit\": \"kWh\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev13\",\n \"name\": \"Bogus sensor\",\n \"type\": \"DevGenericSensor\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"Blahblah\"\n }\n ]\n },\n {\n \"id\": \"dev14\",\n \"name\": \"Hum sensor\",\n \"type\": \"DevHygrometry\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"67\",\n \"unit\": \"%\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev15\",\n \"name\": \"Lum sensor\",\n \"type\": \"DevLuminosity\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"436\",\n \"unit\": \"lux\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev16\",\n \"name\": \"Entrance door Lock\",\n \"type\": \"DevLock\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Status\",\n \"value\": \"1\"\n }\n ]\n },\n {\n \"id\": \"dev17\",\n \"name\": \"Heater\",\n \"type\": \"DevMultiSwitch\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"Eco\"\n },\n {\n \"key\": \"Choices\",\n \"value\": \"Eco,Comfort,Freeze,Stop\"\n }\n ]\n },\n {\n \"id\": \"dev18\",\n \"name\": \"Noise sensor\",\n \"type\": \"DevNoise\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"33\",\n \"unit\": \"db\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev19\",\n \"name\": \"Outdoor pressure\",\n \"type\": \"DevPressure\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"1432\",\n \"unit\": \"mbar\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev20\",\n \"name\": \"Rain sensor\",\n \"type\": \"DevRain\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"5\",\n \"unit\": \"mm/h\",\n \"graphable\": true\n },\n {\n \"key\": \"Accumulation\",\n \"value\": \"182\",\n \"unit\": \"mm\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev21\",\n \"name\": \"Night mode\",\n \"type\": \"DevScene\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"LastRun\",\n \"value\": \"2014-03-12 23:15:65\"\n }\n ]\n },\n {\n \"id\": \"dev22\",\n \"name\": \"Away mode\",\n \"type\": \"DevScene\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"LastRun\",\n \"value\": \"2014-03-16 23:15:65\"\n }\n ]\n },\n {\n \"id\": \"dev23\",\n \"name\": \"Sun UV sensor\",\n \"type\": \"DevUV\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Value\",\n \"value\": \"5\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev24\",\n \"name\": \"Wind sensor\",\n \"type\": \"DevWind\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Speed\",\n \"value\": \"12\",\n \"unit\": \"km/h\",\n \"graphable\": true\n },\n {\n \"key\": \"Direction\",\n \"value\": \"182\",\n \"unit\": \"°\"\n }\n ]\n },\n {\n \"id\": \"dev25\",\n \"name\": \"CO2 Alert sensor\",\n \"type\": \"DevCO2Alert\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"armable\",\n \"value\": \"1\"\n },\n {\n \"key\": \"ackable\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Armed\",\n \"value\": \"0\"\n },\n {\n \"key\": \"Tripped\",\n \"value\": \"0\"\n },\n {\n \"key\": \"lasttrip\",\n \"value\": 1404762161000\n }\n ]\n },\n {\n \"id\": \"dev26\",\n \"name\": \"Outlet and Conso\",\n \"type\": \"DevSwitch\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Status\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Energy\",\n \"value\": \"349\"\n }\n ]\n },\n {\n \"id\": \"dev27\",\n \"name\": \"Light and Conso\",\n \"type\": \"DevDimmer\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"Status\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Level\",\n \"value\": \"80\"\n },\n {\n \"key\": \"Energy\",\n \"value\": \"349\",\n \"unit\": \"W\"\n }\n ]\n },\n {\n \"id\": \"dev28\",\n \"name\": \"Home Thermostat\",\n \"type\": \"DevThermostat\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"curmode\",\n \"value\": \"Comfort\"\n },\n {\n \"key\": \"curtemp\",\n \"value\": \"19.2\",\n \"unit\": \"°C\"\n },\n {\n \"key\": \"cursetpoint\",\n \"value\": \"20.3\"\n },\n {\n \"key\": \"step\",\n \"value\": \"0.5\"\n },\n {\n \"key\": \"minVal\",\n \"value\": \"12.0\"\n },\n {\n \"key\": \"maxVal\",\n \"value\": \"28.0\"\n },\n {\n \"key\": \"availablemodes\",\n \"value\": \"Comfort, Eco, Off\"\n }\n ]\n },\n {\n \"id\": \"dev29\",\n \"name\": \"Temp/Hygro sensor\",\n \"type\": \"DevTempHygro\",\n \"room\": \"roomID2\",\n \"params\": [\n {\n \"key\": \"temp\",\n \"value\": \"21.3\",\n \"unit\": \"°C\",\n \"graphable\": true\n },\n {\n \"key\": \"hygro\",\n \"value\": \"33\",\n \"unit\": \"%\",\n \"graphable\": true\n }\n ]\n },\n {\n \"id\": \"dev30\",\n \"name\": \"RGB Light with dim and white\",\n \"type\": \"DevRGBLight\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"dimmable\",\n \"value\": \"1\"\n },\n {\n \"key\": \"whitechannel\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Status\",\n \"value\": \"1\"\n },\n {\n \"key\": \"Level\",\n \"value\": \"80\"\n },\n {\n \"key\": \"color\",\n \"value\": \"BC93FF26\"\n },\n {\n \"key\": \"Energy\",\n \"value\": \"70\",\n \"unit\": \"W\"\n }\n ]\n },\n {\n \"id\": \"dev31\",\n \"name\": \"RGB Light\",\n \"type\": \"DevRGBLight\",\n \"room\": \"roomID1\",\n \"params\": [\n {\n \"key\": \"dimmable\",\n \"value\": \"0\"\n },\n {\n \"key\": \"whitechannel\",\n \"value\": \"0\"\n },\n {\n \"key\": \"Status\",\n \"value\": \"1\"\n },\n {\n \"key\": \"color\",\n \"value\": \"FFFF2692\"\n },\n {\n \"key\": \"Energy\",\n \"value\": \"50\",\n \"unit\": \"W\"\n }\n ]\n }\n ]\n}","x":362,"y":805,"wires":[["9ad0e7be.8460b8"]]},{"id":"9ad0e7be.8460b8","type":"http response","z":"d2c5762d.790988","name":"","x":597,"y":806,"wires":[]},{"id":"15bff1c8.3e934e","type":"http in","z":"d2c5762d.790988","name":"","url":"/devices","method":"get","swaggerDoc":"","x":84,"y":805,"wires":[["c850787.42bec88"]]}]

  8. I just looked all of this up - it LOOKS like the only way to use this (and only on Android) is via the IP address of the Android phone - which means only locally - this is a great shame... unless I'm missing something - as it means you can't take the APP outside of the home and use it.

  9. OK - still typing (lol) - hope it helps!

    IMO, this Imperihome app has some seriously good UI features if you want a tablet hanging on a wall which speaks back to you and dynamically changes its screen to alert (chow security camera etc).

    To set up node red to work with Imperihome, all the sensor device setup, location and values are handled in one place - its the big json "mess" seen in the function code of the DEVICES flow.
    So, all node red has to do is mung togather the sensor values (as variables) in this json "mess".
    A better way of handling this would be to construct some sort of management web page which collates all the MQTT messages (from sensors) to assemble the DEVICE json text, which the imperihome polls every 5 seconds.

    If you want to control devices from the imperihome app, then it seems that new node-red flows are required to handle this - as specified in the "API" tab of
    i.e. get /devices/{deviceId}/action/{actionName}/{actionParam}

    all good stuff, but a lot of work - could make a seriously sick system though

    1. Still trying to get my head around this... So if you have Node-Red at HOME - and a light... and a sensor... how would you (a) turn the light on and (b) read the sensor if your phone is outside of the house - ie you are not on the local network? (assuming you understand port redirects) - can the app from outside the house, talk both ways to Node-Red?

      1. AsI understand it, the App always starts any comms.
        i.e. the app can
        - control something by posting the value to node red e.g. set the light on or off
        - report the state of something by posting for the value to be returned back

        In both cases, the app can post to an external site (which can be a DDNS pointing to your home router or it can point to the local network IP of your node red).

        1. just remember that while the app is running on your phone, it is constantly polls node red for the latest JSON of values (the default is every 5 seconds).
          That is why there are "HTTP GET" nodes in node red - this sets up node red so that it is "listening" for these polling requests from the APP. Once they are triggering, the function populates the JSON response that gets sent back fro node red to the APP.
          If the app doesn't "poll", then node red will do nothing

  10. Well I've finally been able to figure some of this REST stuff.

    The snipped below will create a single room, containing a single switch called "Kitchen Light". Add the address to ImperiHome (in the same way as already mentioned above), but for clarity I use 192.168.0.XX:1880/hello

    Once loaded, you should see a "Living Room" room with a "Kitchen Light".

    You can then use the switch to control whatever in node-red. In this simple example, I simple use it to say something like "Light is: 0" or "Light is: 1". It should be easy enough to then connect that to a MQTT controlled switch, boiler, etc.

    The flow is currently quite messy, but will look into it more and try and figure out more of this REST stuff.

    [{"id":"29016606.d6fe9a","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/system","method":"get","swaggerDoc":"","x":339.75,"y":70,"wires":[["b19f1564.4e60e8"]]},{"id":"41a2670d.be5d98","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/devices","method":"get","swaggerDoc":"","x":347.56817626953125,"y":152.272723197937,"wires":[["ed84124f.127bf"]]},{"id":"1c7f863a.e3807a","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/rooms","method":"get","swaggerDoc":"","x":327.02274322509766,"y":247.54545211791992,"wires":[["6f2e64da.90d19c"]]},{"id":"3c3c17fc.c3c3e8","type":"http response","z":"d1b6603a.2e49a","name":"","x":640.0227241516113,"y":146.8181757926941,"wires":[]},{"id":"b19f1564.4e60e8","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = { \"id\": \"ISS:Test:01\", \"apiversion\": 1};\nreturn msg;","outputs":1,"noerr":0,"x":515.4772491455078,"y":109.54545783996582,"wires":[["3c3c17fc.c3c3e8","378ba382.c8745c"]]},{"id":"3416915b.cbe96e","type":"http response","z":"d1b6603a.2e49a","name":"","x":632.0227394104004,"y":239.81818425655365,"wires":[]},{"id":"ed84124f.127bf","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = {\"devices\": [{ \"id\": \"dev02\", \"name\": \"Kitchen Light\", \"type\": \"DevSwitch\", \"room\": \"roomID1\", \"params\": [ { \"key\": \"pulseable\", \"value\": \"0\" }, { \"key\": \"Status\", \"value\": \"0\" } ] }]};\nreturn msg;","outputs":1,"noerr":0,"x":512.0227241516113,"y":198.90909910202026,"wires":[["3416915b.cbe96e","378ba382.c8745c"]]},{"id":"ec3ec607.13c138","type":"http response","z":"d1b6603a.2e49a","name":"","x":631.5681495666504,"y":336.90910053253174,"wires":[]},{"id":"6f2e64da.90d19c","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = {\"rooms\": [{ \"id\": \"roomID1\", \"name\": \"Living Room\" }]};\nreturn msg;","outputs":1,"noerr":0,"x":500.6590805053711,"y":300.5454740524292,"wires":[["ec3ec607.13c138","378ba382.c8745c"]]},{"id":"378ba382.c8745c","type":"debug","z":"d1b6603a.2e49a","name":"","active":false,"console":"false","complete":"false","x":742.5681915283203,"y":279.5454434156418,"wires":[]},{"id":"6febf61e.901408","type":"http in","z":"d1b6603a.2e49a","name":"ISS Rest Actions","url":"/hello/devices/:deviceID/action/:actionName/:actionParameter","method":"get","swaggerDoc":"","x":290.9090805053711,"y":365.4545097351074,"wires":[["42df3062.bd20d"]]},{"id":"42df3062.bd20d","type":"switch","z":"d1b6603a.2e49a","name":"","property":"req.params.deviceID","propertyType":"msg","rules":[{"t":"eq","v":"dev02","vt":"str"}],"checkall":"true","outputs":1,"x":452.72727515480733,"y":384.5454150113193,"wires":[["43a3e6d7.bc5c18"]]},{"id":"43a3e6d7.bc5c18","type":"function","z":"d1b6603a.2e49a","name":"","func":"switch (msg.req.params.actionName){\n case \"setStatus\":\n msg.payload = \"Light is: \" + msg.req.params.actionParameter;\n break;\n default:\n break;\n}\nreturn msg;","outputs":1,"noerr":0,"x":548.1818161010742,"y":427.4544954299927,"wires":[["607482d1.9f8b7c"]]},{"id":"607482d1.9f8b7c","type":"debug","z":"d1b6603a.2e49a","name":"","active":true,"console":"false","complete":"payload","x":683.6363677978516,"y":460.90902042388916,"wires":[]}]

  11. Well it turns out the above doesn't work correctly. Evertime ImperiHome would poll the current state of the devices, the switch would go back to being OFF.

    So a simple change to globally store the switch state and to use this when IH polls the current devices gives the following flow. Still messy, but getting there.

    [{"id":"29016606.d6fe9a","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/system","method":"get","swaggerDoc":"","x":339.75,"y":70,"wires":[["b19f1564.4e60e8"]]},{"id":"41a2670d.be5d98","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/devices","method":"get","swaggerDoc":"","x":347.56817626953125,"y":152.272723197937,"wires":[["ed84124f.127bf"]]},{"id":"1c7f863a.e3807a","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/rooms","method":"get","swaggerDoc":"","x":327.02274322509766,"y":247.54545211791992,"wires":[["6f2e64da.90d19c"]]},{"id":"3c3c17fc.c3c3e8","type":"http response","z":"d1b6603a.2e49a","name":"","x":640.0227241516113,"y":146.8181757926941,"wires":[]},{"id":"b19f1564.4e60e8","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = { \"id\": \"ISS:Test:01\", \"apiversion\": 1};\nreturn msg;","outputs":1,"noerr":0,"x":515.4772491455078,"y":109.54545783996582,"wires":[["3c3c17fc.c3c3e8","378ba382.c8745c"]]},{"id":"3416915b.cbe96e","type":"http response","z":"d1b6603a.2e49a","name":"","x":632.0227394104004,"y":239.81818425655365,"wires":[]},{"id":"ed84124f.127bf","type":"function","z":"d1b6603a.2e49a","name":"","func":"var switchState = global.get('switchState')||0;\n\nmsg.payload = {\"devices\": [{ \"id\": \"dev02\", \"name\": \"Kitchen Light\", \"type\": \"DevSwitch\", \"room\": \"roomID1\", \"params\": [ { \"key\": \"pulseable\", \"value\": \"0\" }, { \"key\": \"Status\", \"value\": switchState } ] }]};\nreturn msg;","outputs":1,"noerr":0,"x":512.0227241516113,"y":198.90909910202026,"wires":[["3416915b.cbe96e","378ba382.c8745c","2753b307.d8ac4c"]]},{"id":"ec3ec607.13c138","type":"http response","z":"d1b6603a.2e49a","name":"","x":631.5681495666504,"y":336.90910053253174,"wires":[]},{"id":"6f2e64da.90d19c","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = {\"rooms\": [{ \"id\": \"roomID1\", \"name\": \"Living Room\" }]};\nreturn msg;","outputs":1,"noerr":0,"x":500.6590805053711,"y":300.5454740524292,"wires":[["ec3ec607.13c138","378ba382.c8745c"]]},{"id":"378ba382.c8745c","type":"debug","z":"d1b6603a.2e49a","name":"","active":false,"console":"false","complete":"false","x":742.5681915283203,"y":279.5454434156418,"wires":[]},{"id":"6febf61e.901408","type":"http in","z":"d1b6603a.2e49a","name":"ISS Rest Actions","url":"/hello/devices/:deviceID/action/:actionName/:actionParameter","method":"get","swaggerDoc":"","x":290.9090805053711,"y":365.4545097351074,"wires":[["42df3062.bd20d"]]},{"id":"42df3062.bd20d","type":"switch","z":"d1b6603a.2e49a","name":"","property":"req.params.deviceID","propertyType":"msg","rules":[{"t":"eq","v":"dev02","vt":"str"}],"checkall":"true","outputs":1,"x":452.72727515480733,"y":384.5454150113193,"wires":[["43a3e6d7.bc5c18","3efb40c1.c104c"]]},{"id":"43a3e6d7.bc5c18","type":"function","z":"d1b6603a.2e49a","name":"","func":"switch (msg.req.params.actionName){\n case \"setStatus\":\n msg.payload = \"Light is: \" + msg.req.params.actionParameter;\n global.set('switchState', msg.req.params.actionParameter);\n break;\n default:\n break;\n}\nreturn msg;","outputs":1,"noerr":0,"x":548.1818161010742,"y":427.4544954299927,"wires":[["607482d1.9f8b7c"]]},{"id":"607482d1.9f8b7c","type":"debug","z":"d1b6603a.2e49a","name":"","active":true,"console":"false","complete":"payload","x":683.6363677978516,"y":460.90902042388916,"wires":[]},{"id":"e0f6568.f1f09a8","type":"http response","z":"d1b6603a.2e49a","name":"","x":697.2727127075195,"y":508.18179512023926,"wires":[]},{"id":"3efb40c1.c104c","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = { \"success\": true, \"errormsg\": \"ok\" };\nreturn msg;","outputs":1,"noerr":0,"x":543.6363372802734,"y":483.6363515853882,"wires":[["e0f6568.f1f09a8","607482d1.9f8b7c"]]},{"id":"2753b307.d8ac4c","type":"debug","z":"d1b6603a.2e49a","name":"","active":true,"console":"false","complete":"false","x":771.8181762695312,"y":208.1818084716797,"wires":[]}]

    1. Cheers Steven,
      Works OK for me. I tried it on both a "cloud" node red instance as well as my "on premise" node red instance running on windows.
      Seemed to take a long time to synch up with devices though - probably because I've loaded quite a few systems in IH
      One thing I like - is that you can easily segregate different systems in node red just by using differing extensions e.g. you have used "/hello"

  12. Progress: To follow up on Steven's comments..

    Stephens SECOND flow (import into Node-Red) works.... you'll see he's used
    global.set() and global.get() - turns out these are just variations on using global variables directly.

    So his flow will generate a room with a lightswitch - all you have to do in the (paid) Android app is to set up the basic server pointing to the Node-Red installation (See Steven's instructions in his PREVIOUS comment) and that's basically it. On my phone a room has appeared with a kitchen light and I can turn it on and off and it is VERY PRETTY.

    So global.set("fred",4); is directly interchangeable with;

    I also tried given his example, manually injecting values into his switchState variable - and sure enough the phone changed state accordingly....

    Finally - my PI2 which is running all of this - just rebooted - which it has not done for months since the early days of using BLYNK. Might be totally unrelated but if you try this code from Stephen and not your Pi reboots unexpectedly DO let us know.

    Just need a better understanding of how to expand this and I think Paul might be about to help there.

  13. OK - just posting as requested after a PM with Pete - hopefully makes sense!

    "But how does node-red manage to get a reply back to the App?"
    I think the 3 flows called "System", "Rooms and "Devices" work like something like this when you try to add a system:

    1 of 3) The app calls the "SYSTEM" node-red flow and gets a response like
    "id" : "Cloud9",
    "apiversion" : 1
    i.e. the app recognises that the (node red) system is called "Cloud 9"

    2 of 3) The app calls the "ROOMS" node-red flow and gets a response like
    "rooms": [
    "id": "roomID1",
    "name": "Cloud 9 (Petes) Living Room"
    "id": "roomID2",
    "name": "Cloud 9 (Petes) Kitchen"

    3 of 3) The app now calls the "DEVICES" node-red flow and continues to do so EVERY 5 seconds until the app is stopped
    Think of this bit as a loop polling for the values
    "id": "dev03",
    "name": "Temperature Sensor",
    "type": "DevTemperature",
    "room": "roomID1",
    "params": [
    "key": "Value",
    "value": "21.5",
    "unit": "°C",
    "graphable": true

    In all 3 steps, the APP polls for the JSON that is manufactured in the function code., so to pass values back, the JSON manufactured by the DEVICES flow has to respond to value changes

    "Is there any way to get the data back to the App sitting outside of the house?"
    yes - remember that the APP sucks the values from the JSON manufactured from the DEVICES flow.

    "and if so can the APP recieve data arbitrarily or only when the APP does a poll?"
    Data only flows when there is a "poll" by the APP - so for critical stuff, you want the polling period to be short (5 seconds should be enough really)

  14. Here's a small example containing one switch (for me a boiler), and a single RGB dimmable light. I don't have a RGB to test with, but it seems to be working (from the debug commands I'm getting). Perhaps someone could test it with a working RGB light.

    [{"id":"29016606.d6fe9a","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/system","method":"get","swaggerDoc":"","x":335.75,"y":84,"wires":[["b19f1564.4e60e8"]]},{"id":"41a2670d.be5d98","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/devices","method":"get","swaggerDoc":"","x":337.56817626953125,"y":133.27272033691406,"wires":[["ed84124f.127bf"]]},{"id":"1c7f863a.e3807a","type":"http in","z":"d1b6603a.2e49a","name":"","url":"/hello/rooms","method":"get","swaggerDoc":"","x":328.0227508544922,"y":187.5454559326172,"wires":[["6f2e64da.90d19c"]]},{"id":"3c3c17fc.c3c3e8","type":"http response","z":"d1b6603a.2e49a","name":"","x":806.022705078125,"y":139.81817626953125,"wires":[]},{"id":"b19f1564.4e60e8","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = { \"id\": \"ISS:Test:01\", \"apiversion\": 1};\nreturn msg;","outputs":1,"noerr":0,"x":533.4772338867188,"y":102.54545593261719,"wires":[["3c3c17fc.c3c3e8","378ba382.c8745c"]]},{"id":"ed84124f.127bf","type":"function","z":"d1b6603a.2e49a","name":"","func":"var switchState = global.get('switchState') || 0;\nvar boilerState = global.get('boilerState') || 0;\nvar rgbState = global.get('rgbState') || 0;\nvar rgbLevel = global.get('rgbLevel') || 0;\nvar rgbColour = global.get('rgbColour') || \"AAAAAAAA\";\n\nmsg.payload = {\"devices\": [\n{ \"id\": \"dev03\", \"name\": \"Boiler\", \"type\": \"DevSwitch\", \"room\": \"roomID1\", \"params\": [ { \"key\": \"pulseable\", \"value\": \"0\" }, { \"key\": \"Status\", \"value\": boilerState } ] },\n{\"id\": \"dev04\", \"name\": \"RGB Light\", \"type\": \"DevRGBLight\", \"room\": \"roomID1\", \"params\": [{\"key\": \"dimmable\", \"value\": \"1\"}, {\"key\": \"whitechannel\", \"value\": \"0\"}, {\"key\": \"Status\", \"value\": rgbState}, {\"key\": \"Level\", \"value\": rgbLevel}, {\"key\": \"color\", \"value\": rgbColour}]}\n]};\nreturn msg;","outputs":1,"noerr":0,"x":528.0227355957031,"y":172.9091033935547,"wires":[["378ba382.c8745c","3c3c17fc.c3c3e8"]]},{"id":"6f2e64da.90d19c","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = {\"rooms\": [{ \"id\": \"roomID1\", \"name\": \"Living Room\" }]};\nreturn msg;","outputs":1,"noerr":0,"x":524.6590881347656,"y":230.54547119140625,"wires":[["378ba382.c8745c","3c3c17fc.c3c3e8"]]},{"id":"378ba382.c8745c","type":"debug","z":"d1b6603a.2e49a","name":"","active":false,"console":"false","complete":"false","x":744.5681762695312,"y":231.54544067382812,"wires":[]},{"id":"6febf61e.901408","type":"http in","z":"d1b6603a.2e49a","name":"ISS Rest Actions","url":"/hello/devices/:deviceID/action/:actionName/:actionParameter","method":"get","swaggerDoc":"","x":320.9090881347656,"y":324.4544982910156,"wires":[["42df3062.bd20d"]]},{"id":"42df3062.bd20d","type":"switch","z":"d1b6603a.2e49a","name":"","property":"req.params.deviceID","propertyType":"msg","rules":[{"t":"eq","v":"dev02","vt":"str"},{"t":"eq","v":"dev03","vt":"str"},{"t":"eq","v":"dev04","vt":"str"}],"checkall":"true","outputs":3,"x":471.7272644042969,"y":350.54541015625,"wires":[["43a3e6d7.bc5c18","3efb40c1.c104c"],["c34c74a.f3cb388","ad2e839b.52d18"],["4e810503.b17efc","4e60f73d.b19f08"]]},{"id":"43a3e6d7.bc5c18","type":"function","z":"d1b6603a.2e49a","name":"","func":"switch (msg.req.params.actionName){\n case \"setStatus\":\n msg.payload = \"Light is: \" + msg.req.params.actionParameter;\n global.set('switchState', msg.req.params.actionParameter);\n break;\n default:\n break;\n}\nreturn msg;","outputs":1,"noerr":0,"x":665.1818237304688,"y":331.4544982910156,"wires":[["607482d1.9f8b7c"]]},{"id":"607482d1.9f8b7c","type":"debug","z":"d1b6603a.2e49a","name":"","active":true,"console":"false","complete":"payload","x":845.6363525390625,"y":325.9090270996094,"wires":[]},{"id":"e0f6568.f1f09a8","type":"http response","z":"d1b6603a.2e49a","name":"","x":838.272705078125,"y":404.1817932128906,"wires":[]},{"id":"3efb40c1.c104c","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = { \"success\": true, \"errormsg\": \"ok\" };\nreturn msg;","outputs":1,"noerr":0,"x":667.6363525390625,"y":368.6363525390625,"wires":[["e0f6568.f1f09a8"]]},{"id":"c34c74a.f3cb388","type":"function","z":"d1b6603a.2e49a","name":"","func":"switch (msg.req.params.actionName){\n case \"setStatus\":\n msg.payload = \"Boiler is: \" + msg.req.params.actionParameter;\n global.set('boilerState', msg.req.params.actionParameter);\n break;\n default:\n break;\n}\nreturn msg;","outputs":1,"noerr":0,"x":662,"y":434,"wires":[["607482d1.9f8b7c"]]},{"id":"ad2e839b.52d18","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = { \"success\": true, \"errormsg\": \"ok\" };\nreturn msg;","outputs":1,"noerr":0,"x":663.4545288085938,"y":470.1818542480469,"wires":[["e0f6568.f1f09a8"]]},{"id":"4e810503.b17efc","type":"function","z":"d1b6603a.2e49a","name":"","func":"switch (msg.req.params.actionName){\n case \"setStatus\":\n msg.payload = \"RGB Status is: \" + msg.req.params.actionParameter;\n global.set('rgbState', msg.req.params.actionParameter);\n break;\n case \"setColor\":\n msg.payload = \"RGB colour is: \" + msg.req.params.actionParameter;\n global.set('rgbColour', msg.req.params.actionParameter);\n break;\n case \"setLevel\":\n msg.payload = \"RGB level is: \" + msg.req.params.actionParameter;\n global.set('rgbLevel', msg.req.params.actionParameter);\n break;\n default:\n break;\n}\nreturn msg;","outputs":1,"noerr":0,"x":653,"y":615,"wires":[["844d46d7.7bb2b8"]]},{"id":"844d46d7.7bb2b8","type":"debug","z":"d1b6603a.2e49a","name":"","active":true,"console":"false","complete":"payload","x":833.4545288085938,"y":609.4545288085938,"wires":[]},{"id":"fcaf0393.0351","type":"http response","z":"d1b6603a.2e49a","name":"","x":826.0908813476562,"y":687.727294921875,"wires":[]},{"id":"4e60f73d.b19f08","type":"function","z":"d1b6603a.2e49a","name":"","func":"msg.payload = { \"success\": true, \"errormsg\": \"ok\" };\nreturn msg;","outputs":1,"noerr":0,"x":655.4545288085938,"y":652.1818542480469,"wires":[["fcaf0393.0351"]]}]

    1. It works Steven - things to note in your example - a light is referred to but not used - no problem - a one-liner to add - also a one-liner to add another page.

      If you change one of the global vars - the app updates automatically - but no new debug info comes out - hence the way to control stuff is to use as is and poll the global vars separately - I do that elsewhere.... could do with a couple of mechanisms here - saving the global vars to a disk - I find an easy way to do that is to make a global STRUCT and have a flag in there checked regularly and simply save the struct to a file as JSON. Also need an easy way to note if a global var has changed... but this is all minor stuff. The App and this interface in your later version does indeed appear to work and work well.

      Accordingly I've update the App as this is now a decent place to look to make a start.

  15. Oh and apologies to anyone looking in earlier - the site went dead - probably down to load... I'm assured by the service provider that they have a permanent fix coming up.

  16. Wow... u guys work fast.

    In my experience the best/quickest way to get the dev's attention is via the beta Google+ community

    Some of the other cool features i love:
    - wake up on the device front camera motion - i have this running on a wall mounted tablet. It will turn off the lcd, but when you walk close enough the camera will wake it up.

    -tts: I have a Vera rule that makes the tablet tell me if the garage door is still open at 8pm. " Hey Greg the Garage door is still open"
    - Also one which tells me the days weather forcast if i turn on the kitchen lights between 6-8am.!/speech/sayTTS

    I'm moving off Vera and onto Openhab...and im yet to move these over... perhaps ill do it with NodeRed now 😉

    1. Thanks for that Greg... and now guys - the next step in making this useful - I may have missed something here but if not maybe you can help.

      The RGB controllers outputs the strangest mix I've ever seen - RGB at full strength plus intensity plus saturation.

      So - does anyone have a (preferrably in nodeJS) simple formula (no need to go all perfection) to take R,G,B and intensity and saturation - and produce a final RGB value - because that is all that serial LEDS are interested in. In my own boards I have HSV which would do the job - but that still means converting R,G,B into Hue. That would do me - maybe not quite so useful for others?

      Any takers?

      1. Got RGB LED working. Copy the code below and paste it over the RGB function for dev04. Adapted the shadeColor function from here -

        function shadeColor(color, percent) {
        var f=parseInt(color,16),t=percent<0?0:255,p=percent>16,G=f>>8&0x00FF,B=f&0x0000FF;
        return (0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1);

        switch (msg.req.params.actionName){
        case "setStatus":
        node.warn("RGB Status is: " + msg.req.params.actionParameter);
        global.set('rgbState', msg.req.params.actionParameter);
        case "setColor":
        node.warn("RGB colour is: " + msg.req.params.actionParameter);
        global.set('rgbColour', msg.req.params.actionParameter);
        case "setLevel":
        node.warn("RGB level is: " + msg.req.params.actionParameter);
        global.set('rgbLevel', msg.req.params.actionParameter);
        if (global.get('rgbState') == '0' || global.get('rgbLevel') == '0') {
        msg.payload = 'RGB = 0,0,0';
        } else {
        hexColor = shadeColor(global.get('rgbColour').slice(2), (parseInt(global.get('rgbLevel')) -100) / 100);
        msg.payload = 'RGB = ' + parseInt(hexColor.substr(0,2), 16) + ',' + parseInt(hexColor.substr(2,2), 16) + ',' + parseInt(hexColor.substr(4,2), 16);
        return msg;

        1. Almost... the function is missing R... here is the fixed version..

          function shadeColor(color, percent) {
          var f=parseInt(color,16),t=percent<0?0:255,p=percent>16,R=f>>16&0x00FF,G=f>>8&0x00FF,B=f&0x0000FF;
          return (0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1);

          And right now - adjusting brilliance isn't doing anything - but even if it does - I'm thinking... this is not going to take eye sensitivity into account when adjusting the colours - so anything other than red, green or blue is going to end up changing hue when reduced in brilliance due to our eyes being more sensitive to green?

          Any I right? so the general idea is right - but do we need to do RGB to HSV then take out brilliance and alter V before converting back to RGB??

        2. Another thing - using global variables - they'll need to be changed for every instance of this - if we have a room or building with several of these RGB lights each one will need doctoring... can we use persistent vars which are local to each module - or alter the names of the vars to incorporate the device name somehow??

        3. Thanks for fixing the R. Not sure what happened, my function looked just like yours in node-red but it seems something happened when I pasted it here.

          I'm not sure what you mean by brilliance. From my playing with the RGB control, Saturation and Brightness changed the RGB values in a way that looked right. The shadeColor function scales a bit smarter, but it's not doing any eye perception modeling. I did a little surfing, wow, this topic can go as deep as you want to go. The FastLED library for Arduino covers a lot of this, I may try some of those techniques, or not. I'm just happy I got it working.

          1. The brightness control has no effect on my rgb values whatsoever... want to send me a plain email with a working flow on it (pete at scargill dot org) - and I'll try it - maybe the blog comments system has made some change I'm not seeing...

          2. I'll email you the code.

            When Retain is set to true for the node-red MQTT out node, the value is persistent and does not get wiped out when read. Seems if we're doing MQTT already this would be a handy place to store "globals". Of course if the MQTT broker or RasPi, etc. dies then the global data is also gone. For devices that you can read their state, it should be possible to restore the MQTT globals upon startup (repopulate them). If you need to carry state info over from crashes then perhaps a file or database is the better way to go.

    2. Node-Red does seem to be emerging (at least in my mind) as the ultimate tool for taking stuff in, converting it and spitting it out... and the Raspberry Pi is proving to be very reliable at helping it do that.

  17. Hello,

    If you are interrested, I have a gateway between imperihome and domoticz I'm rewriting in nodeJS, that could be extended to anything else (I already have people using node-red in domoticz that goes through that !)

    Also It gives some idea of mappings if you do it directly from node-red.

    Tell me if I can help (entending or giving suome feedback/support) on this,


    1. Hi there Emanuel

      Well personally I think I'm well on the way - I have lamp, rgb and heat control as starters - I need to convert the RGB+V+S value into an overall RGB value but it all seems to work reliably - I'm assuming other controls will be similar - and I'm not familiar with Dopmoticz - I simply turn everything in Node-Red into MQTT instructions and all my gadgets work by MQTT - makes life very simple. It also means I can take in just about any of the visual interfaces and make them work with existing kit... currently running node-red-contribUI, Blynk and now a test of Imperihome. I'm also controlling via Nextion display via WIFI... however others in here will no doubt be interested in conversion to Domoticz - so by all means keep us up to date as you develop this.

      1. Hello Peter,

        Domoticz has also a mqtt interface, it is smaller than OpenHab (surely more limited) but can run on small PI and has out of the box working and graphs

  18. So - I've added a temperature reading to Steven's wonderful template.....

    Easy - under devices I added...

    {"id": "dev05", "name": "Heating", "type": "DevTemperature", "room": "roomID2", "params": [ { "key": "graphable", "value": "1" } , { "key": "value", "value": stat.display_temperature } ] }

    And now I have a pretty thermometer.. note the value stat.display_temperature is just my temperature global variable.

    All works a treat but..

    Having added the GRAPHABLE parameter - I have no idea how to store or get a graph - pressing the widget does nothing - how to go to the next step and have it give me a popup graph as in the App examples.. Any idea folks? I have to say this is all proving to be very easy until you come to something you've not seen before - like this.

    Thinking about it - it can't possible do a graph automatically as it would be missing stuff when the App is turned off so I assume it is my responsibility to store history of temperature - and that's fine - but... how to get it to appear in the temperature module....??

  19. Great minds think alike...

    Just done the same. Currently trying to get the graph as well.

    In the API doc (which really could do with some more examples!), it says that you can get the history of a sensor using the following call:


    So in my example, that would involve creating a http input node with "/hello//devices/:deviceID/:paramKey/histo/:startdate/:enddate"

    However, I'm still unsure what format the returned values should be in.

    Will keep trying this morning and hopefully come back with a useful example soon.

  20. Here's some info about a new flow that enables history to be read (so that a graph can be displayed).
    Its rough but it demonstrates how it can be done.
    N.B. If after double clicking the temperature value, the graph just shows one dot, expand the range using the button at the top.

    1) Define device "dev05"as

    {"id": "dev05", "name": "Temperature Sensor", "type": "DevTemperature", "room": "roomID1",
    "params": [
    "key": "Value",
    "value": "21.5",
    "unit": "°C",
    "graphable": true

    2) upload this flow for getting the history

    [{"id":"d7119198.702f38","type":"http in","z":"ff136ffc.20a97","name":"[get] History values","url":"/hello/devices/:deviceID/:paramKey/histo/:startdate/:enddate","method":"get","swaggerDoc":"","x":122,"y":950,"wires":[["895d054c.1fa648"]]},{"id":"c8483229.406548","type":"http response","z":"ff136ffc.20a97","name":"","x":593,"y":950,"wires":[]},{"id":"895d054c.1fa648","type":"template","z":"ff136ffc.20a97","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"values\": [\n {\n \"date\": 1437206375649,\n \"value\": 18.2\n },\n {\n \"date\": 1457356375649,\n \"value\": 19.6\n }\n ]\n}","x":365,"y":950.5,"wires":[["c8483229.406548"]]}]

    1. Yep - already onto that Pete - was planning to update blog soon - Steven put some code up and we've been working on that.... so clearly there's a need to store data in a database (I have SQLITE running) and then come up with a flow to read the database on demand to populate those values.

    2. OK - extending the node above should be simple enough (so that it reacts to specific devices).
      IMO, we just need to progress as follows:
      (1) Develop an easy way for someone to recall and change the configuration of rooms/devices (perhaps via http nodes and javascript?)

      (2) Decide on how configuration and sensor data is stored (perhaps Mongodb?)

      (3) Develop a node to read MQTT messages and store the value against the devices configured via (1) & (2)

      (4) Develop The "engine" function code(s) that construct the responding JSON for the 5 flows - SYSTEM, ROOMS, DEVICES, ACTION, HISTORY

      (5) put all the nodes together and test it!

  21. Pete, follow this threads is becoming very difficult... a lot of talk happens in comments, and it's not possible to order them by date, so one have to look for single dates of every comment to check for new ones... also you modify articles but do not say what's changed and where... maybe using strike lines on text that's old and bold for new can help, or a little update at the end of the article... please look for a better way to interact with you... thanks in advance

    1. I know what you mean, there's lots of things going on. But....consider that when things get more stable, Pete S will do his usual magic and write it all up in a separate article for us all and it will be a lot more linear to read of course.
      It's probably best to consider this bit as the discovery stage where many people can contribute if they want to - its bound to get a bit messy really - but hopefully its still informative as an exploration journey etc.
      Pete M

      1. yes, it's the same that we did with Peter a few weeks ago to have a decent implementation of node-red on orange-pi... let's continue the brainstorming, then, and hope for a solution soon 🙂
        thanks Pete and Peter 🙂

      1. take your time, there's a lot of very good stuff on this site... mine were just hints to have a more manageable site for us and you, too 🙂

  22. Hi Pete,

    Does this system have the same problem where by you press a button and the on screen bulb changes even though there is no feedback from the controlled device to say anything has happened.

    I've set the refresh time to 1 second. and if i change the global to 0 then the bulb goes out and switch goes to off. if you then set the refresh to 10 seconds you have to wait 10 seconds to see if the action has taken place.

    Is there a way round this or have i missed something.



    1. Hi Paul,

      As far as I can figure out, the only way to get data to and from the app widgets, buttons, etc. is from the app. Either when say the button is pressed, or the system updates itself(every second, 5 seconds, etc.). I've yet to find a way to send data directly from - say node - to the app.

      So probably best not to have the app polling time too long.

      1. Feedback would be good during a button press.

        The http call can only return success and errormsg neither of which have seem to actually do anything in the app itself.

    2. I understand that following happens:
      - After you press a button in the APP, 3 nodes are usually involved in node red.
      Firstly, the "HTTP GET" node is triggered
      Secondly, the "FUNCTION" node is processed (which populates the response message)
      Thirdly the "HTTP RESPONSE" node sends a response back to the APP.

      So, your answer is really in the hands of 2nd node of node-red (i.e. the "FUNCTION" node). If you want node red to say that the button press was successful, then all you have to do is code a response like the following in the "FUNCTION" node
      "success": true,
      "errormsg": "All OK"

      In the end, the trick of this REST API is that you can program a flow so that DATA COMING FROM THE APP (INTO NODE RED) ALWAYS HAS A REPLY PASSED BACK TO THE APP (FROM NODE RED)

      1. Hi Guys,

        Yes this is what ive found too. If you break the link in the function then the next time the app refreshes the bulb (in this case) changes back.

        I even coded the response to "success":false but nothing happened in the app.

        I wonder if the local server on the app will help. Looking at it now.



  23. Anyone else tried the graphing? Tried 3 sample values for the temperature - along with time stamps - that was yesterday -looked lovely.

    But here's the thing - the store timestamps were around 10am yesterday.

    So TODAY at 9am they showed up in BLUE for TODAY.....instead of RED for yesterday. NOW at lunchtime I get "no data for specified timeframe" - which is right- and If I look at the last week's data sure enough there's the data in yesterday,,

    BUT this morning at 9am - that data SHOULD have shown up as RED for yesterday.

    Am I right?

  24. Hi Peter,

    I have been following your progress for some time and now have 28 devices in my Imperihome device node. Are you aware if there is any limitation to the number of devices?

    I ask because I am seeing a problem after adding my 28th device and it is only happening to that device. The device is a dimmer, when I send a setting to the node from my Imperihome app, for example 30%, the light is set to 30% as expected. Then, as long as I have the app still running on my phone, it will sent 30% every 120 seconds. The problem does not end there, if I now send 80% the light goes to 80%, but the app will still send 30% every 120 seconds and now 80% every 120 seconds, and if I send 0% the app now started sending 30%, 80% and 0% every 120 seconds. If I force the app to stop then everything is fine, I don't get any message every 120 seconds.

    Before I contact the people at Imperihome I just wanted to see if anyone has seen this issue and if so then how was it resolved.


    1. I have no-where near 28 devices but I have noticed 2 issues - occasionally the phone App has issues with external and internal access - when it has access to both - i.e. sitting outside with a phone signal and WIFI. It comes back complaining of too many errors and goes to external only. Also when running RBB LEDS - I sometimes find it simply can't keep up - and will settle at one my my colour settings and 30 seconds later will catch up to the latest one. Not a BIG issue but I really think it would be better if they concentrate on perfecting the API as against adding controls for every home control gadget on the planet.

  25. I have the RGB issue you mention. As for external access, I access my internal network via a VPN connection using openvpn, so when connected imperi home still uses the internal ip. I will contact imperihome about my problem. Not sure how helpful they are though.

    Thank you


  26. Hi,

    Just thought I would let you know I resolved the issue. I forgot to wire the output of the main switch node to the HTTP 200 OK node, so Imperihome was constantly sending the commands because it was never getting the success return message.

    It's been a couple of weeks since I added a node/device and forgot about that part.


Comments are closed.