maxwellhadley / node-red-contrib-rfxcom

node-RED nodes to access an RFXtrx433 transceiver
BSD 2-Clause "Simplified" License
22 stars 13 forks source link

find address of somfy roller shutters #79

Closed jgaret closed 5 years ago

jgaret commented 5 years ago

Hello,

I am currently using jeedom for my home automation system and planning to migrate to node-red. I have several somfy motorized roller shutters already controlled by an RFXTRX433E and working with jeedom.

I am stuck at findind the address to use with my somfy blinds. I've looked up the logs of the rfxcmd process used by jeedom, and I have this kind of logs:

[2019-04-28 06:18:07][DEBUG] : Client connected to [127.0.0.1:51634] [2019-04-28 06:18:07][DEBUG] : Message read from socket: {"apikey":"[REDACTED]","cmd":"send","data":["0C1A000074024FE80100000000"]} [2019-04-28 06:18:07][DEBUG] : Client disconnected from [127.0.0.1:51634] [2019-04-28 06:18:07][DEBUG] : Message received in socket JEEDOM_SOCKET_MESSAGE [2019-04-28 06:18:07][DEBUG] : Test message: 0C1A000074024FE80100000000 [2019-04-28 06:18:07][DEBUG] : flushOutput serial port [2019-04-28 06:18:07][DEBUG] : flushInput serial port [2019-04-28 06:18:07][DEBUG] : Write message to serial port [2019-04-28 06:18:07][DEBUG] : Write data to serial port : 0C 1A 00 00 74 02 4F E8 01 00 00 00 00 [2019-04-28 06:18:07][DEBUG] : Write message ok : 0C 1A 00 00 74 02 4F E8 01 00 00 00 00 [2019-04-28 06:18:07][DEBUG] : Decode message [2019-04-28 06:18:07][DEBUG] : Decode : 0C 1A 00 00 74 02 4F E8 01 00 00 00 00 [2019-04-28 06:18:07][DEBUG] : Test message: 0C 1A 00 00 74 02 4F E8 01 00 00 00 00 [2019-04-28 06:18:07][DEBUG] : PacketType: 1A [2019-04-28 06:18:07][DEBUG] : SubType: 00 [2019-04-28 06:18:07][DEBUG] : SeqNbr: 00 [2019-04-28 06:18:07][DEBUG] : Id1: 74 [2019-04-28 06:18:07][DEBUG] : Id2: 02 [2019-04-28 06:18:07][DEBUG] : Decode data : {'raw': '0C1A000074024FE80100000000', 'signal': 0, 'subtype': '00', 'command': u'Up', 'unitcode': '4F', 'packettype': '1A', 'id': '74024F'} [2019-04-28 06:18:08][DEBUG] : Client connected to [127.0.0.1:51638] [2019-04-28 06:18:08][DEBUG] : Message read from socket: {"apikey":"[REDACTED]","cmd":"send","data":["0C1A0000597387F20100000000"]} [2019-04-28 06:18:08][DEBUG] : Client disconnected from [127.0.0.1:51638] [2019-04-28 06:18:08][DEBUG] : Message received in socket JEEDOM_SOCKET_MESSAGE [2019-04-28 06:18:08][DEBUG] : Test message: 0C1A0000597387F20100000000 [2019-04-28 06:18:08][DEBUG] : flushOutput serial port [2019-04-28 06:18:08][DEBUG] : flushInput serial port [2019-04-28 06:18:08][DEBUG] : Write message to serial port [2019-04-28 06:18:08][DEBUG] : Write data to serial port : 0C 1A 00 00 59 73 87 F2 01 00 00 00 00 [2019-04-28 06:18:08][DEBUG] : Write message ok : 0C 1A 00 00 59 73 87 F2 01 00 00 00 00 [2019-04-28 06:18:08][DEBUG] : Decode message [2019-04-28 06:18:08][DEBUG] : Decode : 0C 1A 00 00 59 73 87 F2 01 00 00 00 00 [2019-04-28 06:18:08][DEBUG] : Test message: 0C 1A 00 00 59 73 87 F2 01 00 00 00 00 [2019-04-28 06:18:08][DEBUG] : PacketType: 1A [2019-04-28 06:18:08][DEBUG] : SubType: 00 [2019-04-28 06:18:08][DEBUG] : SeqNbr: 00 [2019-04-28 06:18:08][DEBUG] : Id1: 59 [2019-04-28 06:18:08][DEBUG] : Id2: 73 [2019-04-28 06:18:08][DEBUG] : Decode data : {'raw': '0C1A0000597387F20100000000', 'signal': 0, 'subtype': '00', 'command': u'Up', 'unitcode': '87', 'packettype': '1A', 'id': '597387'}

