<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.mios.com/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.mios.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Huogas</id>
		<title>MiOS - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.mios.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Huogas"/>
		<link rel="alternate" type="text/html" href="http://wiki.mios.com/index.php/Special:Contributions/Huogas"/>
		<updated>2026-04-18T23:33:47Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.19.8</generator>

	<entry>
		<id>http://wiki.mios.com/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.mios.com/index.php/Main_Page"/>
				<updated>2011-05-27T12:12:59Z</updated>
		
		<summary type="html">&lt;p&gt;Huogas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Welcome to the Mi Casa Verde wiki'''&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [[Special:AllPages]] for a list of all pages &amp;lt;br&amp;gt;&amp;lt;br&amp;gt; '''*Note:''' The Wiki documentation is for both '''Vera 1''' and '''Vera 2''' units with '''UI2''' and '''UI4''' interface &lt;br /&gt;
&lt;br /&gt;
[[Category:Glossary]] [[Category:User_Instructions]] [[Category:How_To]] [[Category:Troubleshooting]] [[Category:Plugins]] [[Category:Hardware]]&lt;/div&gt;</summary>
		<author><name>Huogas</name></author>	</entry>

	<entry>
		<id>http://wiki.mios.com/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.mios.com/index.php/Main_Page"/>
				<updated>2011-05-27T12:09:34Z</updated>
		
		<summary type="html">&lt;p&gt;Huogas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Glossary]]&lt;br /&gt;
[[Category:User Instructions]]&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:Troubleshooting]]&lt;br /&gt;
[[Category:Plugins]]&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Welcome to the Mi Casa Verde wiki'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some useful pages:&lt;br /&gt;
[[Special:Categories]]&lt;br /&gt;
&lt;br /&gt;
See [[Special:AllPages]] for a list of all pages&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Note:''' The Wiki documentation is for both '''Vera 1''' and '''Vera 2''' units  with '''UI2''' and '''UI4''' interface&lt;/div&gt;</summary>
		<author><name>Huogas</name></author>	</entry>

	<entry>
		<id>http://wiki.mios.com/index.php/Desktop_Shortcut</id>
		<title>Desktop Shortcut</title>
		<link rel="alternate" type="text/html" href="http://wiki.mios.com/index.php/Desktop_Shortcut"/>
				<updated>2011-05-26T17:09:08Z</updated>
		
		<summary type="html">&lt;p&gt;Huogas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;br&amp;gt; '''HOWTO setup a desktop shortcut to activate a scene or control a device.''' &lt;br /&gt;
&lt;br /&gt;
1. Get [http://users.ugent.be/~bpuype/wget/#download wget for Windows]. &lt;br /&gt;
&lt;br /&gt;
2. Create a shortcut to it on the Desktop. &lt;br /&gt;
&lt;br /&gt;
3. Right click on the shortcut and open the Shortcut tab. &lt;br /&gt;
&lt;br /&gt;
4. In the Target field append the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;asp&amp;quot;&amp;gt;-q -O NUL &amp;quot;http://&amp;lt;vera_IP&amp;gt;:3480/data_request?id=lu_action&lt;br /&gt;
&amp;amp;serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&amp;amp;action=RunScene&amp;amp;SceneNum=&amp;lt;scene_number&amp;gt;&amp;quot;&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Here's an example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;asp&amp;quot;&amp;gt;&amp;quot;D:\Programs\wget.exe&amp;quot; -q -O NUL &amp;quot;http://192.168.10.1:3480/data_request?id=lu_action &amp;amp;serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&amp;amp;action=RunScene&amp;amp;SceneNum=6&amp;quot;&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
To control a device: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;asp&amp;quot;&amp;gt;http://&amp;lt;vera_IP&amp;gt;:3480/data_request?id=lu_action&amp;amp;output_format=xml&amp;amp;DeviceNum=&amp;lt;device_number&amp;gt; &amp;amp;serviceId=urn:upnp-org:serviceId:SwitchPower1&amp;amp;action=SetTarget&amp;amp;newTargetValue=&amp;lt;1 to turn on, 0 to turn off&amp;gt;&amp;lt;/source&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
You can find the whole Luup requests list [[Luup Requests]]. &lt;br /&gt;
&lt;br /&gt;
To toggle the state with one statement : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;asp&amp;quot;&amp;gt;&amp;quot;http://&amp;lt;veraIP&amp;gt;:3480/data_request?id=lu_action&amp;amp;output_format=xml&amp;amp;DeviceNum=&amp;lt;devId&amp;gt;&amp;amp;serviceId=urn:micasaverde-com:serviceId:HaDevice1&amp;amp;action=ToggleState&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Linux or OSX you can use '''curl -0''' instead of wget.exe &lt;br /&gt;
&lt;br /&gt;
[[Category:User_Instructions]] [[Category:How_To]]&lt;/div&gt;</summary>
		<author><name>Huogas</name></author>	</entry>

	<entry>
		<id>http://wiki.mios.com/index.php/Desktop_Shortcut</id>
		<title>Desktop Shortcut</title>
		<link rel="alternate" type="text/html" href="http://wiki.mios.com/index.php/Desktop_Shortcut"/>
				<updated>2011-05-26T11:40:03Z</updated>
		
		<summary type="html">&lt;p&gt;Huogas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;br&amp;gt; '''HOWTO setup a desktop shortcut to activate a scene or control a device.''' &lt;br /&gt;
&lt;br /&gt;
1. Get [http://users.ugent.be/~bpuype/wget/#download wget for Windows]. &lt;br /&gt;
&lt;br /&gt;
2. Create a shortcut to it on the Desktop. &lt;br /&gt;
&lt;br /&gt;
3. Right click on the shortcut and open the Shortcut tab. &lt;br /&gt;
&lt;br /&gt;
4. In the Target field append the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;asp&amp;quot;&amp;gt;-q -O NUL &amp;quot;http://&amp;lt;vera_IP&amp;gt;:3480/data_request?id=lu_action&lt;br /&gt;
&amp;amp;serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&amp;amp;action=RunScene&amp;amp;SceneNum=&amp;lt;scene_number&amp;gt;&amp;quot;&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Here's an example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;asp&amp;quot;&amp;gt;&amp;quot;D:\Programs\wget.exe&amp;quot; -q -O NUL &amp;quot;http://192.168.10.1:3480/data_request?id=lu_action &amp;amp;serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&amp;amp;action=RunScene&amp;amp;SceneNum=6&amp;quot;&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
To control a device: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;asp&amp;quot;&amp;gt;http://&amp;lt;vera_IP&amp;gt;:3480/data_request?id=lu_action&amp;amp;output_format=xml&amp;amp;DeviceNum=&amp;lt;device_number&amp;gt; &amp;amp;serviceId=urn:upnp-org:serviceId:SwitchPower1&amp;amp;action=SetTarget&amp;amp;newTargetValue=&amp;lt;1 to turn on, 0 to turn off&amp;gt;&amp;lt;/source&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
You can find the whole Luup requests list [[Luup Requests]]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
In Linux or OSX you can use '''curl -0''' instead of wget.exe &lt;br /&gt;
&lt;br /&gt;
[[Category:User_Instructions]] [[Category:How_To]]&lt;/div&gt;</summary>
		<author><name>Huogas</name></author>	</entry>

	<entry>
		<id>http://wiki.mios.com/index.php/Desktop_Shortcut</id>
		<title>Desktop Shortcut</title>
		<link rel="alternate" type="text/html" href="http://wiki.mios.com/index.php/Desktop_Shortcut"/>
				<updated>2011-05-26T11:25:57Z</updated>
		
		<summary type="html">&lt;p&gt;Huogas: New page: Category:User Instructions Category:How To  '''HOWTO setup a desktop shortcut to activate a scene or control a device.'''  1. Get wget for Windows. 2. Create a shortcut to it on th...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:User Instructions]]&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
&lt;br /&gt;
'''HOWTO setup a desktop shortcut to activate a scene or control a device.'''&lt;br /&gt;
&lt;br /&gt;
1. Get wget for Windows.&lt;br /&gt;
2. Create a shortcut to it on the Desktop.&lt;br /&gt;
3. Right click on the shortcut and open the Shortcut tab.&lt;br /&gt;
4. In the Target field append the following:&lt;br /&gt;
Code:&lt;br /&gt;
-q -O NUL &amp;quot;http://&amp;lt;vera_IP&amp;gt;:3480/data_request?id=lu_action&lt;br /&gt;
&amp;amp;serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&amp;amp;action=RunScene&amp;amp;SceneNum=&amp;lt;scene_number&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here's an example:&lt;br /&gt;
Code:&lt;br /&gt;
&amp;quot;D:\Programs\wget.exe&amp;quot; -q -O NUL &amp;quot;http://192.168.10.1:3480/data_request?id=lu_action&lt;br /&gt;
&amp;amp;serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&amp;amp;action=RunScene&amp;amp;SceneNum=6&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To control a device:&lt;br /&gt;
Code:&lt;br /&gt;
http://&amp;lt;vera_IP&amp;gt;:3480/data_request?id=lu_action&amp;amp;output_format=xml&amp;amp;DeviceNum=&amp;lt;device_number&amp;gt;&lt;br /&gt;
&amp;amp;serviceId=urn:upnp-org:serviceId:SwitchPower1&amp;amp;action=SetTarget&amp;amp;newTargetValue=&amp;lt;1 to turn on, 0 to turn off&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find the whole Luup requests list [[Luup_Requests]].&lt;br /&gt;
&lt;br /&gt;
in Linux or OSX you can use curl -0 instead of wget.exe&lt;/div&gt;</summary>
		<author><name>Huogas</name></author>	</entry>

	<entry>
		<id>http://wiki.mios.com/index.php/Scripts_for_scenes</id>
		<title>Scripts for scenes</title>
		<link rel="alternate" type="text/html" href="http://wiki.mios.com/index.php/Scripts_for_scenes"/>
				<updated>2011-05-25T16:45:02Z</updated>
		
		<summary type="html">&lt;p&gt;Huogas: /* Scene that turns on the light when a door sensor is tripped, if the light level is below a user set threshold */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Scene that runs only if a security sensor hasn't been tripped in a set period of time  ==&lt;br /&gt;
&lt;br /&gt;
1. Create a new scene. In that scene:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Create a timer and set it to run every minute.&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
3. In the Luup Code section put the following code: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;local deviceNo = 22&lt;br /&gt;
local period = 15&lt;br /&gt;
&lt;br /&gt;
local SS_SID = &amp;quot;urn:micasaverde-com:serviceId:SecuritySensor1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local armed = luup.variable_get(SS_SID, &amp;quot;Armed&amp;quot;, deviceNo)&lt;br /&gt;
if armed == &amp;quot;1&amp;quot; then&lt;br /&gt;
   local lastTrip = luup.variable_get(SS_SID, &amp;quot;LastTrip&amp;quot;, deviceNo) or os.time()&lt;br /&gt;
   lastTrip = tonumber(lastTrip)&lt;br /&gt;
   if (os.difftime(os.time(), lastTrip) / 60) &amp;gt;= period then&lt;br /&gt;
       return true&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return false&amp;lt;/source&amp;gt;&amp;lt;br&amp;gt; ''deviceNo'' is the sensor's device number, which you can get by going into its Toolbox, in the Advanced tab.&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
''period'' is the time (in minutes) the sensor hasn't been tripped before running the scene.&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
'''Note:''' The sensor must be armed for this to work, but this can be easily changed.&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Scene that runs only if a security sensor has been tripped for a set period of time  ==&lt;br /&gt;
&lt;br /&gt;
1. Create a new scene. In that scene: &lt;br /&gt;
&lt;br /&gt;
2. Create a timer and set it to run every minute. &lt;br /&gt;
&lt;br /&gt;
3. In the Luup Code section put the following code: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;local deviceNo = 22&lt;br /&gt;
local period = 15&lt;br /&gt;
&lt;br /&gt;
local SS_SID = &amp;quot;urn:micasaverde-com:serviceId:SecuritySensor1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local armed = luup.variable_get(SS_SID, &amp;quot;Armed&amp;quot;, deviceNo) or &amp;quot;0&amp;quot;&lt;br /&gt;
if armed == &amp;quot;1&amp;quot; then&lt;br /&gt;
    local tripped = luup.variable_get(SS_SID, &amp;quot;Tripped&amp;quot;, deviceNo) or &amp;quot;0&amp;quot;&lt;br /&gt;
    if tripped == &amp;quot;0&amp;quot; then&lt;br /&gt;
        luup.variable_set(SS_SID, &amp;quot;TripPeriod&amp;quot;, &amp;quot;0&amp;quot;, deviceNo)&lt;br /&gt;
    else&lt;br /&gt;
        local tripPeriod = luup.variable_get(SS_SID, &amp;quot;TripPeriod&amp;quot;, deviceNo) or 0&lt;br /&gt;
        tripPeriod = tonumber(tripPeriod)&lt;br /&gt;
        tripPeriod = tripPeriod + 1&lt;br /&gt;
        luup.variable_set(SS_SID, &amp;quot;TripPeriod&amp;quot;, tripPeriod, deviceNo)&lt;br /&gt;
        if tripPeriod == period then&lt;br /&gt;
            return true&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return false&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
''deviceNo'' is the sensor's device number, which you can get by going into its Toolbox, in the Advanced tab. &lt;br /&gt;
&lt;br /&gt;
''period'' is the time (in minutes) the sensor has been tripped before running the scene. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' The sensor must be armed for this to work, but this can be easily changed &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Scene that runs once at dawn and once at dusk  ==&lt;br /&gt;
&lt;br /&gt;
1. Create a new scene. In that scene:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Create a timer and set it to run every hour (set a different time interval depending on the desired accuracy). &lt;br /&gt;
&lt;br /&gt;
3. In the Luup Code section put the following code: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;local LOW_LEVEL  = 20 -- the light level threshold for night&lt;br /&gt;
local HIGH_LEVEL = 40 -- the light level threshold for day&lt;br /&gt;
local DEVICE_NO  = 13 -- the light sensor device number&lt;br /&gt;
local LS_SID     = &amp;quot;urn:micasaverde-com:serviceId:LightSensor1&amp;quot; -- the LightSensor service ID&lt;br /&gt;
&lt;br /&gt;
local currentLevel = luup.variable_get (LS_SID, &amp;quot;CurrentLevel&amp;quot;, DEVICE_NO) or 0&lt;br /&gt;
currentLevel = tonumber(currentLevel)&lt;br /&gt;
&lt;br /&gt;
if currentLevel &amp;lt;= LOW_LEVEL then&lt;br /&gt;
    local timeOfDay = luup.variable_get (LS_SID, &amp;quot;TimeOfDay&amp;quot;, DEVICE_NO) or &amp;quot;Day&amp;quot;&lt;br /&gt;
    if timeOfDay == &amp;quot;Night&amp;quot; then&lt;br /&gt;
        -- It's night, so the scene has run once.&lt;br /&gt;
        return false&lt;br /&gt;
    else&lt;br /&gt;
        -- It's sunset, run the scene.&lt;br /&gt;
        luup.variable_set (LS_SID, &amp;quot;TimeOfDay&amp;quot;, &amp;quot;Night&amp;quot;, DEVICE_NO)&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
elseif currentLevel &amp;gt;= HIGH_LEVEL then&lt;br /&gt;
    local timeOfDay = luup.variable_get (LS_SID, &amp;quot;TimeOfDay&amp;quot;, DEVICE_NO) or &amp;quot;Night&amp;quot;&lt;br /&gt;
    if timeOfDay == &amp;quot;Day&amp;quot; then&lt;br /&gt;
        -- It's day, so the scene has run once.&lt;br /&gt;
        return false&lt;br /&gt;
    else&lt;br /&gt;
        -- It's morning, run the scene.&lt;br /&gt;
        luup.variable_set (LS_SID, &amp;quot;TimeOfDay&amp;quot;, &amp;quot;Day&amp;quot;, DEVICE_NO)&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Scene that runs only in a user set time interval  ==&lt;br /&gt;
&lt;br /&gt;
Add this code in the Luup Code section: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;local startTime = &amp;quot;22:30&amp;quot;&lt;br /&gt;
local endTime   = &amp;quot;05:30&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local hour = tonumber( startTime:sub( startTime:find(&amp;quot;%d+&amp;quot;) ) )&lt;br /&gt;
local minute = tonumber(startTime:sub(-2))&lt;br /&gt;
&lt;br /&gt;
if hour and minute then&lt;br /&gt;
    startTime = hour * 100 + minute&lt;br /&gt;
else&lt;br /&gt;
    luup.log(&amp;quot;ERROR: invalid start time&amp;quot;)&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
hour = tonumber( endTime:sub( endTime:find(&amp;quot;%d+&amp;quot;) ) )&lt;br /&gt;
minute = tonumber(endTime:sub(-2))&lt;br /&gt;
&lt;br /&gt;
if hour and minute then&lt;br /&gt;
    endTime = hour * 100 + minute&lt;br /&gt;
