Script need it

Posted on
Sun May 03, 2020 3:29 am
Kamen offline
Posts: 7
Joined: May 02, 2020

Script need it

Hi could someone help me to write a script for me? I need to execute this via script.
Code: Select all
local http = require("socket.http")
local ltn12 = require("ltn12")

local path =  "http://IP:47147/api/v1/runactivity"
local payload = [[ {"activity_uuid":"CBD5ADC7-1E1A-4D28-AD0A-36518EE4785B"} ]]
local response_body = { }

local res, code, response_headers, status = http.request
{
   url = path,
   method = "POST",
   headers =
   {
     ["Content-Type"] = "application/json",
     ["Content-Length"] = payload:len()
   },
   source = ltn12.source.string(payload),
   sink = ltn12.sink.table(response_body)
}

It comes from Vera plus Luup code. Thanks in advance!

Posted on
Sun May 03, 2020 4:35 am
DaveL17 offline
User avatar
Posts: 5450
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script need it

Can you explain what the script does and what you're trying to accomplish? It looks like you're grabbing data from an API, but I'm not clear on what you're doing with that data once you request it. This is usually very easy to do in Python.

(I don't know LUUP, and it's one of the reasons I left Vera.)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue May 05, 2020 2:05 am
Kamen offline
Posts: 7
Joined: May 02, 2020

Script need it

Hi I'm using a app called simple control remote for my AV equipment and it is compatible with Indigo server. The sinking of all devices is done from a Hub running on a Mac mini so basically with this script I need to send a comment to the Hub to start activity.watch TV. http://IP:47147/api/v1/runactivity"
{"activity_uuid":"CBD5ADC7-1E1A-4D28-AD0A-36518EE4785B"} I hope that helps. Thank you very much!

Posted on
Tue May 05, 2020 3:39 am
FlyingDiver offline
User avatar
Posts: 4128
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script need it

Code: Select all
import requests
payload = {"activity_uuid":"CBD5ADC7-1E1A-4D28-AD0A-36518EE4785B"}
requests.post("http://IP:47147/api/v1/runactivity", data=payload)

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

Posted on
Tue May 05, 2020 4:39 am
DaveL17 offline
User avatar
Posts: 5450
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script need it

See? So much easier than LUUP.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed May 06, 2020 2:40 am
Kamen offline
Posts: 7
Joined: May 02, 2020

Re: Script need it

Thank you very much for your help! But is not working!

Posted on
Wed May 06, 2020 2:47 am
FlyingDiver offline
User avatar
Posts: 4128
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script need it

Kamen wrote:
Thank you very much for your help! But is not working!


Log output? Error messages?

Also, did you edit the script to put in the actual IP address of the device you're sending that to? You just had "IP" in the sample script. That needs to be changed to the actual IP address.

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

Posted on
Wed May 06, 2020 3:20 am
Kamen offline
Posts: 7
Joined: May 02, 2020

Re: Script need it

Hi thank you for your reply yes I did put the correct IP address, no error message!

Posted on
Wed May 06, 2020 7:40 am
jay (support) offline
Site Admin
User avatar
Posts: 16212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Script need it

I think maybe requests needs to be told the payload is json:

Code: Select all
 import requests
payload = {"activity_uuid":"CBD5ADC7-1E1A-4D28-AD0A-36518EE4785B"}
requests.post("http://IP:47147/api/v1/runactivity", json=payload)


note that the data parameter from the previous script was changed to json - that's the only change.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed May 06, 2020 1:01 pm
Kamen offline
Posts: 7
Joined: May 02, 2020

Re: Script need it

:D :D :D Thank you very much it works perfectly now! I really appreciate your help!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests