Hey Folks!
DDNRN asked me to check whether there’s a way for sunrise and sunset displaying in the gui and already gave me the curl command. I used a similar setup as at the uptime device with an external shell script.
so first create a script in your home/pi directory called sunrise.sh :
#!/bin/bash
# sunrise.sh
# shellscript to extract sunrise and sunset from yahoo weather
# insert your correct location code at w=xxxxxx.
# you can get it at http://weather.yahoo.com and enter your zip or city
sunrise=$(curl -s http://xml.weather.yahoo.com/forecastrss?w=644719 | grep astronomy | awk -F\" '{print $2}'|{ date -f - +%R; })
sunset=$(curl -s http://xml.weather.yahoo.com/forecastrss?w=644719 | grep astronomy | awk -F\" '{print $4}'|{ date -f - +%R; })
echo "Aufgang $sunrise Uhr, Untergang $sunset Uhr"
short translation : Aufgang = sunrise, Untergang = sunset, Uhr = o’clock
then you can create the device in the config.json like this :
{
"id": "sonnenstand",
"name": "Sonne",
"class": "ShellSensor",
"attributeName": "time",
"attributeType": "string",
"attributeUnit": "",
"command": "sudo bash /home/pi/sunrise.sh",
"interval": 3600000
}
the update interval is every hour. so if you reboot the pi before midnight it will update the sunrise/sunset in a relative short time.
well, then have fun with pimatic again
cheers
P.S.: here’s how to get your location code w=
go to http://weather.yahoo.com/ and insert zip or city, hit search weather and read your location code above at the url. simple, isn’t it