JimM has been helping me on the Weather Display forums get my weather station to talk to my Mac, and then output a report that can be turned into Indigo variables. He wrote an applescript that takes the txt file and populates Indigo variables with it, but it doesn't work for me. I'm wondering if anyone might be able to assist...

I've cut down the files to show just one variable. Weather Display updates this indigoreport.txt file every 5 minutes:

OutsideHum:96<br>

This is the applescript in a time/date action:

set filePath to "/Library/Application Support/wdisplay/webfiles/indigoreport.txt"

--Outside Humidity set bolIn to "OutsideHum:"set eolIn to "<br>"set varHum to "wxOutsideHum"

JimM has been helping me on the Weather Display forums get my weather station to talk to my Mac, and then output a report that can be turned into Indigo variables. He wrote an applescript that takes the txt file and populates Indigo variables with it, but it doesn't work for me. I'm wondering if anyone might be able to assist...

I've cut down the files to show just one variable. Weather Display updates this indigoreport.txt file every 5 minutes:

OutsideHum:96<br>

This is the applescript in a time/date action:

set filePath to "/Library/Application Support/wdisplay/webfiles/indigoreport.txt"

--Outside Humidity set bolIn to "OutsideHum:"set eolIn to "<br>"set varHum to "wxOutsideHum"

repeat with theLine in theLines set AppleScript's text item delimiters to ":" set theVarName to text item 1 of theLine set theVarValueAndTrash to text item 2 of theLine set AppleScript's text item delimiters to "<" set theVarValue to text item 1 of theVarValueAndTrash tell application "IndigoServer" set indigoVarName to "wx" & theVarName if not (exists variable indigoVarName) then make new variable with properties {name:indigoVarName, value:theVarValue} else set value of variable indigoVarName to theVarValue end if end tellend repeat

The nice thing about this script is that it will create the variables if they don't already exist by prepending "wx" to the variable name from the file. I don't have a full version of the file to test with, but it should work as long as there are no odd characters in the variable name (no spaces for instance). The script would be even easier if the "<br>" weren't appended to each line (i.e. if it were just "VarName:Value"), but this works fine.

I wouldn't make this an embedded script however - just make it a script file and call it from your time/date action. That way, if something goes wrong, it doesn't hang up the server.

set AppleScript's text item delimiters to ":"repeat with theLine in theLines if (theLine as string) is not equal to "" then set theVarName to text item 1 of theLine set theVarValue to text item 2 of theLine tell application "IndigoServer" set indigoVarName to "wx" & theVarName if not (exists variable indigoVarName) then make new variable with properties {name:indigoVarName, value:theVarValue} else set value of variable indigoVarName to theVarValue end if end tell end ifend repeat

Its been a while since I have been around these parts (couldn't find the password lol)

Jay, I really like your script. namely because it auto names the vars in Indigo whereas the one I have declares them and the user must create them, but they are only created once. The way the indigoreport.txt is set up in Weather Display though my script might help due to the naming conventions in the text file.

I believe bbruck's issue is that you may be naming the Indigo variable to the applescript var (from the script) instead of the wx prefixed variable, try that and see. ie varOut corresponds to and updates wxOutsideTemp in Indigo

Here is my script commented, has been running for 19 months now every 2 minutes so very robust and uses a do shell script command to read the indigoreport.txt in from Weather Display.

NOTE that credit for this script (and the past 18 months of reliable integration with my Weather Display!) goes to CharlieParker of this forum) Thanks Charlie!

set filePath to "/Library/WebServer/Documents/Hosts/HRMWeather/indigoreport.txt"

--SECTION ONE - Define the applescript variables to hold the values for beginning of line, eol, and the Indigo var)--Outside Temp set bolOut to "OutsideTemp:" -- ----------beginning of line charactersset eolOut to "<br>" ----------------------------end of line charactersset varOut to "wxOutsideTemp" -----------applescript variable to hold Indigo variable

--Outside Humidity set bolIn to "OutsideHum:"set eolIn to "<br>"set varHum to "wxOutsideHum"

--Windspeed set bolWin to "WindSpeed:"set eolWin to "<br>"set varWin to "wxWindSpeed"

--GustSpeed: set bolGus to "WindGustSpeed:"set eolGus to "<br>"set varGus to "wxWindGustSpeed"

