Send and receive SMS in Home Assistant with GSM modem

Send and receive SMS in Home Assistant with GSM modem

Yes, it is possible and you don’t need to build anything from sources. Sending SMS from your home could be useful, for example, to send emergency alerts. But what about receiving and parsing SMS messages? Well, I used it to integrate my car security system with my Home Assistant. Now my Home Assistant could start the engine of my car automatically to warm it up before driving to work.

First of all, we need to set up notification service via GSM modem following the official documentation. This will allow us to send SMS messages by calling the notify service, for example in automation action:

action:
  - service: notify.sms
    data:
      message: Hi!

But also this integration allows reading SMS messages sent to the modem phone number by listening to the sms.incoming_sms event.

trigger:
  - platform: event
    event_type: sms.incoming_sms

In automation action, we can now parse the message by searching keywords in it:

action:
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{'engine is off' in trigger.event.data['text']}}
        sequence:
          -  ...

Here we are checking for the engine is off text in incoming SMS to perform some action. For example, to set the value of some input_boolean.