Cynical Weather

Posted on
Sat Feb 01, 2014 4:07 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Cynical Weather

All right, a new plugin. Shiny!

Cynical Weather is basically two plugins held together by a common theme, the external environment of your house.

One (Orientation devices) simply tells you where the Sun is. I use that to tell my drapes to close when the Sun shines in their windows (and open again when it moves on). That was a fun exercise in celestial mechanics.

The other is a Dark Sky interface. Dark Sky offers "hyperlocal" weather - right now, down to the mile. It's the data that drives Apps like "Check The Weather" and, well, "Dark Sky." They offer an API and the plugin taps into that. The current version basically just gets you the current weather. I'm sure you'll let me know what much more awesome functionality I could add. :-)

Note that Dark Sky requires that (each of) you get an "API key" from them. That's so they can distinguish people in order to find and cut off abusers of their (free) service. As far as I know, these are good guys and they're on the level and offering a great service instead of hoarding their code for their own Apps.

And yes, that was the one that made me break down and write the SSL interface that a few of you have already found useful. :-)

Cheers
-- perry

Posted on
Sat Feb 01, 2014 7:58 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Cynical Weather

Very cool Perry. Will this offer the "It's about to rain" beta functionality that is present in the iOS dark sky app? It takes about 15 minutes to walk the dog and I'm constantly checking that app to find a hole in the rain to get him out there.

Posted on
Sat Feb 01, 2014 9:09 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Cynical Weather

Dewster35 wrote:
Very cool Perry. Will this offer the "It's about to rain" beta functionality that is present in the iOS dark sky app? It takes about 15 minutes to walk the dog and I'm constantly checking that app to find a hole in the rain to get him out there.

The first version does not, but I think I have the necessary data. Any suggestions on how to make that look in Indigo?

Cheers
-- perry

Posted on
Sun Feb 02, 2014 9:38 am
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Cynical Weather

Very cool. I wouldn't think you would need anything fancy for Indigo.... just a precip state that would be yes or no? I believe there aren't any other options... there either is precipitation starting in the next 15 minutes or not.

Posted on
Sun Feb 02, 2014 1:10 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Cynical Weather

How about an event that fires as soon as you get the signal from forecast.io that it's about to start raining? That seems like the perfect solution, no?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Feb 02, 2014 2:31 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Cynical Weather

*Squeal* Just what i always wanted.. Perry, you’re the man!

As for extra features i think the one main thing i’d like to see is future forecasts and summaries. Specifically i think i’d like to see today and tomorrows weather as listed on the forecast.io site, e.g. working it something like this:
todaysummary: Partly cloudy overnight.
todayforecast1: 4pm rain
todayforecast1temp: 6ºC
todayforecast2: 6pm cloudy
todayforecast2temp: 7ºC
todayforecast3: 7pm rain
todayforecast3temp: 7ºC
todayforecast4: 8pm clear
todayforecast4temp: 5ºC

then same idea for the next day. These would be rolling updates for the current and next hour slots (which is afaik how it’s broken down?) so they could be easily displayed on a control page.

I’d also quite like to see the summary of weather for the following week.. e.g.:

day3summary: Windy overnight, with light rain in the morning and overnight.
day3high: 3ºC
day3low: 1ºC
day4summary: Windy until afternoon, with light rain until evening.
day4high: 4ºC
day4low: 2ºC
day5summary: Partly cloudy until evening.
day5high: 6ºC
day5low: 3ºC

It’d also be nice for all of these fields to have an icon that’s associated with it.. so if i create a control page i can have different icons and images to see how it’s looking at a glance.

Looking at the JSON data it looks like all this is available.. but it’s difficult to tell.. so much info condensed into such little space.. i don’t know how you can make heads or tails of it!

Computer says no.

Posted on
Sun Feb 02, 2014 2:38 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Cynical Weather

jay (support) wrote:
How about an event that fires as soon as you get the signal from forecast.io that it's about to start raining? That seems like the perfect solution, no?

It's never quite as easy as that, is it? :-)

There is no "signal". Forecast.io is an HTTP/JSON service; it needs to be polled. You basically get "odds that it'll rain in the next minute," "odds that it'll rain in the minute after that," etc. It's up to us to figure out what that means in terms of expecting rain; the odds shift over time (but there's no easy "stuff changed" indicator), and if we poll too often we'll get locked out (or start paying).

Yes, just firing an event when it'll start raining soon is probably the right API. But first I have to figure out a good formula, and a way to test the underlying code in Sunny California, where it rains twice in a blue moon…

Cheers
-- perry

Posted on
Sun Feb 02, 2014 2:47 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Cynical Weather

durosity wrote:
As for extra features i think the one main thing i’d like to see is future forecasts and summaries. Specifically i think i’d like to see today and tomorrows weather as listed on the forecast.io site, e.g. working it something like this:
todaysummary: Partly cloudy overnight.
todayforecast1: 4pm rain
todayforecast1temp: 6ºC

Yeah, about that…

I really, really wish Indigo plugins had some way to present tabular data in a decent way. You know, like arrays and dicts of data assigned to states? I really hate the idea of giving my plugin objects hundreds of obscurely named states with a naming convention to go along. It offends the programmer in me. :-)

It’d also be nice for all of these fields to have an icon that’s associated with it.. so if i create a control page i can have different icons and images to see how it’s looking at a glance.

