Lightning and Domoticz

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!
freijn
Posts: 31
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend
Contact:

Re: Lightning and Domoticz

Postby freijn » Wednesday 19 April 2017 13:08

If you start the script from putty , end it with an & enperant which makes it keep running in the background while exiting Putty.

python script.py &

User avatar
Siewert308SW
Posts: 463
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Lightning and Domoticz

Postby Siewert308SW » Thursday 20 April 2017 22:40

Maybe a dumb question or im in need of glasses. ;-)
The script works well and counter updates as it should be.
But my question is as i want the lighting strikes per hour, how do you guys retrieve the strikes per hour in python or bash so that the output can be used else where.
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

phoenixblue
Posts: 46
Joined: Friday 25 November 2016 12:20
Target OS: Raspberry Pi
Domoticz version: 3.6198
Contact:

Re: Lightning and Domoticz

Postby phoenixblue » Thursday 20 April 2017 23:25

Just for my clearance, do you mean the info per hour inside Domoticz or do you mean the import file?

The import file itself is updated every 2 minutes server based from an central database.

freijn
Posts: 31
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend
Contact:

Re: Lightning and Domoticz

Postby freijn » Friday 21 April 2017 14:34

@Siewert
I see you have domoticz as well. Counting in a couter and then click on 'log' gives you a diagram per hr.

as per Phoenixblue please give us some details about your requirements

User avatar
Siewert308SW
Posts: 463
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Lightning and Domoticz

Postby Siewert308SW » Friday 21 April 2017 17:14

freijn wrote:@Siewert
I see you have domoticz as well. Counting in a couter and then click on 'log' gives you a diagram per hr.

as per Phoenixblue please give us some details about your requirements


Phoenixblue knows what i mean as he pm me to clear the sky in our own language ;-)
I know the counter shown you a per hour diagram, but the main question is how to retrieve that so i get a usable output to use somewhere else.
I know you can get daily and monthly by a json but hourly isn't possible, or am i missing something.
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

tontze
Posts: 142
Joined: Thursday 12 January 2017 16:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Lightning and Domoticz

Postby tontze » Sunday 23 April 2017 8:05

Hi !

I have script to make lightning.py to run as service.

You should copy this startup script to /etc/init.d folder named as "lightning"

copy lightning checker script lightning.py to /usr/local/bin

Code: Select all

#! /bin/sh
#
# /etc/init.d/lightning
#
### BEGIN INIT INFO
# Provides:          lightning
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: This daemon manages lightning detection : lightning
### END INIT INFO

# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=pi

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DAEMON=/usr/local/bin/lightning.py

# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/lightning/lightning.pid

NAME=lightning

test -x $DAEMON_OPTS || exit 0

. /lib/lsb/init-functions


do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started

        if pidofproc -p $PIDFILE "$DAEMON" > /dev/null 2>&1 ; then
                return 1
        fi
}

case "$1" in
  start)
     log_daemon_msg "Starting $NAME"
     do_start
     RET_STATUS=$?
     case "$RET_STATUS" in
        1)
           log_success_msg
           [ "$VERBOSE" != no ] && [ $RET_STATUS = 1 ] && log_warning_msg "Daemon was already running"
        ;;
        *)
           start-stop-daemon --start  --background --oknodo --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --exec $DAEMON  $DAEMON_OPTS
           log_end_msg $?
        ;;
     esac
     ;;
  stop)
     log_daemon_msg "Stopping $NAME"
     start-stop-daemon --stop --pidfile $PIDFILE --retry 10
     log_end_msg $?
   ;;
  force-reload|restart)
     $0 stop
     $0 start
   ;;
  status)
     status_of_proc -p $PIDFILE $DAEMON $NAME  && exit 0 || exit $?
   ;;
 *)
   echo "Usage: /etc/init.d/lightning {start|stop|restart|force-reload|status}"
   exit 1
  ;;
esac
exit 0


Do :

Code: Select all

sudo chmod 755 /usr/local/bin/lightning.py


Code: Select all

sudo chmod 755 /etc/init.d/lightning


And finally add it as service :

Code: Select all

sudo update-rc.d lightning defaults


Try it out :

Code: Select all

sudo /etc/init.d/lightning start

and

Code: Select all

sudo /etc/init.d/lightning stop
-----------------------------------------
Rpi 3 / Razberry 2
RFLink 433mhz
Mi Light

phoenixblue
Posts: 46
Joined: Friday 25 November 2016 12:20
Target OS: Raspberry Pi
Domoticz version: 3.6198
Contact:

Re: Lightning and Domoticz

Postby phoenixblue » Monday 24 April 2017 20:57

Thanks for this solution!


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests