开云体育

Re: Controlling Alexa (Amazon) via JMRI


 

You need to add a closing “ to the last line.

That just defines a routine to do the communication. To invoke it

trigger_url(url)

will do the operation. But that URL (last line) doesn’t look right to me.

Bob

On Mar 16, 2025, at 12:14?PM, Human[c]ity Junction via groups.io <heath@...> wrote:

This is what ChatGPT suggested, I do not know if this is accurate or if it will work. It is supposedly Python, not Jython, so not sure if it would run within JMRI.
import java.net.HttpURLConnection
import java.net.URL
def trigger_url(url):
try:
connection = java.net.URL(url).openConnection()
connection.setRequestMethod("GET")
connection.setDoOutput(False)
connection.connect()
response_code = connection.getResponseCode()
connection.disconnect()
return response_code
except Exception as e:
print("Error triggering URL:", e)
return None
# URL to be triggered in the background
url = "(url)
--
Heath @ Human[c]ity




Bob Jacobsen
rgj1927@...

Join [email protected] to automatically receive all group messages.