boekweg wrote:Thanks for you help, I do get the same error message. Also if I change the int for a str
theVar1 = indigo.variables[258092774].value
theVar2 = indigo.variables[1797074476].value
theVar1Float = float(theVar1.split(' ')[0]) # splits the field on a space and you access the first element in the resultant list [0] and converts it to a float as your field has a decimal point
theVar2Float = float(theVar2.split(' ')[0])
theDiffFloat = theVar1Float - theVar2Float
theDiffString = str('%.3f kWh' % theDiff) # gives you 3 decimal places
indigo.variable.updateValue(783072313, theDiffString)
# Listing variables, subtracting, updating variable
theVar1 = indigo.variables[392364558]
theVar2 = indigo.variables[908595901]
theDif =str(int(theVar1.value) - int(theVar2.value))
indigo.variable.updateValue(1505943804, ((theDif)))
Script Error embedded script: invalid literal for int() with base 10: '52.3'
Script Error Exception Traceback (most recent call shown last):
embedded script, line 6, at top level
ValueError: invalid literal for int() with base 10: '52.3'
# Listing variables, subtracting, updating variable
theVar1 = indigo.variables[392364558]
theVar2 = indigo.variables[908595901]
theDif =str(float(theVar1.value) - float(theVar2.value))
indigo.variable.updateValue(1505943804, theDif)
>>> a = '52.3'
>>> print(int(a))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '52.3'
>>> a = 52.3
>>> print(int(a))
52
>>> a = '52'
>>> print(int(a))
52
Users browsing this forum: No registered users and 7 guests