<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=Lua_-_Light_off_at_Sunset</id>
	<title>Lua - Light off at Sunset - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=Lua_-_Light_off_at_Sunset"/>
	<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=Lua_-_Light_off_at_Sunset&amp;action=history"/>
	<updated>2026-09-18T22:41:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=Lua_-_Light_off_at_Sunset&amp;diff=14739&amp;oldid=prev</id>
		<title>Walter vl: Title</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=Lua_-_Light_off_at_Sunset&amp;diff=14739&amp;oldid=prev"/>
		<updated>2020-12-29T16:25:20Z</updated>

		<summary type="html">&lt;p&gt;Title&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:dzVents - Light off at Sunset}}&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
The purpose of this script is to turn off a light at sunset on each weekday. &lt;br /&gt;
&lt;br /&gt;
This script could be used to automatically turn off lights at sunset to begin preparing for bed. &lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
This script’s only dependency is a light that is compatible with Domoticz. &lt;br /&gt;
&lt;br /&gt;
This script was written and tested using a Yeelight and functioned properly. &lt;br /&gt;
&lt;br /&gt;
==Domoticz Setup==&lt;br /&gt;
This script will require that you have a switch that connects to the light you are trying to use. You will need the name of your switch to substitute for ‘home yeelight’ in the script below. &lt;br /&gt;
&lt;br /&gt;
==Installation Instructions==&lt;br /&gt;
Copy this script in your &amp;#039;&amp;#039;&amp;#039;domoticz\scripts\dzVents\scripts&amp;#039;&amp;#039;&amp;#039; folder.&lt;br /&gt;
&lt;br /&gt;
YeeLight Installation instructions: [[YeeLight|Click Here]]&lt;br /&gt;
&lt;br /&gt;
==Script with Comments==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Lua&amp;quot;&amp;gt;&lt;br /&gt;
return &lt;br /&gt;
{&lt;br /&gt;
    on = &lt;br /&gt;
    {&lt;br /&gt;
   --Runs script at sunset each weekday&lt;br /&gt;
        timer = {&amp;#039;at sunset on mon, tue, wed, thu, fri&amp;#039;},&lt;br /&gt;
    },&lt;br /&gt;
    &lt;br /&gt;
    execute = function(domoticz, timer)&lt;br /&gt;
        light = domoticz.devices(&amp;#039;home yeelight&amp;#039;)&lt;br /&gt;
   &lt;br /&gt;
        --check to see if the light is still on&lt;br /&gt;
        if (light.state == &amp;#039;On&amp;#039;) then&lt;br /&gt;
            --If the light is still on at sunset, turn off the light and log &lt;br /&gt;
            --appropriate message&lt;br /&gt;
            light.switchOff()&lt;br /&gt;
            domoticz.log(&amp;#039;The light was detected on at sunset on a weekday. The light is now off.&amp;#039;)&lt;br /&gt;
        else &lt;br /&gt;
           --Will log this message if light was already off&lt;br /&gt;
           domoticz.log(&amp;#039;Light was already off&amp;#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The script above can be customized very easily. &lt;br /&gt;
&lt;br /&gt;
To run the script at a different time besides sunset, change the timer variable to match when you want the script to run. &lt;br /&gt;
&lt;br /&gt;
==Enjoy!==&lt;br /&gt;
I hope this script can be of some use to you and your team if applicable whether it be further development, bug fixes, and improvements!&lt;br /&gt;
[[Category:DzVents]]&lt;br /&gt;
{{DEFAULTSORT:dzVents - Light off at Sunset}}&lt;/div&gt;</summary>
		<author><name>Walter vl</name></author>
	</entry>
</feed>