This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

How to control the KNX bus via SMS and send notices via SMS?
#1
Exclamation 
Hi everyone, Please help me.

How to send and receive sms messages  on logical machine via GSM modem or 3G?

Then how can control KNX bus and send notifications via SMS?

I did try to follow the example on page openrb.com but still failed.


Thank so much,
Reply
#2
(25.08.2015, 14:12)Hoang189 Wrote: Hi everyone, Please help me.

How to send and receive sms messages  on logical machine via GSM modem or 3G?

Then how can control KNX bus and send notifications via SMS?

I did try to follow the example on page openrb.com but still failed.


Thank so much,

Upppp !


Help me ,please.
Reply
#3
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

5. To send SMS from a script:
Code:
require('user.sms')
sendsms('12345678', 'test sms')

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

Attached Files
.lua   init.lua (Size: 199 bytes / Downloads: 111)
.lua   resident.lua (Size: 3.49 KB / Downloads: 117)
.lua   user.sms.lua (Size: 9.11 KB / Downloads: 132)
Reply
#4
Hi all,

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?

Thanks & kind regards, Robin
Reply
#5
Why not go with Ethernet to the LM and use push messages, or Twilio?

The guides are on the openrb site. I've tried out push messages and email notifications myself and they
worked like charm. Not too difficult to setup.
Reply
#6
Thank you, but it will not do for my purposes.

- 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.
Reply
#7
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.
Reply
#8
I've did a little searching an came up with this here:
USB over Ethernet Server


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.

Do you see any potential issues with this setup?
Reply
#9
Router with USB is a safer bet, considering the price of USB-Ethernet gateway and that it might have driver/latency issues.
Reply
#10
My Apple AirPort Extreme  (latest version) has a built in USB-Port. Do you think I can get the Huawei E173 modem to work with the LM on this port?
Reply
#11
As far as I know you cannot use USB modems with Apple routers.
Reply
#12
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.
Reply
#13
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).
Reply
#14
You can use something like this:
https://www.olimex.com/Products/OLinuXin...e-hardware

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.
Reply
#15
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.

@Sandstrand: Thank you very much for the hint!
Reply
#16
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.
Reply
#17
You can use "eventhandler" in smstools config, which will execute a program when SMS has been received. This way you can forward messages to your LM.
Reply
#18
Sorry to ask, but how would you do that in detail?
Reply
#19
Here's a partially implemented example, you can extend it

First you have to install Lua on your device. Standard Lua version 5.1 or higher will work.

In smsd.conf you have to add this line in general config before [GSM1]:
Code:
eventhandler = /var/spool/sms/handler.lua

Then you have to create /var/spool/sms/handler.lua file with the code below and make it executable (chmod 0755)
Code:
#!/usr/bin/lua

function parseheader(line, message)
  local pos, data, header

  pos = line:find(':')
  if not pos then
    return
  end

  header = line:sub(1, pos - 1)
  data = line:sub(pos + 2)

  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
Reply
#20
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".
Reply


Forum Jump: