1. Place the contents of user.sms.lua into a new user library called "sms"
2. Create a Resident script for SMS handler. Set sleep interval to 0 and place the contents of resident.lua into the script.
You might have to edit this line:
Code:
comport = 'ttyUSB1'
And try ttyUSB0 or ttyUSB2, different modems have different ports that can work with SMS. You must disable / enable resident script after changing port name.
3. Add the contents of init.lua to the Start-up script, you have to reboot LM via Systems config afterwards. Do not reboot via power cycle or you might lose your newly created scripts.
4. Edit script the resident and set the PIN and allowed numbers for SMS handler
6. Command syntax:
a. Write to bus:
W ALIAS VALUE
b. Read from bus:
R ALIAS
On read request, script will reply with SMS message containing current value of selected object.
ALIAS can be:
a. Group address (e.g. 1/1/1)
b. Name (e.g. Obj1). If name contains spaces then it must be escaped usign double quotes (e.g. "Room Temperature")
NOTE:
a. Object data type and name must be set in Objects tab. Otherwise script won't be able to read and write to object.
b. Only ASCII symbols are accepted in the message.
Examples:
a. Binary write:
W 1/1/1 true
b. Scaling write:
W LED1Red 67
c. Temperature (floating point) write:
W "Room Setpoint" 22.5
d. Read:
R 2/1/1
I might be implementing SMS functionality as well. A question to this example: My LM3:Reactor sits in the cellar, with the main electrical installation. I have absolutely no cellphone reception down there. How do I get this to work?
- USB Extension is limited to 3 to 5m according to specs, therefore no solution.
- Cellular repeater in the cellar is also no solution
Best solution would be Ethernet instead of USB, i.e. connecting the Modem to the Router on the ground floor. Anyone got experience with such a solution?
- It will have to be bi-directional
- Preferred use of a local phone carrier without routing sensible data over the internet (the write-to-bus from the phone is potentially a threat, although whitelisting the phonenumber probably already does a lot). I know that mobile carriers are maybe not that safe as well, but at least it data will be transferred within the country (or even same phone mast), except for holidays of course.
There are Mikrotik routers with USB port and SMS support on OS level, but it will still require some additional scriping both on LM and router side.
Another solution is to use any kind of Linux box and open-source software like smstools.
I have the LM3:Reactor connected to the LAN. The above USB over Ethernet Server connected to the same LAN via Ethernet in a location with good cell phone reception. Huawei E173 modem connected to the USB over Ethernet Server.
You are right, that USB port has only a few devices allowed.
It looks like using a Linux Box combined with smstools as you suggested earlier on is the way to go. smstools will pick up text messages from a directory, so that part will be easy, i.e. getting the LogicMachine to write text files to a directory.
Any suggestions on the Linux Box? Should be 24/7, low power consumption.
Raspberry Pi with a good enclosure. Cheap, efficient and easy to set up with Raspbian.
I have one at home controlling an arduino with some other features for my home network. Been running steadily for over a year without a single reboot (except for one town wide power failure).
You might require an external power supply for USB modem using USB power injector cable as this board can only source up to 1A, which might be not enough for some modems.
09.09.2015, 12:20 (This post was last modified: 09.09.2015, 12:54 by RSV4.)
Thank you. I think I'll go with the Raspberry PI B+, seems widespread and well documented, which is important to me. My cellphone provider sells the following modem "Huawei USB Modem E3531 3G". I hope I'll get that one to work with the Raspberry.
When using smstools I do understand that outgoing messages need be placed in a directory where they get queued, fetched and sent. So far so good. On the incoming side, messages are placed in a different directory. Here is where my question starts: I will configure the incoming path as a network path where the LM3 also has access. Is there already a scripting solution for LM3 which will periodically check the directory for new files and more important will be able to parse the file, send and read information from the KNX Bus and then will write a textfile to the outgoing folder in order to have smstools send the reply?
I am totally excited about being able to communicate with my home without having to open up my router to the outside which I do not want to do.
if header == 'From' then
message.from = data
elseif header == 'Length' then
message.body = {}
end
end
function parse(filename)
local file, cmd, proc, body, message
-- check that file exists
file = io.open(filename)
if not file then
print('cannot open', filename)
return
end
file:close()
-- file can contain null bytes, so normal read might fail
cmd = string.format('cat %s | tr -d \\\\0', filename)
proc = io.popen(cmd)
message = {}
for line in proc:lines() do
if message.body then
if #line >= 2 then
table.insert(message.body, line)
end
else
parseheader(line, message)
end
end
proc:close()
if message.body then
message.body = table.concat(message.body)
end
print('From', message.from)
print('Body', message.body)
end
status, filename = arg[ 1 ], arg[ 2 ]
-- validate command line arguments
if type(status) == 'string' or type(filename) == 'string' then
if status == 'RECEIVED' then
parse(filename)
else
print('Wrong status', status)
end
end
Thank you very much for the parsing example on the device side.
Could you please explain how communication with the LM should be implemented? If I extend the above example and possibly dump the parsed result to a network drive, how do pick this up with the LM?
Once I get the LM to pick up the message, parsing on the LM side is no problem, meaning writing to the KNX bus according to a text like "LIGHT OFFICE ON".