We have a project that we will integrate with Somfy blinds and shutter.
We will communicate and control with some extra transmitter/gateway device which is converting RS485 commands to RF signals.
All blinds and shutters get RF commands from this transmitter/gateway device.
It has a special for RS485 protocol and commands for communication & control.
We need to implement this protocol commands to LM.
I attached RS485 protocol guide & transmitter/gateway device documentation below.
What we need ?
We need to communicate with transmitter/gateway to send basic blinds & shutter commands. such as open/close,up/down etc.
16.01.2017, 15:48 (This post was last modified: 16.01.2017, 15:49 by buuuudzik.)
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.
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.
Somfy = {
ch01 = {
up = string.char(0x7F,0xF2,0xFA,0xB8,0x43,0xFA,0x00,0x00,0x00,0xFF,0xFE,0x06,0x5D),}}
and in event communication function also i have done this code also
- 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
but the last end i given the error so i have removed end also
In event base script i have done the
omfy_send(cmd)
port = require('serial').open('/dev/RS485', {
baudrate = 4800,
parity = 'odd',
duplex = 'half',
databits = 8,
stopbits = 1
})
string.char(0x7F,0xF2,0xFA,0xB8,0x43,0xFA,0x00,0x00,0x00,0xFF,0xFE,0x06,0x5D),}}
this with the hexacode given by somfy vendor
but the contoller is not working
so please tell the procedure todo because i am doing it first time
You must have:
- id of your Somfy RS-485 transmitter,
- path to your RS-485 port from Logic Machine (often LM has more than one),
- use frame builder to prepare apropriate command e.g. up or down
- you can log the response from serial
(17.09.2020, 18:17)buuuudzik Wrote: You must have:
- id of your Somfy RS-485 transmitter,
- path to your RS-485 port from Logic Machine (often LM has more than one),
- use frame builder to prepare apropriate command e.g. up or down
- you can log the response from serial
Hi
- yes i have id of the transmitter but where i have to write
- i have connected to the RS485-3 means port 3
- using the frame builder only i have all hexa codes
so this is the code i have write in event based script but it is not working
-- for curtain up
if not port then
require('serial')
port = serial.open('/dev/RS485-3', {
baudrate = 4800,
parity = 'odd',
databits = 8,
stopbits = 1,
duplex = 'half'
})
port:flush()
end
if port then
ch01=up
char = string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xB5, 0x2B, 0xFA, 0xFF, 0xFE, 0x06, 0x43)
-- wait for 1.5 seconds
os.sleep(0.1)
char = string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xB5, 0x2B, 0xFA, 0xFF, 0xFE, 0x06, 0x43)
alert(char)
port:write(char)
end
-- For curtain down
if not port then
require('serial')
port = serial.open('/dev/RS485-3', {
baudrate = 4800,
parity = 'odd',
databits = 8,
stopbits = 1,
duplex = 'half'
})
port:flush()
end
if port then
char = string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xB5, 0x2B, 0xFA, 0xFF, 0xFE, 0x06, 0x42)
-- wait for 1.5 seconds
os.sleep(0.1)
char = string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xB5, 0x2B, 0xFA, 0xFF, 0xFE, 0x06, 0x42)
alert(char)
port:write(char)
end
FWIW, I have shutters/blinds RF integration based on Sonoff RF bridge flashed with custom firmware, it connects to MQTT that's running on LM, but it also needs WiFi to run. It's super cheap and easy to program, and you can issue simple MQTT commands to operate.
(17.09.2020, 18:17)buuuudzik Wrote: You must have:
- id of your Somfy RS-485 transmitter,
- path to your RS-485 port from Logic Machine (often LM has more than one),
- use frame builder to prepare apropriate command e.g. up or down
- you can log the response from serial
Hi Buuuudzik,
Have you had experience with reading the response from the nodes?
I.e. if you use the broadcast message 'get node address'??
The returned message from the node appears as symbols when logged?
With the script below i now can control one motor. But that motor was already programmed by a remote control. Now my question is if someone can tell me if and how it's possible to program a new motor from scratch on please as i totaly don't understand the protocol and all of its functions. There is no manuel explaining the RTS protocol so i'm really confused..
if value == false then
res, err = port:write(string.char(0x7F,0xF2,0xFA,0xC9,0x7B,0xFA,0x00,0x00,0x00,0xFE,0xFE,0x06,0xA5))
else
res, err = port:write(string.char(0x7F,0xF2,0xFA,0xC9,0x7B,0xFA,0x00,0x00,0x00,0xFE,0xFD,0x06,0xA4))
end
(14.09.2023, 13:41)Joep Wrote: With the script below i now can control one motor. But that motor was already programmed by a remote control. Now my question is if someone can tell me if and how it's possible to program a new motor from scratch on please as i totaly don't understand the protocol and all of its functions. There is no manuel explaining the RTS protocol so i'm really confused..
if value == false then
res, err = port:write(string.char(0x7F,0xF2,0xFA,0xC9,0x7B,0xFA,0x00,0x00,0x00,0xFE,0xFE,0x06,0xA5))
else
res, err = port:write(string.char(0x7F,0xF2,0xFA,0xC9,0x7B,0xFA,0x00,0x00,0x00,0xFE,0xFD,0x06,0xA4))
end
log(res, err)
You should know address of motors and implement your sendRS485 function with your connection parameters.
Check code below it would be great if it works you, but I can't be responsible for it.
It work with my motors.
(14.09.2023, 13:41)Joep Wrote: With the script below i now can control one motor. But that motor was already programmed by a remote control. Now my question is if someone can tell me if and how it's possible to program a new motor from scratch on please as i totaly don't understand the protocol and all of its functions. There is no manuel explaining the RTS protocol so i'm really confused..
if value == false then
res, err = port:write(string.char(0x7F,0xF2,0xFA,0xC9,0x7B,0xFA,0x00,0x00,0x00,0xFE,0xFE,0x06,0xA5))
else
res, err = port:write(string.char(0x7F,0xF2,0xFA,0xC9,0x7B,0xFA,0x00,0x00,0x00,0xFE,0xFD,0x06,0xA4))
end
log(res, err)
You should know address of motors and implement your sendRS485 function with your connection parameters.
Check code below it would be great if it works you, but I can't be responsible for it.
It work with my motors.
if endian == "little" then
lowByte, highByte = highByte, lowByte
end
return highByte,lowByte
end
Thanks for your answer and sharing your code. My biggest issue is how to set the correct channel? How is this done? First with a Somfy remote and once paired you can also control it by the script or how does it work?
15.09.2023, 19:47 (This post was last modified: 15.09.2023, 19:49 by Bitver.)
(15.09.2023, 12:04)Joep Wrote: Thanks for your answer and sharing your code. My biggest issue is how to set the correct channel? How is this done? First with a Somfy remote and once paired you can also control it by the script or how does it work?
Only address is needed for control by script. If you need RTS channels check rs485windowSetChannel function or remote controller.
Also I think you should check your motors documentation first for proper initial installation.
(15.09.2023, 12:04)Joep Wrote: Thanks for your answer and sharing your code. My biggest issue is how to set the correct channel? How is this done? First with a Somfy remote and once paired you can also control it by the script or how does it work?
Only address is needed for control by script. If you need RTS channels check rs485windowSetChannel function or remote controller.
Also I think you should check your motors documentation first for proper initial installation.