[Resolved] TrickleStar remote to razberry

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
alx
Posts: 5
Joined: 20 Oct 2014 23:02

[Resolved] TrickleStar remote to razberry

Post by alx »

Hi razberry users,

I'm new to zwave technology, and I'd like your advice about my project :

- I've got a working razberry (installed with access to web interface) and a TrickleStar Remote Control : http://laboutiquededomotique.com/teleco ... -wave.html

- I'd like to use the remote control to generate http requests from the raspberrypi

I've tried different ways to connect the remote control to the razberry, using this remote as the primay controller for example, it seems to work in configuration mode.

But once I pass to operation mode, the remote gives me an error, and I'm not sure where to check the debug on the razberry side (the queue is not showing anything).

What would be your advice to debug this connection issue ? Have you got other advices relative to this project ?

Thanks a lot,

Alex
Last edited by alx on 23 Oct 2014 02:04, edited 1 time in total.
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: TrickleStar remote to razberry

Post by pofs »

The queue shows only outgoing requests, while you need to see incoming.

The easiest way is to run

Code: Select all

tail -f /var/log/z-way-server.log
in SSH session and see what happens when you're pressing a button on remote.

But I don't like the idea of remote (i.e. portable controller) to be primary one.
alx
Posts: 5
Joined: 20 Oct 2014 23:02

Re: TrickleStar remote to razberry

Post by alx »

Thanks pofs for your reply, I'll have a look at the z-way-server.log file.

If you don't like the idea of the remote being the primary controller, how would you configure this setup ? the remote being a secondary controller ?
alx
Posts: 5
Joined: 20 Oct 2014 23:02

Re: TrickleStar remote to razberry

Post by alx »

Thanks a lot pofs, I've persisted a bit, and found how to make the Tricklestar remote as a secundary controller, and now I'm able to catch events in the logs :

Code: Select all

[2014-10-22 22:46:25.381] RECEIVED: ( 01 08 00 04 04 02 02 27 04 D4 )
[2014-10-22 22:46:25.383] SENT ACK
[2014-10-22 22:46:25.384] SETDATA devices.2.data.lastReceived = 0 (0x00000000)
[2014-10-22 22:46:25.385] Node 2:0 CC SwitchAll: On
[2014-10-22 22:46:25.386] SETDATA devices.2.instances.0.commandClasses.39.data.onOff = True

[2014-10-22 22:46:36.950] RECEIVED: ( 01 08 00 04 04 02 02 27 05 D5 )
[2014-10-22 22:46:36.952] SENT ACK
[2014-10-22 22:46:36.953] SETDATA devices.2.data.lastReceived = 0 (0x00000000)
[2014-10-22 22:46:36.954] Node 2:0 CC SwitchAll: Off
[2014-10-22 22:46:36.955] SETDATA devices.2.instances.0.commandClasses.39.data.onOff = False
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: [Resolved] TrickleStar remote to razberry

Post by pofs »

Ok, so now you should bind on change of that onOff value and make requests in the handler.
I believe there's a custom code module in Automation for that, so you can make http.request() call there. Look into dev manual to get more info about accepted parameters to fulfil your needs.

If there's no such a module, it is still quite simple to write the logic:

Code: Select all

var cc = zway.devices[deviceId].instances[0].commandClasses[39];
cc.data.onOff.bind(function(type) {
    if (type == 0x01 /* Updated */) {
        http.request({ ... });
    }
});
alx
Posts: 5
Joined: 20 Oct 2014 23:02

Re: [Resolved] TrickleStar remote to razberry

Post by alx »

I'm not sure where to place this module.

There's a /opt/z-way-server/automation folder, with a list of modules inside, but the npm install is giving me an error.
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: [Resolved] TrickleStar remote to razberry

Post by pofs »

If you want to create an actual module (for example, take DummyDevice as a base, also refer dev documentation on modules), you might just place a folder with it into userModules folder. It will be automatically available in the modules list after restart.

Otherwise you may just put your code in the end of main.js, but it is not recommended (won't survive updates).
alx
Posts: 5
Joined: 20 Oct 2014 23:02

Re: [Resolved] TrickleStar remote to razberry

Post by alx »

I've tried this piece of code in userModules/RemoteControl/index.js :

Code: Select all

function RemoteControl (id, controller) {
    RemoteControl.super_.call(this, id, controller);
}

inherits(RemoteControl, AutomationModule);

_module = RemoteControl;

RemoteControl.prototype.init = function (config) {
    RemoteControl.super_.prototype.init.call(this, config);

    var self = this;
    var deviceId = 2;

    var cc = zway.devices[deviceId].instances[0].commandClasses[39];
    cc.data.onOff.bind(function(type) {
        console.log('Remote type : ' + type);
        if (type == 0x01 /* Updated */) {
            http.request({
              url: 'http://localhost/record',
              method: 'get',
              async: true,
              success: function(response) {
            	  var data = typeof(response.data) == "object" ? "(" + JSON.stringify(response.data) + ")": response.data.toString();
              },
              error: function(response) {
                  console.log("Can not make request: " + response.statusText);
              }
            }); 
        }
    });
};

RemoteControl.prototype.stop = function () {
    RemoteControl.super_.prototype.stop.call(this);
};
This module seems to load after /etc/init.d/z-way-server restart :

Code: Select all

[2014-10-23 00:11:50.569] Loading module RemoteControl from userModules/RemoteControl/index.js
[2014-10-23 00:11:50.571] Scheduling execution of file: automation/userModules/RemoteControl/index.js
[2014-10-23 00:11:50.575] Executing script: function RemoteControl (id, controller) { ...
But I'm not able to catch the console.log from the script after pressing the remote buttons :

Code: Select all

[2014-10-23 00:12:22.138] RECEIVED: ( 01 08 00 04 04 02 02 27 05 D5 )
[2014-10-23 00:12:22.138] SENT ACK
[2014-10-23 00:12:22.138] SETDATA devices.2.data.lastReceived = 0 (0x00000000)
[2014-10-23 00:12:22.140] Node 2:0 CC SwitchAll: Off
[2014-10-23 00:12:22.142] SETDATA devices.2.instances.0.commandClasses.39.data.onOff = False
[2014-10-23 00:12:33.277] RECEIVED: ( 01 08 00 04 04 02 02 27 04 D4 )
[2014-10-23 00:12:33.278] SENT ACK
[2014-10-23 00:12:33.278] SETDATA devices.2.data.lastReceived = 0 (0x00000000)
[2014-10-23 00:12:33.278] Node 2:0 CC SwitchAll: On
[2014-10-23 00:12:33.278] SETDATA devices.2.instances.0.commandClasses.39.data.onOff = True
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: [Resolved] TrickleStar remote to razberry

Post by pofs »

Have you added module.json as well? Don't forget to set appropriate load priority (in case of old HA) or dependency on ZWave (in case of new one).

You also need to enable your module in HA, it is not enabled by default.
Post Reply