--Today's Rain set bolDra to "RainToday:"set eolDra to "<br>"set varDra to "wxRainToday"

--#Days without rain set bolDnr to "DayswithnoRain:"set eolDnr to "<br>"set varDnr to "wxDayswithnoRain"

--Rain Last7 Days set bolRlw to "RainLast7Days:"set eolRlw to "<br>"set varRlw to "wxRainLast7Days"

-- Weather Report from the Airportset bolWrm to "WeatherReportMetar:"set eolWrm to "<br>"set varWrm to "wxWeatherReportMetar"

-- Weather Report from the Stationset bolWst to "WeatherConditionsStation:"set eolWst to "<br>"set varWst to "wxWeatherConditionsStation"

Its been a while since I have been around these parts (couldn't find the password lol)

Jay, I really like your script. namely because it auto names the vars in Indigo whereas the one I have declares them and the user must create them, but they are only created once. The way the indigoreport.txt is set up in Weather Display though my script might help due to the naming conventions in the text file.

I believe bbruck's issue is that you may be naming the Indigo variable to the applescript var (from the script) instead of the wx prefixed variable, try that and see. ie varOut corresponds to and updates wxOutsideTemp in Indigo

Here is my script commented, has been running for 19 months now every 2 minutes so very robust and uses a do shell script command to read the indigoreport.txt in from Weather Display.

NOTE that credit for this script (and the past 18 months of reliable integration with my Weather Display!) goes to CharlieParker of this forum) Thanks Charlie!

set filePath to "/Library/WebServer/Documents/Hosts/HRMWeather/indigoreport.txt"

--SECTION ONE - Define the applescript variables to hold the values for beginning of line, eol, and the Indigo var)--Outside Temp set bolOut to "OutsideTemp:" -- ----------beginning of line charactersset eolOut to "<br>" ----------------------------end of line charactersset varOut to "wxOutsideTemp" -----------applescript variable to hold Indigo variable

--Outside Humidity set bolIn to "OutsideHum:"set eolIn to "<br>"set varHum to "wxOutsideHum"

--Windspeed set bolWin to "WindSpeed:"set eolWin to "<br>"set varWin to "wxWindSpeed"

--GustSpeed: set bolGus to "WindGustSpeed:"set eolGus to "<br>"set varGus to "wxWindGustSpeed"

--Today's Rain set bolDra to "RainToday:"set eolDra to "<br>"set varDra to "wxRainToday"

--#Days without rain set bolDnr to "DayswithnoRain:"set eolDnr to "<br>"set varDnr to "wxDayswithnoRain"

--Rain Last7 Days set bolRlw to "RainLast7Days:"set eolRlw to "<br>"set varRlw to "wxRainLast7Days"

-- Weather Report from the Airportset bolWrm to "WeatherReportMetar:"set eolWrm to "<br>"set varWrm to "wxWeatherReportMetar"

-- Weather Report from the Stationset bolWst to "WeatherConditionsStation:"set eolWst to "<br>"set varWst to "wxWeatherConditionsStation"

Now I'm going to give Jay's a try to see if it's as robust, love it's simplicity... will let you know how it does with the Weather Display file.

All the best

Jim

Thanks Jim - I also tried your script and the sed command wasn't returning anything, which is why switched to all AppleScript. I wonder if an OS (and sed) version difference is the issue? I was trying it on 10.6.2.

