Converting an applescript to python

Posted on
Mon Apr 02, 2018 7:55 am
george99 offline
Posts: 224
Joined: May 27, 2015

Converting an applescript to python

Since AppleScript will be gone soon, I am hoping someone can help me convert my applescripts to python.
I am not very well versed in python. Hopefully somebody here knows how.
I have an AppleScript here that opens and activity in "Simple Control":

Code: Select all
#!

do shell script " curl 'http://192.168.0.82:47147/api/v1/runactivity' -d '{ \"activity_uuid\" : \"53E364DE-D44B-4419-BE6F-1F03D208C1D5\", \"toggle_state\" : \"on\" }' "



If anybody can translate this to python, I would appreciate it.

Thanks.

Posted on
Mon Apr 02, 2018 8:24 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Converting an applescript to python

Try this:
Code: Select all
import requests

data = '{ "activity_uuid" : "53E364DE-D44B-4419-BE6F-1F03D208C1D5", "toggle_state" : "on" }'

response = requests.post('http://192.168.0.82:47147/api/v1/runactivity', data=data)

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Apr 02, 2018 8:27 am
george99 offline
Posts: 224
Joined: May 27, 2015

Re: Converting an applescript to python

Works, thanks!

Posted on
Mon Apr 02, 2018 8:56 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Converting an applescript to python

[MODERATOR NOTE] moved to the appropriate forum.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 02, 2018 8:59 am
george99 offline
Posts: 224
Joined: May 27, 2015

Re: Converting an applescript to python

Ahh ok, missed that. Thanks.

Posted on
Mon Apr 02, 2018 9:01 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: Converting an applescript to python

Allow me to point out that if that "activity_uuid" is not dynamic, neither AppleScript nor Python are required for this.

Create a shell script that does what you want. Set the script's executable permissions. Point Indigo at the external script.

Right?

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Apr 02, 2018 9:40 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Converting an applescript to python

Point of fact, that AppleScript will continue to work (if the uuid is static) since it doesn't target the Indigo Server... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 02, 2018 9:43 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Converting an applescript to python

jay (support) wrote:
Point of fact, that AppleScript will continue to work (if the uuid is static) since it doesn't target the Indigo Server... ;)

Does that mean that you are leaving in the various AppleScript dialogs/text boxes in Indigo in 7.2 or are you saying that it would be fine so long as it was external?

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Apr 02, 2018 9:51 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Converting an applescript to python

It's likely that the embedded script boxes will not support AppleScript so it would have to be an external script. But it would continue to work as an external script.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest