picofssd doesn't obey time.sleep

Support for the UPS PIco HV3.0A

picofssd doesn't obey time.sleep

Postby Siewert30SW » Mon Feb 27, 2017 9:30 pm

Didn't had a clue where to ask or put my question in the forum.
But today i was trying to amend the /usr/bin/picofssd.

Reason:
I run my Home Automation from my Pi3 with Domoticz as Domotica System.
Domoticz needs a gracefull shutdown before the system is going down due to a empty battery.
If it's closed the hard way then the sqlite database gets corrupt.
I also need some time to do some task before shuttingdown.
So that when the power outage is over and Pi restarted the system can startup my house again in the previous state like lights On and such.

So i wanted to catch the shutdown command and before it really shutsdown letting Domoticz know it is going down.
I just need a minute to do some tasks, in the picofssd i wrote some extra lines to switch a virtual switch in domoticz which shutsdown my house.
But what ever i try, the /usr/bin/picofssd doens't like the time.sleep.
So when the fssd kicks in all commands are i put in are executed with 5 seconds and not 60 seconds as i want it to.
Why doesn't /urs/bin/picofssd like timesleep.

My snippet from /urs/bin/picofssd:
Code: Select all
          def isr(self, channel):
                """
                GPIO interrupt service routine
                """

                # This test is here because the user *might* have another HAT plugged in or another circuit that produces a
                # falling-edge signal on another GPIO pin.
                if channel != CLOCK_PIN:
                        return

                # we can get the state of a pin with GPIO.input even when it is currently configured as an output
                self.sqwave = not GPIO.input(PULSE_PIN)

                # set pulse pin low before changing it to input to look for shutdown signal
                GPIO.output(PULSE_PIN, False)
                GPIO.setup(PULSE_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
                if not GPIO.input(PULSE_PIN):
           # pin is low, this is shutdown signal from pico
         self.counter += 1
         self.log.warning("Raspberry lost power supply, Pi will shutdown")
                        self.log.warning("Domoticz will be stopped before shutting down")
         os.system('curl "127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=141&switchcmd=Off"')
         self.alert_email()
         time.sleep(50)
         os.system('sudo service domoticz.sh stop')
         time.sleep(10)
         os.system('/sbin/shutdown -h now')
                else:
                        self.counter = 0

Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz / RFXtrx433E
1x RPi3 - PiHole / logging gas,elec
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/CoCo stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub
pico_status: @ GitHub
User avatar
Siewert30SW
 
Posts: 190
Joined: Fri Jan 06, 2017 8:06 pm
Location: The Netherlands

Return to UPS PIco HV3.0A

Who is online

Users browsing this forum: Bing [Bot] and 1 guest