Send SMS with USB GSM modem when alarm triggered

Please ignore my question above. Sorry for the trouble. It is not an HA or SMS issue, but a simcard issue. Took me a half a day to come to this conclusion.

Using a Huawei E220 in HA OS on a virtual machine, I get network dropouts at random, and the modem doesn’t reconnect. I think the dropout is a signal strength issue, but no reconnection is the problem.
Restarting the SMS integration doesn’t help, and the integration debug messages just show a connection that is lost. I’ve tried resetting the modem via AT commands from a shellscript but that doesn’t work. I looked at resetting the USB device, but that’s not possible in HA OS.
The only solution I’ve found is to restart HA via the “Home Assistant Core Integration: Restart” service. At the moment I have an automation that restarts HA every time the network drops.
As the underlying OS doesn’t restart, it can’t be an issue with the USB subsystem, and I’m guessing it’s restarting Gammu that gets it to reconnect.
Does anyone have any faultfinding steps they can suggest?
Is there a smaller part of the HA system that can be restarted to regain connection?

@Oscar_Calvo I receive SMS from the garbage collectors a couple of times a week, unfurtunately their messages are longer than 160 characters, which means it has to be split up.

It seems to be a issue to do that. i can easily send out messages longer than 160 characters from home assistant but i will not receive them if they are longer than 160.

Is there a way to intercept them and shorten them or ignore the splitted part ( i am mostly interested in the first 2 lines of the text, which has dates and what is being collected)

I have similar problem with my Huawei E3272 modem in HAOS.
Modem connection runs in an indefinite cycle:

  1. Connection works for exactly 40 seconds then disconnects
  2. Next connection starts in cca 11 minutes + 10-20 seconds
    Here you can see the devices:
    image
    and the connection cycle:

    Following messages appear in the DEBUG log:
2023-03-05 15:02:38.325 INFO (MainThread) [homeassistant.components.sms] Fetching Device network state data recovered
2023-03-05 15:02:38.365 INFO (MainThread) [homeassistant.components.sms] Fetching Device signal state data recovered
2023-03-05 15:03:18.235 ERROR (MainThread) [homeassistant.components.sms] Timeout fetching Device network state data
2023-03-05 15:03:18.361 ERROR (MainThread) [homeassistant.components.sms] Timeout fetching Device signal state data

Not sure how to fix the problem for a long time, it’s not new.

In my case it was a signal/noise ratio problem. A better antenna fixed the issue for me.

Thanks for suggestion, I was also expecting weak signal could be the issue reason so I was waiting with reporting after buying an antenna. But after connecting 2 small antennas and re-test the situation is exactly the same.
I will move the modem to another location and monitor the signal to be sure it’s not the problem reason.

Tested the signal in Windows PC via Huawei Mobile Partner, it’s OK
Connection works for minutes there until I disconnect.
I have re-configured setport via terminal to mode “4G MODEM” + “4G PCUI” before plugging back to HassOS:

AT^SETPORT=?
^SETPORT:1: 3G MODEM
^SETPORT:2: 3G PCUI
^SETPORT:7C: SerialC
^SETPORT:78: Shell A
^SETPORT:79: Shell B
^SETPORT:76: NCM
^SETPORT:A1: CDROM
^SETPORT:A2: SD
^SETPORT:61: 4G MODEM
^SETPORT:62: 4G PCUI
^SETPORT:7B: SerialB
^SETPORT:7A: Serial

AT^SETPORT="FF;61,62"
AT^RESET

Seems I have finally found the solution. Re-created the integration in HA again with the second usb device /dev/serial/by-id/usb-Technology_Mobile_FFFFFFFFFFFFFFFF-if01-port0 and port speed set to Auto.
It finally WORKS without dropping the connections. :slight_smile:

Great, thanks! I didn’t think of setting setport on another computer.
Hopefully that works, if not I’ll have to spend another 50sek on a E3272!

Hi
I bought SIM800C Module Like this:
https://www.amazon.com/gp/product/B087Z6F953/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

I installed HAOS on Lattepanda embedded Board (Generic 86-64) with these informations:

information

after connecting the module to USB port when I want to add integration Device " SMS Notification Via GSM Modem" , This error occurs:

Error

In the event that before connecting the module, a window opened that it want the device name.

when in terminal enter these commands:

when I add this code to Configuration.yml:
Configuration

when I want To restart the HA this error display:
HA Restart

Please Help me.
Thanks

Good day.
I found your script here, and it works perfectly… from the command line.

