Page 2 of 2
Re: Can anyone lend a hand with payloads please?
Posted: Tue May 02, 2017 7:45 pm
by jonib
loveleejohn wrote:Got ya. Here's what the plugin outputs to the log when I use the "dump result to log" action.
OK, so it returns a custom object, I assume how to access the information is documented somewhere maybe the plugins support thread.
jonib
Re: Can anyone lend a hand with payloads please?
Posted: Tue May 02, 2017 8:12 pm
by loveleejohn
Thanks for the help on it jonib. I wanted to learn about payloads in general here but I'm also working out the fineprint with kg over here:
viewtopic.php?f=9&t=8203&start=60
I didn't mean to end up with this topic blending into the plugin but it was the most current example. I see that kg is back over there now so I'll see if I can get his help since this you have suggested that this plugin uses custom objects. Thanks for the help though!

Re: Can anyone lend a hand with payloads please?
Posted: Wed May 03, 2017 4:15 am
by kgschlosser
loveleejohn wrote: Now it seems that the weather plugin's payload is a dictionary if I'm understanding correctly.
This is a double edged answer. and the answer is both a yes and a no at the same time. not sure if ya like that answer. and that is why i stated
kgschlosser wrote:there is more to it then that but as a starting point this will get you where you need to go.
in a previous post.
The payload is actually a python object. and that python object can be used in the typical python object manner or as a dictionary
so if you wanted to get the temperature you can do this.
weather_object.temp
or you can do this
weather_object['temp_f']
so the object acts like a dictionary but it reality it is not.
now there is something to notice here... there is no _f when accessing the objects attribute for the temp. this is because the code is done in such a way that it will automatically return temp_c or temp_f depending on if you specified Imperial or Metric in the action. when accessing the information like a dict it is really intended for a more advanced user so a lot of the "fluff" doesn't carry over into it. this is so that if you set the action to return metric data but for some reason you wanted to display the imperial you have a way to go about it.
Re: Can anyone lend a hand with payloads please?
Posted: Thu May 04, 2017 6:25 pm
by loveleejohn
the answer is both a yes and a no at the same time.
Now even the code is acting like a politician?!

Just kidding. I will try to keep that in mind as I experiement with your plugin kg. Thanks!
Re: Can anyone lend a hand with payloads please?
Posted: Mon May 08, 2017 2:22 pm
by kgschlosser
well that is one of the really cool thing about python. everything in it is an object. and it's just a series of methods (functions in a class) that dictate what "type" of object it is. whether it is an integer, dictionary, list. You could almost create a class that is all of them at the same time. almost... there are some data objects that share methods but pass different data to them. Actually I have been trying to bend that a little bit for a cool feature that might be added to EG some day. it's proving to be very difficult. and just as i was typing this the thought crossed my mind about how I can possibly handle it. But that is what makes python a fantastic programming language is it's ability to change as it is actually running. being so dynamic makes it hard but also easy at the same time. as an example... take a look at eg.result. at any given point while EG is running it could be any data type. it's always changing. that's what makes it easy is because it can change (this is not the case in other languages) but hard because you never know what type it is going to be next .
Re: Can anyone lend a hand with payloads please?
Posted: Sun May 14, 2017 5:38 pm
by loveleejohn
Yep it's that element of suprise that is making me lose my hair! Lol. Thanks for the hints though.
