So I’ve been looking for a relatively minor project to help get me more accustomed to luup (basics of the syntax, table manipulation, parsing strings, etc.), my choice: plug-in of sorts called “Say The Weather”.
I also think this is a “cool” little project as it bridges the work of multiple authors to create a “new product”…it shows a glimpse of what the community can do from seemingly disparate projects. “Hmmmm…I want Vera to ‘tell me the weather…’ Hey…lolodomo has a Sonos plug in here…and hey…guessed has a Weather plug-in over here…” Neat-o.
Executive Summary: Hear a “natural language” weather report from your Sonos system, DLNA Device, or Imperihome device based on data points gathered from the Wunderground Weather app.
The guiding principals for this plug-in:
- Require as little “set-up” as possible and be fully functional.
- Make almost all parameters of the SayTheWeather action optional.
- Allow an optional certain degree of end-user customizability with the phrases used when creating the weather statement.
- Support US and Metric units, for both input parameters and the output statement.
The following apps are needed to make full use of SayTheWeather functionality:
- REQUIRED: Wunderground Weather App Versions 1.5 and later of SayTheWeather requires version 1.58 or later of the Wunderground Weather App.
The following are optional render targets. Without at least one render target, you won’t be able to actually hear an audible announcement. You can still generate a text weather statement, however:
- OPTIONAL: Sonos App
- OPTIONAL: DLNA App
- OPTIONAL: Imperihome App
If you are using a render target, you’ll want to make sure that the basic Text to Speech functionality is working prior to trying SayTheWeather.
Vera Version Compatibility: This has been tested with UI7 and UI5. (UI5 for versions 1.7 and later.)
To install: (Install the latest version directly from your Vera via the App Store).
Setup
:
3) Custom UI tabs have been created to manage the default values for the app as well as weather phrases and limits. They are slightly different depending on the UI version of Vera that you are running:
UI7
a) Defaults
b) Weather Alerts
c) Condition Phrases (1) – (Manage and test phrases for first 10 weather conditions)
d) Condition Phrases (2) – (Manage and test phrases for second 10 weather conditions)
e) Temperature Phrases – Manage and test temperature phrases and limits
f) Wind Speed Phrases – Manage and test wind speed phrases and limits
[u][b]UI5[/b][/u]
a) Defaults
b) Weather Alerts
c) Conditions -- Manage and test phrases for all 20 weather conditions phrases)
e) Temperature -- Manage and test temperature phrases and limits
f) Wind -- Manage and test wind speed phrases and limits
More details on using the are found in this post.
The “SayTheWeather” action is implemented in the “urn:joeyd-com:serviceId:SayTheWeather1” service. You can call on this action with the advanced scene editor in UI7, or with luup code. The complete syntax of the luup call is:
luup.call_action("urn:joeyd-com:serviceId:SayTheWeather1","SayTheWeather",
{DontSay = "",
RenderTargetID= "",
PrefixStatement="",
SuffixStatement="",
IncludeLocation="",
IncludeCurrentConditions="",
IncludeForecasts="",
IncludeAlerts = "",
Volume="",
SonosZone="",
SonosSameVolumeForAll="",
}
,[DeviceNumber])
Note: DeviceNumber is the device number of your SayTheWeather device…NOT your sonos, DLNA or Imperihome devices.
Technically, all of the parameters are optional. SayTheWeather will look to your default values (on your “Defaults” tab) to use for any parameters that you omit. This way, you can define your own default values up front and then if desired omit them from the action statement. Here are the parameters defined for the SayTheWeather action:
DontSay=“true/false” If DontSay is “true” Sonos is not called on. The weather announcement text is simply written to the
RenderTargetID: The Device ID of the render target. (Imperihome plugin Device ID, or DLNA plugin Device ID…not used for Sonos)
CompleteWeatherStatement state variable and the text is displayed in the “control” tab.
PrefixStatement = “[any text]”. If supplied, this text is read prior to the rest of the weather announcement.
SuffixStatement = “[any text]”. If supplied, this text is read after the rest of the weather announcement.
IncludeLocation=“true / false”. If true, the location of the weather station is announced.
IncludeCurrentConditions=“true / false”. If true, the current conditions are announced.
IncludeForecasts=“01” Specifiy which (if any) forecasts to include. (See below for further explanation).
IncludeAlerts: “changes”,“all”, or “none”. Specifies which weather alerts to include in the announcement. “changes” means that any alert that has either never been spoken, or has changed since it has last been spoken will be included in the announcement.
Volume= [number form 1 to 100]. If specified, sets the volume for the weather announcement. Imperihome does not currently support volume, so the announcement will be played at your device’s current setting.
SonosZone=“[Comma delimited Zone names, or ‘ALL’]” Specifies which sonos zone(s) to play the announcement on.
SonosSameVolumeForAll=“true/false”. If true, instructs sonos to play all zones at the volume specified by the SonosVolume.
And here’s how it all works…This is a sample of the output…a Weather Announcement:
Good morning! Here's the local weather from Shongum, in Randolph, New Jersey. Presently, we are experiencing cloudy conditions with the temperature a very cold 31 degrees. There is a light breeze around 3 miles per hour gusting to a moderate breeze around 15 miles per hour. For the immediate forecast we are expecting partly cloudy skies with very cold temperatures ranging from 28 to 34 degrees. Expect a light breeze around 5 miles per hour. For tomorrow's forecast we are expecting partly cloudy skies with very cold temperatures ranging from 28 to 38 degrees. Expect a light breeze around 5 miles per hour. There is 1 weather alert to report. The first alert is new. A winter weather warning is currently in effect until 7:00 PM tonight. Have a nice day!
The weather announcement is composed of 6 “statements”, in this order (though each of these statements can be turned off depending on the parameters when you call the action):
[prefix] [location] [current conditions] [forecasts][alerts] [suffix]
Here is the luup.call that created the sample announcement:
luup.call_action("urn:joeyd-com:serviceId:SayTheWeather1","SayTheWeather",
{PrefixStatement="Good Morning!"
SuffixStatement="Have a nice day!"
IncludeLocation="true",
IncludeCurrentConditions="true",
IncludeAlerts = "ALL",
IncludeForecasts="01"
}
,[DeviceNumber])
The prefix and suffix (if supplied) are simply passed to the beginning and of the weather announcement. Because IncludeLocation is “true”, the statement about the location (“Here’s the weather from…”) was included. Because IncludeCurrentConditions is “true”, the “Presently…” statement was included that describes the current conditions.
The IncludeForecasts parameter works a little differently. It is a string of digits that represent which forecasts you want to include (if any) in the weather announcement. These digits correspond to the Weather plug-in’s forecast values. Typically 0 refers to the immediate forecast (today), 1 corresponds to tomorrow, etc. Currently the weather plug-in supports forecasts 0-3. The exact nature of what the numerals represent depend on the weather station you are reporting from. (As does whether or not there is data available for any / all of them).
Example: to only include the immediate forecast (0) and tomorrow’s forecast (1), the IncludeForecasts parameter should be “01”. If you want the forecast only for the “day after tomorrow”, the parameter is “2”. To hear forecasts for all available days, the parameter is “0123”, and so on.
The “Sonos…” parameters are passed to the Sonos plug-in to address the following: “on what zones you want to hear the announcement, at which volume(s), using which TTS engine, and in what language”. For details on how to construct these parameters, please see the Sonos plug-in page. You can specify default values for all of these.
Default Values and Personal Customization of the Weather Statement Phrases:
For an explanation of the UI to manage the default values and phrase customization, see this post here.
Automatic Alerts
SayTheWeather’s weather information is updated automatically whenever the Weather Apps data refreshes. If new weather alert information is received, you can elect to have SayTheWather immediately announce the alert. Refer to this image to go along with the following instructions for alerts:
Default Alert Behavior When Saying The Weather: This option pertains to the standard weather announcement and how alerts are handled by default. If you choose “ALL”, then all active alerts are read with the weather announcement. “CHANGES” indicates that only those alerts that are new, or have changed since the last time they were read are included. “NONE” indicates that alerts are not to be read with the weather statement.
Auto Alerts If enabled, SayTheWeather will automatically announce weather alerts when they come in, pending active hours.
Active Hours If auto alerts are enabled, they will be said aloud as long as the current time is within the active hours you specify. If an alert occurs during quiet hours, it will be announced automatically when the next active hours start. For example, suppose your active hours are between 7:00 AM and 9:00 AM and again from 5:00 PM to 10:00 PM. If an alert comes in at 2:00 AM, it will not be announced until 7:00 AM.
Changelog:
Dec 21, 2014: 1.0 Released
Dec 22, 2014: 1.1 Released:
Fixed conversion issue. Will also now initialize based on the units selected in in the Weather App
Fixed weather location statement being placed before prefix statement.
Added simplistic JSON file which appears may be required with the latest VERA firmware released (1.7.481) if you want to see the information within the “standard” tabs like “advanced”…
Dec 31, 2014: 1.2 Released:
Fixed an additional conversion issue.
Added UI to enable much easier management and testing of phrases and default settings.
Added button to default device that “Says The Weather” with the default settings set by the user.
This version was approved for App Store release and can be installed from the app store as of Jan 5, 2015.
Jan 19, 2015: 1.5 Released:
Added support for Weather Alerts
Fixed an issue affecting those with temperature or humidity sensors that were not related to the weather app.
Fixed an issue when you tried to say an alert / weather to a sonos zone that was not set-up as a device. This is no longer required.
Feb 3, 2015: 1.7 Released:
Added support for UI5
Added support for DLNA and Imperihome render targets.
Feb 10, 2015: 1.8 Released:
Fixed periodic “chirping” issue with Sonos when automatic alerts were enabled but there were no alerts to be said.