Author Topic: Weather Forecasts?  (Read 19887 times)

Offline guessed

  • Master Member
  • *******
  • Posts: 5293
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
Re: Weather Forecasts?
« Reply #15 on: December 29, 2012, 04:22:10 pm »
The ServiceId shouldn't be changed, but you should change the deviceId's (23, and 8 in @ smadhu's example) to match those from your environment.

Offline jschaubel

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Weather Forecasts?
« Reply #16 on: December 31, 2012, 07:02:41 am »
the luup coe now works when I run the scene manually.  How do I tell it to check the weather condition on its own and run or turn off the scene?

thanks for your help

Offline smadhu

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Weather Forecasts?
« Reply #17 on: January 01, 2013, 01:49:21 pm »
Smadhu thanks for the help.  I have not knowledge of luup code, but I'd really like to learn it.

I'm assuming I set up a scene, put your code in and just change the device from :switchpower1 to the name of my device?  is is smart to avoid spaces in device names when writing code?

If I wanted it to turn on when it is raining and less than 2 degrees would it look like this:

local t = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "ConditionGroup", 23)
local s = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "Condition", 23)
if   ( 
         string.find(t,"sleet")
         or string.find(t,"rain")
         -- since some conditions do not seem to be grouped
         or string.find(s,"drizzle")
         or string.find(s,"freezing")   
     
     )
and
if   (temperature<2)
         
then
-- switch ON outside module
 luup.call_action("urn:upnp-org:serviceId:front snow mats", "SetTarget", {newTargetValue = "1"},  8 )
else
-- switch OFF outside module
 luup.call_action("urn:upnp-org:serviceId:front snow mats", "SetTarget", {newTargetValue = "0"},  8 )
end

I appreciate your help.  any advice where I can go on the web to learn luup code
You could put the code below in a Scene and set the Scene to run on a schedule. You can perform the action in code or manage devices and delays in the Scene. You can then return "true/false" in Luup. Since the Luup code is evaluated last, returning "false" will cause the scene to abort.
The MCV wiki and forums are a good place to learn lua. Change device numbers to match yours and test in Vera UI under APPS-->Develop Apps-->Test Luup

local t = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "ConditionGroup", 23)
local s = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "Condition", 23)
--Get the current temperature
local outsideTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 44)

if   (
         string.find(t,"sleet")
         or string.find(t,"rain")
         -- since some conditions do not seem to be grouped
         or string.find(s,"drizzle")
         or string.find(s,"freezing")   
     
     )
and
  (outsideTemp<2)
         
then
-- allow the scene to run
 return true
else
-- prevent scene from running
  return false
end

Offline smadhu

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Weather Forecasts?
« Reply #18 on: January 01, 2013, 03:43:22 pm »
In the code I posted, you may want to explicitly cast outsideTemp as a number using the "tonumber" function

.......
and
  (tonumber(outsideTemp) < 2)
.......

Offline kyb2012

  • Full Member
  • ***
  • Posts: 118
  • Karma: +4/-0
Re: Weather Forecasts?
« Reply #19 on: February 14, 2014, 03:14:15 pm »
First of this is a great plugin @guessed!
Do you have any updates on implementing forecasts into your plugin?  (I know you must get asked a lot. :-))
I was looking at the xml returned from wunderground, and I think that if you were to use the following code, it could get the next day's high/low temps, weather condition, %chance of precipitation and windspeed.

&lt;period>2&lt;/period>
        &lt;high>&lt;fahrenheit>(.-)&lt;/fahrenheit>&lt;celsius>(.-)&lt;/celsius>&lt;/high>
        &lt;low>&lt;fahrenheit>(.-)&lt;/fahrenheit>&lt;celsius>(.-)&lt;/celsius>&lt;/low>.*
        &lt;conditions>(.*)&lt;/conditions>&lt;icon>(.-)&lt;/icon>.*&lt;pop>(.-)&lt;/pop>.*
   &lt;avewind>&lt;mph>(%d-%.?%d-)&lt;/mph>&lt;kph>(%d-%.?%d-)&lt;/kph>.*

The easiest thing to do may be to create another instance of your plugin and assign these values to the appropriate values that you already have available for current day's values.

I just hooked up a wireless on/off valve to my outside sprinkler using the GC100 relay and I was hoping to use PLEG (awesome!) and weather plugin (terrific!) with forecasts to determine when to water the garden.

Thanks for your consideration.

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: Weather Forecasts?
« Reply #20 on: February 14, 2014, 03:27:31 pm »
Forecasts would be great to add.

Just sharing my PLEG for irrigation control.  It allows me to:

Conform with watering restrictions, only goes on target days.
Vary the watering by season
I have scenes adjust the zone time separately (but it is going into PLEG as soon as I get the chance)
Cancel if it rained substantially in the last 24hrs
Alerts when it watered, push notifications to HomeWave
Alerts when it didn't run, and tells me why

have fun and share your techniques...

