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.

eg.result and persistent values in webserver

If you have a question or need help, this is the place to be.
Post Reply
sintei
Posts: 26
Joined: Thu Oct 09, 2014 9:46 am

eg.result and persistent values in webserver

Post by sintei »

Hello,

I've hit another wall.

Edited to make more sense:

I'm trying to use persistent variables in teh webserver plugin.

I got 2 python scripts. One where I receive a temperature and put it in eg.globals.temperature.
And another one where I do the same but with luminance and put it in eg.globals.luminance.
I then broadcasts these.

Code: Select all

mytemperature = eg.event.payload
eg.globals.temperature = mytemperature [3]
eg.plugins.Webserver.SetPersistentValue(u'ptemperature', u'{eg.globals.temperature}', False, False)
eg.plugins.BroadcastListener.Broadcast(u'!!!tem{eg.globals.temperature}///', u'', 33333)

Code: Select all

myluminance = eg.event.payload
eg.globals.luminance = myluminance [3]
eg.plugins.BroadcastListener.Broadcast(u'!!!lum{eg.globals.luminance}///', u'', 33333)
eg.plugins.Webserver.SetPersistentValue(u'pluminance', u'{eg.globals.luminance}', False, False)
I then have another scripts that when requested by an event, should read the persistent variable and then broadcast it.

Code: Select all

eg.plugins.Webserver.GetPersistentValue(u'pluminance', True)
eg.globals.luminance = eg.result
eg.plugins.BroadcastListener.Broadcast(u'!!!lum{eg.globals.luminance}///', u'', 33333)

Code: Select all

eg.plugins.Webserver.GetPersistentValue(u'ptemperature', False)
eg.globals.temperature = eg.result
eg.plugins.BroadcastListener.Broadcast(u'!!!temp{eg.globals.temperature}///', u'', 33333)
i thought eg.result should take the last action and show the result.
But it does not do this, it just returns a none.

Maybe GetPersistentValue is not an action? If not, how do I print/use/broadcast the value of my Persistent value?

Cheers
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: eg.result and persistent values in webserver

Post by Sem;colon »

You are right, eg.result is the result of the last action, but as you are still inside the script action it will not work as you want it to.
Do:
eg.globals.luminance=eg.plugins.Webserver.GetPersistentValue(u'pluminance', True)
If you like my work, Image me a drink :wink:
sintei
Posts: 26
Joined: Thu Oct 09, 2014 9:46 am

Re: eg.result and persistent values in webserver

Post by sintei »

Ahhh, thanks for pointing it out.
And for the help :) Got it working now..
Cheers Sem;colon!
mbonaccors
Posts: 16
Joined: Thu Apr 26, 2012 2:46 am

Re: eg.result and persistent values in webserver

Post by mbonaccors »

hey guys, im curious why is it useful to use their variables feature in webserver? I typically set variables directly as eg.globals.variablenames directly via Python scripts. I can call
these via the website anytime using {{eg.globals.variblenames}}. Is there something that I am missing out on?

I also have a question about calling variables from eventghost via my website using angular.js $http.get and/or $http.post. My goal is for the site to dynamically display images, button states etc. dynamically without having to refresh the page to see the result. This the only downside of my current setup is that the objects don't dynamically refresh so I need to reload the page - which is slow and causes various issues.

Thanks for the help!

-Matt B.
sintei
Posts: 26
Joined: Thu Oct 09, 2014 9:46 am

Re: eg.result and persistent values in webserver

Post by sintei »

I use webserver as the variable is stored and can be recalled even after a reboot :)
Post Reply