loafbread wrote:That's it. Thanks. Its works on all three stations I track.
Good deal. Glad it's working for you.
Cheers!
loafbread wrote:That's it. Thanks. Its works on all three stations I track.
import re
string = "Partly cloudy skies. A stray shower or thunderstorm is possible. Low 62F. Winds ENE at 5 to 10 mph." # This will come from the device state foreText1
def fixTemp(match):
return match.group(1)
def fixWind(match):
wind_dict = {'N': 'north', 'NNE': 'north northeast', 'NE': 'northeast', 'ENE': 'east northeast', 'E': 'east', 'ESE': 'east southeast', 'SE': 'southeast',
'SSE': 'south southeast', 'S': 'south', 'SSW': 'south southwest', 'SW': 'southwest', 'WSW': 'west southwest', 'W': 'west',
'WNW': 'west northwest', 'NW': 'northwest', 'NNW': 'north northwest'}
match = match.group(1).replace(' ', '')
return u" {0} ".format(wind_dict[match])
string_1 = re.sub(r'([0-9]+)([F|C])', fixTemp, string)
string_2 = re.sub(r'( [NESW]+ )', fixWind, string_1)
print(string_2) # This will become a save to variable statement.
import re
dev = indigo.devices[1149686816]
string = dev.states["foreText1"]
def fixTemp(match):
temp = float(match.group(1)) # Note this new bit covers the request to round the temperature.
temp = round(temp, 0)
temp = int(temp)
return str(temp)
def fixWind(match):
wind_dict = {'N': 'north', 'NNE': 'north northeast', 'NE': 'northeast', 'ENE': 'east northeast', 'E': 'east', 'ESE': 'east southeast', 'SE': 'southeast',
'SSE': 'south southeast', 'S': 'south', 'SSW': 'south southwest', 'SW': 'southwest', 'WSW': 'west southwest', 'W': 'west',
'WNW': 'west northwest', 'NW': 'northwest', 'NNW': 'north northwest'}
match = match.group(1).replace(' ', '')
return u" {0} ".format(wind_dict[match])
string_1 = re.sub(r'([0-9]+)([F|C])', fixTemp, string)
string_2 = re.sub(r'( [NESW]+ )', fixWind, string_1)
indigo.variable.updateValue(1308289177, string_2)
wideglidejrp wrote:You said, "an embedded script window instead of using the Python shell." I am catching on, but missing something really basic. I actually did use an embedded script window. The reason for the Python shell was so I could see the results of the code by printing variables. How do I do that in the embedded script window? I.E. I type print "Hello, world" in the window, where does the result get displayed? It does not appear in the log.
wideglidejrp wrote:Still getting indentation error...
wideglidejrp wrote:I repasted the two indented statements and that fixed the error but now getting an error with the strings. Strange. I wonder if this has anything to do with me using vnc from another Mac on the LAN to the one running Indigo.
import re
dev = indigo.devices[1149686816]
string = dev.states["foreText1"]
def fixTemp(match):
temp = float(match.group(1)) # Note this new bit covers the request to round the temperature.
temp = round(temp, 0)
temp = int(temp)
return str(temp)
def fixWind(match):
wind_dict = {'N': 'north', 'NNE': 'north northeast', 'NE': 'northeast', 'ENE': 'east northeast', 'E': 'east', 'ESE': 'east southeast', 'SE': 'southeast',
'SSE': 'south southeast', 'S': 'south', 'SSW': 'south southwest', 'SW': 'southwest', 'WSW': 'west southwest', 'W': 'west',
'WNW': 'west northwest', 'NW': 'northwest', 'NNW': 'north northwest'}
match = match.group(1).replace(' ', '')
return u" {0} ".format(wind_dict[match])
string_1 = re.sub(r'([0-9]+)([F|C])', fixTemp, string)
string_2 = re.sub(r'( [NESW]+ )', fixWind, string_1)
indigo.variable.updateValue(1308289177, string_2)
roquej wrote:Upgrade to the latest version as I am looking to lower the CPU load on the Indigo server. Keeping my fingers crossed. FYI, getting the follow error:
Started plugin "WUnderground 1.1.9"
WUnderground Error Problem parsing 10-day forecast data. Error: (Line 1798 ('key windUnits not found in dict')
JP
Users browsing this forum: No registered users and 6 guests