Page 1 of 2

AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Tue Oct 02, 2012 9:55 pm
by joaomgcd
Hi.

I've created an EventGhost plugin for the AutoRemote Android app.
AutoRemote is an app that lets you control your Android device from wherever you are via any browser, PC or another Android device. It works as a Tasker plugin, so you can pretty much do anything on your phone remotely.

Tasker can also react to anything and everything, so that makes it the perfect "sensor" for automation.

So, the EventGhost plugin can send and receive messages to and from your phone. What this does is it lets you make your PC and phone work in tandem, and react to situations only one or the other knows about.

So, for instance, when I log in to my PC at work, my phone goes into silence mode. Or when I arrive home and connect to my Wifi connection, my favourite song starts playing on my PC.

I currently distribute the plugin via my AutoRemote desktop app (which also lets you automate, albeit to a lower level than EventGhost), but would like to know if it would be possible to be included in the EventGhost stock plugins.

AutoRemote is available in Google Play here: http://goo.gl/Fyuba

Thanks for reading, and congratulations for a great app! :D

joaomgcd

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Dec 26, 2012 11:36 am
by zian
Thanks for the sharing of your stuff joaomgcd.

But this post doesn't belong in EvenGhost News.
How's about we move it to the PlugIn Section?

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Dec 26, 2012 4:02 pm
by joaomgcd
I just put it there because terRemote and EG Remote also have threads there.
But thanks for your attention! :)

So, anyway this could be included in the standard EventGhost release package?

Thanks again.

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Dec 31, 2012 2:56 pm
by joaomgcd
Hi again.

Maybe you can help me with a problem I'm having.

I can add the AutoRemote plugin to the EventGhost tree with no problem, and add an Android device within the plugin.
After this, I can save the EventGhost tree and it will save and restore settings correctly.

After using AutoRemote though, if I try to add another plugin afterwards and try to save the EventGhost settings, it always gives me this error:

PicklingError: Can't pickle <class eg.CorePluginModule.AutoRemote.AutoRemoteDevice at 0x03FD5A80>: it's not the same object as eg.CorePluginModule.AutoRemote.AutoRemoteDevice

AutoRemoteDevice is just a class with 3 string fields that I use to save my device settings. Shouldn't I use custom classes to store settings like these? What can I do to this class to make it serializable?

Thanks in advance.

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Dec 31, 2012 3:03 pm
by krambriw
Put your eg plugin here so we can have a look at your source code

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Dec 31, 2012 3:09 pm
by joaomgcd
Ok, here it is.

The AutoRemoteDevice class is at the end of the file.

Thanks.

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Jan 02, 2013 7:27 am
by krambriw
The thing seems impossible for me to test but I have some findings that might help you (and some general comments)

You have the following defined in the configuration for the plugin:

Code: Select all

    def Configure(
        self,
        prefix="HTTP",
        port=1818,
        name="EventGhost",
        devices=[],
        publicIp="",
        authUsername="",
        authPassword=""
    ):

Please note that you should not have a "comma" at the end of the last line

Then you should also have it like this this (even if you are not using the variables for the moment):

Code: Select all

        while panel.Affirmed():
            panel.SetResult(
            	"AutoRemote",
                portCtrl.GetValue(),
                nameCtrl.GetValue(),
                self.devices,
                publicIpCtrl.GetValue(),
                authUsername,
                authPassword
            )
In general,

- why are you re-importing libraries in several places???
- keep the line length at 79 chars
- you use incorrect chars for indents, you have tabs in several places instead of 4 spaces (editor setting???)
- clean up the code, it is hard to read, keep line length at 79 chars, use guideline for indentations and line spacing and others

Best regards, Walter

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Thu Jan 03, 2013 8:45 am
by joaomgcd
Walter, thank you very much for your response.

I agree, the code is not pretty. But in part the problem is that this was the first time I ever worked with python, and I didn't even know those basic rules you mentioned.
I'll clean up the code a bit and see if that solves it.

Thanks again!

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Thu Jan 03, 2013 11:43 am
by krambriw
Dear Joaomgcd,

I tried to search on the net a bit as well for the typical error and there where some findings related that indicated that importing of libraries could have an impact but I do not know. Also it might be that the class needs to be of a kind that matches eg but also here I am not sure. Maybe you can use the python shell from eg's help menu and browse the name space...also here I am not enough experienced.

I also tried to modify your code, making the class simpler but nothing helped so far...

If Pako reads this, I think he would be one of the very few that could give some advice.

Best regards, Walter

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Thu Jan 03, 2013 1:12 pm
by joaomgcd
Thanks very much Walter. I really appreciate you helping!
Hope Pako sees this...

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Thu Jan 03, 2013 5:24 pm
by Pako
I tried to look at it, but I can not.
My editor does not work with this file.
Please use 4 space characters instead of tab.
Then I'll be able to look at it.
However, I am not able to try it. I do not own any Android phone. I have only a Sony Ericsson K510i.

Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Thu Jan 03, 2013 5:34 pm
by krambriw
My Dear Pako, first of all a Happy New Year, I hope you had a good break with family and friends!

Once there is a new modified version available, I think it is possible to reproduce the error without an android (I will try and help as well)

My best regards, Walter

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Fri Jan 04, 2013 8:09 am
by joaomgcd
Thank you both very much for helping with this.
I will try and make a compatible version soon and link to a tutorial on how to get it working so you can easily reproduce the error.

Thanks again!

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Jan 07, 2013 12:13 pm
by joaomgcd
Ok, here's the updated file.
Hope this one is better. Forgive my pythonian ignorance. :oops:

Here's how to reproduce the error:

- Create a new EventGhost configuration
- Add the AutoRemote plugin
- Fill in "Device name" as fake
- Fill in "Device Personal URL" with http://goo.gl/BFbcy ; Press TAB
- Click the "Add" button
- Click "Ok"
- Save EventGhost configuration. There should be no errors
- Add any other plugin
- Save EventGhost configuration. The mentioned error should now appear in the log.

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Jan 07, 2013 3:50 pm
by Pako
Attached is a corrected version.

Pako