So, I was guessing these two devices where of address: RFY/0x7402/4F RFY/0x5973/87

Trying them, I have to types of return messages: The first one returns:

RFXCOM: Unknown RFY remote ID (5)

The second:

Error: Invalid unit code 87

Do you know how can I find the addresses from my current setup ?

Milmoor commented 5 years ago

Nr. 5 is alive (or not) Remote ID 5 seems to be a special case. For my Somfy devices, I had to use 0 instead of 5.

Current addresses Instead of trying to find the current addresses, just program new ones? It works the same as adding a new remote control. Just switch to the correct channel on your remote, press program on the old one, and the send the new ID/Unit you want to use. In my case, I used an ID in Domoticz with my RFXcom which was too long (6 positions) for this Node-red module (max 5 positions). This solved it quite easily for me. More info here: https://service.somfy.com/downloads/nam_v4/telisrts_programming.pdf

Not working yet, somehow the programming doesn't work. I'll be back.

maxwellhadley commented 5 years ago

The RFXCOM documentation I have says the ID is in fact 3 bytes, with the unitcode as the 4th byte, so your examples would be using addresses 0x74024F/232 and 0x597387/242. Both of these are invalid: the address part must be between 0x1 and 0xFFFFF (inclusive), and for subtype 0 (Somfy RTS, Simu) the unitcode must be between 0 to 4 (inclusive).

If your RFXtrx433E is working with Jeedom, it may be that the firmware installed is very old - do you know what the version is? The status text under any rfx node in NodeRED will show this.

As far as I know, the best approach is to choose a new 'remote address' and reprogram the blind motor as described in the node-rfxcom documentation. A message payload of program will send the program command to the address specified in the topic.

jgaret commented 5 years ago

I currently have a v1005 firmware,

Reading the node-rfxcom documentation, I've found that there's a call listRemotes(). I guess that it could be useful to find my registered remotes, no ?

But I am not quite used to programming in nodejs and I am not sure if I do things the right way. Here is the code I attempt to run :

var rfxcom = require('rfxcom');
var rfxtrx = new rfxcom.RfxCom("/dev/ttyUSB0", {debug: true});
var sleep = require('system-sleep');

rfxtrx.initialise(function () {
            console.log("Device initialised");
});

sleep(10000);
var rfy = new rfxcom.Rfy(rfxtrx, rfxcom.rfy.RFY, {venetianBlindsMode: "EU"});
console.log(rfy.listRemotes());

And it returns this to the console log :