Offline guessed

  • Master Member
  • *******
  • Posts: 5293
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
Re: Weather Forecasts?
« Reply #21 on: February 18, 2014, 01:44:56 pm »
I have a version of the Weather Plugin that has forecast data (the 3 days of it that Wunderground was already providing the Plugin's internals), I'm just mulling over the best way to expose this to folks.

I know the ways I can do it, but I'm trying to minimize impact on the user-machines once it's exposed.

ie. Don't materially impact existing users, allow folks to enable it if they want to pay the additional resource costs.

Some of the options will result in an explosion of Child Devices, but will work well with the native/declarative Vera Scene scripting options.  Others work better for Control points (ones wanting to display a Weather widget with forecasts, for example), but do so at the sacrifice of declarative scripting (forcing you to use Lua, for example, to access the data or to complicate the Scene options)

Anyhow, this is important, as it's likely that the # & type of forecast/current values that people want to see will likely expand over time (exp since I only expose a few key ones right now)

I'm just weighing the options at the moment, since I'd like to avoid becoming the Support team's next scape-goat for Vera instability ;)


To give you a sense for what I'm currently exposing (under the Parent node, for now), see the data below.  This option is targetted at Control Points that want to display a Weather Widget (with ordered-days of data):

Service:
    urn:upnp-micasaverde-com:serviceId:Weather1
Variables:
    Forecast.1.HighTemperature ... now: 64
    Forecast.1.LowTemperature  ... now: 43
    Forecast.1.Condition was:  ... now: Partly Cloudy
    Forecast.1.ConditionGroup  ... now: partlycloudy


and similar variables for Forecast.2.*, Forecast.3.*, Forecast.0.* (today)


Nothing final at this point, just the work to extract the right bits of data.  Formats, service & variable names (etc) subject to change.

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: Weather Forecasts?
« Reply #22 on: February 18, 2014, 02:02:42 pm »
I use (and appreciate) this app a lot.

How about adding to the setup panel wherein users select (by check box) which components they want to use?  Saving the master device adds (deletes) the additional devices.  Ideally (in my case) your upgrade would have to detect which of the other devices user has already deleted, because they didn't use them.

Offline guessed

  • Master Member
  • *******
  • Posts: 5293
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
Re: Weather Forecasts?
« Reply #23 on: February 18, 2014, 02:13:41 pm »
I'm trying to avoid complex configuration for users.  The type of configuration I was more along the lines of "how many days" of forecast you want, and then it creates the corresponding Children (for folks wanting the declarative scripting options)

I'm more of a "less is more" type person when it comes to configuration, so I don't want to add a zillion options to the config page.... partly because it would force me to use Javascript (and the corresponding UI4/5 vs UI6 code-compatibility headaches) but mostly because we already have a set of users that can't set it up now (see some of the comments on the apps.mios.com review page, some folks don't seem to be able to find the plugin's Help link  8) )

I can also do this completely without Child devices, but it'll clutter the Scene creation options, since I'd have to list every combination of parameter.day.value in there (the downside of aggregating the forecast variables under the parent)

Those are the things I'm considering, but overall the plan is to have the "extras" off by default, except for these "parent-owned" variables, and not to provide too many options (so-as to avoid confusion for the new users).

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: Weather Forecasts?
« Reply #24 on: February 18, 2014, 02:16:30 pm »
I like the one device thought.

Anyway, I like the app ad trust you will work out a great update.

Offline guessed

  • Master Member
  • *******
  • Posts: 5293
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
Re: Weather Forecasts?
« Reply #25 on: February 18, 2014, 07:57:31 pm »
Glad you like it, and that it's useful to you.  It's my oldest Vera code (both good, and bad) just trying to ensure that I ensure stability as it evolves... which can be constraining, but hopefully not too much.

I added a few more variables to the parent-node, based upon previous requests, so the prototype version now at least captures/records state for the following:

Variables:
    WindDegrees ... now: 19
    WindSpeed   ... now: 0.0
    WindGust    ... now: 4.0
    LastUpdate  ... now: 1392768177
(the timestamp of last change from WUI itself vs HADevice::LastUpdate which is when the plugin last made a change)

    Forecast.1.MaxWind          ... now: 12
    Forecast.1.MaxWindDirection ... now: NW
    Forecast.1.MaxWindDegrees   ... now: 319


Offline thebgrian

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Weather Forecasts?
« Reply #26 on: February 26, 2014, 04:20:19 pm »
Hi, guessed
Thank you for the great plugin! Is the forecast functionality available to the public?

Offline guessed

  • Master Member
  • *******
  • Posts: 5293
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
Re: Weather Forecasts?
« Reply #27 on: February 26, 2014, 07:45:07 pm »
Is the forecast functionality available to the public?
Not yet...

Offline thebgrian

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Weather Forecasts?
« Reply #28 on: March 24, 2014, 05:19:34 pm »
Hi, Guessed

Just wanted to check if you have plans to make the forecast option publicly available. I think it will be very helpful for controlling irrigation systems etc.
Thank you!

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 10037
  • Karma: +759/-141
Re: Weather Forecasts?
« Reply #29 on: March 24, 2014, 06:17:40 pm »
I use the Weather Plugin to facilitate Automation ... I do not use Vera as the Display of my local weather conditions.
Although I do like to see the Weather Parameters that I use in my Automation.
It does not matter to me if these are all parameters of the parent devices ... or split out as child devices.
The resource overhead for child devices is not that much ... the developer overhead is larger.
Personally I would hate to see an explosion of child devices ... so if you create them I would like to be able to only create the ones I am interested in.

I would like to see: "Solar Radiation"  ... I think that would be a better way to control inside lighting than using offsets from sunrise and sunset.

 
UI6 already has a Weather Banner added to the top of the UI6 dashboard. I have no idea where they are getting their weather ... But I consider this wasted space!
As well as their pre-defined 4 scenes (Presets): Home, Away, Night, Vacation that are on their main page.