ThingBox

tmpAE2DUpdate 03/01/2016 17:00: 

I spent (wasted) much of New Year’s Eve and New Year’s Day setting up a brand new “Jessie” installation on a Raspberry Pi 2,  at the end of which I had managed to put 2 copies of Node-Red on the same machine, the sound would not come out of the 3.5” adaptor (yes, I’d messed with Raspi-Config) and the serial adaptor would not appear. Previous installations in “Wheezy” had worked fine – but this one – using “Jessie” was determined to be a pain in the bum.

(For the uninitiated, “Wheezy” and “Jessie” are code-names for versions of “Raspbian” – the operating system used on the Rasberry Pi computers).

ThingboxAnd so it was that someone in the blog pointed me to ThingBox – a package I’d looked at ages ago and which I’d previously dismissed as it was a little simple. For my purposes I needed a lot of software on the Pi (much of which subsequently proved to be un-necessary such as the full-blown MYSQL database).

I decided to look again.

Well, things have moved on. I’m not entirely sure they’ve used “Jessie” as the www directory is still /var/www – but I digress.

Installing “ThingBox” which is a combination of operating system, various tools and a special-purpose “Node-Red” – designed for non-programmers – is all quite simple really. Grab a 16GB SD card, grab the .IMG file from their website, install the .img file using Win32DiskManager or whatever is your favourite tool for blowing images. Plug in the Internet lead and speaker cable – add power and wait.

In about 30 seconds or so – you’re done with phase one – a fully working Node-Red installation.

You don’t even have to go looking for ThingBox as it appears on your network as “http://thethingbox.local/

I had my reservations – this was not designed for “experts” and I wondered if it would be too restrictive.

If you want to go tinkering with WinSCP to remote access the actual operating system – the username is root and the password is rasberry – and it soon became clear that I would need this – as I could see no sign of a database and today I use SqlLite3.

MP3, sound, serial, PI IO etc are all on there and working and two of those had been my problem to start with. My owb nodes are missing as are a couple of others for speech etc but now it is even easier to install these as the guys who developed ThingBox have added tools to do this.

I need SQLITE3 and so I went about installing that using WinSCP and my normal “script” – suffice it to say that this killed ThingBox – because it installed PHP or at least put Apashe back in charge of Port 80 – so – I went into the ThingBox config file at /root/thethingbox/thethingbox.js and sure enough they had set the system to use port 80 rather than the normal 1880 – I initially set it back to 1880 but then decided it would be a much better idea to set Apache to port 81 and leave ThingBox alone. That worked.

Thingbox worked perfectly – as did SQLITE3 (the node has to be installed manually in a terminal – the usual “npm install…” then I figured as I’d make a batch file to install that, I may as well have the batch file install SQLITE and all my nodes.

I also installed node-red-contrib-ui – it appeared in the editor but would not work in the normal address of thethingbox.local:1880/ui – or even thethingbox.local/ui  which was a worry until blog reader LEORRR pointed out that changing that to /api/ui works just fine.

There is a tool within the package for installing nodes - you don’t even have to go to the command line – which is always a good thing. But for whatever reason it would not accept the  SQLITE3 node – thankfully that went in the normal way from the the command line – hence my idea to use a script – necessary anyway to speed up implementation in the event of an update to ThingBox.

I appear to have a working setup with very little effort and with more working nodes than I’d managed myself.

The file /root/thethingbox/thethingbox.js looked remarkably like the normal settings.js for Node-Red and so I went in and had a tinker. I’ve just copied the relevant bits here and marked in RED the ones I changed.

    functionGlobalContext: {
        settings: settings_ttb
        ,userDir: userDir
        ,settingslib: require('/root/thethingbox/settingsttb.js')
        ,wpi: require('node-red/node_modules/wiring-pi') // https://www.npmjs.com/package/wiring-pi
        ,CryptoJS: require('node-red/node_modules/crypto-js') // https://www.npmjs.com/package/cryptojs

        ,moment:require('moment')
        ,fs:require('fs')

    },

    adminAuth: {
        type: "credentials",
        users: [{
           username: "admin",
            password: "$2a etc etc etc",
            permissions: "*"
        }]
    },

    httpNodeAuth: {user:"user", pass:"63255 etc etc etc"}
   
};

I added in my normal security (only works with recent versions of Node-Red) as you see above and a couple of useful includes (assuming MOMENT has been added also by NPM)

Well, it all works  - BUT for the httpNodeAuth. The editor asks for a login password as normal – and that’s great, but critically the UI does NOT ask for a password – I still have no idea why not.

So clearly if the designers make significant changes, a script is going to be needed to automate putting my stuff back in (easy) but that security for the UI needs sorting.

I left lots of questions with the designer and eventually he came back to me but he was heading off to some exhibition so I don’t expect to hear from him for a few days. He agrees that UI is important so it may be we can sort this out with Andrei (UI) involved  - I don’t want to distract him right now as he’s going to work on using .PNGs in the UI and that’s important too.

