Skip to content

SMSModem Binding ​

This binding connects to a USB serial GSM modem (or a network exposed one, see ser2net) and allows openHAB to send and receive SMS through it.

Serial modem should all use the same communication protocol (AT message) and therefore this binding should be compatible with every dongle. However, there is a gap between theory and reality and success may vary. The protocol stack is based on the no longer supported smslib project (more precisely a v4 fork), and all modems supported by this library should be OK.

The following devices have been reported functional:

  • Huawei E180
  • Huawei E173
  • Huawei E1550
  • Huawei E272

Devices that are reported to have issues:

  • Huawei E303C

Supported Things ​

Two things are supported by this binding:

  • A smsmodembridge, representing the dongle connected on the local computer
  • A smsmodemremotebridge, representing the dongle exposed over the network (with ser2net or other similar software)
  • A smsconversation, representing a conversation between one distant msisdn and the msisdn on the sim card in the dongle.

Discovery ​

There is no discovery process for smsmodembridge or smsmodemremotebridge Thing. A smsconversation Thing will be discovered and added to the inbox everytime the modem should receive a SMS by a new sender.

Thing Configuration ​

The smsmodembridge or smsmodemremotebridge things requires at least two parameters to work properly.

For local smsmodembridge:

Parameter Nametypedirect serial modem
serialPorttextThe serial port to access (eg. /dev/tty/USBx)
baudintegerBaud rate

For remote smsmodemremotebridge:

Parameter Nametypeserial over network
iptextIP address of the computer hosting the ser2net service
networkPortintegerThe network port of the ser2net service

The other parameters are optional:

Parameter Nametypedescription
simPintextIf your sim card is protected, fill this field with the PIN code
pollingIntervalintegerDelay between two checks for new message (in seconds)
delayBetweenSendintegerDelay to wait between two messages post (in milliseconds, could be necessary for slow modem)

The smsconversation Thing is just a shortcut to address/receive messages with a specific msisdn. It is not mandatory to use the binding, as you can use action and trigger channel to send/receive a message once the smsmodem bridge is configured.

Parameter Nametypedescription
recipienttextThe msisdn of the phone you want to discuss with.
deliveryReportbooleanIf enabled, ask the network for a delivery report (default false)
encodingtextThe encoding to use when sending the message (either Enc7, Enc8, EncUcs2, EncCustom, default is Enc7). EncUcs2 is good for non latin character, but SMS character size limit is then reduced

Channels ​

The smsconversation supports the following channels:

channeltypedescription
receiveStringThe last message received
sendStringA message to send
deliverystatusStringDelivery status (either UNKNOWN, QUEUED, SENT, PENDING, DELIVERED, EXPIRED, or FAILED). Several status are only possible if the delivery report parameter is enabled

Trigger channels ​

The smsmodembridge and smsmodemremotebridge has the following trigger channel:

Channel IDevent
receivetriggerThe msisdn and message received (concatened with the '|' character as a separator)

Rule action ​

This binding includes a rule action to send SMS.

javascript
(Rule DSL)
val smsAction = getActions("smsmodem","smsmodem:smsmodembridge:<uid>")
javascript
(javascript JSR)
var smsAction = actions.get("smsmodem","smsmodem:smsmodembridge:<uid>");

Where uid is the Bridge UID of the smsmodembridge Thing.

Once this action instance is retrieved, you can invoke the 'send' method on it:

java
smsAction.sendSMS("1234567890", "Hello world!")

Or with a special encoding:

java
smsAction.sendSMS("1234567890", "Hello world!", "EncUcs2")

Full Example ​

Thing configuration ​

things/smsmodem.things:

dsl
Bridge smsmodem:smsmodembridge:adonglename "USB 3G Dongle " [ serialPort="/dev/ttyUSB0", baud="19200" ] {
    Thing smsconversation aconversationname [ recipient="XXXXXXXXXXX", deliveryReport="true" ]
}

Send SMS ​

sms.rules for DSL:

rules
rule "Alarm by SMS"
when
   Item Alarm changed
then
   val smsAction = getActions("smsmodem","smsmodem:smsmodembridge:dongleuid")
   smsAction.sendSMS("33123456789", "Alert !")
end

Receive and forward SMS ​

sms.py with the python helper library:

python
@rule("smscommand.receive", description="Receive SMS and resend it")
@when("Channel smsmodem:smsmodembridge:dongleuid:receivetrigger triggered")
def smscommand(event):
    sender_and_message = event.event.split("|")
    sender = sender_and_message[0]
    content = sender_and_message[1]
    actions.get("smsmodem", "smsmodem:smsmodembridge:dongleuid").send("336123456789", sender + " just send the following message: " + content)