You can do this in such way:
1. prepare a user.somfy library with:
- a table with every commands for every channel (up, down, +, -, program, set) e.g.
- communication function
2. Use it in event-based script.
3. You can also improve this with a function of buffering based on UDP because somfy transmitter is very slow. E.g. for sending step command 0,4s; up/down 0,6s; program 6s. So when you will send some command too fast(too soon after last command), it will not work.
Please check:
http://forum.logicmachine.net/showthread...ight=somfy
1. prepare a user.somfy library with:
- a table with every commands for every channel (up, down, +, -, program, set) e.g.
Code:
Somfy = {
ch01 = {
up = string.char(0x7F,0xF2,0xFA,0xB8,0x43,0xFA,0x00,0x00,0x00,0xFF,0xFE,0x06,0x5D),}}
- communication function
Code:
-- Send to Somfy transmitter
somfy_send(cmd)
port = require('serial').open('/dev/RS485', {
baudrate = 4800,
parity = 'odd',
duplex = 'half',
databits = 8,
stopbits = 1
})
port:write(cmd)
end
2. Use it in event-based script.
Code:
somfy_send(Somfy.ch01.up)
3. You can also improve this with a function of buffering based on UDP because somfy transmitter is very slow. E.g. for sending step command 0,4s; up/down 0,6s; program 6s. So when you will send some command too fast(too soon after last command), it will not work.
Please check:
http://forum.logicmachine.net/showthread...ight=somfy