Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Weather Underground Plugin
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
ok here is the latest and greatest
Added a help tab that gives the layout of the plugins data class
Added polling this can be accessed form the plugin config dialog.
Added 2 new actions StartPoll and StopPoll the poll has to already exist for either one of these to work.
I have removed the triggering of an event when an action is called. this is due to the events taking place from the polling
The polling thread window will inform you if you are going to go over 10 requests per minute.
the settings are all pretty self explanatory.
There is one glitch I am still trying to hammer out. the polling idea is so it will trigger an event if something has changed.. while this does work for a string return a jason or ElementTree object. it is not functioning for the plugins data class. if you use the data class it will always trigger an event. I will figure out what the issue is.
but here it is
Added a help tab that gives the layout of the plugins data class
Added polling this can be accessed form the plugin config dialog.
Added 2 new actions StartPoll and StopPoll the poll has to already exist for either one of these to work.
I have removed the triggering of an event when an action is called. this is due to the events taking place from the polling
The polling thread window will inform you if you are going to go over 10 requests per minute.
the settings are all pretty self explanatory.
There is one glitch I am still trying to hammer out. the polling idea is so it will trigger an event if something has changed.. while this does work for a string return a jason or ElementTree object. it is not functioning for the plugins data class. if you use the data class it will always trigger an event. I will figure out what the issue is.
but here it is
- Attachments
-
- WeatherUnderground.1.4b.egplugin
- (25.51 KiB) Downloaded 139 times
Re: Weather Underground Plugin
Sounds awesome. I'll try to get around to really playing with this now that polling events are going. Also, maybe change the placeholder for the api key. I kinda found that confusing how you had the api key url there too. Maybe you were thinking to direct people there to get a key. You could add a link in the config if that was the case. Sorry, just nitpicking.
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
no worries. I was trying to direct people to where to get it. But i guess i can just add it as a link to the config dialog.
I am going to add an option to the polling to either trigger an event every time the poll takes place. or to trigger an event only of the data has changed. This will be in the next release along with the fixed isdirty on the data class
I am going to add an option to the polling to either trigger an event every time the poll takes place. or to trigger an event only of the data has changed. This will be in the next release along with the fixed isdirty on the data class
-
loveleejohn
- Experienced User
- Posts: 133
- Joined: Thu Dec 10, 2015 12:09 am
Re: Weather Underground Plugin
It's great to see this one's still going. I ran away to try to grasp the basics of python and I actually have a few scripts that work in my tree now! lol. That said, for some reason I can't figure out how to do the basic task of printing the current weather conditions in the log with this plugin. It's not your fault kg! I think you've done a great job, I'm just really really slow with Eventghost.
I'll head over to the coding corner and see if someone can help me get my python certificate so I can try this out!
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
lol
no worries
it's very simple actually.. all the actions work this way
so make your action...
then do a dump result to log action.
easy cheezy
the whole thing is set up in such a way that if you do a print eg.result it will automatically convert that data class into a formatted text output.. so if you wanted to display is as an OSD instead you would wrap the result in str() this is what print does internally but if you wanted to make use of the text elsewhere that is the mechanism to do it
Now if you wanted say a specific date for a forecast. you would make the forecast action then create a python script and enter the code below. but changing the date to the date you want
and if you happen to just want the Nighttime forecast
So as another example. if you wanted to dynamically get the forecast for tomorrow.. meaning that when tomorrow comes then tomorrow will be the day after.. if you get my meaning.. this will always give the forecast for the day after the current day.
remember to make your forecast action then add this to a PythonScript below it.
the line if you change the days= to 2 it will give the forecast for the day after tomorrow. and so on and so forth. remember to not exceed the number of days the forecast is for. so a 4 day forcast the most you could set the days= to is 3 and for a 10 day the most you could set it to is 9. This is because today is one of those days in the forecast. and if you wanted to always print the forecast for today then you would simply remove that line.
today is always the day the Script is run on. and tomorrow is always the day after the script is run on.
no worries
it's very simple actually.. all the actions work this way
so make your action...
then do a dump result to log action.
easy cheezy
the whole thing is set up in such a way that if you do a print eg.result it will automatically convert that data class into a formatted text output.. so if you wanted to display is as an OSD instead you would wrap the result in str() this is what print does internally but if you wanted to make use of the text elsewhere that is the mechanism to do it
Code: Select all
str(eg.result)
Code: Select all
print eg.result.May01
Code: Select all
print eg.result.May01.Night
So as another example. if you wanted to dynamically get the forecast for tomorrow.. meaning that when tomorrow comes then tomorrow will be the day after.. if you get my meaning.. this will always give the forecast for the day after the current day.
remember to make your forecast action then add this to a PythonScript below it.
Code: Select all
import datetime
date = datetime.datetime.now()
date += datetime.timedelta(days=1)
forecast_date = date .strftime('%b%d').lower()
print eg.result[forecast_date]
Code: Select all
date += datetime.timedelta(days=1) today is always the day the Script is run on. and tomorrow is always the day after the script is run on.
-
loveleejohn
- Experienced User
- Posts: 133
- Joined: Thu Dec 10, 2015 12:09 am
Re: Weather Underground Plugin
Ok thanks kg! I'm sure you know it'll probably take me a week just to get this to work so I'll let you know how I fare when all the dust has settled. Lol.
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
The data in the forecast can be access in 2 ways. either as an object attribute or as a dictionary. if accessing it as a dictionary then the key always has to be lowercase.
is the same as doing
I set it up this way to make it easier to dynamically grab data. because doing the following is easier to understand and read
then having to do this
Code: Select all
eg.result.May01
Code: Select all
eg.result['may01']
Code: Select all
dynamic_date = 'may01'
forecast = eg.result[dynamic_date]
Code: Select all
dynamic_date = 'may01'
forecast = getattr(eg.result, dynamic_date.title())
-
loveleejohn
- Experienced User
- Posts: 133
- Joined: Thu Dec 10, 2015 12:09 am
Re: Weather Underground Plugin
Someone needs to hide this program from me! Sadly it's not working. I am seeing a lot of red in the log when I copy and paste your code into a new python action that I place right after the original weather underground action within the macro. The main issue is saying something about str having no attribute May01. 
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
What you have to remember also is that if you ask for something like a temperature. and you use the object method of grabbing the data
example for current conditions temperature
it will automatically return the proper unit of measure. so if you told it to use imperial in the action then it will return Fahrenheit
but if you access it using the dictionary method then you will have to use the unit of measure. which changes depending on what action you use. so use the Help thing to show the tree exploded view of the actual data to know what the keys are
this was done so if you needed the data from the opposite of what you selected in the action you can still access it.
example for current conditions temperature
Code: Select all
eg.result.High
but if you access it using the dictionary method then you will have to use the unit of measure. which changes depending on what action you use. so use the Help thing to show the tree exploded view of the actual data to know what the keys are
Code: Select all
eg.result['high']['fahrenheit']
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
go into the action and click on the other tab (can't remember what i named it.) in there is should show you the data. and the proper key names.
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
I gotta get to work tho.. I will check back in a little later maybe an hour or so and see how you made out.
-
loveleejohn
- Experienced User
- Posts: 133
- Joined: Thu Dec 10, 2015 12:09 am
Re: Weather Underground Plugin
No hurries kg! I will have to nibble at this because I am certain the issue is based on my lack of understanding. Hope you have a great time at the job. Cheers for now.
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
LOL my job is at my house. so I don't have to go very far... But have you had any success??
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Weather Underground Plugin
copy and paste this into your tree and see if it runs
and also try this one as well
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-beta6">
<Macro Name="Four Day Forecast" Expanded="True">
<Action>
WeatherUnderground.Forecast(u'CO', u'Evergreen', u'', False, True, False, False)
</Action>
<Action>
EventGhost.DumpResult()
</Action>
</Macro>
</EventGhost>
and also try this one as well
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-beta6">
<Macro Name="Four Day Forecast" Expanded="True">
<Action>
WeatherUnderground.Forecast(u'CO', u'Evergreen', u'', False, True, False, False)
</Action>
<Action>
EventGhost.PythonScript(u'eg.result = eg.result.May01')
</Action>
<Action>
EventGhost.DumpResult()
</Action>
</Macro>
</EventGhost>
-
loveleejohn
- Experienced User
- Posts: 133
- Joined: Thu Dec 10, 2015 12:09 am
Re: Weather Underground Plugin
Must be awesome to work from home. Hiring?! Lol. jk. Anyways I tried your magical button that's always been in eventghost that I of course have never seen until today!
Magically it dumps a complete payload into the log area in eventghost. Now I'm gonna use what I just saw Jonib posts in my other forum post to see if I can pull this together. I think this is gonna be a nifty plugin!
