The Vera Community forums have moved!

Advanced => Programming => Scene Scripting => Topic started by: guest13242 on August 10, 2011, 10:16:13 am

Title: location and editing scenes in ssh
Post by: guest13242 on August 10, 2011, 10:16:13 am
Hi everybody, I'm sorry for silly question. but I can't find anywhere in the forum that  I can edit scenes when I'm SSH to micasaverde. I would like to look to coding scenes and editing it. Which file should I look? I don't want to do it from GUI. for an example I want to change delay 1 second to turn off the light switch, but the scenes GUI only allowed 5 second delay.

Thank you for all advices you can give.
Title: Re: location and editing scenes in ssh
Post by: Ap15e on August 11, 2011, 07:46:54 am
http://wiki.micasaverde.com/index.php/Scene_Syntax
Title: Re: location and editing scenes in ssh
Post by: guest13242 on August 11, 2011, 10:00:42 am
can you please help me to write a simple code luup. Device #21 turn on for 1 second and turn off. Thank you so much
Title: Re: location and editing scenes in ssh
Post by: mcvflorin on August 11, 2011, 11:06:23 am
Add this Lua code to the scene:
Code: [Select]
local DEVICE = 21
local SECONDS = 1

function turnOffDevice()
    luup.call_action ("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, DEVICE)
end

luup.call_action ("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, DEVICE)
luup.call_delay ("turnOffDevice", SECONDS, "")

This turns on your DEVICE and after SECONDS seconds turns it off.