TelldusLive

273 views
Skip to first unread message

Joakim Vindgard

unread,
Jun 6, 2016, 7:38:19 AM6/6/16
to Node-RED
Hi!

I have recently started to use Node-Red and I must say that it's an awesome tool. I am a programmer but I really love the simplicity of Node-Red without reducing the possibilities.

I have tried to use the TelldusLive code available at https://github.com/TheThingSystem/node-telldus-live/ but I can't seem to get it to work. I just posted an issue in the GitHub repo but I am just curious if you guys have any ideas. The issue can be found here https://github.com/TheThingSystem/node-telldus-live/issues/8

Hi!

I have tried to use your code in my Node Red installation with no success. I have noted my versions of Node Red/Node.js. And I can't seem to get your code to work. I hope that you can help me.

6 Jun 13:19:54 - [info] Node-RED version: v0.13.4
6 Jun 13:19:54 - [info] Node.js  version: v4.2.2
6 Jun 13:19:54 - [info] Linux 3.11.10-29-default x64 LE

I have tried to enable it by adding the code below to settings.js in the functionGlobalContext part.

TelldusAPI:require("telldus-live")

and by adding var TelldusAPI = require('telldus-live'); to the acctual function node and to a bunch of places in the settings.js

When adding the var TelldusAPI = require('telldus-live'); in the function node I get this error message.

screen shot 2016-06-06 at 13 29 21

And if i remove the var TelldusAPI = require('telldus-live'); part I get this error message.

screen shot 2016-06-06 at 13 32 04

I am not that familiar with Node.js but I hope to get starting using your module since I have a Tellstick Net.

Best regards,
Jocke


Keep up the awesome work!

Best regards,
Jocke

Walter Kraembring

unread,
Jun 6, 2016, 8:02:09 AM6/6/16
to Node-RED
When adding the var TelldusAPI = require('telldus-live'); in the function node I get this error message.

What happens if you try:

var TelldusAPI = global.get('telldus-live'); 

BR Walter

Joakim Vindgard

unread,
Jun 6, 2016, 8:07:16 AM6/6/16
to Node-RED
Hi Walter!

When doing as you suggested I get the following error message.

6 Jun 14:05:49 - [error] [function:TelldusLive] TypeError: Cannot read property 'TelldusAPI' of undefined

Best regards,
Jocke

Walter Kraembring

unread,
Jun 6, 2016, 8:40:12 AM6/6/16
to Node-RED
In the settings.js, find the function "functionGlobalContext"

Try to insert with the full path to the telldus live js module library (where it is installed)

    functionGlobalContext: {
        tellduslive:require('/...full path...to the lib')
// os:require('os'),
        // bonescript:require('bonescript'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    },



Then in your function node
var TelldusAPI = global.get('tellduslive'); 

Timur Fatykhov

unread,
Jun 6, 2016, 8:43:54 AM6/6/16
to Node-RED
If you defined this in functionGlobalContext: - TelldusAPI:require("telldus-live") then in your function you need to use following:

var myTelldusAPI = global.get('TelldusAPI'); 

Walter Kraembring

unread,
Jun 6, 2016, 10:03:56 AM6/6/16
to Node-RED
I do not have a Telldus Net but just tested this myself with the following

installed the telldus live modules in /home/pi/.node-red/node_modules

in settings.js:

    functionGlobalContext: {
        tellduslive:require('telldus-live')
        //tellduslive:require('/home/pi/.node-red/node_modules/telldus-live')
// os:require('os'),
        // bonescript:require('bonescript'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    },



in function node:
var TelldusAPI = global.get('tellduslive'); 
msg.payload = TelldusAPI;
return msg;

Using a debug node, this gives

/6/2016, 4:03:11 PM47d58b69.265e84msg.payload : Object{ "commands": { "on": 1, "off": 2, "bell": 4, "dim": 16, "up": 128, "down": 256 } }

Julian Knight

unread,
Jun 6, 2016, 11:38:54 AM6/6/16
to Node-RED
I am sure that the information the others are giving will get you to the right place. Just to point out another way - not really best but OK for testing at least. There is a contributed node called something like "unsafe-function" which I believe does allow you to do a require in code within the function definition.

Within the normal function node, you are actually running JavaScript within a node.js VM which limits what you can do. This is, of course, much safer for general use.

Joakim Jacobsson

unread,
Jun 6, 2016, 5:15:11 PM6/6/16
to node...@googlegroups.com
Hey Guys!

I did what you said Walter and it works like a charm. I am now connected to TelldusLive and I can hopefully start using the API.

Thank you very much for your help. I didn't expect to get so much help so fast.

Keep up the good work!

Best regards,
Jocke

Walter Kraembring

unread,
Jun 7, 2016, 2:38:15 AM6/7/16
to Node-RED
Joakim, sounds fine!

Please keep this thread alive by giving feedback of your experience as well as sharing your flows later when *things* are working fine for you. Many users do have the TellStick Duo and for this there is already a nice node contribution available (https://www.npmjs.com/package/node-red-contrib-tellstick)

For the TellStick Net owners I am sure this topic will raise high interest

Best regards, Walter

Steinar Johnsen

unread,
Dec 14, 2016, 4:12:44 PM12/14/16
to Node-RED
Hi,
I'm trying to get this to work with thethingbox image on my Pi, but i can't figure out what files to put the lines Walter wrote.
Just started with this, so i'm a total noob at this area... :) 

Best regards.
Steinar
Reply all
Reply to author
Forward
0 new messages