Send SMS with USB GSM modem when alarm triggered

Here is an example: I publish to an mqtt queue


alias: Publish incoming SMS
description: ''
trigger:
  - platform: event
    event_type: sms.incoming_sms
condition: []
action:
  - service: mqtt.publish
    data:
      topic: sms/incoming_sms
      payload_template: '{{trigger.event.data}}'
mode: queued
max: 50

1 Like

But this example not turn ON or OFF a Relay or other device like SonOff or Shelly relay.

- id: ucidi_becu
  alias: ucidi_becu
  trigger:
  - platform: event
    event_type: sms.incoming_sms
  condition:
  - condition: 
    condition: template
    value_template: '{{ "ucidi_becu" in trigger.event.data.text }}'
  action:
  - service: switch.turn_off
    entity_id: switch.hallway

2 Likes

Thank you Petrica, is working.

Hi,
Anyone can suggest me an AliExpress link for an USB GSM module to connect to raspberry 3b+ and HASSOS, I need only to send SMS!

Regards

You think it’s possible to do the same on HASSOS?

HI,

I’m trying to setup the SIM800 usb modem, but I’m not able to add the device to the integration
It seems that the device got detected

21-12-31 02:17:54 INFO (MainThread) [supervisor.hardware.monitor] Detecting HardwareAction.ADD hardware /dev/ttyUSB0 - /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0

I tried both the /dev/ttyUSB0 and /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0, but it doesn’t work
image

This is my config

can you help me to understand how to troubleshoot the issue?
regards

I read the entire discussion and I tried to follow the common recommended steps
image

I don’t see any config file10-gsm-modem.rules, do I need to manually create it?

[ 235.982708] usb 1-1.3: new full-speed USB device number 4 using xhci_hcd
[ 236.094935] usb 1-1.3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[ 236.094953] usb 1-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 236.094979] usb 1-1.3: Product: USB Serial
[ 236.099829] ch341 1-1.3:1.0: ch341-uart converter detected
[ 236.107289] usb 1-1.3: ch341-uart converter now attached to ttyUSB0

For the HAT version you need to modify the file config.txt in your boot partition to activation the serial port:

enable_uart=1

HI @Oscar_Calvo ,

I’m using this guy

how i should do that?

Hello,

I would also like to apply the SMS application, and found a (2x) huawei e3372h-153 via “Marktplaats” (Dutch E-bay) but unfortunately I can’t get it to work through Proxmox, I only see it in HA as a USB disk.

I also tried some solutions to put the e3372h in stick mode, but I couldn’t manage that unfortunately.

I was wondering what a properly working SMS USB stick is without having to reprogram it first.

As an SMS provider I use a Vodafone PrePaid SIM card.
My Home Assistant runs on a NUC on a proxmox virtual machine.

Hi,

In the first place, thanks for this great integration!
Just want to share my setup and experience.
I’m running Home Assistant OS on a Raspberry pi 3b from SSD. Powering from a DC UPS and a 12V to 5V DC-DC converter, which can handle 3A.
Had at home a SIM800L EVB board and decided to connect it. I was testing on windows with a USB-TTL converter and then on Raspbian and was working ok.
Then I thought why I use a USB converter if the raspberry has serial support. The TTL level was confusing for this EVB board as it has 5V input and the chip is working at 2.8V. Somewhere it was stated that it is compatible with 2.8, 3.3 and 5V. It was not clear how, so I was digging more and found that there is a built in level converter which is using the VDD pin.
So connected to a raspberry directly VCC to 5V, GND to GND, RX to TX and TX to RX and VDD to 3.3V, enabled uart in config.txt and it was working ok after that using /dev/serial0.
This board can consume 2A, which is quite high, I have checked and raspberry’s 5V pin is directly connected to supply. So far I did not see any power problems.

Setting up the integration in HA was confusing to me. When I added to the config file it was not working and appeared that another instance was started which was taking the control of the serial port.
So I spent quite some time adding removing. Eventually what was working for me was to add the integration manually first in HA and then add to the config file, after that it was ok. Still unclear if quotes are needed or not around the phone number. Currently I have quotes and works that way, it can send SMS. Today I was also testing incoming SMS and a notification was triggered in about 3 minutes.
I’m on the latest version of Home Assistant OS and Core:
Home Assistant OS 7.1
core-2021.12.9


image

I was using information in this thread to setup in HA and all works great.
Thank you!

1 Like

Good afternoon, I can’t send SMS, write an error ERROR (MainThread) [homeassistant.components.sms.notify] Sending to +38067******* failed: ERR_GETTING_SMSC

Modem Huawei E170.

Integration setup

sms:
   device: /dev/serial/by-id/usb-HUAWEI_Technology_HUAWEI_Mobile-if00-port0
notify:
   platform: sms
     name: sms_person_id_2
     recipient: '+38067*******'

The modem itself is defined in integrations and reads IMEI and signal strength.

Hi, It seems your SMS service center number is not configured on the SIM card. You can search for it how to configure. There are instructions like How can I enter the SMS service center (SMSC) number manually? | Sony UK

Hello,
first of all thanks @Oscar_Calvo for the great plugin! Over the last days I was trying to make my raspberry pi’s Supervised Installation communicate over SMS using the SMS Integration. The problem was that Home Assistant couldn’t talk to the device (ERR_TIMEOUT). The GSM Device I am using is the Geeethech GPRS Shield based on SIM900, connected over Serial. After spending some time reading the Gammu manual, I noticed that there is the ability to manually set the baud rate in the connection string. Replacing in config_flow.py line 24, and in init.py line 42, the Connection string from at to at19200 solved the problem and now I am able to use it!

I wonder if it’s possible in a future update to include a property in the configuration for the connection (let the default be at) as well, to avoid user interaction with the source code.

For anyone else with similar issues, you can read how to connect the Geeetech Shield to Raspberry PI and integrate it with Home Assistant in my blog.

Thanks for the feedback, please file a new issue with the details, this should be fairly easy to fix.

Thanks for the immediate response! I will fill a new issue now!

Hi @Oscar_Calvo, I have a device that doesn’t allowing setting the SMSC (via command or dialer system you linked above). I’ve had luck sending messages using -smscnumber +4474XXXXXXX in command line gammu, is there a way to manually set it?
I’ve tried editing the notify.py line 62 to encoded_message["SMSC"] = {"Number": "+4474XXXXXXX"} but continue to get the ERR_GETTING_SMSC

Put the SIM in a phone and configure it using the phone. Make sure the phone can send and receive messages before using it with home-assistant.

Nevermind, I’ve fixed the issue. If anyone else can’t set a SMSC on their device and are getting the ERR_GETTING_SMSC (this seems common when using a phone as a modem as they perform the SMSC via software not via the sim… especially old Android phones), they can do so manually,

  1. Create a custom_components folder in your HA config (if you don’t have one already) and in that create a sms folder and place the SMS github files in the folder
  2. Edit notify.py line 62 to encoded_message["SMSC"] = {"Number": "+4474XXXXXXX"} adding in your carriers Message Centre number (also called a service centre number)
  3. Edit the manifest.json file adding in "version": "0.0.1", between lines 2 and 3

Restart HA and it should work. Do note that the integration will no longer update automatically.

Another tip if using an android phone, is enable USB debugging in the developer settings. None of the phones I tested worked otherwise.

Works great, thanks @Oscar_Calvo for all your hard work on this!

1 Like