First, let's get the hard part out of the way:
- Code: Select all
# This is the device ID to use for the weather information:
dev = indigo.devices[949793465]
# Set up the values that we are going to use:
alert_description = dev.states["alertDescription1"]
alert_status = dev.states["alertStatus"]
chance_of_rain = str(int(round(dev.states["forePop1"])))
current_temperature = str(int(round(dev.states["temp"])))
current_weather = dev.states["currentWeather"]
fore_conditions = dev.states["conditions2"]
fore_rain = str(int(round(dev.states["forePop2"])))
fore_temp = str(int(round(dev.states["foreHigh2"])))
location_city = dev.states["locationCity"]
relative_humidity = str(int(round(dev.states["relativeHumidity"])))
today_high = str(int(round(dev.states["foreHigh1"])))
# This is what Indigo will speak.
indigo.server.speak("{0} weather.".format(location_city))
indigo.server.speak("Current conditions are {0} with a temperature of {1} degrees.".format(current_weather, current_temperature))
indigo.server.speak("Relative humidity level of {0} percent.".format(relative_humidity))
indigo.server.speak("Today's high temperature is forecast to be {0} degrees and there is a {1} percent chance of precipitation.".format(today_high, chance_of_rain))
if alert_status:
indigo.server.speak("There is currently a {0}".format(alert_description))
indigo.server.speak("Tomorrow's weather is {0} with a high of {1} degrees and {2} percent chance of precipitation.".format(fore_conditions, fore_temp, fore_rain))
For the line that says:
- Code: Select all
dev = indigo.devices[123]
The variables come next and are references to WUnderground device states. To get device state information, scroll down in the device window, right click on a custom state and copy the Python reference. Note that non-string values need to be converted to strings in order for Indigo to be able to speak them.
Then, add a corresponding 'indigo.server.speak' block to the next section to establish what Indigo will say, and how it will say it.
The above is just an example to show the kinds of things you can do. And there are many more WUnderground states to choose from.