Telstra Notification add-on

did you ever find a solution for this? I’m having the same problem

Not yet. I did contact Telstra, I need to supply them withl some more info.

I’m having the same issue.

I think the telstra notify component needs to be changed to use the URL for Auth instead of

Check out forum post

I dont get auth errors anymore when I update the URL. But am getting

[31m2017-11-02 14:16:32 ERROR (SyncWorker_14) [homeassistant.components.notify.telstra] Failed to send SMS. Status code: 401e[0m

Possibly somethign else wrong with my config though.

@psy How did you update the URL? Is a simple code change that can be done locally? If so, which file?


Edit: Sorry Just answered my own question following the advice here and here:

Edit 2:
I am also still getting the 401 error though. I tried changing the URL on line 74 to but then i got a 404 error. I have also tried changing SMS to NSMS on line 94. So anyone got a working example?

Hi Gav,

I updated the two URL’s as per the link to the telstra dev forum that Dinoaus posted. I also changed the scope from SMS to NSMS

I now appear to auth successfully, and get a token however I get an error 500 when attempting to send an SMS.

I updated the file (but take it that you’ve already found this).
I haven’t had a chance to get a better look at the file. May do so over the w/end.

Thanks. Let us know if you have any success

@psy What are you using as the message_resource? When I change it to I get a 404 error?

message_resource is set to

as documented here

note my programming skills aren’t brilliant, so I’m fumbling my way through this.

I am trying to find some time to work out what is going wrong. All I have done so far is retrieved the full error message. Might help someone:

“message”:“Technical error : Execution of JS.ModifyMessageIdURLResponse failed with error: Javascript runtime error: "TypeError: Cannot call method "map" of undefined. (modifyMessageIdURLResponse.js:57)" : An error has occurred while processing your request, please refer to API Docs for summary on the issue”

Edit: Someone has posted this exact query to the Telstra Dev forum so I have also followed that up there as well.

Just spotted this thread and thought this might help, Ive just pushed the Node SDK

Also before you send an SMS/MMS you need to hit the provisioning API against your app to get issued a mobile number first.

Thanks Steve.

I found a python example linked from the dev Telstra page and have modified this.
I can send sms’ messages in python now.

Will modify the file for Homeassistant now that I know it works.

Evening all.

Got it working!

Thanks Steve, Gav and all others. Not sure how I publish this?

My python skills are rubbish, so it probably needs a bit of cleanup.

@psy Did you want to just paste your code in here for now and we can take a look at it?

Ill post it tonight. Im not sure it’s accurate, as I registered a phone number using the python sample code, so not sure what impact that will have.

Essentially I just added a provision section and called that as part of the send sms component.

Telstra API platform for notify component.

For more details about this platform, please refer to the documentation at
import logging

import requests
import voluptuous as vol

from homeassistant.components.notify import (
    BaseNotificationService, ATTR_TITLE, PLATFORM_SCHEMA)
from homeassistant.const import CONTENT_TYPE_JSON, HTTP_HEADER_CONTENT_TYPE
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

CONF_CONSUMER_KEY = 'consumer_key'
CONF_CONSUMER_SECRET = 'consumer_secret'
CONF_PHONE_NUMBER = 'phone_number'

    vol.Required(CONF_CONSUMER_KEY): cv.string,
    vol.Required(CONF_CONSUMER_SECRET): cv.string,
    vol.Required(CONF_PHONE_NUMBER): cv.string,

def get_service(hass, config, discovery_info=None):
    """Get the Telstra SMS API notification service."""
    consumer_key = config.get(CONF_CONSUMER_KEY)
    consumer_secret = config.get(CONF_CONSUMER_SECRET)
    phone_number = config.get(CONF_PHONE_NUMBER)

    if _authenticate(consumer_key, consumer_secret) is False:
        _LOGGER.exception("Error obtaining authorization from Telstra API")
        return None

    return TelstraNotificationService(
        consumer_key, consumer_secret, phone_number)

class TelstraNotificationService(BaseNotificationService):
    """Implementation of a notification service for the Telstra SMS API."""

    def __init__(self, consumer_key, consumer_secret, phone_number):
        """Initialize the service."""
        self._consumer_key = consumer_key
        self._consumer_secret = consumer_secret
        self._phone_number = phone_number

    def send_message(self, message="", **kwargs):
        """Send a message to a user."""
        title = kwargs.get(ATTR_TITLE)

        # Retrieve authorization first
        token_response = _authenticate(
            self._consumer_key, self._consumer_secret)
        if token_response is False:
            _LOGGER.exception("Error obtaining authorization from Telstra API")

        provision_response = _provision(token_response)
        if provision_response is False:
            _LOGGER.exception("Error provisioning number from Telstra API")

        # Send the SMS
        if title:
            text = '{} {}'.format(title, message)
            text = message

        message_data = {
            'to': self._phone_number,
            'body': text,
        message_resource = ''
        message_headers = {
            'Authorization': 'Bearer ' + token_response['access_token'],
        message_response =
            message_resource, headers=message_headers, json=message_data,

        if message_response.status_code != 202:
            _LOGGER.exception("Failed to send SMS. Status code: %d",

def _authenticate(consumer_key, consumer_secret):
    """Authenticate with the Telstra API."""
    token_data = {
        'client_id': consumer_key,
        'client_secret': consumer_secret,
        'grant_type': 'client_credentials',
        'scope': 'NSMS'
    token_resource = ''
    token_response = requests.get(
        token_resource, params=token_data, timeout=10).json()

    if 'error' in token_response:
        return False

    return token_response
def _provision(token_response):
    """Provision a number with the Telstra API."""
    provision_data = {
        'Authorization': 'Bearer ' + token_response['access_token'],

    provision_resource = ''
    provision_response = requests.get(
        provision_resource, params=provision_data, timeout=10).json()

    if 'error' in provision_response:
        return False

    return provision_response

Thanks @psy

That looks great. All would be working I think except the API says I have exceeded my quota so the SMS didnt send :frowning: I havent tried 1000 times so looks like their API still needs some work tracking usage but I cant complain since it was free!


It’s a 1000 sms limit in total, not per month.

Yeah I wouldnt have tried sending 1000 times. Might have to create a new account…