- Code: Select all
x = 'P1VM-34.5'
start = x.find('P1VM') + 4
vol = x[start:]
indigo.variable.updateValue(123456, vol)
or condensed down:
- Code: Select all
x = 'P1VM-34.5'
indigo.variable.updateValue(123456, x[x.find('P1VM') + 4:])
Dave
x = 'P1VM-34.5'
start = x.find('P1VM') + 4
vol = x[start:]
indigo.variable.updateValue(123456, vol)
x = 'P1VM-34.5'
indigo.variable.updateValue(123456, x[x.find('P1VM') + 4:])
DaveL17 wrote:Hi Korey - here's one way to do it (presumes that the value you're looking for will always follow 'P1VM'). You'll need to figure out how to grab the string in the first place...
- Code: Select all
x = 'P1VM-34.5'
start = x.find('P1VM') + 4
vol = x[start:]
indigo.variable.updateValue(123456, vol)
or condensed down:
- Code: Select all
x = 'P1VM-34.5'
indigo.variable.updateValue(123456, x[x.find('P1VM') + 4:])
Dave
>>> x = 'P1VM-34.5'
>>> print x[x.find('P1VM') + 4:]
-34.5
>>> x = 'P1VM-19.0'
>>> print x[x.find('P1VM') + 4:]
-19.0
>>> x = 'P1VM-123456.789'
>>> print x[x.find('P1VM') + 4:]
-123456.789
>>> x = "P1VM Why, oh why didn't I take the blue pill?"
>>> print x[x.find('P1VM') + 4:]
Why, oh why didn't I take the blue pill?
>>>
x = indigo.variables[1959029577].value # Get the value from the variable.
start = x.find('P1VM') + 4
vol = x[start:]
indigo.variable.updateValue(63670514, vol)
Korey wrote:The trigger will now fire, just unsure how to pass the -34.5 to a variable, not the whole P1VM-34.5 as it is currently doing
I assume there is a simple python script I could run in the trigger to remove the prefix?
Thanks Guys.
P1VM(.*)
Perry The Cynic wrote:
Each Recognized Input event has its own variable that you can specify. And by the magic of regular expressions, you can ask for only part of your input string to end up in the variable. Try something likeas the matched string, and the variable should end up set to -34.5 (as a string, since all Indigo variables are strings). The event will still "eat" the whole string; but it'll only store the part between parentheses.
- Code: Select all
P1VM(.*)
Cheers
-- perry
Users browsing this forum: No registered users and 1 guest