My iPhone 4 control page

Posted on
Tue Feb 22, 2011 9:33 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

Scotsman: This is a superb weather script. Thank you for your efforts.


I've written a few lines to parse out the text lines for the iphone. Just add the new "day1Period1Line1" etc variables and put this as a second action: embedded applescript in your time date action. Modify the control page to see the full forecast. If someone knows how to make it recognize words instead of splitting them that would be great. Modify the character numbers to fit your screen. I'm using Arial 14.

This has been updated to account for up to 6 lines of text.


Code: Select all
using terms from application "IndigoServer"
   tell application "IndigoServer"
      set day1Period1Forecast to value of variable "Wunderground_Day1Period1TextForecast" as string
      set day1Period2Forecast to value of variable "Wunderground_Day1Period2TextForecast" as string
      
      if length of day1Period1Forecast is less than 91 then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to ""
         set value of variable "day1Period1Line4" to ""
         set value of variable "day1Period1Line5" to ""
         set value of variable "day1Period1Line6" to ""
      end if
      
      if ((length of day1Period1Forecast is greater than 90) and (length of day1Period1Forecast is less than 136)) then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to ""
         set value of variable "day1Period1Line5" to ""
         set value of variable "day1Period1Line6" to ""
      end if
      
      
      if ((length of day1Period1Forecast is greater than 135) and (length of day1Period1Forecast is less than 181)) then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through 135 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters 136 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line5" to ""
         set value of variable "day1Period1Line6" to ""
      end if
      
      if ((length of day1Period1Forecast is greater than 180) and (length of day1Period1Forecast is less than 226)) then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through 135 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters 136 through 180 of day1Period1Forecast) as string
         set value of variable "day1Period1Line5" to (characters 181 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line6" to ""
      end if
      
      if length of day1Period1Forecast is greater than 225 then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through 135 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters 136 through 180 of day1Period1Forecast) as string
         set value of variable "day1Period1Line5" to (characters 181 through 225 of day1Period1Forecast) as string
         set value of variable "day1Period1Line6" to (characters 226 through -1 of day1Period1Forecast) as string
      end if
      
      
      --These are for period 2
      
      if length of day1Period2Forecast is less than 91 then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to ""
         set value of variable "day1Period2Line4" to ""
         set value of variable "day1Period2Line5" to ""
         set value of variable "day1Period2Line6" to ""
      end if
      
      if ((length of day1Period2Forecast is greater than 90) and (length of day1Period2Forecast is less than 136)) then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to ""
         set value of variable "day1Period2Line5" to ""
         set value of variable "day1Period2Line6" to ""
      end if
      
      if ((length of day1Period2Forecast is greater than 135) and (length of day1Period2Forecast is less than 181)) then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through 135 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters 136 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line5" to ""
         set value of variable "day1Period2Line6" to ""
      end if
      
      if ((length of day1Period2Forecast is greater than 180) and (length of day1Period2Forecast is less than 226)) then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through 135 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters 136 through 180 of day1Period2Forecast) as string
         set value of variable "day1Period2Line5" to (characters 181 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line6" to ""
      end if
      
      
      if length of day1Period2Forecast is greater than 225 then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through 135 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters 136 through 180 of day1Period2Forecast) as string
         set value of variable "day1Period2Line5" to (characters 181 through 255 of day1Period2Forecast) as string
         set value of variable "day1Period2Line6" to (characters 226 through -1 of day1Period2Forecast) as string
      end if
      
   end tell
end using terms from






[edit Feb 27, 2011] Corrected a couple of numbers in the less than/greater than statements.
Attachments
Weather Text.tiff
Weather Text.tiff (43.64 KiB) Viewed 8632 times
Last edited by hamw on Tue Mar 01, 2011 6:26 am, edited 4 times in total.

Posted on
Sun Feb 27, 2011 8:55 am
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

Realized that forecasts came in different lengths. Modded the script above to account for up to 5 lines of text.

Again, just change the character numbers to match your text size/screen width.

Edited script Feb 27 as the numbers in the less than/greater than statements were off by a digit.

Posted on
Sun Feb 27, 2011 8:20 pm
scotsman offline
Posts: 66
Joined: Aug 14, 2010
Location: Austin, Texas

