Yes, replace the entire first parameter with your phone number starting with the plus sign plus your country code plus your number (no dashes or parenthesis)
If someone could wrap this up into a add-on, many HA nobs like me would be delighted.
I am hoping for, one day, where I have a USB-GSM dongle attached to my Pi, and if internet goes down the dongle takes over until internet is up again. That would be a security system to trust.
For the last four months had lighting taking out my internet twice. One time my internet service provider used one week to get internet back. Being able to use GSM as backup, or as a main communication device for a cabin up in the mountain where cable internet is not available, would make HA complete as a security device.
Whilst this work is all great, there are many variables to consider… especially considering the type of dongle/bearer etc…
I would push for a Gammu Addon instead… https://github.com/pajikos/sms-gammu-gateway … use the right tools for the right job and don’t try to re-invent the wheel… or do, but then don’t complain about breaking changes down the line… but as i started off by saying… well done on the hard work and getting this working…
The problem with Gammu is that it does not uses an async approach to talk to the modem, it locks
for every single call to the modem.
The goals will be to use the async serial interface for python to make sure we don’t use the global python lock which if used in Home Assistant will block.
I do agree, however, maybe we should create another python async friendly library to abstract SMS commands and then have a hass specific extension on top of that.
Today I completed my migration to hassio.
However, I ran into a problem in how Alpine recognizes the Hauwei USB stick, it refuses to install the usb serial driver for it.
In other Linux distros you are supposed to run usb_switch, however running this in hass.io give me the following error:
This is a version of a python script compatible with hassio:
import serial
import sys
import getopt
import logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
DEST=sys.argv[1]
#MD="/dev/ttyUSB2"
MD="COM10"
if (len(sys.argv) > 2):
message=sys.argv[2]
else:
message = ''
for line in sys.stdin:
message+=line
logging.debug('Sending message '+message+' to '+DEST)
logging.debug('Opening serial port '+MD)
ser = serial.Serial(MD) # open serial port
ser.write(b'\x1a') # Flush any previuos attempts to send message
ser.flush()
logging.debug('Sending AT+CMGF command')
line = b''
ser.write(b'AT+CMGF=1\r')
while line!=b'OK\r\n':
line = ser.readline()
logging.debug('Response '+str(line))
ser.flush()
logging.debug('Sending AT+CMGS command')
line = b''
phoneAsAscii = bytes(DEST, 'ascii')
ser.write(b'AT+CMGS="'+phoneAsAscii+b'"\r')
while line!=b'> \r\n':
line = ser.readline()
logging.debug('Response '+str(line))
ser.flush()
logging.debug('Sending message')
messageAsAscii = bytes(message, 'ascii')
ser.write(messageAsAscii + b'\x1a')
line = b''
while line!=b'OK\r\n':
line = ser.readline()
logging.debug('Response '+str(line))
ser.close()
Another good reason to have a native SMS integration.
Invalid config for [sms]: No device at /dev/ttyUSB3 found for dictionary value @ data['sms']['device']. Got '/dev/ttyUSB3'. (See /config/configuration.yaml, line 210).