<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.geekworm.com/index.php?action=history&amp;feed=atom&amp;title=CommentStreams%3A2b543ed81c6d2188ca20c72f9045582c</id>
	<title>CommentStreams:2b543ed81c6d2188ca20c72f9045582c - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.geekworm.com/index.php?action=history&amp;feed=atom&amp;title=CommentStreams%3A2b543ed81c6d2188ca20c72f9045582c"/>
	<link rel="alternate" type="text/html" href="https://wiki.geekworm.com/index.php?title=CommentStreams:2b543ed81c6d2188ca20c72f9045582c&amp;action=history"/>
	<updated>2026-07-26T09:48:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.geekworm.com/index.php?title=CommentStreams:2b543ed81c6d2188ca20c72f9045582c&amp;diff=34442&amp;oldid=prev</id>
		<title>87.122.222.160: Migrated comment #5095</title>
		<link rel="alternate" type="text/html" href="https://wiki.geekworm.com/index.php?title=CommentStreams:2b543ed81c6d2188ca20c72f9045582c&amp;diff=34442&amp;oldid=prev"/>
		<updated>2024-09-04T04:49:58Z</updated>

		<summary type="html">&lt;p&gt;Migrated comment #5095&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Hello all,&lt;br /&gt;
&lt;br /&gt;
I edited a script for shutting down on powerloss after x seconds.&lt;br /&gt;
For automatic shutdown, I call it with crontab.&lt;br /&gt;
The mod of the file has to be changed to 755 before. (chmod)&lt;br /&gt;
&lt;br /&gt;
I hope this helps.&lt;br /&gt;
&lt;br /&gt;
Greetings&lt;br /&gt;
&lt;br /&gt;
Below the Script:&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
#This python script is only suitable for UPS Shield X1200, X1201 and X1202&lt;br /&gt;
&lt;br /&gt;
import gpiod&lt;br /&gt;
import time&lt;br /&gt;
from subprocess import call&lt;br /&gt;
&lt;br /&gt;
PLD_PIN = 6&lt;br /&gt;
chip = gpiod.Chip(&amp;#039;gpiochip4&amp;#039;)&lt;br /&gt;
pld_line = chip.get_line(PLD_PIN)&lt;br /&gt;
pld_line.request(consumer=&amp;quot;PLD&amp;quot;, type=gpiod.LINE_REQ_DIR_IN)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
        while True:&lt;br /&gt;
                pld_state = pld_line.get_value()&lt;br /&gt;
&lt;br /&gt;
                if pld_state == 0:&lt;br /&gt;
                        print (&amp;quot;Powerloss detected&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
                        time.sleep(10) # Change this to preferred value&lt;br /&gt;
&lt;br /&gt;
                        pld_state = pld_line.get_value()&lt;br /&gt;
&lt;br /&gt;
                        if pld_state == 1:&lt;br /&gt;
                                print (&amp;quot;Power ready&amp;quot;)&lt;br /&gt;
                                pass&lt;br /&gt;
                        else:&lt;br /&gt;
                                print (&amp;quot;Shutting down&amp;quot;)&lt;br /&gt;
                                time.sleep(1)&lt;br /&gt;
                                call(&amp;quot;sudo nohup shutdown -h now&amp;quot;, shell=True)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
        pld_line.release()&amp;lt;!-- migrated from Comments; original IP: 87.122.222.160 --&amp;gt;&lt;/div&gt;</summary>
		<author><name>87.122.222.160</name></author>
	</entry>
</feed>