Error: Invalid literal for int() with base 10:
Error: Invalid literal for int() with base 10:
I am getting this error:
Variable Devices Error exception in deviceStartComm(Temperature (Master-AWAir)): invalid literal for int() with base 10: ''
Variable Devices Error Error in plugin execution ServerReplacedElem:
Traceback (most recent call last):
File "plugin.py", line 150, in variableUpdated
ValueError: invalid literal for int() with base 10: ''
The variable is a temperature reading (example 75.6). The variable name is "awair_Master_0_temp"
Ideas?
Thank you!
JP
Variable Devices Error exception in deviceStartComm(Temperature (Master-AWAir)): invalid literal for int() with base 10: ''
Variable Devices Error Error in plugin execution ServerReplacedElem:
Traceback (most recent call last):
File "plugin.py", line 150, in variableUpdated
ValueError: invalid literal for int() with base 10: ''
The variable is a temperature reading (example 75.6). The variable name is "awair_Master_0_temp"
Ideas?
Thank you!
JP
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Error: Invalid literal for int() with base 10:
Something is trying to convert an empty string to an integer. Which doesn't work. Are you sure that variable has an appropriate value in it?
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: Error: Invalid literal for int() with base 10:
I think so. See image.
- Attachments
-
- Screen Shot 2020-11-12 at 11.02.18 AM.png (185.04 KiB) Viewed 5100 times
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Error: Invalid literal for int() with base 10:
How is that variable getting set? Is there a script that's possibly clearing it first, then setting the new value?
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: Error: Invalid literal for int() with base 10:
Yes, I am using a script. This is the code I am suing to set the value:
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_0_value"]) ,1)
indigo.variable.updateValue(awairVarID, value= str(varValue))
awairDevice is a GhostXML feed.
awairVarID is the variable I set and trying to use with Variable Device
Makes sense?
JP
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_0_value"]) ,1)
indigo.variable.updateValue(awairVarID, value= str(varValue))
awairDevice is a GhostXML feed.
awairVarID is the variable I set and trying to use with Variable Device
Makes sense?
JP
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Error: Invalid literal for int() with base 10:
Yeah, that should work. Any particular reason you're doing a two step device -> variable -> device? I think you could probably use the Masquerade plugin to do it in one step. And maybe avoid this error.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: Error: Invalid literal for int() with base 10:
Because the "interesting folks" at AWAir have an API that changes its orders list as you check for changes in data. That means I must search the values provided for "temp", in the index, then use that value.
This is the full code:
I am not a programmer, so I am sure this code could be much more efficient (if you have any suggestions, it would be appreciated!), but it seems to work. Not sure how to make this work with the Masquerade plugin in this use case.
Any idea what could be causing the problem?
JP
This is the full code:
Code: Select all
#type of value
lookValue = "temp"
# define variable ID
awairVarID = "awair_Master_0_temp"
try:
index0 = str( indigo.devices[awairDevice].states["data_0_sensors_0_comp"] )
index1 = str( indigo.devices[awairDevice].states["data_0_sensors_1_comp"] )
index2 = str( indigo.devices[awairDevice].states["data_0_sensors_2_comp"] )
index3 = str( indigo.devices[awairDevice].states["data_0_sensors_3_comp"] )
index4 = str( indigo.devices[awairDevice].states["data_0_sensors_4_comp"] )
except:
indigo.variable.updateValue("awair_Master_status", value="Could not retreive Master temperature data")
indigo.server.log ("awair_Master_status = " + "Could not retrive Master temperature data")
exit(0)
if (index0 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_0_value"]) ,1)
indigo.variable.updateValue(awairVarID, value= str(varValue))
elif (index1 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_1_value"]) ,1)
indigo.variable.updateValue(awairVarID, value= str(varValue))
elif (index2 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_2_value"]) ,1)
indigo.variable.updateValue(awairVarID, value= str(varValue))
elif (index3 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_3_value"]) ,1)
indigo.variable.updateValue(awairVarID, value= str(varValue))
else:
varValue = round(float(indigo.devices[awairDevice].states["data_0_sensors_4_value"]) ,1)
indigo.variable.updateValue(awairVarID, value= str(varValue))
Any idea what could be causing the problem?
JP
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Error: Invalid literal for int() with base 10:
Depending on the input conditions, that script could fail silently. Try this:
Code: Select all
#type of value
lookValue = "temp"
# define variable ID
awairVarID = "awair_Master_0_temp"
try:
index0 = str( indigo.devices[awairDevice].states["data_0_sensors_0_comp"] )
index1 = str( indigo.devices[awairDevice].states["data_0_sensors_1_comp"] )
index2 = str( indigo.devices[awairDevice].states["data_0_sensors_2_comp"] )
index3 = str( indigo.devices[awairDevice].states["data_0_sensors_3_comp"] )
index4 = str( indigo.devices[awairDevice].states["data_0_sensors_4_comp"] )
except:
indigo.variable.updateValue("awair_Master_status", value="Could not retrieve Master temperature data")
indigo.variable.updateValue(awairVarID, value="0.0")
indigo.server.log ("awair_Master_status = " + "Could not retrieve Master temperature data")
exit(0)
if (index0 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_0_value"]) ,1)
elif (index1 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_1_value"]) ,1)
elif (index2 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_2_value"]) ,1)
elif (index3 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_3_value"]) ,1)
elif (index4 == lookValue):
varValue = round( float(indigo.devices[awairDevice].states["data_0_sensors_4_value"]) ,1)
else:
indigo.variable.updateValue("awair_Master_status", value="lookValue not found")
indigo.server.log ("awair_Master_status = " + "lookValue not found")
varValue = 0.0
indigo.variable.updateValue(awairVarID, value= str(varValue))
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Error: Invalid literal for int() with base 10:
That's still not how I would write it if I were starting from scratch, but it's better. Honestly, given that the data returned doesn't work well with GhostXML, you're probably better off just doing the whole thing in a single Python script and not using the plugin at all.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: Error: Invalid literal for int() with base 10:
Thank you for the code suggestion!
Let me try, as that was the first way I tried to address the problem. However, I stopped because had not realized the ordered list kept changing and I thought the incorrect values were my code.
Will report if that takes care of the Variable Device issues.
Again, thank you for all the help and plugins.
JP
Let me try, as that was the first way I tried to address the problem. However, I stopped because had not realized the ordered list kept changing and I thought the incorrect values were my code.
Will report if that takes care of the Variable Device issues.
Again, thank you for all the help and plugins.
JP
Re: Error: Invalid literal for int() with base 10:
Actually, that error is nothing to do with your script (although everything Joe has said is correct).roquej wrote:I am getting this error:
Variable Devices Error exception in deviceStartComm(Temperature (Master-AWAir)): invalid literal for int() with base 10: ''
Variable Devices Error Error in plugin execution ServerReplacedElem:
Traceback (most recent call last):
File "plugin.py", line 150, in variableUpdated
ValueError: invalid literal for int() with base 10: ''
In your "Variable Device" device, you need to select a valid variable in the "State to display: " box. I suspect it's either blank or an old variable, as my code is returning '' which is the (bad choice of) default value.
I'll fix the plugin to default to 0 instead of '' so that line of code doesn't fail.
Peter
Re: Error: Invalid literal for int() with base 10:
First, I converted everything to using a script and that works great.
Second, I installed 1.05 and the problem solved
Thank all!
JP
Sent from my iPad using Tapatalk Pro
Second, I installed 1.05 and the problem solved
Thank all!
JP
Sent from my iPad using Tapatalk Pro