Send SMS with USB GSM modem when alarm triggered

I also don’t see any event for received SMS.

Is it already included on HA 0.112?

According to the release notes linking to pull 37015

Yes, but it seems not be working, the incoming.

No logs at all, no event triggered. Weird.

Some Huawei modems provide 2 serial interfaces, only of them can actually receive SMS notifications but both can send SMS.
If you are in this boat try to change the serial device to the other one.

Can you post your logs?

@Oscar_Calvo, please, check: https://github.com/home-assistant/core/pull/37576

Looks like I have quite the choice - I’m currently using USB0 mapped to /dev/sms:

[   10.336224] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[   10.336526] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[   10.340206] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2

I’ll have to have a play at some point but not tonight - I’m spending this week migrating monitoring services at work to a new host so don’t want to overload myself. Funnily enough I think our SMS system uses the same modem through a Windows machine, and I had similar issues with ports there IIRC.

This will fix it: https://github.com/home-assistant/core/pull/37577

1 Like

Is there a way to log incoming messages?

1 Like

I had a quick play this afternoon whilst waiting on the results of some automated post-migration tests.

Removing the integration (which was using /dev/sms mapped to ttyUSB0) and trying with first ttyUSB1 and then ttyUSB2 leaves me none the wiser.
ttyUSB1 fails to complete adding the integration as it is non-responsive.
ttyUSB2 leaves me still with only outgoing sms and the gsm signal status, so I’ve reverted back to my mapped /dev/sms configuration which works fine for outgoing sms and signal status.

In practice I’d be unlikely to use inbound SMS but now my curiosity is piqued…

Q: With a successful two-way integration should we see an sms.incoming_sms listener under Available Events in Developer Tools > Events?

hello
I’m facing to an issue when I activate the sms in the configuration
I get this error
Component error: sms - Requirements for sms not found: [‘python-gammu==2.12’].
on the debian I already have gammu

ii  gammu                                 1.40.0-1                                     amd64        mobile phone management utility
ii  gammu-smsd                            1.40.0-1                                     amd64        SMS message daemon
ii  libgammu-dev                          1.40.0-1                                     amd64        mobile phone management library (development files)
ii  libgammu-i18n                         1.40.0-1                                     all          mobile phone management library (i18n files)
ii  libgammu8                             1.40.0-1                                     amd64        mobile phone management library
ii  python-gammu                          2.12-1                                       amd64        Python module to communicate with mobile phones (Python 2)

I can send sms from the debian cli with the script you made

I tried to install python-gammu into terminal of home assisstant through the web interface but the apt-get command is not found

home assisstant is installed into docker, I don’t know how to install python-gammu on it

here is the full log:

Détails du journal ( ERROR )
Logger: homeassistant.util.package
Source: util/package.py:95
First occurred: 15:29:17 (1 occurrences)
Last logged: 15:29:17

Unable to install package python-gammu==2.12: ERROR: Command errored out with exit status 101: command: /usr/local/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nd7pituz/python-gammu/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nd7pituz/python-gammu/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-31ql23ax cwd: /tmp/pip-install-nd7pituz/python-gammu/ Complete output (5 lines): Failed to find Gammu! Either it is not installed or not found. After install Gammu ensure that setup finds it by any of: * Specify path to it using GAMMU_PATH in environment. * Install pkg-config. ---------------------------------------- ERROR: Command errored out with exit status 101: python setup.py egg_info Check the logs for full command output. WARNING: You are using pip version 20.1.1; however, version 20.2.2 is available. You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.

any help will be appreciated :slight_smile:
thank you

You seem to be using an old version of home-assistant, could you upgrade to the latest?

hello Oscar,
I looked at my version and it seems be to the last
can you tell me if I’m wrong ?

arch	x86_64
chassis	laptop
dev	false
docker	true
docker_version	19.03.12
hassio	true
host_os	Debian GNU/Linux 10 (buster)
installation_type	Home Assistant Supervised
os_name	Linux
os_version	4.19.0-9-amd64
python_version	3.8.3
supervisor	232
timezone	Europe/Paris
version	0.114.0
virtualenv	false

thank you

I dont understand what is requesting python-gammu==2.12
The sms integration requires python-gammu=3.1

could run pip install python-gammu=3.1

on debian, the last version seems to be 2.12-1

[buster (stable)](https://packages.debian.org/en/buster/python-gammu) (python): Python module to communicate with mobile phones (Python 2)
2.12-1: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390390x

also, here is my output:
samos99@HA:/tmp# sudo pip install python-gammu==3.1
Collecting python-gammu==3.1
Could not find a version that satisfies the requirement python-gammu==3.1 (from versions: 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12)
No matching distribution found for python-gammu==3.1

hello, I found this in the source in this file manifest.json

{
  "domain": "sms",
  "name": "SMS",
  "documentation": "https://github.com/ocalvo/ha-sms/blob/1a867ef6d6fd1722b3140dda4e1ec9a6468c8073/README.md",
  "requirements": ["python-gammu==2.12"], <<<<<< this is the source of my problem 
  "dependencies": [],
  "codeowners": ["@ocalvo"]
}

I dug down a bit further into this as I now have a use case for receiving SMS in HA.

It looks very much to me like the Huawei Modem E3531 is not supported by gammu for receiving SMS messages - based on my own tests posted above and the open issue on GitHub

I’d love to be corrected on this, as it saves me hunting down an alternative fully supported modem.

Edit: Alternatively if I’m correct on the above, suggestions for a modem that fully supports send and receive appreciated.

So after confirming my suspicions that the E3531 only supports sending SMS via gammu (regardless of which interface is selected) I was able to track down a vintage unlocked Huawei E220 to work with.

I tested with gammu from command line as root and as the homeassistant user (which is already a member of the dialout user group). This is with HA Core v0.114.4 in a Python 3.7 venv on Ubuntu 18.04.

  1. lsusb output
ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270/E870 HSDPA/HSUPA` Modem
  1. mapped to /dev/sms with udev (unnecessary but my preference):
    sudo nano /etc/udev/rules.d/999-sms-gateway.rules
#symlink to Huawei USB Modem E220 - added kernel tag as udev
KERNEL=="ttyUSB1", SUBSYSTEM=="tty", ATTRS{idVendor}=="12d1", ATTRS{idProduct}== "1003", SYMLINK+="sms"
  1. restarted udev, then unplug modem and plug back in.
    sudo udevadm control --reload

  2. Configure homeassistant via UI for port /dev/sms

  3. Restart HA.

  4. Profit

Event 0 fired 13:00:
{
    "event_type": "sms.incoming_sms",
    "data": {
        "phone": "<redacted>",
        "date": "2020-08-29 13:00:21",
        "text": "Victory is mine!"
    },
    "origin": "LOCAL",
    "time_fired": "2020-08-29T12:00:25.316059+00:00",
    "context": {
        "id": "392152f8e9ef11ea8fb857b3a4c2668a",
        "parent_id": null,
        "user_id": null
    }
}
1 Like

Take a look here : https://community.jeedom.com/t/sms-huawei-e3531-sim-free-retour-dexperience/20271
Maybe we can make it work

I see that there is some info missing from the docs - like in example that there is ‘sms.incoming_sms’ event that can be used in automations… :slight_smile:
Anyway - is there any chance to add some way to have USSD or custom AT command requests?
I’d like to know values of signal (could be sensor set by integration) but also cash amount left on prepaid card I have.
Currently only way to see that is to use USSD code.

I use SIM800L via UART, works with the integration.