Giter Site home page Giter Site logo

tediore / sms2mqtt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from domochip/sms2mqtt

0.0 1.0 1.0 119 KB

Gateway to send/receive SMS through MQTT using an USB GSM dongle (gammu)

License: GNU General Public License v3.0

Dockerfile 4.78% Python 95.22%

sms2mqtt's Introduction

Prerequisites

You need a GSM dongle "compatible" with Gammu : https://wammu.eu/phones/
Even if your dongle is not listed, it should works with.

If you need specific gammu settings to be added, feel free to open a PR or an issue.

How does it work

Diagram

How-to

Install

For Docker, run it by executing the following commmand:

docker run \
    -d \
    --name sms2mqtt \
    --restart=always \
    --device=/dev/ttyUSB0:/dev/mobile \
    -e PIN="1234" \
    -e HOST="192.168.1.x" \
    -e PORT=1883 \
    -e PREFIX="sms2mqtt" \
    -e CLIENTID="sms2mqttclid" \
    -e USER="usr" \
    -e PASSWORD="pass" \
    domochip/sms2mqtt

For Docker-Compose, use the following yaml:

version: '3'
services:
  sms2mqtt:
    container_name: sms2mqtt
    image: domochip/sms2mqtt
    devices:
    - /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile-if00-port0:/dev/mobile
    environment:
    - PIN=1234
    - HOST=10.0.0.2
    - PORT=1883
    - PREFIX=sms2mqtt
    - CLIENTID=sms2mqttclid
    - USER=mqtt_username
    - PASSWORD=mqtt_password
    restart: always

Configure

Device

  • device: Location of GSM dongle (replace /dev/ttyUSB0 with yours), it need to be mapped to /dev/mobile

NOTE: The /dev/ttyUSBx path of your GSM modem could change on reboot, so it's recommended to use the /dev/serial/by-id/ path or symlink udev rules to avoid this issue.

Environment variables

  • PIN: Optional, Pin code of your SIM
  • HOST: IP address or hostname of your MQTT broker
  • PORT: Optional, port of your MQTT broker
  • PREFIX: Optional, MQTT prefix used in topics for subscribe/publish
  • CLIENTID: Optional, MQTT client id to use
  • USER: Optional, MQTT username
  • PASSWORD: Optional, MQTT password

Send

The default {prefix} for topics is sms2mqtt.

To send SMS:

  1. Publish this payload to topic sms2mqtt/send :
    {"number":"+33612345678", "text":"This is a test message"}
  2. SMS is sent
  3. A confirmation is sent back through MQTT to topic sms2mqtt/sent :
    {"result":"success", "datetime":"2021-01-23 13:00:00", "number":"+33612345678", "text":"This is a test message"}
  • ✔️ SMS to multiple Numbers using semicolon (;) seperated list. A confirmation will be sent back for each numbers.
  • ✔️ very long messages (more than 160 char).
  • ✔️ unicode messages containing emoji like : {"number":"+33612345678", "text":"It's working fine 👌"}
  • ✔️ very long messages containing emoji

Receive

Received SMS are published to topic sms2mqtt/received like this :
{"datetime":"2021-01-23 13:30:00", "number":"+31415926535", "text":"Hi, Be the Pi with you"}

  • ✔️ long SMS messages
  • ❌ any MMS

Other topic

  • sms2mqtt/signal: A signal quality payload is published when quality change
    E.g. {"SignalStrength": -71, "SignalPercent": 63, "BitErrorRate": -1}

Troubleshoot

Logs

You need to have a look at logs using :
docker logs sms2mqtt

Updating

To update to the latest Docker image:

docker stop sms2mqtt
docker rm sms2mqtt
docker rmi domochip/sms2mqtt
# Now run the container again, Docker will automatically pull the latest image.

Ref/Thanks

I want to thanks those repositories for their codes that inspired me :

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.