Hi,
I wrote a new protocol for my awning. It has 3 states: “out”, “in” and “stop” and the device id. The only thing is that I don’t know the brand of the remote. Perhaps someone can use it for his awning:
awning1.coffee:
module.exports = (helper) ->
pulsesToBinaryMapping = {
'320101': '' #header
'01': '0' #binary 0
'10': '1' #binary 1
'14': '' #footer
}
binaryToPulse = {
'0': '01'
'1': '10'
}
return protocolInfo = {
name: 'awning1'
type: 'switch'
values:
id:
type: "number"
command:
type: "string"
brands: ["awningCode"]
pulseLengths: [376, 732, 1560, 4736, 7768]
pulseCounts: 168
decodePulses: (pulses) ->
# pulses for out and in is something like:
#320101
#1001010101100101010101010110011010100101101010010110010101
#10010101
#10010101
#10
#320101
#1001010101100101010101010110011010100101101010010110010101
#10010101
#10010101
#14'
# we first map the sequences to binary
binary = helper.map(pulses, pulsesToBinaryMapping)
# binary is now something like: '10000100000001011100111001000 10011001'
# now we extract the data from that string
# | 10000100000001011100111001000 | 1000 | 1000 |
# | ID | command | command |
#
# | 1 |
# |fixed |
#
# | 10000100000001011100111001000 | 1000 | 1000 |
# | ID | command | command |
commandcode = binary[29..32]
switch commandcode
when "1001" then command = "in"
when "1000" then command = "out"
when "1010" then command = "stop"
else command = "code:#{commandcode}"
return result= {
id: helper.binaryToNumber(binary, 0, 28)
command: command
}
encodeMessage: (message) ->
id = helper.map(helper.numberToBinary(message.id, 29), binaryToPulse)
switch message.command
when "in" then commandcode = "1001"
when "out" then commandcode = "1000"
when "stop" then commandcode = "1010"
else #this gives the ability for personal commands
if message.command[0..4] is "code:"
commandcode = message.command[5..]
commandcode = helper.map(commandcode, binaryToPulse)
return "320101#{id}#{commandcode}#{commandcode}10320101#{id}#{commandcode}#{commandcode}14"
}
config.json:
{
"id": "markise1",
"name": "Markise",
"class": "HomeduinoRFButtonsDevice",
"buttons": [
{
"id": "mark1",
"text": "Ausfahren",
"protocols": [
{
"name": "awning1",
"options": {
"id": 276871624,
"command": "out"
}
}
]
},
{
"id": "mark2",
"text": "Stop",
"protocols": [
{
"name": "awning1",
"options": {
"id": 276871624,
"command": "stop"
}
}
]
},
{
"id": "mark3",
"text": "Reinfahren",
"protocols": [
{
"name": "awning1",
"options": {
"id": 276871624,
"command": "in"
}
}
]
}
]
},
debug:
received: [ 292, 416, 736, 1568, 4724, 7772 ] 43020221020202022102020202020202210221212102022121210202210202022102020221020202214302022102020202210202020202020221022121210202212121020221020202210202022102020225
output:
Sending Protocol: awning1 id: 276871624 command: in all: false Pin: 4 Repeats: 7
The only thing I’m missing is a “3-state” button which can control the awning like this:
[Bild](kaeufl.no-ip.org/2015-05-16 00_11_51-pimatic.jpg)