Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # phinfo.sh [yyyymmdd]
- #
- # post current date to pimatic, if true enhanced by name of public holiday
- # "yyyymmdd" # run script in test mode
- #-----------------------------------------------------------------------------
- . /home/pi/pimatic-holiday/pimaticAPI.sh
- PIMATIC_VAR1="publicHoliday"
- PIMATIC_VAR2="today"
- PIMATIC_VAR3="sunposition"
- #
- # check and get runstring parameter
- #
- if [ "$1" ]
- then
- qday=$1
- DEBUG="true"
- else
- qday="today"
- fi
- qdate=$(date -d "$qday" +"%d.%m.%Y")
- public_holiday=$(curl -s http://www.ferienkalender.com/ferien_deutschland/Hessen/2015-ferien-hessen.htm | grep "$qdate" | awk 'BEGIN{RS="</td></tr><tr";FS="><td align=left>";} {print $2,$3;}'| grep "$qdate" | awk 'BEGIN{FS="<b>";} {print $3,$2;}' | awk 'BEGIN{FS="</b></td><td align=right>";} {print $2," - ",$1;}' )
- if [ "$public_holiday" ]
- then
- phday="true"
- else
- phday="false"
- public_holiday="$(date -d "$qday" +"%A"), $qdate"
- fi
- if [ "$DEBUG" = "true" ]; then echo ":$phday:$public_holiday:"; fi
- pimatic_var_value="\"$phday\""
- write_to_pimatic $PIMATIC_VAR1 "$pimatic_var_value"
- pimatic_var_value="\"$public_holiday\""
- write_to_pimatic $PIMATIC_VAR2 "$pimatic_var_value"
- #
- # get sunrise and sunset time
- #
- sunrise=$(curl -s http://weather.yahooapis.com/forecastrss?w=642800 | grep astronomy | awk -F\" '{print $2}' | { date -f - +%R; })
- sunset=$(curl -s http://weather.yahooapis.com/forecastrss?w=644719 | grep astronomy | awk -F\" '{print $4}'|{ date -f - +%R; })
- sunposition="Aufgang $sunrise Uhr, Untergang $sunset Uhr"
- if [ "$DEBUG" = "true" ]; then echo "$sunposition"; fi
- pimatic_var_value="\"$sunposition\""
- write_to_pimatic $PIMATIC_VAR3 "$pimatic_var_value"
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement