Binary switch and http call

Hi all,
I would like to create a virtual device that pressing the ON button calls the url:

http: //ip_address/on.py

and pressing the key OFF the url:

http: //ip_address/off.py

I created several virtual devices (temperature, humidity, motion) but I can not successfully create this device.

Greetings.

You should be able to do this with Lua code in a scene. If you are running UI5, you could have a single scene and use two triggers with Lua code in the Luup event. I don’t think this is possible in UI7 so you would need to use two separate scenes.

For the On event:

luup.inet.wget("http://ip_address/on.py",5)

For the Off event:

luup.inet.wget("http://ip_address/off.py",5)

My Vera Lite runs UI5 and I used this method (with a VirtualSwitch), but I wanted to know if it is possible to directly modify a virtual device to achieve the same result.

Thanks.

G.

[quote=“gimaru, post:3, topic:184643”]My Vera Lite runs UI5 and I used this method (with a VirtualSwitch), but I wanted to know if it is possible to directly modify a virtual device to achieve the same result.

Thanks.

G.[/quote]

To do this, you would need to provide an Implementation file for the virtual device. In this file, you would add code to the SetTarget action to send the http requests. When you have uploaded the file to Vera, you specify it on the device’s Advanced tab in the variable impl_file.

I have attached a basic Implementation file for a virtual binary switch to get you started. See Luup Plugins by Hand for more information.

Thanks.

I will study :smiley:

G.