<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Sunrise / Sunset switch Raspberry Pi with Python	</title>
	<atom:link href="https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/feed/" rel="self" type="application/rss+xml" />
	<link>https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/</link>
	<description>Life is too short to remove USB safely …</description>
	<lastBuildDate>Thu, 20 Jan 2022 16:17:10 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.2</generator>
	<item>
		<title>
		By: guyfawkes		</title>
		<link>https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-684</link>

		<dc:creator><![CDATA[guyfawkes]]></dc:creator>
		<pubDate>Thu, 10 Jun 2021 15:27:08 +0000</pubDate>
		<guid isPermaLink="false">https://vpn-expert.info/?p=296#comment-684</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-683&quot;&gt;Paresh Chauhan&lt;/a&gt;.

You can add hours to the times given - for example:

d.time() + timedelta(hours=9)

would add additional 9 hours]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-683">Paresh Chauhan</a>.</p>
<p>You can add hours to the times given &#8211; for example:</p>
<p>d.time() + timedelta(hours=9)</p>
<p>would add additional 9 hours</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Paresh Chauhan		</title>
		<link>https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-683</link>

		<dc:creator><![CDATA[Paresh Chauhan]]></dc:creator>
		<pubDate>Thu, 10 Jun 2021 15:06:51 +0000</pubDate>
		<guid isPermaLink="false">https://vpn-expert.info/?p=296#comment-683</guid>

					<description><![CDATA[Hello,
Nic information about the above function you gave. i have a task and need some suggestion from from your side related to the task.
For my task in need that my circuit should be &#039;ON&#039; after certain time from the sunrise (lets say at 12:00 pm in the afternoon and should turn &#039;OFF&#039; at the sunset depending upon the latitude and longitude. How should i proceed with coding? Any suggestion would be helful. since i am new to programming and i need some guidance.]]></description>
			<content:encoded><![CDATA[<p>Hello,<br />
Nic information about the above function you gave. i have a task and need some suggestion from from your side related to the task.<br />
For my task in need that my circuit should be &#8216;ON&#8217; after certain time from the sunrise (lets say at 12:00 pm in the afternoon and should turn &#8216;OFF&#8217; at the sunset depending upon the latitude and longitude. How should i proceed with coding? Any suggestion would be helful. since i am new to programming and i need some guidance.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: guyfawkes		</title>
		<link>https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-682</link>

		<dc:creator><![CDATA[guyfawkes]]></dc:creator>
		<pubDate>Mon, 30 Mar 2020 19:36:54 +0000</pubDate>
		<guid isPermaLink="false">https://vpn-expert.info/?p=296#comment-682</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-681&quot;&gt;Steve Higham&lt;/a&gt;.

Cool ...

You can define it like &lt;em&gt;sunset_time&lt;/em&gt; but with set numbers. In my example with &lt;em&gt;elevenoff&lt;/em&gt; it could be:

&lt;code&gt;elevenoff = time(int(23), int(00))&lt;/code&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-681">Steve Higham</a>.</p>
<p>Cool &#8230;</p>
<p>You can define it like <em>sunset_time</em> but with set numbers. In my example with <em>elevenoff</em> it could be:</p>
<p><code>elevenoff = time(int(23), int(00))</code></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Steve Higham		</title>
		<link>https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-681</link>

		<dc:creator><![CDATA[Steve Higham]]></dc:creator>
		<pubDate>Mon, 30 Mar 2020 18:46:28 +0000</pubDate>
		<guid isPermaLink="false">https://vpn-expert.info/?p=296#comment-681</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-679&quot;&gt;Steve Higham&lt;/a&gt;.

Hi,

Thanks for your reply, I&#039;ll give your suggestions a try &#038; let you know how it goes.
One thing I am not clear on is how to get the time ( ie 23:00) into the correct format to compare with sunset_time  and time_now

Thanks]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-679">Steve Higham</a>.</p>
<p>Hi,</p>
<p>Thanks for your reply, I&#8217;ll give your suggestions a try &amp; let you know how it goes.<br />
One thing I am not clear on is how to get the time ( ie 23:00) into the correct format to compare with sunset_time  and time_now</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: guyfawkes		</title>
		<link>https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-680</link>

		<dc:creator><![CDATA[guyfawkes]]></dc:creator>
		<pubDate>Mon, 30 Mar 2020 16:18:42 +0000</pubDate>
		<guid isPermaLink="false">https://vpn-expert.info/?p=296#comment-680</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-679&quot;&gt;Steve Higham&lt;/a&gt;.

Hi,

in your use case wouldn&#039;t it be easier just to use an off the shelf time switch? Normally they have a random on/off integrated.

But to answer your question: in this use case I would switch the if-else-statement and check for &lt;em&gt;sunset_time&lt;/em&gt; and a new parameter called e.g. &lt;em&gt;elevenoff&lt;/em&gt; that is set to 23:00hrs. If the time is in between — switch on.

To add the random part you first need to import &lt;em&gt;random&lt;/em&gt;:

&lt;code&gt;import random&lt;/code&gt;

In the ON part you generate for example a random number in between 1 and 10

&lt;code&gt;random_number = random.randint(1, 10)&lt;/code&gt;

Now you switch as you like — for example if the number is smaller than 4 switch on — else switch off.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-679">Steve Higham</a>.</p>
<p>Hi,</p>
<p>in your use case wouldn&#8217;t it be easier just to use an off the shelf time switch? Normally they have a random on/off integrated.</p>
<p>But to answer your question: in this use case I would switch the if-else-statement and check for <em>sunset_time</em> and a new parameter called e.g. <em>elevenoff</em> that is set to 23:00hrs. If the time is in between — switch on.</p>
<p>To add the random part you first need to import <em>random</em>:</p>
<p><code>import random</code></p>
<p>In the ON part you generate for example a random number in between 1 and 10</p>
<p><code>random_number = random.randint(1, 10)</code></p>
<p>Now you switch as you like — for example if the number is smaller than 4 switch on — else switch off.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Steve Higham		</title>
		<link>https://vpn-expert.info/sunrise-sunset-switch-raspberry-pi-with-python/comment-page-1/#comment-679</link>

		<dc:creator><![CDATA[Steve Higham]]></dc:creator>
		<pubDate>Mon, 30 Mar 2020 15:37:37 +0000</pubDate>
		<guid isPermaLink="false">https://vpn-expert.info/?p=296#comment-679</guid>

					<description><![CDATA[Hi,
Thanks for this article, it is what I have been looking for, though I could do with advice on how to make a couple of modifications.
I have a Raspberry Pi (3) controlling my lounge &#038; hall lights while I am away from home. 
Your program would allow the switching ON of the lights at sunset time, but I do not want the lights to be on all night. 
Can you advise on how to modify the program to allow &#039;hard coding&#039; of an OFF time for the lights eg. 23:00hrs, rather than at sunrise.
If possible I would also like to switch the lights ON &#038; OFF randomly during the ON period - to simulate people being in the house.
I am not skilled at writing Python code, so would appreciate any help you can offer. Many thanks]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
Thanks for this article, it is what I have been looking for, though I could do with advice on how to make a couple of modifications.<br />
I have a Raspberry Pi (3) controlling my lounge &amp; hall lights while I am away from home.<br />
Your program would allow the switching ON of the lights at sunset time, but I do not want the lights to be on all night.<br />
Can you advise on how to modify the program to allow &#8216;hard coding&#8217; of an OFF time for the lights eg. 23:00hrs, rather than at sunrise.<br />
If possible I would also like to switch the lights ON &amp; OFF randomly during the ON period &#8211; to simulate people being in the house.<br />
I am not skilled at writing Python code, so would appreciate any help you can offer. Many thanks</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
