rfcontroljs
Advanced tools
Comparing version 0.0.33 to 0.0.34
@@ -6,3 +6,3 @@ var doesProtocolMatch, helper, protocols, sortIndices, | ||
protocols = ['weather1', 'weather2', 'weather3', 'weather4', 'weather5', 'weather6', 'weather7', 'switch1', 'switch2', 'switch3', 'switch4', 'switch5', 'switch6', 'switch7', 'switch8', 'switch9', 'switch10', 'switch11', 'switch12', 'switch13', 'switch14', 'switch15', 'switch16', 'switch17', 'rolling1', 'dimmer1', 'pir1', 'pir2', 'pir3', 'pir4', 'pir5', 'contact1', 'contact2', 'generic', 'alarm1', 'led1', 'led2', 'led3', 'led4', 'doorbell1', 'awning1', 'shutter1']; | ||
protocols = ['weather1', 'weather2', 'weather3', 'weather4', 'weather5', 'weather6', 'weather7', 'weather8', 'switch1', 'switch2', 'switch3', 'switch4', 'switch5', 'switch6', 'switch7', 'switch8', 'switch9', 'switch10', 'switch11', 'switch12', 'switch13', 'switch14', 'switch15', 'switch16', 'switch17', 'switch18', 'switch19', 'switch20', 'rolling1', 'dimmer1', 'pir1', 'pir2', 'pir3', 'pir4', 'pir5', 'contact1', 'contact2', 'contact3', 'generic', 'alarm1', 'led1', 'led2', 'led3', 'led4', 'doorbell1', 'awning1', 'shutter1']; | ||
@@ -9,0 +9,0 @@ protocols = protocols.map((function(_this) { |
@@ -25,4 +25,4 @@ module.exports = function(helper) { | ||
brands: ["awningCode"], | ||
pulseLengths: [376, 732, 1560, 4736, 7768], | ||
pulseCounts: 168, | ||
pulseLengths: [352, 740, 1580, 4720, 7772], | ||
pulseCount: 164, | ||
decodePulses: function(pulses) { | ||
@@ -32,15 +32,12 @@ var binary, command, commandcode, result; | ||
commandcode = binary.slice(31, 35); | ||
switch (commandcode) { | ||
case "1001": | ||
command = "in"; | ||
break; | ||
case "1000": | ||
command = "out"; | ||
break; | ||
case "1010": | ||
command = "stop"; | ||
break; | ||
default: | ||
command = "code:" + commandcode; | ||
} | ||
command = ((function() { | ||
switch (commandcode) { | ||
case '1001': | ||
return 'in'; | ||
case '1000': | ||
return 'out'; | ||
case '1010': | ||
return 'stop'; | ||
} | ||
})()); | ||
return result = { | ||
@@ -54,17 +51,12 @@ id: helper.binaryToNumber(binary, 0, 30), | ||
id = helper.map(helper.numberToBinary(message.id, 31), binaryToPulse); | ||
switch (message.command) { | ||
case "in": | ||
commandcode = "1001"; | ||
break; | ||
case "out": | ||
commandcode = "1000"; | ||
break; | ||
case "stop": | ||
commandcode = "1010"; | ||
break; | ||
default: | ||
if (message.command.slice(0, 5) === "code:") { | ||
commandcode = message.command.slice(5); | ||
} | ||
} | ||
commandcode = ((function() { | ||
switch (message.command) { | ||
case 'in': | ||
return '1001'; | ||
case 'out': | ||
return '1000'; | ||
case 'stop': | ||
return '1010'; | ||
} | ||
})()); | ||
commandcode = helper.map(commandcode, binaryToPulse); | ||
@@ -71,0 +63,0 @@ return "32" + id + commandcode + commandcode + "1032" + id + commandcode + commandcode + "14"; |
@@ -15,3 +15,3 @@ module.exports = function(helper) { | ||
name: 'shutter1', | ||
type: 'switch', | ||
type: 'command', | ||
values: { | ||
@@ -21,4 +21,4 @@ id: { | ||
}, | ||
state: { | ||
type: "boolean" | ||
command: { | ||
type: "string" | ||
} | ||
@@ -28,33 +28,39 @@ }, | ||
pulseLengths: [280, 736, 1532, 4752, 7796], | ||
pulseCounts: 168, | ||
pulseCount: 164, | ||
decodePulses: function(pulses) { | ||
var binary, result, state_binary, state_boolean; | ||
var binary, command, commandcode, result; | ||
binary = helper.map(pulses, pulsesToBinaryMapping); | ||
state_binary = binary.slice(31, 35); | ||
switch (state_binary) { | ||
case "1001": | ||
state_boolean = false; | ||
break; | ||
case "1000": | ||
state_boolean = true; | ||
} | ||
commandcode = binary.slice(31, 35); | ||
command = ((function() { | ||
switch (commandcode) { | ||
case '1000': | ||
return 'up'; | ||
case '1001': | ||
return 'down'; | ||
case '1010': | ||
return 'stop'; | ||
} | ||
})()); | ||
return result = { | ||
id: helper.binaryToNumber(binary, 0, 30), | ||
state: state_boolean | ||
command: command | ||
}; | ||
}, | ||
encodeMessage: function(message) { | ||
var id, state_binary, state_pulse; | ||
var commandcode, id; | ||
id = helper.map(helper.numberToBinary(message.id, 31), binaryToPulse); | ||
switch (message.state) { | ||
case false: | ||
state_binary = "1001"; | ||
break; | ||
case true: | ||
state_binary = "1000"; | ||
} | ||
state_pulse = helper.map(state_binary, binaryToPulse); | ||
return "32" + id + state_pulse + state_pulse + "1032" + id + state_pulse + state_pulse + "14"; | ||
commandcode = ((function() { | ||
switch (message.command) { | ||
case 'up': | ||
return '1000'; | ||
case 'down': | ||
return '1001'; | ||
case 'stop': | ||
return '1010'; | ||
} | ||
})()); | ||
commandcode = helper.map(commandcode, binaryToPulse); | ||
return "32" + id + commandcode + commandcode + "1032" + id + commandcode + commandcode + "14"; | ||
} | ||
}; | ||
}; |
{ | ||
"name": "rfcontroljs", | ||
"version": "0.0.33", | ||
"version": "0.0.34", | ||
"description": "Protocol support for different 433mhz switches and weather stations for the RFControl Arduino library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
174713
57
3659