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
--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/47ab7379-e50b-4309-a2ce-ba1857a6cbd6%40googlegroups.com.
Have you looked at the "alarm" example? It is included in the "examples" subdirectory. Documentation in the Customizing Guide.
On Thu, Oct 3, 2019 at 7:02 AM Ramesh Rasappan <prra...@gmail.com> 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
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 weewx...@googlegroups.com.
@Pilla, although I got it working (see above), I am still interested to see your script! maybe you are handling it in a better way! (you could send it to me: chittukuruvii at. gmail)
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 and parse it with a bash script. I am sharing here my work (could be useful for some noob like me!).
#!/bin/bashvar=$(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 integerif (("$heat_index" > 32 && "$heat_index" < 39))thenlast_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 -s 150 -g 30mS blablabla/home/pi/bin/relay_on_off offecho "Heat index: '${vars[41]}'"/bin/date +%s > /home/pi/bin/announcements/heat_index_1elseecho "Ran less than $last_run_minutes minutes"fielif (("$heat_index" > 38 && "$heat_index" < 45))thenlast_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 xxxxxxxxxxxx/home/pi/bin/relay_on_off offecho "Heat index: '${vars[41]}'"/bin/date +%s > /home/pi/bin/announcements/heat_index_2elseecho "Ran less than $last_run_minutes minutes"fielif (("$heat_index" > 45))thenlast_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 xxxxxxxxxxx/home/pi/bin/relay_on_off offecho "Heat index: '${vars[41]}'"/bin/date +%s > /home/pi/bin/announcements/heat_index_3elseecho "Ran less than $last_run_minutes minutes"fielsetruefirain_rate=${vars[8]%.*} #convert into integerif (("$rain_rate" > 1 && "$heat_index" < 2))thenlast_run=$(cat /home/pi/bin/announcements/rain_rate_1)last_run_minutes=$(( ($current_time - $last_run) / $MPHR ))if (("$last_run_minutes" > 60))thenprintf "Subject: Light Rain $rain_rate at MIR\n\nIt's raining" | ssmtp email/bin/date +%s > /home/pi/bin/announcements/rain_rate_1elseecho "Ran less than $last_run_minutes minutes"fielif (("$rain_rate" > 2 && "$heat_index" < 7))thenlast_run=$(cat /home/pi/bin/announcements/rain_rate_2)last_run_minutes=$(( ($current_time - $last_run) / $MPHR ))if (("$last_run_minutes" > 30))thenprintf "Subject: Moderate Rain $rain_rate at MIR\n\nIt's raining" | ssmtp email/bin/date +%s > /home/pi/bin/announcements/rain_rate_2elseecho "Ran less than $last_run_minutes minutes"fielif (("$rain_rate" > 7 && "$heat_index" < 20))thenlast_run=$(cat /home/pi/bin/announcements/rain_rate_3)last_run_minutes=$(( ($current_time - $last_run) / $MPHR ))if (("$last_run_minutes" > 15))thenprintf "Subject: Heavy Rain $rain_rate at MIR\n\nIt's raining" | ssmtp email/bin/date +%s > /home/pi/bin/announcements/rain_rate_3elseecho "Ran less than $last_run_minutes minutes"fielif (("$rain_rate" > 20))thenlast_run=$(cat /home/pi/bin/announcements/rain_rate_4)last_run_minutes=$(( ($current_time - $last_run) / $MPHR ))if (("$last_run_minutes" > 15))thenprintf "Subject: Violent Rain $rain_rate at MIR\n\nIt's raining" | ssmtp email/bin/date +%s > /home/pi/bin/announcements/rain_rate_4elseecho "Ran less than $last_run_minutes minutes"fielsetruefi
/home/weewx/skins/Seasons/skin.conf
[[VremStanica]]
encoding = strict_ascii
template = VremStanica.txt.tmpl
/home/weewx/skins/Seasons/VremStanica.txt.tmpl
Time $current.dateTime.raw
InTemp $current.inTemp.format(add_label=False)
OutTemp $current.outTemp.format(add_label=False)
Dewpoint $current.dewpoint.format(add_label=False)
Humidity $current.outHumidity.format(add_label=False)
WindSpeed $current.windSpeed
WindCardinal $current.windDir.ordinal_compass
WindDirection $current.windDir
RainRate $current.rainRate.format(add_label=False)
Sunrise $almanac.sun.rise.raw
Sunset $almanac.sun.set.raw
/home/weewx/public_html/VremStanica.tx
eval $(awk '
{
if ($1 == "RainRate" && $2 > "0,0")
print ""$1"=\""int ($2+1)"\""
else if ($1 == "WindCardinal") # leave original
print ""$1"=\""$2"\""
else # convert to integer
print ""$1"=\""int ($2)"\""
}' /home/weewx/public_html/VremStanica.txt)
RoletaKisaFlag="/root/RoletaKisaFlag"
echo "$RoletaDignuta" > "${RoletaKisaFlag}"
touch "${RoletaKisaFlag}"
RoletaKisaFlagAge=$(date -r "${RoletaKisaFlag}" +%s)