How to create a .cmd file with a Vera HTTP request in it? (Resolved)

Hi

If I paste this in to a browser it works and turns on the appliance module:

http://192.168.0.11:3480/data_request?id=lu_action&output_format=xml&DeviceNum=17&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1

I would like to create a Windows .cmd file that contains the above HTTP request. I assume I need to use WGET.

I tried creating a .cmd file with this in it:

wget http://192.168.0.11:3480/data_request?id=lu_action&output_format=xml&DeviceNum=17&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1

However when I run the .cmd file the appliance module does not turn on, below is the output text I see:

C:\Lights\Vera Commands>wget http://192.168.0.11:3480/data_request?id=lu_action
& output_format=xml & DeviceNum=17 & serviceId=urn:upnp-org:serviceId:Switch
ower1 & action=SetTarget & newTargetValue=1
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
–2012-08-19 22:18:40-- http://192.168.0.11:3480/data_request?id=lu_action
Connecting to 192.168.0.11:3480… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [text]
Saving to: `data_request@id=lu_action’

[ <=>                                   ] 24          --.-K/s   in 0s

2012-08-19 22:18:40 (281 KB/s) - `data_request@id=lu_action’ saved [24]

‘output_format’ is not recognized as an internal or external command,
operable program or batch file.
‘DeviceNum’ is not recognized as an internal or external command,
operable program or batch file.
‘serviceId’ is not recognized as an internal or external command,
operable program or batch file.
‘action’ is not recognized as an internal or external command,
operable program or batch file.
‘newTargetValue’ is not recognized as an internal or external command,
operable program or batch file.

It also then creates a file called data_request@id=lu_action in the folder where my .cmd file is, I don’t want these files whatever they are?

What would be the correct syntax to put in to the .cmd file ??

Thank you.

Think I just got lucky?

This seems to work and deletes that file:

wget --delete-after “http://192.168.0.11:3480/data_request?id=lu_action&output_format=xml&DeviceNum=17&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1

Had to put the quotes round the HTTP string

Is this the best way to create these .cmd files ?

OK so now I can turn devices on and off via HTTP requests in .cmd files. How do I run scenes via HTTP command ?

Can someone please give me an example of a HTTP request for running a scene?

Thanks

Looking at this wiki page it gives an example for running a scene as:

To run a scene, you send the action ‘RunScene’ like this::
http://ipadress:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=

However when I try in the browser I get an error:

http://192.168.0.11:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=1

[b]This page contains the following errors:

error on line 2 at column 28: xmlns:u: ‘Unknown Service’ is not a valid URI
Below is a rendering of the page up to the first error.[/b]

This is why I hate coding, think I have to put <> round the scene num ?

I have done this and now it says:

ERROR: Invalid Scene

However I used this URL to give me a list of all the scenes and devices and it shows their IDs in there:

http://192.168.0.11/port_3480/data_request?id=lu_sdata&output_format=xml

The scene I am trying to create a HTTP url for is ID 2

http://192.168.0.11:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=<2>

Is the ID number different from the scene number ?

If I edit the Lounge Off scene in Vera web UI it says its scene number 2, so why is it invalid scene ?

I have no idea why but these URLs have started working now if I paste them in to the browser, I didn’t need the <> btw.

Lounge On

http://192.168.0.11:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=1

Lounge Off

http://192.168.0.11:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=2

However in the browser it still says:

[b]This page contains the following errors:

error on line 2 at column 28: xmlns:u: ‘Unknown Service’ is not a valid URI
Below is a rendering of the page up to the first error.[/b]

If I then put these URLs in to a Lounge-On.cmd and a Lounge-Off.cmd file and double click them the scene is run OK and the lights go on and off. So guess I don’t need to worry about this ‘Unknown Service’ is not a valid URI error ?

Lounge-On.cmd

wget --delete-after "http://192.168.0.11:3480/data_request?id=lu_action&output_format=xml&DeviceNum=17&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1"

Lounge-Off.cmd

wget --delete-after "http://192.168.0.11:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=2"

If your wondering why I want to create these .cmd files, once I have them created, I will be able to run them on the Windows Media Center PC, initiating them from either my Logitech Harmony universal remote control with custom buttons on the LCD screen, or by using my Amulet Voice activated MCE remote control. So I can speak “Lounge-on” in to the Amulet remote and then it runs one of the .cmd files and the lights come on!

I’ve finished creating all my .cmd files on the Windows 7 HTPC for initiating various scenes and controlling devices in VeraLite. They work well with my Logitech Harmony universal remote control. ;D

Hi @cw-kid

Thank you so much for sharing this (it’s well timed as) my friend’s built a php5 script that looks at all his unread emails for a particular piece of information (such as a sender/subject/keyword) and once found, it would run a scene particular - He was having trouble getting it to work/run on the command lie so I’lll let him know your findings, if he’s not fixed it already.