29 Apr 14:06:01 - [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 29 Apr 14:06:01 - [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00 29 Apr 14:06:01 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,00,01,02,53,05,11,08,2F,80,01,02,1C,03,52,46,58,43,4F,4D 29 Apr 14:06:01 - [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,02,07,00,00,00,00,00,00,00,00,00 29 Apr 14:06:02 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,07,02,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D 29 Apr 14:06:02 - [rfxcom] on /dev/ttyUSB0 - Copyright RFXCOM 29 Apr 14:06:02 - [rfxcom] on /dev/ttyUSB0 - Started command message queue Device initialised 29 Apr 14:06:05 - [rfxcom] on /dev/ttyUSB0 - Queued : 0C,1A,00,03,00,00,01,01,06,00,00,00,00 3 29 Apr 14:06:05 - [rfxcom] on /dev/ttyUSB0 - Sent : 0C,1A,00,03,00,00,01,01,06,00,00,00,00 29 Apr 14:06:06 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,03,03,00,00,05,8A,9E,03,69,67,68,74,20,52,46,58,43,4F,4D 29 Apr 14:06:06 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,03,03,00,01,0B,35,17,0B,69,67,68,74,20,52,46,58,43,4F,4D 29 Apr 14:06:06 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,03,03,00,02,03,2F,43,08,69,67,68,74,20,52,46,58,43,4F,4D 29 Apr 14:06:07 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,03,03,00,03,0F,73,87,02,69,67,68,74,20,52,46,58,43,4F,4D 29 Apr 14:06:07 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,03,03,00,04,0E,02,4F,08,69,67,68,74,20,52,46,58,43,4F,4D 29 Apr 14:06:07 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,03,03,00,05,0B,6E,E7,04,69,67,68,74,20,52,46,58,43,4F,4D 29 Apr 14:06:07 - [rfxcom] on /dev/ttyUSB0 - Received: 14,01,03,03,00,06,06,C1,57,01,69,67,68,74,20,52,46,58,43,4F,4D

That seems good, I have 7 registered remotes in Jeedom. Now, I need to find the RFXCOM doc to know the message format and find the device ID and unitcode from them.

maxwellhadley commented 5 years ago

You need to listen to the rfyremoteslist event of your rfxtrx object

jgaret commented 5 years ago

Hum... that seems a little beyond my nodejs skills.... Would you have some example code for that ?

Will that give something more than the "Received" lines of my previous post ?

jgaret commented 5 years ago

Ok ! I've got it !

var rfxcom = require('rfxcom');

var rfxtrx = new rfxcom.RfxCom("/dev/ttyUSB0", {debug: true});

var sleep = require('system-sleep');

rfxtrx.initialise(function () {
            console.log("Device initialised");
});

sleep(10000);
var rfy = new rfxcom.Rfy(rfxtrx, rfxcom.rfy.RFY, {venetianBlindsMode: "EU"});
console.log(rfy.listRemotes());

rfxtrx.on("rfyremoteslist", function (evt) {
        console.log(evt);
});

And the result is :

[ { remoteNumber: 0, remoteType: 'RFY', deviceId: '0x058A9E/3', idBytes: [ 5, 138, 158 ], unitCode: 3, randomCode: 105, rollingCode: 26472 }, { remoteNumber: 1, remoteType: 'RFY', deviceId: '0x0B3517/11', idBytes: [ 11, 53, 23 ], unitCode: 11, randomCode: 105, rollingCode: 26472 }, { remoteNumber: 2, remoteType: 'RFY', deviceId: '0x032F43/8', idBytes: [ 3, 47, 67 ], unitCode: 8, randomCode: 105, rollingCode: 26472 }, { remoteNumber: 3, remoteType: 'RFY', deviceId: '0x0F7387/2', idBytes: [ 15, 115, 135 ], unitCode: 2, randomCode: 105, rollingCode: 26472 }, { remoteNumber: 4, remoteType: 'RFY', deviceId: '0x0E024F/8', idBytes: [ 14, 2, 79 ], unitCode: 8, randomCode: 105, rollingCode: 26472 }, { remoteNumber: 5, remoteType: 'RFY', deviceId: '0x0B6EE7/4', idBytes: [ 11, 110, 231 ], unitCode: 4, randomCode: 105, rollingCode: 26472 }, { remoteNumber: 6, remoteType: 'RFY', deviceId: '0x06C157/1', idBytes: [ 6, 193, 87 ], unitCode: 1, randomCode: 105, rollingCode: 26472 } ]

So, unit codes of 11 and 8 are valid (as they work with Jeedom). I've succesfully sent a command to an already existing remote on my rfxtrx. I'll try later if I change the code of the rfxcom library to allow unit codes > 4 if all the motors respond to commands.

jgaret commented 5 years ago

I confirm that it works well with unit codes of 8 and 11. There might be something wrong with your documentation.

I would close this issue. Should I post a PR to update the unitcode restriction on node-rfxcom ?

maxwellhadley commented 5 years ago

When you 'it works well with unit codes of 8 and 11', you mean Jeedom does? Node-rfxcom should throw an exception for codes > 4. Presumably the blind motors respond correctly? Can you confirm this is subtype 0, 'RFY'.

It looks like there might be an error in the RFXCOM SDK documentation!

jgaret commented 5 years ago

I mean that I am able to control my somfy blind motors from node-red. I have modified the node-rfxcom rfy.js file to allow unit codes up to 0x0f to be able to do so. For example, this topic RFY/0x0B3517/11 with payload Up works well.

I've opened pull request on node-rfxcom : https://github.com/rfxcom/node-rfxcom/pull/86

maxwellhadley commented 5 years ago

I have checked with RFXCOM, and it appears that operation with unit codes higher than 4, especially with codes 5 & 6, may not always work reliably. It is recommended not to use unit numbers higher than 4. Since node-rfxcom isn't restricted to a single 'remote' address, there is no real need to use higher unit codes anyway.