How would i make an integration for when someone disarms alarmo to say

send to 555-555-1212
msg “Owen disarmed the system”

would you know where to point me in the right direction?

Good day

I have a trouble with SMS notification via GSM-Modem, its failed whit timeout error. I use SIM800C usb version, on x86 home assistant, in attchet screenshot USB0 is Sim800c, USB1 is zigbee cordinator,

Thanks for support in advance


This seems to have worked, but only after I deleted and re-created the integration. There was also a firmware update for the dongle that I applied.

Are you sure that ttyUSB1 is the zigbee co-ordinator? Both ttyUSB0 and ttyUSB1 look like they’re associated with the same device. In most cases the second USB serial instance is the correct one.
Another possibility is that your device doesn’t respond properly some of the AT commands (AT+IPR=? maybe), so you will have to manually set the baud rate.
Otherwise try a reset using a serial terminal. You’ll have to find the AT command list for your device to see what ‘factory reset’ is.

In the end I changed to a Huawei E173 - works flawlessly. I could get the E220 to stay connected better but it was still a bit flaky. The E173 and E220 are about the same second hand these days, so it’s the better option.

1 Like

Hello, does anyone knows if its possible to do this with a huawei routeur like this one ?
It has a USB plug ?

No, I don’t think this one will work.

I’m trying to setup my SIM800C on RPi4. Its inserted into USB
Here is my terminal output.


I started the Integration, then in the Device I put
/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
as suggested, however, not able to work :frowning:
I’m getting error ‘Failed to connect’
image

image

Any help please

1 Like

facing the same issue as ausfas using SIM800C

[core-ssh config]$ ls -lsah /dev/ttyUSB0
     0 crw-rw----    1 root     audio     188,   0 May 15 19:52 /dev/ttyUSB0
[core-ssh config]$ ls -lsah /dev/serial/by-id/usb-*
     0 lrwxrwxrwx    1 root     root          13 May 15 19:36 /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 -> ../../ttyUSB0
     0 lrwxrwxrwx    1 root     root          13 May 15 19:36 /dev/serial/by-id/usb-ITEAD_SONOFF_Zigbee_3.0_USB_Dongle_Plus_V2_20221201211523-if00 -> ../../ttyACM0
2023-05-15 19:42:51.579 ERROR (MainThread) [homeassistant.components.sms.gateway] Failed to initialize, error ERR_DEVICEOPENERROR
2023-05-15 19:43:06.680 ERROR (MainThread) [homeassistant.components.sms.gateway] Failed to initialize, error ERR_DEVICEOPENERROR

i also tried so send a msg by commandline but looks like device is busy

[core-ssh config]$ cat sendSms.sh
#!/bin/bash
DEST=$1
MD="/dev/ttyUSB0"
message="$2"
echo "Sending $message to $DEST"
stty -F $MD 9600 min 100 time 2 -hupcl brkint ignpar -opost -onlcr -isig -icanon -echo
chat TIMEOUT 10 "" "AT+CMGF=1" "OK" > $MD < $MD
chat TIMEOUT 10 "" "AT+CMGS=\"$DEST\"" "OK" > $MD < $MD
chat TIMEOUT 10 "" "$message^Z" "OK" > $MD < $MD

[core-ssh config]$ ./sendSms.sh 123 "EXAMPLE"
Sending EXAMPLE to 123
stty: can't open '/dev/ttyUSB0': Resource busy
./sendSms.sh: line 18: /dev/ttyUSB0: Resource busy
./sendSms.sh: line 19: /dev/ttyUSB0: Resource busy
./sendSms.sh: line 20: /dev/ttyUSB0: Resource busy

lsof doesn’t show any usage

