Smsmodem : Binding for SMS on a GSM serial modem

Hello,

The smsmodem is now merged in the main repository, and will be included in the 3.4 official openHAB version.
Please see the open post for more information (warning : breaking changes in the last release !)

2 Likes

Thank you!

I would recommend to unpublish the binding from the marketplace as soon as OH 3.4 is released. This will avoid confusion for users.

1 Like

Hi,

i tried to install the Binding from the community marketplace. Installtion worked well, but OpenHab logs following error on startup:

2022-12-09 10:45:03.579 [ERROR] [Events.Framework                    ] - FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.smsmodem [264]
  Unresolved requirement: Import-Package: org.openhab.core.io.transport.serial

        at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1783) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) ~[org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) [org.eclipse.osgi-3.17.200.jar:?]
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) [org.eclipse.osgi-3.17.200.jar:?]

Has anyone any clues on whats going wrong?

I heard that there are issues with dependencies installation when using the marketplace.

Do you have another binding using a serial component ?
If not, then I suggest you install one, such as the zwave or zigbee binding.
It could install the serial dependencies and with luck unlock the smsbinding (do not hesitate to stop / start openHAB)

I also saw an old suggestion. You could use this command on the openHAB console :

feature:install openhab-transport-serial

Installing the ZigBee binding first helped. But now the binding doesn’t let me configure a modem. My modem has serial port /dev/ttyUSB0 or /dev/usb_modem (linked). If I try to set the Serial Port to either of these ports, the binding says

{serialPort=Der Wert /dev/ttyUSB0 ist nicht in den erlaubten Optionen enthalten. Erlaubte Optionen sind: [ParameterOption [value=“/dev/ttyS0”, label=“/dev/ttyS0”]]}

which means “The value /dev/ttyUSB0 is not one of the permitted options. Permitted options are: [ParameterOption [value=”/dev/ttyS0", label=“/dev/ttyS0”]]

Any advice?

Hello,

It seems that the openhab serial provider doesn’t recognize your /dev/ttyUSB0 as a serial device. Strange.
So, I just made for you a release that doesn’t enforce the serial property to be a recognized one. The text is now a simple text with no further verification. It will allow you to create the thing. Could you please test it ?

You can download it here and install it in your addon repository. Warning : you have to remove the smsmodem binding installed from the marketplace, otherwise behavior is unknown.

But I’m not very optimistic, if you system doesn’t recognize it as a serial port, it seems dubious that the serial provider can work with it. But it is worth a try anyway.

What is the model of your device ?
Does it work with other similar software, like gammu ?

The binding accepts /dev/ttyUSB0 as a port now, but it now complains about an configuration error (see screenshot).

Sending SMS via gammu works fine and the device is a Huawei E169:

frank@raspberrypi:/usr/share/openhab/addons $ lsusb
Bus 001 Device 005: ID 12d1:1001 Huawei Technologies Co., Ltd. E161/E169/E620/E800 HSDPA Modem
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Thanks for the information.
There is definitely something fishy with the serial provider.
This is a common functionnality provided by the openHAB core project to access serial port.
I just asked a question on the dedicated development forum to see if someone can help us.

How did you install openHAB?

If you don’t run openHABian, you’ll have to configure some permissions to get access to serial ports. It’s explained in https://www.openhab.org/docs/administration/serial.html#serial-port-configuration :

Depending on Linux distribution, you might need to add the user running openHAB to dialout user group.With Debian openHAB installation: sudo usermod -a -G dialout openhab. The user will need to logout from all login instances and log back in to see their new group added. If the user added to this group still cannot get permission, rebooting the box to ensure the new group permission is attached to the user is suggested.

I’m running OpenHAB on the latest Raspbian OS. So i ran the steps described in the link, but problem stays the same :frowning:

What is the output of these commands:

ls -l /dev/ttyUSB0

groups <user>

Where you substitute the <user> with the user that runs openHAB.

Currently my modem has the port /dev/ttyUSB1, but i have a symbolic link to it. Output is as follows.

frank@raspberrypi:~ $ ls -l /dev/ttyUSB1
crw-rw---- 1 root users 188, 1 Dec 12 08:34 /dev/ttyUSB1
frank@raspberrypi:~ $ ls -l /dev/usb_modem
lrwxrwxrwx 1 root root 7 Dec 12 08:34 /dev/usb_modem -> ttyUSB1
frank@raspberrypi:~ $ groups openhab
openhab : openhab tty dialout audio bluetooth

Parameter EXTRA_JAVA_OPTS in /etc/default/openhab is set like so:

EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyUSB1:/dev/usb_modem"

OpenHAB is running under user openhab

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
 7484 openhab   20   0  656916 504940  13868 S   1.7  53.5  14:09.00 java

IIRC Raspberry Pi OS would normally assign the dialout group and not the users group to serial devices. Perhaps that is some kind of custom config?

So if the openhab user is not part of that group, try adding the openhab user to the users group.

As a test you can also change the group manually to dialout with:

sudo chown root:dialout /dev/ttyUSB1

or test by giving every user permission to use it:

sudo chmod o+rw /dev/ttyUSB1

Those changes will only last until the device is disconnected or the OS is restarted.

I would also first test by using /dev/ttyUSB1 in the openHAB Thing configuration and only try the symlink after that works.

BAM! This did the trick. Thank you so much!

1 Like

How could I miss to check this before ?!!!
Thank you @wborn

As wborn suggests, this change will not last after the next reboot. You have to either :
1- configure udev to set root:dialog ownership to /dev/ttyUSB1
2- add openhab to the users group

(2 is far more easier but less conventionnal)

Damn! Cheered too soon … after rebooting, the port is now /dev/ttyUSB0 … so I set the group of ttyUSB0 to dialout (sudo chown root:dialout /dev/ttyUSB0) but now the bridge says, that /dev/ttyUSB0 is no option for the serial port parameter :frowning: . Right now im trying to set the port of the device back to /dev/ttyUSB1 by rebooting to check if the port is the problem.

EDIT: After rebooting several times the modem got the port /dev/ttyUSB1 again and now the bridge goes online with port set to /dev/ttyUSB1 as well as /dev/usb_modem … I’m absolutely clueless why … :frowning:

On Linux, the ttyUSBx assigned is not guaranteed to be the same upon reboot.
Unless you set it with a udev rule.
You can find many tutorials on internet, like this one.

I’m working on a pull request that allow to use symbolic link (human readable brand + model, more stable) created by the kernel in many distribution under /dev/serial/by-id, to simplify thing. But it won’t make it, if accepted, in the next openHAB 3.4 version.
(The JAR bundle I made for you some post ago is able to handle this kind of symbolic link, but not the one currently on the market place)

I know. But I’m surprised, that it works when the modem gets assigned to the port /dev/ttyUSB1, but not when it gets assigned to the port /dev/ttyUSB0, although both ports are set in the EXTRA_JAVA_OPTS configuration and I assigned the group dialout to both ports …

I already defined a udev rule to generate a symbolic link /dev/usb_modem to the actual port and /dev/usb_modem works fine as a parameter in the bridge as long as the real port is /dev/ttyUSB1 … it doesn’t when the port is /dev/ttyUSB0 though …

Wow, OK ! I didn’t get it.
Indeed, it is very strange, and I have absolutely no clue…