Re: My iPhone 4 control page

That's awesome hamw. I was wondering how on earth I could get my forecast variables to split across lines. I look forward to adding that to my page, but also hoping that v.5 is going to fix this problem without Applescript gymnastics.

You asked about my weather icons. I uploaded them to the user contribution library here:

http://www.perceptiveautomation.com/filelib/index.php?id=130

Hope that helps.

Posted on
Sun Feb 27, 2011 9:30 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

Thanks, but it was your script that got me motivated. However, I just got a six line forecast so will have to mod script again..... :roll:

BTW got the icons, they are great.

Posted on
Tue Mar 01, 2011 6:31 am
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

Ok, script is updated for 6 lines of text. Let me know if there are any issues.

BTW I have not looked too closely at the weather script but a lot of times when the day prediction (not the forecast but the little blurb for the six day forecast) says clear, the weather condition lists partly cloudy and that is the icon that is selected. Any ideas? Also, is there a way to set the time zone? The icons remain in night phase well after dawn. For instance the night icon is currently displayed and it is 7:30 AM. May just be Wunderground....

Posted on
Fri Jul 22, 2011 7:24 am
arskrett offline
Posts: 20
Joined: Jul 22, 2011

Re: My iPhone 4 control page

Sounds like great pages, but for some reason I cant get them to show here in the forum? anybody else not seeing them?
are they deleted maybe?

Posted on
Tue Feb 18, 2020 7:57 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

Has anyone updated these forecast line parsings in Python, or is there a plugin that allows a natural text line flow readable forecast for control pages?

Posted on
Thu Feb 20, 2020 1:30 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: My iPhone 4 control page

It won’t take many lines to recreate that properly in python as a trigger and built in script.

Ping me back if nobody gets to it before me, later tonight.


Sent from my iPhone using Tapatalk Pro

Posted on
Thu Feb 20, 2020 9:50 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: My iPhone 4 control page

hamw wrote:
Has anyone updated these forecast line parsings in Python, or is there a plugin that allows a natural text line flow readable forecast for control pages?


Have a look at my Matplotlib plugin. There is a built-in device type that will wrap long lines of text and convert them to PNG files for control pages. You control the number of characters per line, font, color, etc.

Screen Shot 2020-02-20 at 9.49.29 AM.png
Screen Shot 2020-02-20 at 9.49.29 AM.png (156.06 KiB) Viewed 4677 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Feb 28, 2020 4:31 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

That’s a great idea and it works — Thank you! — but the font is itsy-bitsy. Anyway to get a font size in that box that matches the standard control page fonts? Or is there another setting?

Posted on
Fri Feb 28, 2020 4:41 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: My iPhone 4 control page

There's a font size setting in the device configuration--is that not working for you?

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Feb 29, 2020 5:09 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

I was able to increase the font size. Still getting used to it and I think I had to refresh the image. That said, it does not appear to be wrapping. See below... Ignore the text below the refreshing URL box... that's from the previous AppleScript forecast. Any thoughts would be appreciated.
Attachments
Image.jpeg
Image.jpeg (285.16 KiB) Viewed 4239 times

Posted on
Sat Feb 29, 2020 10:04 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: My iPhone 4 control page

Looks like you've got the characters setting set to 1000 characters per line (the help bubble text for that control isn't the most clear). Here's what I have as setting for one of my controls that's meant to be viewed full screen on a non-retinal MacBook Air:

Screen Shot 2020-02-29 at 9.51.51 PM.png
Screen Shot 2020-02-29 at 9.51.51 PM.png (27.75 KiB) Viewed 4224 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Mar 01, 2020 10:40 am
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

My iPhone 4 control page

@hamw I while back I wrote a python script that takes in a string (from an Indigo variable) and a specified height and width in pixels and it outputs a png so the font size, lines, and line breaks perfectly fit. It requires the Pillow library- i’ll go digging for it if that interests you.

Edit: found it: Formatted text alerts pushed to Kindle 7 domopads!
https://r.tapatalk.com/shareLink/topic? ... source=app

Who is online

Users browsing this forum: No registered users and 1 guest