That's actually what the icon state is about. It's one of a dozen-or-so strings ("clear", "cloudy", etc.) that's meant to iconically summarize the situation. I think Indigo already has a way of turning that into images on control pages (you provide the images, of course). I can't actually vend graphics directly; the plugin API doesn't currently support that (that's the web server tie-in we've been talking about here and there).

Looking at the JSON data it looks like all this is available.. but it’s difficult to tell.. so much info condensed into such little space.. i don’t know how you can make heads or tails of it!

Slowly. :-)

Actually, the forecast.io folks are super helpful; they're (justly) proud of their baby. But at heart, their data is raw and needs to be cooked and seasoned to taste to be useful. That's why there's multiple Apps making actual money in presenting it… including their own.

Cheers
-- perry

Posted on
Sun Feb 02, 2014 2:48 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Cynical Weather

Perry, I'm sure there is plenty enough interest in the community to test. I know I would be more than willing.

Posted on
Sun Feb 02, 2014 2:59 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Cynical Weather

Perry The Cynic wrote:
I really, really wish Indigo plugins had some way to present tabular data in a decent way. You know, like arrays and dicts of data assigned to states? I really hate the idea of giving my plugin objects hundreds of obscurely named states with a naming convention to go along. It offends the programmer in me.


Indeed.. something else for M&J to add to their ever expanding wish list (I suspect by now it’s longer than anyone can imagine). However in the mean time it would be rather nice to add…… ;)

Perry The Cynic wrote:
That's actually what the icon state is about. It's one of a dozen-or-so strings ("clear", "cloudy", etc.) that's meant to iconically summarize the situation. I think Indigo already has a way of turning that into images on control pages (you provide the images, of course). I can't actually vend graphics directly; the plugin API doesn't currently support that (that's the web server tie-in we've been talking about here and there).


Ah yes sorry i already knew that.. i more meant icons states for the rest of the forecasts. I’ve already got the current icon field working for the information that’s already there :)

As for testing i can certainly help there… i’m surprised we haven’t evolved webbed feet over here :P

Computer says no.

Posted on
Sun Feb 02, 2014 6:06 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Cynical Weather

durosity wrote:
Perry The Cynic wrote:
I really, really wish Indigo plugins had some way to present tabular data in a decent way. You know, like arrays and dicts of data assigned to states? I really hate the idea of giving my plugin objects hundreds of obscurely named states with a naming convention to go along. It offends the programmer in me.


Indeed.. something else for M&J to add to their ever expanding wish list (I suspect by now it’s longer than anyone can imagine). However in the mean time it would be rather nice to add……


It's been on the list since before we released 6.0 - the problem is that kind of change is very pervasive so we have to coordinate releases of every app including Indigo Touch.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Feb 15, 2014 12:52 pm
rhanson offline
Posts: 192
Joined: Apr 30, 2013

Re: Cynical Weather

Perry, the device has a property named "index", which conflicts with SQL Logger, because it tries to create a column named "index", which is a reserved word. Could that be modified to sunIndex or something?

Thanks for the awesome plugin!!

Posted on
Sat Feb 15, 2014 1:03 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Cynical Weather

rhanson wrote:
Perry, the device has a property named "index", which conflicts with SQL Logger, because it tries to create a column named "index", which is a reserved word. Could that be modified to sunIndex or something?

Interesting. I'm using SQL Logger (with the PostgrSQL backend) and have no trouble. Which backend are you using?

The SQL standard has a perfectly fine way to say "this may look like a keyword but it's just a name" (put it in quotes), so it's likely that the particular backend you're using is either failing to quote identifiers or is missing "index" in some table of keywords-to-escape. (In other words, it sounds like an SQL Logger issue.)

If that doesn't work out for you, I'll be happy to rename "index".

Cheers
-- perry

Posted on
Sat Feb 15, 2014 3:37 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Cynical Weather

If your analysis is correct, then technically it's not a SQL Logger plugin issue, but rather a SQLite issue (which is the only other SQL database option besides PostgreSQL)… :)

I just tried creating a table in SQLite using SQLiteManager and it seemed to work - maybe the problem is with the Python SQLite libraries.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Feb 16, 2014 1:08 pm
rhanson offline
Posts: 192
Joined: Apr 30, 2013

Re: Cynical Weather

Yes, SQLite.

The error that popped up was this:

Code: Select all
2014-02-15 10:42:22   SQL Logger   creating table device_history_1176915653 for "new device 1"
2014-02-15 10:42:22   SQL Logger Error   exception trying to create table device_history_1176915653 ("new device 1")
2014-02-15 10:42:22   SQL Logger Error   near "index": syntax error
2014-02-15 10:42:22   SQL Logger Error   CREATE TABLE device_history_1176915653 ( id #AUTO_INCR_KEY, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, azimuth INTEGER, height INTEGER, index INTEGER);
2014-02-15 10:42:22   SQL Logger Error   exception trying to insert row into table device_history_1176915653 ("new device 1") -- unable to modify table
2014-02-15 10:42:22   SQL Logger Error   near "index": syntax error
2014-02-15 10:42:22   SQL Logger Error   INSERT INTO device_history_1176915653 (azimuth, height, index) VALUES (%s, %s, %s);


Notice I said there was a "conflict". I'm not placing the blame in any particular direction. haha :-)

Who is online

Users browsing this forum: No registered users and 4 guests