Sending REST commands to a non-HA (ISY) system

Just have the basics working with Rhasspy. Know enough to be dangerous.
Have been able to turn an Insteon smart switch on and off through an ISY994 with Rhasspy using the LOCAL COMMAND intent handling that points to a python script using 'REST" commands. The ISY system accepts RESTful commands and can control or provide data back based on the specific command.

The intent handling script uses import of python REQUESTS api.

  1. Is this the best intent handling method to send http based rest commands to third party systems?
  2. Attempting to add any speech related function within the if statement, either before or after the REST transmission causes the REST command and the speech not to work. Remark out either the REST command or the speech instructions and either will work. Not both.
  3. Is it possible to issue a REST command and parse the response and feed it back to be spoken by Rhasspy? Just as in the example below, but from a third party vs getting an internal system time?



import sys
import json
import random
import datetime
import time

import requests
from requests.auth import HTTPBasicAuth

auth = HTTPBasicAuth(‘admin’, ‘admin’)

def speech(text):
global o
o[“speech”] = {“text”: text}

get json from stdin and load into python dict

o = json.loads(

intent = o[“intent”][“name”]

if intent == “LightOn”:
#speech(‘Turning lights on’)
requests.get(‘ 40 F4 1/cmd/DON’, auth=auth)

if intent == “LightOff”:
requests.get(‘ 40 F4 1/cmd/DOF’, auth=auth)

if intent == “GetTime”:
now =
speech(“It’s %s %d %s.” % (now.strftime(‘%H’), now.minute, now.strftime(‘%p’)))