In summary: If the issue of the UI password can be resolved (this would apply to any other package sitting on top of Node-Red – web page etc… and see below for reasons for failure -  provided there are no hidden demons I have yet to discover,  this looks like a reasonable way to get Node-Red up and running. Well done to the people at theThingBox.io for what must have been quite a lot of work.

Bugs/Issues: Although I can open up a terminal and type “reboot” – there still seems to be to shut the package down – but see further down – I came up with a solution.

The security for UI needs sorting and I noticed issues with the SOUND and VOLUME nodes. The SOUND node states that one of the outputs activates when the sound is finished. It does NOT.. it comes back before the end. I installed and used MPG123 and fired that off via an EXEC node instead – that works a treat. Finally VOLUME – might just be me but I could not see how to change the volume – there’s a slider that does not seem to do much. Perhaps someone can enlighten me on that. Opening a terminal and typing …amixer set PCM 0, 100% sorts it out but that’s hardly satisfactory – nor permanent for starters. I tried that in an EXEC node – nothing.

When installing SQLITE it is necessary to change 2 references to port 80 to 81 in /etc/apache2/ports.conf and one reference in /etc/apache2/sites-enabled/000-default

And I found a rather crude solution to turning the Pi off – one that lends itself to automation..  In the Node-Red editor – add an EXEC node and in there, (un-tick the box for appending) – put “shutdown –h now” without the quotes.  Send any input to that EXEC box and the system will shut down entirely leaving only the PI red light on. Simples.

Just about got a script working to take the pain away. The ONLY thing I’ve not been able to crack is putting password security back onto /api/ui – and it turns out that isn’t going to work as Thingbox is not using the latest Node-Red yet (it is also using Wheezy not Jessie (thanks for that, Dave).

I assuming SOUND will get fixed and that there really is a use for that VOLUME control. 

Facebooktwittergoogle_pluspinterestlinkedin

9 thoughts on “ThingBox

  1. Thanks for that Leorrr - as a result of that head start, I've re-written the blog - I found out where the settings file was - changed the port back to normal and the UI address back to normal. I even have password protection back on the Node-Red section but strangely NOT on the /UI part which needs fixing - that and figuring out how to turn the Pi OFF!! "reboot" works in a terminal, but "shutdown now" and variants just sit there looking at you.

    Other than that - great progress.

  2. Just my 2p - I found Thingbox to be an ideal way to quickly get a MQTT / Node-Red system up and running (with lots of useful nodes pre-installed). But for me, I found I still had to add my own nodes and the build discrepancies from a standard install probed to be too distracting e.g. the need to use "/api".

    Without Thingbox, a system like this hasto be manually built and whilst this a lot more hassle, it does mean that you get a MQTT/ node-red system which you are more in control of and more people can help you if you encounter problems.

    I found the best thing was to keep 2 images - one for the latest thingbox release (too see what's new!) and another for my own install (with it's own install script).

    1. Hi pete - well as you'll see from the updated blog it is easy to get rid of the /API but I take your point. It is a lot of work to set this up normally - and I'm finding it harder in Jessie than in Wheezy for some reason.

    2. Just about got a script running (I'm not that clever with scripts) - got it installing everything - need it to change the port numbers over in 2 files) - then it's just a case of loading up Thingbox, running the script and copying over my flows...

  3. Hi Peter,

    On my Thingbox the login is root/raspberry, not root/blackberry as stated in the article.

    Your blog is one of my daily reads. You realise with all these new toys to play with you'll never have enough time now 🙂

  4. Have you had the chance to investigate the possibilities of Weaved, which is a simple way of connecting to Raspberries or other units over the web.
    They have solved the problems around connecting to node-red.

    What I am looking for is a simple way to connect to the contrib-ui directly from the web without having to add /ui to the url supplied by weaved when logging into the service on port 1880 on the Raspberry.

    I find your pages very informative and useful, and very often I end up in your webpage when searching using google. I have a small wireless network collecting data, which in turn is parsed and rebuilt using node-red running in a Raspberry PI. For real time presentation I use dweet.io and Freeboard.io.

    I have a test running at freeboard.io/board/3yYMrt.
    This is just used to disply fresh data, and also some status info about age and battery status.

    For historical display I have chosen a simple approach by just use contrib-ui graph with a suitable time depth. Access to these graphs are given by Weaved, but I have to add /ui to the url at login time. I am in the matter of finding a way to move the /ui page to a separate port number. This will enable instant access to the ui web page from Weaved login.

    1. Hi there..

      Not come across WEAVED yet, I connect Raspberries together using MQTT in Node-Red, didn't know there was a problem connecting to Node-Red, contrib-ui is now dead in favour of it's successor DASHBOARD, I did use Freeboard but DASHBOARD does all of that... and for graphing I now use Imperihome and have temperature and humidity data for several months stored on the PI in a SQLITE database.... before you do any more on /ui suggest you consider dashboard as ui no longer supported.

      Thanks for the info... all interesting stuff.

      Regards

      Pete.

Leave a Reply

Your email address will not be published. Required fields are marked *