May-16-2017, 06:09 PM
(May-08-2017, 07:07 AM)buran Wrote: As I said it assumes that forecast.currently() actually returns string, that can be passed to your device to read it. This was not the case - it returnsThanks! I got the data to read onto the sign using str, so a small step forward, but for some reason it will read <forecastioDataPoint instance: Clear skies , rather than just reading the clear skies part, any clue why the str is pulling that information?ForecastioDataPoint
object. So you need to access its properties to get what you want - str.
import datetime import forecastio from pyledsign.minisign import MiniSign def main(): """ Run load_forecast() with the given lat, lng, and time arguments. """ api_key = 'YOUR API KEY' lat = -31.967819 lng = 115.87718 time = datetime.datetime(2017, 06, 05, 6, 0, 0) forecast = forecastio.load_forecast(api_key, lat, lng, time=time) mysign = MiniSign(devicetype='sign') print "===========Currently Data=========" current_weather = forecast.currently() print current_weather.summary print current_weather.temperature mysign.queuemsg(data=current_weather.summary) mysign.queuemsg(data='Temperature: {}'.format(current_weather.temperature)) by_hour = forecast.hourly() print 'Hourly Summary: {}'.format(by_hour.summary) mysign.queuemsg(data='Hourly Summary: {}'.format(by_hour.summary)) mysign.sendqueue(device='/dev/ttyUSB0') if __name__ == "__main__": main()I keep this to minimum - i.e. only current weather and hourly forecast summary. Note that minutely(), hourly(), daily() returnForecastioDataBlock
object. Anyway you need to read forecastio docs to develop further (I assume that's what you want at the end)
I am using the
# queue up a text message
mysign.queuemesg(
data= str(forecast.currently())
)