thank you all, I got it working in a couple of ways; i. use in-built alarm.py ii. install extension crt: Cumulus Real-Time to get real-time data, parse it with a bash script (sending an email or speak some alert!). I am sharing here my work (could be useful for some noob like me!).
I couldn't continue using the alarm.py due to its limitation like i. I can't set more than one alarm ii. Custom the subject of the email with body message! i. use in-built alarm.py -------------------------------------------- > $ sudo cp /usr/share/doc/weewx/examples/alarm.py /usr/share/weewx/user/ > $ sudo nano /etc/weewx/weewx.conf > add the following in the bottom --------------- > [Alarm] > expression = "outTemp < 40.0" > time_wait = 3600 > smtp_host = smtp.gmail.com > smtp_user = [email protected] > smtp_password = mypass; > mailto = [email protected] > from = [email protected] > subject = "Alarm message from WeeWX" > --------------- add "user.alarm.MyAlarm" in the same file as below --------------- > [Engine] > [[Services]] > report_services = weewx.engine.StdPrint, weewx.engine.StdReport, > user.alarm.MyAlarm > --------------- > $ sudo /etc/init.d/weewx restart > -------------------------------------------- ii. install extension crt: Cumulus Real-Time to get real-time data and parse it with a bash script. Download: http://lancet.mit.edu/mwall/projects/weather/releases/weewx-crt-0.18.tgz $ wee_extension --install weewx-crt-x.y.tgz > Modify weewx.conf > $ sudo nano /etc/weewx/weewx.conf > [CumulusRealTime] > filename = /var/www/html/weather/realtime.txt > unit_system = METRIC # options are US, METRIC, METRICWX > place the file under /var/www/html/weather/realtime.txt but not in the recommended place /var/tmp/realtime.txt $ sudo /etc/init.d/weewx restart > $ cat /var/www/html/PWS/realtime.txt My bash script #!/bin/bash > > >> var=$(cat /var/www/html/PWS/realtime.txt) > > vars=( $var ) > > MPHR=60 # Minutes per hour. > > current_time=$(date +%s) > > #echo "Temperature: '${vars[2]}'" > > #echo "Heat index: '${vars[41]}'" > > #echo "Wind speed: '${vars[5]}'" > > #echo "Rain rate: '${vars[8]}'" > > #echo "Rain fall: '${vars[9]}'" > > heat_index=${vars[41]%.*} #convert into integer >> > if (("$heat_index" > 32 && "$heat_index" < 39)) > > then > > last_run=$(cat /home/pi/bin/announcements/heat_index_1) > > last_run_minutes=$(( ($current_time - $last_run) / $MPHR )) > > if (("$last_run_minutes" > 60)) > > then > > /home/pi/bin/relay_on_off on > > /bin/sleep 1 > > /usr/bin/omxplayer -o local /home/pi/Music/announcement.mp3 > > /usr/bin/espeak blablablabla > > /home/pi/bin/relay_on_off off > > echo "Heat index: '${vars[41]}'" > > /bin/date +%s > /home/pi/bin/announcements/heat_index_1 > > else > > echo "Ran less than $last_run_minutes minutes" > > fi > > elif (("$heat_index" > 38 && "$heat_index" < 45)) > > then > > last_run=$(cat /home/pi/bin/announcements/heat_index_2) > > last_run_minutes=$(( ($current_time - $last_run) / $MPHR )) > > if (("$last_run_minutes" > 30)) > > then > > /home/pi/bin/relay_on_off on > > /bin/sleep 1 > > /usr/bin/espeak blablabla > > /home/pi/bin/relay_on_off off > > echo "Heat index: '${vars[41]}'" > > /bin/date +%s > /home/pi/bin/announcements/heat_index_2 > > else > > echo "Ran less than $last_run_minutes minutes" > > fi > > elif (("$heat_index" > 45)) > > then > > last_run=$(cat /home/pi/bin/announcements/heat_index_3) > > last_run_minutes=$(( ($current_time - $last_run) / $MPHR )) > > if (("$last_run_minutes" > 15)) > > then > > /home/pi/bin/relay_on_off on > > /bin/sleep 1 > > /usr/bin/espeak cccccccc > > /home/pi/bin/relay_on_off off > > echo "Heat index: '${vars[41]}'" > > /bin/date +%s > /home/pi/bin/announcements/heat_index_3 > > else > > echo "Ran less than $last_run_minutes minutes" > > fi > > else > > true > > fi > > rain_rate=${vars[8]%.*} #convert into integer > > if (("$rain_rate" > 1 && "$heat_index" < 2)) > > then > > last_run=$(cat /home/pi/bin/announcements/rain_rate_1) > > last_run_minutes=$(( ($current_time - $last_run) / $MPHR )) > > if (("$last_run_minutes" > 60)) > > then > > printf "Subject: Light Rain $rain_rate at MIR\n\nIt's raining" | ssmtp >> [email protected] > > /bin/date +%s > /home/pi/bin/announcements/rain_rate_1 > > else > > echo "Ran less than $last_run_minutes minutes" > > fi > > elif (("$rain_rate" > 2 && "$heat_index" < 7)) > > then > > last_run=$(cat /home/pi/bin/announcements/rain_rate_2) > > last_run_minutes=$(( ($current_time - $last_run) / $MPHR )) > > if (("$last_run_minutes" > 30)) > > then > > printf "Subject: Moderate Rain $rain_rate at MIR\n\nIt's raining" | >> ssmtp [email protected] > > /bin/date +%s > /home/pi/bin/announcements/rain_rate_2 > > else > > echo "Ran less than $last_run_minutes minutes" > > fi > > elif (("$rain_rate" > 7 && "$heat_index" < 20)) > > then > > last_run=$(cat /home/pi/bin/announcements/rain_rate_3) > > last_run_minutes=$(( ($current_time - $last_run) / $MPHR )) > > if (("$last_run_minutes" > 15)) > > then > > printf "Subject: Heavy Rain $rain_rate at MIR\n\nIt's raining" | >> ssmtp [email protected] > > /bin/date +%s > /home/pi/bin/announcements/rain_rate_3 > > else > > echo "Ran less than $last_run_minutes minutes" > > fi > > elif (("$rain_rate" > 20)) > > then > > last_run=$(cat /home/pi/bin/announcements/rain_rate_4) > > last_run_minutes=$(( ($current_time - $last_run) / $MPHR )) > > if (("$last_run_minutes" > 15)) > > then > > printf "Subject: Violent Rain $rain_rate at MIR\n\nIt's raining" | >> ssmtp [email protected] > > /bin/date +%s > /home/pi/bin/announcements/rain_rate_4 > > else > > echo "Ran less than $last_run_minutes minutes" > > fi > > else > > true > > fi > > > On Monday, October 7, 2019 at 6:22:01 PM UTC+5:30, Pila wrote: > > If you really want just to send a notification, use alarm.Py. > > If you want to base automation on this data, I can provide example how I > did it. But you would still need to solve sending e-mails on your own since > my RPI Zero uses my router to do so. > > Na 5. listopada 2019. 18:34:06 CEST, Ramesh Rasappan <[email protected] > <javascript:>> wrote: >> >> do you parse the html page? could you please share the shell script? >> thanks >> >> On Friday, October 4, 2019 at 5:19:09 PM UTC+5:30, Pila wrote: >>> >>> If you really want notification, it can generate email. >>> >>> I use data to close shutters if it rains from the west half. I simply >>> parse generated page and extract data I need. All from shell script. 5 >>> lines of code to extract 8 variables. My Zero jest closed shutters since it >>> was sunset. >>> >>> Na 3. listopada 2019. 16:01:58 CEST, Ramesh Rasappan <[email protected]> >>> wrote: >>>> >>>> My current setup pulls weather data from Offset console using >>>> weewx-wh23xx driver. I want to run a bash script that can get the current >>>> weather and send me a notification if it meets the criteria. >>>> >>>> >>>> I could probably get the weather data directly from PWS console >>>> using weewx-wh23xx driver but I can't figure out this!! Of course one >>>> could >>>> use sqlite3 to pull the data from either weewx database >>>> (/var/lib/weewx/weewx.sdb) but it looks complicated for me that I have to >>>> run some complex script to retrieve the current data! >>>> >>>> >>>> Can you share some script that can pull the current data from either >>>> weewx database or from the console? thank you >>>> >>>> >>>> >>>> >>> -- >>> Poslano sa mog Android uređaja sa K-9 Mail. Molim vas oprostite na mojoj >>> sažetosti. >>> >> -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/b0a00ce6-710e-4310-95d0-2896a7e9d8ee%40googlegroups.com.
