The sms
integration allows having a local execution SMS notification via Gammu. This is ideal when the internet is offline or when the power goes out.
This integration provides the following platforms:
To add the SMS notifications via GSM-modem integration to your Home Assistant instance, use this My button:
If the above My button doesn’t work, you can also perform the following steps manually:
Browse to your Home Assistant instance.
Go to Settings > Devices & Services.
In the bottom right corner, select the Add Integration button.
From the list, select SMS notifications via GSM-modem.
Follow the instructions on screen to complete the setup.
An SMS message can be sent by calling the notify.sms
. It will send the message to all phone numbers specified in the target
parameter.
To use notifications, please see the getting started with automation page.
action
:
service
:
notify.sms
data
:
message
:
"
This
is
a
message
for
you!"
target
:
"
+5068081-8181"
Some devices (receiving or sending) do not support Unicode (the default encoding). For these you can disable Unicode:
action
:
service
:
notify.sms
data
:
message
:
"
This
is
a
message
for
you
in
ANSI"
target
:
"
+5068081-8181"
data
:
unicode
:
False
You can also receive SMS messages that are sent to the SIM card number in your device.
Every time there is a message received, event: sms.incoming_sms
is fired with date, phone number and text message.
Sample automation that forward all SMS to user1
:
template
:
-
sensor
:
-
name
:
"
User1
Phone
Number"
state
:
!secret
user1_phone_number
notify_sms_user1
:
alias
:
"
Notify
via
SMS
to
User1"
fields
:
message
:
description
:
"
The
message
content"
example
:
"
The
light
is
on!"
sequence
:
-
service
:
notify.sms
data
:
message
:
"
{{
message
}}"
target
:
"
{{
states('sensor.user1_phone_number')
}}"
mode
:
single
icon
:
mdi:chat-alert
-
alias
:
"
Forward
SMS"
trigger
:
-
platform
:
event
event_type
:
sms.incoming_sms
action
:
-
service
:
script.notify_sms_user1
data
:
message
:
|
From: {{trigger.event.data.phone}}
{{trigger.event.data.text}} mode: single
You will need a USB GSM stick modem or device like SIM800L v2 connected via USB UART.
Search in the Gammu database for modems with AT connection.
For some unknown reason, the rule that converts these modems from storage devices into serial devices may not run automatically. To work around this problem, follow the procedure below to change the modem mode and (optionally) create udev
rule on a configuration USB stick for the device to switch to serial mode persistently.
usb_modeswitch
software to switch the modem operational mode (for Debian/Ubuntu distros):sudo
apt update &&
sudo
apt install
usb-modeswitch -y
lsusb
, its output should be similar to this:bus 000 device 001: ID 1FFF:342a
bus 001 device 005: ID 12d1:15ca <--------
Huawei is usually 12d1
bus 000 device 002: ID 2354:5352
bus 000 device 002: ID 1232:15ca
Identify the brand for your GSM modem, copy the brand_Id
and product_id
(In this case brand_id = 12d1
and product_Id = 15ca
)
sudo
/sbin/usb_modeswitch -X
-v
12d1 -p
15ca
Re-plug the device. After this the modem correct should work without the following ‘udev’ rule.
Set this content in file udev\10-gsm-modem.rules
in the configuration USB:
(Replace brand_Id
and product_id
for the numbers reported by lsusb
)
ACTION
==
"add"
\
, ATTRS{
idVendor}==
"brand_Id"
\
, ATTRS{
idProduct}==
"product_Id"
\
, RUN+=
"/sbin/usb_modeswitch -X -v brand_Id -p product_Id"
Here is a sample configuration file:
ACTION
==
"add"
\
, ATTRS{
idVendor}==
"12d1"
\
, ATTRS{
idProduct}==
"15ca"
\
, RUN+=
"/sbin/usb_modeswitch -X -v 12d1 -p 15ca"
Re-plug the USB stick, reboot the device, run lsusb
again.
The resulting product id now should be different and the brand id should be the same.
And ls -l /dev/*USB*
should now report your device.
If the device is still not recognized, remove the parameter -X from the usb_modeswitch command and reboot again.
Suggest an edit to this page, or provide/view feedback for this page.
With high quality products and considerate service, we will work together with you to enhance your business and improve the efficiency. Please don't hesitate to contact us to get more details of gsm modems.