Variables not set immediately (trigger insert state)

Posted on
Mon Oct 09, 2017 1:13 pm
Umtauscher offline
User avatar
Posts: 566
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Variables not set immediately (trigger insert state)

I understand the blocking problem. But as I understand it, using python will make the inital problem worse.
So the only sultion for my problem would be to send the request and afterwards using the same script start the GhostXML plugin to update the state from the same script, but how would I do that?
In fact it seems all too complicated for such a simple action.

Posted on
Mon Oct 09, 2017 1:20 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Variables not set immediately (trigger insert state)

I don't understand the details about what you are doing exactly, but why not have your python script: 1) send the HTTP request via requests module (see example I linked to), 2) once it replies have the script tell the GhostXML plugin to perform its query? If it is all in the same script then it will be sequential and you won't have any problems with the update not yet having occurred.

Does the GhostXML Plugin script define an Indigo action you can put in an Action Group? if so, it is trivial to tell Indigo to execute an Action Group from a python script.

Image

Posted on
Mon Oct 09, 2017 1:21 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Variables not set immediately (trigger insert state)

Umtauscher wrote:
I understand the blocking problem. But as I understand it, using python will make the inital problem worse.
So the only sultion for my problem would be to send the request and afterwards using the same script start the GhostXML plugin to update the state from the same script, but how would I do that?
In fact it seems all too complicated for such a simple action.


I think you're overcomplicating this, perhaps due to your aversion to Python. You should be able to do the web request and then parse the result to update the variable all in one fairly short Python script. What exactly do you have the GhostXML plugin reading? Does the result have to be in the GhostXML state or can it be in a variable?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 09, 2017 1:37 pm
Umtauscher offline
User avatar
Posts: 566
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Variables not set immediately (trigger insert state)

I have to send a http request to one of my network speaker and afterwards trigger the refresh of a single device. ( which I could do by simply clicking)
I don't know how to do that in a script. - Python or Applescript.
I really hate to have to script something trivial like that.
And you are right, I don't like python. at all ;-)

Posted on
Mon Oct 09, 2017 1:40 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Variables not set immediately (trigger insert state)

You need a script of some sort to do the http request, so adding the device refresh to the end of the script isn't really unreasonable.

What do you mean by "refresh"? The same as clicking the "Send Status Request" button in the UI? Or something else?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 09, 2017 1:50 pm
Umtauscher offline
User avatar
Posts: 566
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Variables not set immediately (trigger insert state)

Thanks for trying to help.

I have an action group that has 2 actions

1. embedded apple scrip:
Code: Select all
do shell script "/usr/bin/curl -s -m 15 http://wx030-1.voyager95.de/YamahaExtendedControl/v1/main/setMute?enable=true; /usr/bin/curl -s -m 15 http://wx030-1.voyager95.de/YamahaExtendedControl/v1/main/setPower?power=standby; wait; "


2. Refresh data for device (GhostXML Action)
wx30-1
The ghostXML refreshes the state variables

So basically I Mute the speaker, Switch it to standby and GhostXML refreshes the state of that speaker which is reflected in a virtual device.
Last edited by Umtauscher on Tue Oct 10, 2017 3:48 am, edited 1 time in total.

Posted on
Mon Oct 09, 2017 2:03 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Variables not set immediately (trigger insert state)

This code should work to cause the GhostXML refresh:

Code: Select all
ghost = "com.fogbert.indigoplugin.GhostXML"
ghostPlugin = indigo.server.getPlugin(ghost)
if ghostPlugin.isEnabled():
   ghostPlugin.executeAction("refreshDataForDev", deviceId=XXXXXXX)


Combine that with the previously posted code to use the requests module to call your URL and you should be good. You didn't use code tags on the AppleScript you posted, so I can't really see what it's doing. The forum software is messing it up.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Oct 10, 2017 3:59 am
Umtauscher offline
User avatar
Posts: 566
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Variables not set immediately (trigger insert state)

Thanks Joe for your help. I really appreciate it.
I will test it tonight.


Cheers
Wilhelm

Who is online

Users browsing this forum: No registered users and 3 guests