RFLink and more things to control!!
I picked up a couple of new mains-controlling gizmos that use 433MHz control signals from Maplins today:
I got the energyEGG things on the back of a recent Scargill tech blog entry, which mentioned someone getting an energyEGG PIR motion sensor and a few controllable switches as a "last ones, all gone" deal from Maplin. I checked out their current stock, unfortunately no EGGs left, but they did have some 2-gang switches for 99p each. Since Scargill had already contacted the RFLink software chap, Frank, with various debug traces, I've dropped him a line to see if he's going to support them. Watch this space...
Meanwhile, back at the (stacked-baked-clay-cuboid-lump) hut, I've been bashing away with the Maplin Remote Control switches. Here's the skinny:
- energyEGG smart light switches - 2-gang; these were 99p each, so gotta be worth a try
- Maplin's own Remote Control Socket - 3 pack; about £14
energyEgg Switch (L) Remote Control Switch (R) |
Remote Control Switch - rear |
Meanwhile, back at the (stacked-baked-clay-cuboid-lump) hut, I've been bashing away with the Maplin Remote Control switches. Here's the skinny:
- They are supported by RFLink (hurray!), as Maplin RSL366 devices
- RFLink detects the remote control as protocol "TriState"
- The control and switches can be switched to use 4 different Codes (I-IV), using
- A tiny 4-position slider on the remote
- The upper rotary switch on the switch rear
- There are 4 sets of ON/OFF buttons on the remote (see the picture above); each switch uses the lower rotary switch to configure its Channel (1-4)
- All of this seems to work pretty well using the remote control
Right. Time for some traces...
- Code I/Channel 1 ON:
- 20;33;TriState;ID=02a2aa;SWITCH=2;CMD=ON;
- Code IV/Channel 4 OFF:
- 20;34;TriState;ID=02aa8a;SWITCH=2;CMD=OFF;
Looks easy enough, right? Well, it is... kinda. I made up a table of the Code/Channel combinations to test them all...
Then I made up a NodeRed function that would generate an appropriate RFLink command string in the format "10;TriState;<id>;2;{ON|OFF}" when presented with a NodeRed message with the right properties.
Here's the Flow Tab with the relevant components on it:
Here's the code in the TriState Control node:
Code | Channel | ID | Code | Channel |
I | 1 | 02a2aa | 02a | 2aa |
I | 2 | 02a8aa | 02a | 8aa |
I | 3 | 02aa2a | 02a | a2a |
I | 4 | 02aa8a | 02a | a8a |
II | 1 | 08a2aa | 08a | 2aa |
II | 2 | 08a8aa | 08a | 8aa |
II | 3 | 08aa2a | 08a | a2a |
II | 4 | 08aa8a | 08a | a8a |
III | 1 | 0a22aa | 0a2 | 2aa |
III | 2 | 0a28aa | 8aa | |
III | 3 | 0a2a2a | a2a | |
III | 4 | 0a2a8a | a8a | |
IV | 1 | 0a82aa | 0a8 | 2aa |
IV | 2 | 0a88aa | 8aa | |
IV | 3 | 0a8a2a | a2a | |
IV | 4 | 0a8a8a | a8a |
TriState Remore Switch Control Nodes |
- TriState Control - Function node that generates the control string for RFLink when it receives a message with code/channel/state in it
- TriState Test Driver - simple JS routine that generates a fixed message for testing
- TriState X/N On/Off - insert widgets with msg.payload set to a hardcoded RFLink control string - my original test widgets; unfortunately CR/LF is required, hence...
- Add CRLF - Function node that just adds CR/LF to msg.payload, and
- Message Doubler - Function node that just repeats the input msg; added as part of testing to see if it made things more reliable
- Input Link node - allows other flows to send control messages to this Flow
- Output Link node - this node sends RFLink control messages to the RFLink flow
Here's the code in the TriState Control node:
/* Incoming message has:
code: 1-4
channel: 1-4
state: ON/OFF or 1/0
Outgoing generates a pair of messages to set
the required state in the TriState device on
the specified code/channel.
*/
// Accept msg.xxxx and msg.payload.xxxx
if (msg.payload !== undefined) {
if ((msg.payload.code !== undefined) && (msg.code === undefined))
msg.code = msg.payload.code;
if ((msg.payload.channel !== undefined) && (msg.channel === undefined))
msg.channel = msg.payload.channel;
if ((msg.payload.state !== undefined) && (msg.state === undefined))
msg.state = msg.payload.state;
}
if (msg.code < 1 || msg.code > 4) {
node.error("TriState Control: Invalid Code: " + msg.code);
return null;
}
if (msg.channel < 1 || msg.channel > 4) {
node.error("TriState Control: Invalid Channel: " + msg.channel);
return null;
}
msg.state = msg.state.toUpperCase();
if ((msg.state != "ON") && (msg.state != "OFF") && (msg.state != 1) && (msg.state !== 0)) {
node.error("TriState Control: Invalid State: " + msg.state);
return null;
}
var code_s = ["02a", "08a", "0a2", "0a8"];
var chan_s = ["2aa", "8aa", "a2a", "a8a"];
var msg_out = "10;Tristate;" + code_s[msg.code-1] + chan_s[msg.channel-1] + ";2;";
switch (msg.state) {
case "OFF":
case 0:
msg_out = msg_out + "OFF;";
break;
case "ON":
case 1:
msg_out = msg_out + "ON;";
break;
}
msg.payload = msg_out + "\r\n";
return [ [ msg, msg ] ];
It attempts to allow msg.code|channel|state or msg.payload.code|channel|state to control the control message generation. Great! The test injectors make the switches turn on and off on request.
Tricky Bits
Tricky Bits
- 433MHz is easily masked by dense metal objects - I had two switches on the same extension array, but with one close to the subwoofer, containing lot of metal bits, for my computer speakers. The first one worked perfectly, the second seemed to work intermittently at best. I switched locations, and the first now was intermittent, in the shadow of the subwoofer.
- RFLink requires CR/LF on the end of control strings!! At least, although it seems to work without, using commands like "VERSION", when I sent "10" messages to signal the switches without they didn't seem to work. This could have been due to other things, and I changed more than one thing at a time... Bad Boy.
- The TriState Remote Control seems to send differing signals on short and long presses. Although switching ON seemed to work consistently, switching OFF didn't. I was a bit fooled for a while by the fact that the remote sends a single signal for a quick press (Code/Channel/Switch/OFF), and two signals for a long press, on the release (Code/Channel/Switch/OFF) and (Code?/Channel?/Switch/ON). I haven't analysed the second signal Code/Channel, but when things weren't turning off properly I experimented sending it after the OFF signal. Eventually I realised I only needed the OFF, so fixed up the TriState Control code to send the OFF message 2 times, in case one got lost!
Comments
Post a Comment