else&lt;br /&gt;
    luup.log(&amp;quot;ERROR: invalid end time&amp;quot;)&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local currentTime = os.date(&amp;quot;*t&amp;quot;)&lt;br /&gt;
currentTime = currentTime.hour * 100 + currentTime.min&lt;br /&gt;
&lt;br /&gt;
luup.log(&amp;quot;startTime = &amp;quot; .. startTime .. &amp;quot;; currentTime = &amp;quot; .. currentTime .. &amp;quot;; endTime = &amp;quot; .. endTime)&lt;br /&gt;
&lt;br /&gt;
if startTime &amp;lt;= endTime then&lt;br /&gt;
    -- Both the start time and the end time are in the same day:&lt;br /&gt;
    -- if the current time is in the given interval, run the scene.&lt;br /&gt;
    if startTime &amp;lt;= currentTime and currentTime &amp;lt;= endTime then&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
else&lt;br /&gt;
    -- The start time is before midnight, and the end time is after midnight:&lt;br /&gt;
    -- if the current time is not outside the given interval, run the scene.&lt;br /&gt;
    if not (endTime &amp;lt; currentTime and currentTime &amp;lt; startTime) then&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return false&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This code allows the scene to run only between 22:30 and 5:30. &lt;br /&gt;
&lt;br /&gt;
== Scene that turns on the light when it detects movement and turns off the light when it doesn't detect movement for a while  ==&lt;br /&gt;
&lt;br /&gt;
1. Create a scene to turn on the light when a sensor is tripped. &lt;br /&gt;
&lt;br /&gt;
2. Add this code in the ''Luup code'' section: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;local sensorDeviceNo = 16 -- Motion Sensor device number&lt;br /&gt;
local lightDeviceNo = 13 -- Light device number&lt;br /&gt;
local period = 10 -- Seconds&lt;br /&gt;
&lt;br /&gt;
local SS_SID = &amp;quot;urn:micasaverde-com:serviceId:SecuritySensor1&amp;quot; -- Security Sensor Service ID&lt;br /&gt;
local SP_SID = &amp;quot;urn:upnp-org:serviceId:SwitchPower1&amp;quot; -- Switch Power Service ID&lt;br /&gt;
&lt;br /&gt;
function checkLastTrip()&lt;br /&gt;
    local lastTrip = luup.variable_get (SS_SID, &amp;quot;LastTrip&amp;quot;, sensorDeviceNo) or os.time()&lt;br /&gt;
    if (os.difftime (os.time(), tonumber (lastTrip)) &amp;gt;= period) then&lt;br /&gt;
        luup.call_action (SP_SID, &amp;quot;SetTarget&amp;quot;, {[&amp;quot;newTargetValue&amp;quot;] = 0}, lightDeviceNo) -- Turn off the light.&lt;br /&gt;
    else&lt;br /&gt;
        luup.call_delay (&amp;quot;checkLastTrip&amp;quot;, period) -- Check when the sensor was last tripped every &amp;lt;period&amp;gt; seconds.&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
luup.call_delay (&amp;quot;checkLastTrip&amp;quot;, period)&lt;br /&gt;
&lt;br /&gt;
return true&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Scene that '''do something''' (ex: turn on a lamp) if the light level is below a user set threshold ==&lt;br /&gt;
&lt;br /&gt;
1. Create a scene to turn on the light when the sensor is tripped. &lt;br /&gt;
&lt;br /&gt;
2. Add this code in the ''Luup code'' section: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;local LOW_LEVEL  = 20 -- the light level threshold for night&lt;br /&gt;
local DEVICE_NO  = 33 -- the light sensor device number&lt;br /&gt;
local LS_SID     = &amp;quot;urn:micasaverde-com:serviceId:LightSensor1&amp;quot; -- the LightSensor service ID&lt;br /&gt;
&lt;br /&gt;
local currentLevel = luup.variable_get (LS_SID, &amp;quot;CurrentLevel&amp;quot;, DEVICE_NO) or 0&lt;br /&gt;
currentLevel = tonumber(currentLevel)&lt;br /&gt;
&lt;br /&gt;
if currentLevel &amp;lt;= LOW_LEVEL then&lt;br /&gt;
    return true&lt;br /&gt;
else&lt;br /&gt;
    return false&lt;br /&gt;
end&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
[[Category:User_Instructions]] [[Category:How_To]]&lt;/div&gt;</summary>
		<author><name>Huogas</name></author>	</entry>

	</feed>