Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Convert dictionary results to integer

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Convert dictionary results to integer

Post 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')
Attachments
EG python parse.png
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Convert dictionary results to integer

Post 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
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Convert dictionary results to integer

Post by yokel22 »

Pako,

Thanks for your help. This is what it's kicking back on your script.
Attachments
pako.jpg
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Convert dictionary results to integer

Post 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
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Convert dictionary results to integer

Post 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.
Dragon470
Experienced User
Posts: 205
Joined: Thu Feb 10, 2011 2:16 am

Re: Convert dictionary results to integer

Post 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.
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Convert dictionary results to integer

Post 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.
Post Reply