[core-ssh config]$ lsof /dev/ttyUSB0
1       /package/admin/s6-2.11.2.0/command/s6-svscan    0       /dev/null
1       /package/admin/s6-2.11.2.0/command/s6-svscan    1       pipe:[18601]
1       /package/admin/s6-2.11.2.0/command/s6-svscan    2       pipe:[18602]
1       /package/admin/s6-2.11.2.0/command/s6-svscan    3       /run/service/.s6-svscan/lock
1       /package/admin/s6-2.11.2.0/command/s6-svscan    5       /run/service/.s6-svscan/control
1       /package/admin/s6-2.11.2.0/command/s6-svscan    6       /run/service/.s6-svscan/control
1       /package/admin/s6-2.11.2.0/command/s6-svscan    7       anon_inode:[signalfd]
15      /package/admin/s6-2.11.2.0/command/s6-supervise 0       /dev/null
15      /package/admin/s6-2.11.2.0/command/s6-supervise 1       pipe:[18601]
15      /package/admin/s6-2.11.2.0/command/s6-supervise 2       pipe:[18602]
15      /package/admin/s6-2.11.2.0/command/s6-supervise 3       /run/service/s6-linux-init-shutdownd/supervise/lock
15      /package/admin/s6-2.11.2.0/command/s6-supervise 4       /run/service/s6-linux-init-shutdownd/supervise/control
15      /package/admin/s6-2.11.2.0/command/s6-supervise 5       /run/service/s6-linux-init-shutdownd/supervise/control
15      /package/admin/s6-2.11.2.0/command/s6-supervise 6       anon_inode:[signalfd]
18      /package/admin/s6-linux-init-1.0.8.1/command/s6-linux-init-shutdownd    0       /dev/null
18      /package/admin/s6-linux-init-1.0.8.1/command/s6-linux-init-shutdownd    1       pipe:[18601]
18      /package/admin/s6-linux-init-1.0.8.1/command/s6-linux-init-shutdownd    2       pipe:[18602]
18      /package/admin/s6-linux-init-1.0.8.1/command/s6-linux-init-shutdownd    3       /run/service/s6-linux-init-shutdownd/fifo
18      /package/admin/s6-linux-init-1.0.8.1/command/s6-linux-init-shutdownd    4       /run/service/s6-linux-init-shutdownd/fifo
24      /package/admin/s6-2.11.2.0/command/s6-supervise 0       /dev/null
24      /package/admin/s6-2.11.2.0/command/s6-supervise 1       pipe:[18601]
24      /package/admin/s6-2.11.2.0/command/s6-supervise 2       pipe:[18602]
24      /package/admin/s6-2.11.2.0/command/s6-supervise 3       /run/s6-rc:s6-rc-init:hdpMkL/servicedirs/s6rc-fdholder/supervise/lock
24      /package/admin/s6-2.11.2.0/command/s6-supervise 4       /run/s6-rc:s6-rc-init:hdpMkL/servicedirs/s6rc-fdholder/supervise/control
24      /package/admin/s6-2.11.2.0/command/s6-supervise 5       /run/s6-rc:s6-rc-init:hdpMkL/servicedirs/s6rc-fdholder/supervise/control
24      /package/admin/s6-2.11.2.0/command/s6-supervise 6       anon_inode:[signalfd]
25      /package/admin/s6-2.11.2.0/command/s6-supervise 0       /dev/null
25      /package/admin/s6-2.11.2.0/command/s6-supervise 1       pipe:[18601]
25      /package/admin/s6-2.11.2.0/command/s6-supervise 2       pipe:[18602]
25      /package/admin/s6-2.11.2.0/command/s6-supervise 3       /run/s6-rc:s6-rc-init:hdpMkL/servicedirs/s6rc-oneshot-runner/supervise/lock
25      /package/admin/s6-2.11.2.0/command/s6-supervise 4       /run/s6-rc:s6-rc-init:hdpMkL/servicedirs/s6rc-oneshot-runner/supervise/control
25      /package/admin/s6-2.11.2.0/command/s6-supervise 5       /run/s6-rc:s6-rc-init:hdpMkL/servicedirs/s6rc-oneshot-runner/supervise/control
25      /package/admin/s6-2.11.2.0/command/s6-supervise 6       anon_inode:[signalfd]
33      /package/admin/s6-2.11.2.0/command/s6-ipcserverd        0       socket:[19695]
33      /package/admin/s6-2.11.2.0/command/s6-ipcserverd        2       pipe:[18601]
33      /package/admin/s6-2.11.2.0/command/s6-ipcserverd        3       anon_inode:[signalfd]
142     /package/admin/s6-2.11.2.0/command/s6-supervise 0       /dev/null
142     /package/admin/s6-2.11.2.0/command/s6-supervise 1       pipe:[18601]
142     /package/admin/s6-2.11.2.0/command/s6-supervise 2       pipe:[18602]
142     /package/admin/s6-2.11.2.0/command/s6-supervise 3       /run/s6/legacy-services/sshd/supervise/lock
142     /package/admin/s6-2.11.2.0/command/s6-supervise 4       /run/s6/legacy-services/sshd/supervise/control
142     /package/admin/s6-2.11.2.0/command/s6-supervise 5       /run/s6/legacy-services/sshd/supervise/control
142     /package/admin/s6-2.11.2.0/command/s6-supervise 6       anon_inode:[signalfd]
143     /package/admin/s6-2.11.2.0/command/s6-supervise 0       /dev/null
143     /package/admin/s6-2.11.2.0/command/s6-supervise 1       pipe:[18601]
143     /package/admin/s6-2.11.2.0/command/s6-supervise 2       pipe:[18602]
143     /package/admin/s6-2.11.2.0/command/s6-supervise 3       /run/s6/legacy-services/ttyd/supervise/lock
143     /package/admin/s6-2.11.2.0/command/s6-supervise 4       /run/s6/legacy-services/ttyd/supervise/control
143     /package/admin/s6-2.11.2.0/command/s6-supervise 5       /run/s6/legacy-services/ttyd/supervise/control
143     /package/admin/s6-2.11.2.0/command/s6-supervise 6       anon_inode:[signalfd]
145     /usr/bin/ttyd   0       /dev/null
145     /usr/bin/ttyd   1       pipe:[18601]
145     /usr/bin/ttyd   2       pipe:[18602]
145     /usr/bin/ttyd   3       anon_inode:[eventpoll]
145     /usr/bin/ttyd   4       pipe:[19894]
145     /usr/bin/ttyd   5       pipe:[19894]
145     /usr/bin/ttyd   6       pipe:[19895]
145     /usr/bin/ttyd   7       pipe:[19895]
145     /usr/bin/ttyd   8       anon_inode:[eventfd]
145     /usr/bin/ttyd   9       /dev/urandom
145     /usr/bin/ttyd   10      anon_inode:[eventfd]
145     /usr/bin/ttyd   11      socket:[18896]
145     /usr/bin/ttyd   12      socket:[18897]
145     /usr/bin/ttyd   13      socket:[29223]
145     /usr/bin/ttyd   14      /dev/ptmx
145     /usr/bin/ttyd   15      /dev/null
145     /usr/bin/ttyd   16      /dev/ptmx
145     /usr/bin/ttyd   17      /dev/ptmx
155     /usr/sbin/sshd  0       /dev/null
155     /usr/sbin/sshd  1       pipe:[18601]
155     /usr/sbin/sshd  2       pipe:[18602]
155     /usr/sbin/sshd  3       socket:[19951]
155     /usr/sbin/sshd  4       socket:[19952]
185     /usr/bin/tmux   0       /dev/null
185     /usr/bin/tmux   1       /dev/null
185     /usr/bin/tmux   2       /dev/null
185     /usr/bin/tmux   3       pipe:[21175]
185     /usr/bin/tmux   4       pipe:[21175]
185     /usr/bin/tmux   5       socket:[29769]
185     /usr/bin/tmux   6       socket:[21176]
185     /usr/bin/tmux   7       /dev/pts/2
185     /usr/bin/tmux   8       /dev/ptmx
186     /bin/bash       0       /dev/pts/1
186     /bin/bash       1       /dev/pts/1
186     /bin/bash       2       /dev/pts/1
186     /bin/bash       255     /dev/pts/1
191     /usr/sbin/sshd  0       /dev/null
191     /usr/sbin/sshd  1       /dev/null
191     /usr/sbin/sshd  2       pipe:[18602]
191     /usr/sbin/sshd  3       /dev/ptmx
191     /usr/sbin/sshd  4       socket:[21211]
191     /usr/sbin/sshd  6       socket:[21227]
191     /usr/sbin/sshd  7       /dev/ptmx
191     /usr/sbin/sshd  8       /dev/ptmx
193     /bin/bash       0       /dev/pts/0
193     /bin/bash       1       /dev/pts/0
193     /bin/bash       2       /dev/pts/0
193     /bin/bash       255     /dev/pts/0
239     /usr/bin/tmux   0       /dev/pts/2
239     /usr/bin/tmux   1       /dev/pts/2
239     /usr/bin/tmux   2       /dev/pts/2
239     /usr/bin/tmux   3       pipe:[29767]
239     /usr/bin/tmux   4       pipe:[29767]
239     /usr/bin/tmux   5       socket:[29768]

maybe also helful:

Thanks it was the same issue --the Sim card direction.
Integration is picking it up, however not registering

Don’t buy SIM800C (for Australia) it’s only for 2G, even 3G will be shut down later this year.
What a waste. … Someone should have mentioned it on the SMS integration page