Page 1 of 1
Convert dictionary results to integer
Posted: Mon Apr 27, 2015 2:33 pm
by yokel22
I'm trying to get a variable from a payload to run in the nest plugin. I have everything parsed out fine but it tells me it's an invalid format. The script works fine when i substitute my variable with a integer. I was hoping someone here might be able to tell me what i'm doing wrong.
Code: Select all
p = str(eg.event.payload)
print eg.event.string
print eg.event.payload
p = p.split(',')
d = p[1].lstrip("[' ")
id = d.rstrip("'")
t = p[2].lstrip(" ' ")
temp = t.rstrip("'] ")
eg.globals.temp2 = temp
print eg.globals.temp2
eg.plugins.Nest.set_temp('temp2', 'id')
Re: Convert dictionary results to integer
Posted: Mon Apr 27, 2015 5:27 pm
by Pako
Try this:
Code: Select all
p = eg.event.payload
print eg.event.string
print repr(p) #format check
id = str(p[1])
temp = int(p[2])
eg.globals.temp2 = temp
print eg.globals.temp2
#eg.plugins.Nest.set_temp('temp2', 'id')
eg.plugins.Nest.set_temp(temp, id)
Pako
Re: Convert dictionary results to integer
Posted: Mon Apr 27, 2015 5:48 pm
by yokel22
Pako,
Thanks for your help. This is what it's kicking back on your script.
Re: Convert dictionary results to integer
Posted: Mon Apr 27, 2015 7:45 pm
by Pako
I do not know Nest plugin (I actually have no idea what it is), so I do not know how you have to pass arguments.
However it is clear that the problem is solved with the parsing.
Pako
Re: Convert dictionary results to integer
Posted: Mon Apr 27, 2015 8:49 pm
by yokel22
I appreciate any help i can get. I probably should've posted in the nest plugin section. I just wasn't sure if it was a nest specific thing or not. thanks.
Re: Convert dictionary results to integer
Posted: Mon Apr 27, 2015 10:58 pm
by Dragon470
hello yokel22,
I actually am the creator of the Nest plugin, while I don't update it anymore do to their newer terms of service, I can help solve this really easily.
You did everything correct up to your last line. By placing the 'temp' and 'id' it was not getting the value in the variable. Like in what Pako had.
eg.plugins.Nest.set_temp(temp, id)
works just fine with the incoming string you had.
Re: Convert dictionary results to integer
Posted: Mon Apr 27, 2015 11:16 pm
by yokel22
Thank you both. I feel silly having to ask these kinds of questions. Sure enough, it's working beautifully now. I could of swore i was passing the user id through.