Anyway, I literally tossed that script together early this morning, so it may not be super robust (it would probably fail if the file didn't exist for instance). The first version also failed because of a blank line, but that's fixed now. Anyway, I'm sure if there are any other issues they could be fixed pretty quickly.

Jay thanks for putting the script together works great 100% a lot better than my attempt

If any of you are familiar enough with Weather Display to know if it can post values to a custom URL, then an even more elegant solution is something like I did with LWC - it posts data to an IWS plugin I wrote every 5 minutes. The plugin then populates the data into Indigo variables. It's nice cause there's no intermediary file involved, and you only have to worry about setting the software to "push" the values (vs a push to file and then a pull from the file to Indigo). The LWC plugin is pretty simple really - if WD can do either POST or GET data to a URL then it should be pretty simple to use it as a pattern for a WD plugin. I looked, but I didn't see that ability in WD, although I will admit that the UI totally bewilders me so I could be missing it.

Just a comment. I would think that 5 minutes would keep me away from a plugin. That became a big issue here many times in unstable weather here and now I actually run my applescript every 1 minute in the winter as of late, but probably will return to 2 minutes in the summer months.

Also, a big issue will be what tags we can send over to Indigo through a plugin. The basics is boring. I want to know things like rain last 7 days, all time rain rate, Fire Weather Index, as I do now and show on the Indigo page with the applescript. There are 2000 tags in Weather Display, so this would be important to have the capability to receive any of them. That's what separates WD from the rest.

WD does have that capability in the Windows version now, according to Windy the developer over there (which is also running on many Macs through Fusion/Parallels although I prefer the Mac flavor ). He says it can be added to the Mac. I suggested a Control Panel just for configing info to Indigo. You should contact him. Seeing what he has written in due to user requests, I'm betting this is doable.

Thanks Jim - I also tried your script and the sed command wasn't returning anything, which is why switched to all AppleScript. I wonder if an OS (and sed) version difference is the issue? I was trying it on 10.6.2.

Hi Jay, I am on 10.6.2 (Snow Leopard) as well.

I used your script this morning, and first of all love it! Agreed though robustness may be an issue. If you could reset the text item delimiters at the end of the tell it would be a good thing

The "sed" command is unchanged between Os's. I wonder out loud if there are extra characters finding there way into the code through posting. You may want to check and ensure the Set commands in the bottom section (per my most recent version) are are on single lines in the embed window (stretching the window to confirm.) I found the shell script command to be 100% robust and reliable and I think that is the key, especially with Applescript's Snow leopard bug, but that only seems to involve the finder app/system events, so it doesn't apply to your script.

I also have to set up each Indigo variable to the name above (prefixed with wx in the applescript)

That said, bbruck, I would highly recommend this script, all you would do is take out the <br> in the indigo.txt file I used as line endings and save it. The rest is automatic with Jay's script. indigoreport.txt will be created, and the variables populated. A plum with Jay's script is you would just add whatever tags you want to go to Indigo, to the indigo.txt file, and they would auto appear in Indigo variables whether you set them up or not. ... whereas with mine there is maintenance required to set up/modify new vars.

Jay, if you could revise the script to reset delimeters to default ( I can't remember the command right off the tip of my head) I will test for another 24 hours, then will this over at the WD forum on success, in my Applescript/Indigo posts and will suggest replacing mine with this script.

Just a comment. I would think that 5 minutes would keep me away from a plugin. That became a big issue here many times in unstable weather here and now I actually run my applescript every 1 minute in the winter as of late, but probably will return to 2 minutes in the summer months.

I picked 5 minutes because it suited my needs - but that's the beauty of an IWS plugin - the polling is controlled by the sender, so i could configure LWC to send it every 1 minute.

I used your script this morning, and first of all love it! Agreed though robustness may be an issue. If you could reset the text item delimiters at the end of the tell it would be a good thing

There are two camps about this - one for and one against. I am a member of the latter for several reasons: 1) you should NEVER assume that they are what you want them to be because the default is "" - that's right, none. So, without setting them, you're actually just pulling apart each character. And 2) only scripts that run in the same instance of an AppleScript are effected so it doesn't do anything useful to reset them.

There are two camps about this - one for and one against. I am a member of the latter for several reasons: 1) you should NEVER assume that they are what you want them to be because the default is "" - that's right, none. So, without setting them, you're actually just pulling apart each character. And 2) only scripts that run in the same instance of an AppleScript are effected so it doesn't do anything useful to reset them.

AHA! I never knew about #2, thought it was a global thing. Thanks for clearing that up.

jay wrote:

I picked 5 minutes because it suited my needs - but that's the beauty of an IWS plugin - the polling is controlled by the sender, so i could configure LWC to send it every 1 minute.

Do you think it could be configured either at the WD end (via POST) or in Indigo as I'm sure users would have many different reasons as I for wanting different intervals. Also, just for my own info, WD does a lot of posting to other websites both through file transfer and through a URL which the user actually selects some parameters as well as the timing, so could the plugin be like a "listener" that once active, just listens for posts from WD to a port (tcp or otherwise) then sets and or creates/sets the variable? or am I way off base here.