Trixology
WeatherCat => WeatherCat Web Templates => Topic started by: jenkins007 on December 11, 2012, 01:58:48 PM
-
I am using Mac 10.7.5 and WeatherCat 1.0.2. I am a long time user of LWC and now WeatherCat. I use it to get current weather information from my sensor array (Davis Pro II) into my home automation system (Indigo). The variables are used in many different areas including turning heat lamps on/off for the chicken coup as well as thermostats for window units.
The Custom Web pages (Ajaxeline AJAX and PHP template) look excellent and would like to use them, but the information needs to get into the Indigo variables also. I am a software tester, not a programmer. The current script being used to import the variables into Indigo is a python script, while the templates use PHP.
####################
## IMPORTS
import cherrypy
from cherrypy import _cperror
from indigopy import indigoconn as ic
from indigopy import indigodb as idb
from indigopy.basereqhandler import BaseRequestHandler, kTrueStr, kFalseStr, kEmptyStr, kTextPageStr, kHtmlPageStr, kXmlPageStr
####################
# Optional hook to provide a plugin name (will be shown in Event Log)
def PlugInName():
return u"LWC Plugin"
# Optional hook called when the IndigoWebServer first connects to IndigoServer
def IndigoConnected():
pass
# Optional hook called when the IndigoWebServer disconnect from IndigoServer
def IndigoDisconnected():
pass
####################
# here to supress the log message
def NullLog(logMessage):
pass
####################
class MyRequestHandler(BaseRequestHandler):
""" Handles HTTP page requests. """
####################
def __init__(self, logFunc, debugLogFunc):
BaseRequestHandler.__init__(self, logFunc, debugLogFunc)
####################
def index(self):
# Push a log message to Indigo's Event Log window.
logmessage = "LWC Custom CGI URL: http://makomelserver/lwc/importData?\n\nUnlike the LWC example, you don't need to add an ID or PASSWORD parameter since the IWS is already has protection"
self._Log(logmessage)
# Set the HTTP response header Content-Type to show that we're going to be returning plain text (not HTML)
cherrypy.response.headers['Content-Type'] = 'text/plain'
# Return the actual content part of the HTTP message
return logmessage
index.exposed = True # exposed = True must be set for handler func to be called
####################
def importData(self, **params):
cherrypy.response.headers['Content-Type'] = 'text/plain'
saveLogFunc = cherrypy.server.indigoDb._Log
try:
cherrypy.server.indigoDb._Log = NullLog
for param, value in cherrypy.request.params.items():
if param != "action" and param != "ID" and param != "PASSWORD":
param = "LWC_" + param
cherrypy.server.indigoDb.VariableSetValue(cherrypy.server.indigoConn, param, value)
finally:
cherrypy.server.indigoDb._Log = saveLogFunc
# Push the log message to Indigo's Event Log window.
self._Log("LWC Weather Data Updated")
# Return the actual content part of the HTTP message
return "OK"
importData.exposed = True # exposed = True must be set for handler func to be called
I would like to use the Ajaxeline AJAX and PHP template and get the variables in Indigo updated realtime. I don't mind if the variables change names or some get added. Currently WeatherCat is pointed to the import data object to get the variables updated. I don't know if WeatherCat can be pointed to 2 different directories to update each or the perl script be converted and added to the PHP template. Is this a simple request?
-
Hi and welcome to the forum!
WeatherCat can process files from multiple directories via the 'Additional Files' feature found in the Custom Web preferences - these can come from any location and have independent processing times associated with them. I don't know if it helps your situation, but it might be worth looking at.
-
Getting closer. I added the submit_Weather.php and the WCTag.php files as the additional files (I removed the user ID and Password loops on the submit_weather.php file).
The WCTag.php. file gets populated with all the details of my weather station and the graphs and almanac appear fine on the web page. But the first 4 rows of the web page do not show. Those show the data in the currdata.xml file. WeatherCat doesn't parse that file (i've tried). How does that file get populated with the data from the WCTag.php file?
-
Getting closer. I added the submit_Weather.php and the WCTag.php files as the additional files (I removed the user ID and Password loops on the submit_weather.php file).
The WCTag.php. file gets populated with all the details of my weather station and the graphs and almanac appear fine on the web page. But the first 4 rows of the web page do not show. Those show the data in the currdata.xml file. WeatherCat doesn't parse that file (i've tried). How does that file get populated with the data from the WCTag.php file?
The cgi is what populates the curdata.xml file and without the user/pw combo, that file won't get populated. I'm about to head out now, but I see what you're after. It should be possible to configure ajaxeline normally and then modify that python script to just parse the curdata.xml file to get the variables you need. There's another indigo script out there that will read your realtime data from wunderground if you use that. It's not the exact same solution that you want here but the end result is essentially the same and it's what I use currently.
I am not a python guy (except writing some scripts for arcpy at work) but I'll take a look at this.
-
Here's the script that will download your data from WU (assuming you use it). If so, then I think this will solve your issues.
http://www.perceptiveautomation.com/filelib/index.php
Click the Miscellaneous link and scroll about 2/3 down and you'll see the Weather Underground script. I'm using it here and it works great.
No changes needed to the templates or anything to get the data you need.
-
Thanks. I am using the Wundergound plugin script to get the weather data into Indigo. It isnt the best solution and it doesn't get all the data, specifically the internal temp. When the internet is down it doesn't work, obviously. But it is a start and works as a temporary solution. Instead of it updating the variables every 2 seconds, it updates a lot slower. But again, I love weather cat and its capabilities. Thanks for the help!
-
Well, I couldn't stand it any longer. It appeared that Wunderground made a maintenance change which rendered the import data into Indigo non-functioning... So I created an XML file with the weather cat tags, and then created an applescript to read the file and populate the Indigo variables. It works good. I couldn't get the XML to loop and automatically read the XML tags. Not sure why that didn't work, but I spent many hours trying. Finally, hardcoding the XML tags worked fine. Looks like it is an Applescript issue, as I tried multiple permutations. I now get more variables into Indigo which makes it easier for my irrigation logic. If anyone wants it, I will be happy to share. I will look at putting it in the Indigo user contribution area.
-
I'd love to have your script. I'm just moving from Weather-Display to WeatherCat and I was using the embedded Indigo stuff in Weather-Display to populate variables in Indigo to make irrigation choices.
Thanks, Bill
-
Welcome aboard Bill! :)
Steve
-
I found out an interesting thing. I have Indigo 4 and it has a Weather-Display plug-in script that was working for me forever. Since I moved over to WeatherCat I thought I'd have to reinvent that wheel. Turns out not.
I went into Indigo and deleted all the WD_xxxxxx variables. Then I went into WeatherCat's Custom CGI preference and put in "http://indigoserver:8176/wd/importData?" and started the custom CGI in WeatherCat and viola! All the data from WeatherCat showed up in Indigo's variable list as "WD_<weathercat tag> = <value>. You get an error one time when it creates a variable to accept data it didn't have before but that's all the pain there is.
I could go into the WD script in Indigo and do a global find and replace of WD for WC but I probably won't.
Bill
-
Welcome Bill. I would be happy to send you the scripts. Using the CGI import also works. I cannot since I upload data to my website and use that functionality for that. My script also picks up many more variables and can easily be tailored using whatever tags you want (since Stu has created it to be very flexible - Thanks Stu!). Where do I send it? There will be 2 files - one that WC updates and another is a script run from Indigo as often as you wish to import that data.