URL - /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=
-
I’ve just started to have a play with iOS Shortcut and one of my test cases is to see if I can do the following
- select a a file (.lua or .txt) on my iPad
- extract the entire script/contents
- encode the data obtained
- append the encode content to the end of the RunLua action.
- call the URL
http://myIP/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=
Below is a screenshot of the workflow I have built in Shortcuts, which seems pretty straight forward, and it does generate a encoded URL, however the actual request itself does not complete. I get an ‘OK’ response back eventually, but the code is not actioned, and the logs don’t seem to tell me anything..
The code I’m extracting from the Lua file works fine in the test Lua window, so i’m not sure what’s occurring differently, between the two routes, maybe it’s the encryption being used ?..
Is anyone able to help me test this, and see if they can generate a long / multi line RunLua encoded URL (if not via Shortcut, then by some that can help me with the root cause to then address that in Shortcut
-
Things I notice:
- URL does not have device number (
DeviceNum=0
) - Should use
id=action
notid=lu_action
(updated standard) Code
value is not base64-encoded on this function, which means the code must be URL-encoded as all query parameters in a GET request must be, and if the total length of the request URL including query parameters is more than 1024 bytes, you must use POST rather than GET for the request and pass the query parameters in the body (MIME typeapplication/x-www-form-urlencoded
, specified in theContent-Type
header for the request).- You're not showing the final "encoded" URL as submitted, or stating what encoding you are using (you just say "encode the data obtained" and not what kind), so any of that could be incorrect and we wouldn't know/be able to tell you.
- Luup is pretty good at logging action requests as received, irrespective of their eventual success, so if you're not finding this in the logs, it's either not getting to the box or you're not looking for the right thing. A search for
RunLua
should find the entries.
- URL does not have device number (
-
Things I notice:
- URL does not have device number (
DeviceNum=0
) - Should use
id=action
notid=lu_action
(updated standard) Code
value is not base64-encoded on this function, which means the code must be URL-encoded as all query parameters in a GET request must be, and if the total length of the request URL including query parameters is more than 1024 bytes, you must use POST rather than GET for the request and pass the query parameters in the body (MIME typeapplication/x-www-form-urlencoded
, specified in theContent-Type
header for the request).- You're not showing the final "encoded" URL as submitted, or stating what encoding you are using (you just say "encode the data obtained" and not what kind), so any of that could be incorrect and we wouldn't know/be able to tell you.
- Luup is pretty good at logging action requests as received, irrespective of their eventual success, so if you're not finding this in the logs, it's either not getting to the box or you're not looking for the right thing. A search for
RunLua
should find the entries.
@toggledbits said in URL - /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=:
Things I notice:
- URL does not have device number (
DeviceNum=0
)
The testing I had done, did not seem to require one, what would I use - see working example further down..
- Should use
id=action
notid=lu_action
(updated standard)
Thanks, i had it working, with lu_action, but will look to update to ensure it’s current..
Code
value is not base64-encoded on this function, which means the code must be URL-encoded as all query parameters in a GET request must be, and if the total length of the request URL including query parameters is more than 1024 bytes, you must use POST rather than GET for the request and pass the query parameters in the body (MIME typeapplication/x-www-form-urlencoded
, specified in theContent-Type
header for the request).
OK, that makes it interesting, I’ll have to add some sort of character count in to the workflow....
- You're not showing the final "encoded" URL as submitted, or stating what encoding you are using (you just say "encode the data obtained" and not what kind), so any of that could be incorrect and we wouldn't know/be able to tell you.
Yeah, sorry I’m testing it with a Prowl notification URL, which has my API key in, so didn’t want to post that, but will show it as working example lower down
- Luup is pretty good at logging action requests as received, irrespective of their eventual success, so if you're not finding this in the logs, it's either not getting to the box or you're not looking for the right thing. A search for
RunLua
should find the entries.
As always, thanks again..
Here is a working RunLua&Code I managed to get working via a browser URL call
http://192.168.1.10:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=local%20function%20my_escape%20%28s%29%0A%20%20%20%20s%20%3D%20string.gsub%28s%2C%20%22%20%22%2C%20%22%2B%22%29%0A%20%20%20%20return%20s%0Aend%0A%0Alocal%20function%20my_prowl%20%28appl%2C%20event%2C%20description%29%0A%20%20%20%20local%20prowl_url%20%20%20%20%20%20%3D%20%22https%3A%2F%2Fapi.prowlapp.com%2Fpublicapi%2Fadd%3Fapikey%3D%22%0A%20%20%20%20%20%20%20%20..%20%224581181d251acedeb3808d4myapikey758b21f%22%0A%20%20%20%20%20%20%20%20..%20%22%26application%3D%22%20..%20my_escape%28appl%29%0A%20%20%20%20%20%20%20%20..%20%22%26event%3D%22%20%20%20%20%20%20%20%20%20..%20my_escape%28event%29%0A%20%20%20%20%20%20%20%20..%20%22%26description%3D%22%20..%20my_escape%28description%29%0A%20%20%20%20%20%20%20%20..%20%22%26priority%3D-1%22%0A%20%20%20%20%20%20%20%20..%20%22%26url%3Dhttps%3A%2F%2Fwww.google.co.uk%2F%22%0A%20%20%20%20luup.inet.wget%28prowl_url%29%0Aend%0A%0Amy_prowl%20%28%22Vera%20Home%20Controller%22%2C%20%22Testing%20code%22%2C%20%22this%20could%20any%20description%22%29
- URL does not have device number (
-
@toggledbits said in URL - /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=:
Things I notice:
- URL does not have device number (
DeviceNum=0
)
The testing I had done, did not seem to require one, what would I use - see working example further down..
- Should use
id=action
notid=lu_action
(updated standard)
Thanks, i had it working, with lu_action, but will look to update to ensure it’s current..
Code
value is not base64-encoded on this function, which means the code must be URL-encoded as all query parameters in a GET request must be, and if the total length of the request URL including query parameters is more than 1024 bytes, you must use POST rather than GET for the request and pass the query parameters in the body (MIME typeapplication/x-www-form-urlencoded
, specified in theContent-Type
header for the request).
OK, that makes it interesting, I’ll have to add some sort of character count in to the workflow....
- You're not showing the final "encoded" URL as submitted, or stating what encoding you are using (you just say "encode the data obtained" and not what kind), so any of that could be incorrect and we wouldn't know/be able to tell you.
Yeah, sorry I’m testing it with a Prowl notification URL, which has my API key in, so didn’t want to post that, but will show it as working example lower down
- Luup is pretty good at logging action requests as received, irrespective of their eventual success, so if you're not finding this in the logs, it's either not getting to the box or you're not looking for the right thing. A search for
RunLua
should find the entries.
As always, thanks again..
Here is a working RunLua&Code I managed to get working via a browser URL call
http://192.168.1.10:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=local%20function%20my_escape%20%28s%29%0A%20%20%20%20s%20%3D%20string.gsub%28s%2C%20%22%20%22%2C%20%22%2B%22%29%0A%20%20%20%20return%20s%0Aend%0A%0Alocal%20function%20my_prowl%20%28appl%2C%20event%2C%20description%29%0A%20%20%20%20local%20prowl_url%20%20%20%20%20%20%3D%20%22https%3A%2F%2Fapi.prowlapp.com%2Fpublicapi%2Fadd%3Fapikey%3D%22%0A%20%20%20%20%20%20%20%20..%20%224581181d251acedeb3808d4myapikey758b21f%22%0A%20%20%20%20%20%20%20%20..%20%22%26application%3D%22%20..%20my_escape%28appl%29%0A%20%20%20%20%20%20%20%20..%20%22%26event%3D%22%20%20%20%20%20%20%20%20%20..%20my_escape%28event%29%0A%20%20%20%20%20%20%20%20..%20%22%26description%3D%22%20..%20my_escape%28description%29%0A%20%20%20%20%20%20%20%20..%20%22%26priority%3D-1%22%0A%20%20%20%20%20%20%20%20..%20%22%26url%3Dhttps%3A%2F%2Fwww.google.co.uk%2F%22%0A%20%20%20%20luup.inet.wget%28prowl_url%29%0Aend%0A%0Amy_prowl%20%28%22Vera%20Home%20Controller%22%2C%20%22Testing%20code%22%2C%20%22this%20could%20any%20description%22%29
@parkerc said in URL - /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=:
@toggledbits said in URL - /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=:
Things I notice:- URL does not have device number (
DeviceNum=0
)
The testing I had done, did not seem to require one, what would I use - see working example further down..
- Should use
id=action
notid=lu_action
(updated standard)
Thanks, i had it working, with lu_action, but will look to update to ensure it’s current..
Code
value is not base64-encoded on this function, which means the code must be URL-encoded as all query parameters in a GET request must be, and if the total length of the request URL including query parameters is more than 1024 bytes, you must use POST rather than GET for the request and pass the query parameters in the body (MIME typeapplication/x-www-form-urlencoded
, specified in theContent-Type
header for the request).
OK, that makes it interesting, I’ll have to add some sort of character count in to the workflow....
- You're not showing the final "encoded" URL as submitted, or stating what encoding you are using (you just say "encode the data obtained" and not what kind), so any of that could be incorrect and we wouldn't know/be able to tell you.
Yeah, sorry I’m testing it with a Prowl notification URL, which has my API key in, so didn’t want to post that, but will show it as working example lower down
- Luup is pretty good at logging action requests as received, irrespective of their eventual success, so if you're not finding this in the logs, it's either not getting to the box or you're not looking for the right thing. A search for
RunLua
should find the entries.
Checking again, it does have something, but it does not seem to tell me anything of use
01 11/29/21 10:49:00.579 FileUtils::ReadURL 28/resp:0 user: pass: size 1 https://api.prowlapp.com/publicapi/add?apikey= 4581181d251acedeb3808d4myapikey758b21f&application=Vera Home Controller&event=Testing code&description=this could any description&priority=-1&url=https://www.google.co.uk/ response: <0x73ec6520>
As always, thanks again..
Here is a RunLua&Code submission, that is working via a browser URL call, I’d be using this as the basis for this Shortcut
http://192.168.1.10:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=local%20function%20my_escape%20%28s%29%0A%20%20%20%20s%20%3D%20string.gsub%28s%2C%20%22%20%22%2C%20%22%2B%22%29%0A%20%20%20%20return%20s%0Aend%0A%0Alocal%20function%20my_prowl%20%28appl%2C%20event%2C%20description%29%0A%20%20%20%20local%20prowl_url%20%20%20%20%20%20%3D%20%22https%3A%2F%2Fapi.prowlapp.com%2Fpublicapi%2Fadd%3Fapikey%3D%22%0A%20%20%20%20%20%20%20%20..%20%224581181d251acedeb3808d4myapikey758b21f%22%0A%20%20%20%20%20%20%20%20..%20%22%26application%3D%22%20..%20my_escape%28appl%29%0A%20%20%20%20%20%20%20%20..%20%22%26event%3D%22%20%20%20%20%20%20%20%20%20..%20my_escape%28event%29%0A%20%20%20%20%20%20%20%20..%20%22%26description%3D%22%20..%20my_escape%28description%29%0A%20%20%20%20%20%20%20%20..%20%22%26priority%3D-1%22%0A%20%20%20%20%20%20%20%20..%20%22%26url%3Dhttps%3A%2F%2Fwww.google.co.uk%2F%22%0A%20%20%20%20luup.inet.wget%28prowl_url%29%0Aend%0A%0Amy_prowl%20%28%22Vera%20Home%20Controller%22%2C%20%22Testing%20code%22%2C%20%22this%20could%20any%20description%22%29
- URL does not have device number (
-
@toggledbits said in URL - /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=:
Things I notice:
- URL does not have device number (
DeviceNum=0
)
The testing I had done, did not seem to require one, what would I use - see working example further down..
- Should use
id=action
notid=lu_action
(updated standard)
Thanks, i had it working, with lu_action, but will look to update to ensure it’s current..
Code
value is not base64-encoded on this function, which means the code must be URL-encoded as all query parameters in a GET request must be, and if the total length of the request URL including query parameters is more than 1024 bytes, you must use POST rather than GET for the request and pass the query parameters in the body (MIME typeapplication/x-www-form-urlencoded
, specified in theContent-Type
header for the request).
OK, that makes it interesting, I’ll have to add some sort of character count in to the workflow....
- You're not showing the final "encoded" URL as submitted, or stating what encoding you are using (you just say "encode the data obtained" and not what kind), so any of that could be incorrect and we wouldn't know/be able to tell you.
Yeah, sorry I’m testing it with a Prowl notification URL, which has my API key in, so didn’t want to post that, but will show it as working example lower down
- Luup is pretty good at logging action requests as received, irrespective of their eventual success, so if you're not finding this in the logs, it's either not getting to the box or you're not looking for the right thing. A search for
RunLua
should find the entries.
As always, thanks again..
Here is a working RunLua&Code I managed to get working via a browser URL call
http://192.168.1.10:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=local%20function%20my_escape%20%28s%29%0A%20%20%20%20s%20%3D%20string.gsub%28s%2C%20%22%20%22%2C%20%22%2B%22%29%0A%20%20%20%20return%20s%0Aend%0A%0Alocal%20function%20my_prowl%20%28appl%2C%20event%2C%20description%29%0A%20%20%20%20local%20prowl_url%20%20%20%20%20%20%3D%20%22https%3A%2F%2Fapi.prowlapp.com%2Fpublicapi%2Fadd%3Fapikey%3D%22%0A%20%20%20%20%20%20%20%20..%20%224581181d251acedeb3808d4myapikey758b21f%22%0A%20%20%20%20%20%20%20%20..%20%22%26application%3D%22%20..%20my_escape%28appl%29%0A%20%20%20%20%20%20%20%20..%20%22%26event%3D%22%20%20%20%20%20%20%20%20%20..%20my_escape%28event%29%0A%20%20%20%20%20%20%20%20..%20%22%26description%3D%22%20..%20my_escape%28description%29%0A%20%20%20%20%20%20%20%20..%20%22%26priority%3D-1%22%0A%20%20%20%20%20%20%20%20..%20%22%26url%3Dhttps%3A%2F%2Fwww.google.co.uk%2F%22%0A%20%20%20%20luup.inet.wget%28prowl_url%29%0Aend%0A%0Amy_prowl%20%28%22Vera%20Home%20Controller%22%2C%20%22Testing%20code%22%2C%20%22this%20could%20any%20description%22%29
@parkerc said in URL - /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=:
Here is a working RunLua&Code I managed to get working via a browser URL call
That URL is 1126 bytes, too long for a GET. The browser is automatically shifting to POST as I described. You'll need to do the same.
- URL does not have device number (