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.

webserver plugin and eg.event.payload

Questions and comments specific to a particular plugin should go here.
Post Reply
holle75
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

webserver plugin and eg.event.payload

Post by holle75 »

Hi there,

i┬┤m sending my href in the format "http://192.168.1.39/index.html?HTTPMasterVolume&11&0" to EG┬┤s webserver.
the purpose is to trigger the Master Volume in a Python Script with

Code: Select all

eg.WinApi.SoundMixer.SetMasterVolume(eg.event.payload)
the result is an error

Code: Select all

Traceback (most recent call last):
Python script "64", line 1, in <module>
eg.WinApi.SoundMixer.SetMasterVolume(eg.event.payload)
File "C:\Programme\EventGhost\eg\WinApi\SoundMixer.py", line 201, in SetMasterVolume
newValue = int((value / 100.0) * (maximum - minimum)) + minimum
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

when i print (eg.event.payload) with

Code: Select all

print (eg.event.payload)
the result in the log is

Code: Select all

[u'11', u'0']
As EG┬┤s webserver supposedly is expecting

Code: Select all

eg.WinApi.SoundMixer.SetMasterVolume(x.0, 0)
and eg.event.payload comes with [u'11', u'0'] this error makes sense to me.

The question is: how could i get rid of the u' in the payload?

Thank you for any hints

best

H.

EDIT:

i could manage to strip down [u'11', u'0'] to 11 with

Code: Select all

str = eg.event.payload
print str
vol = str[0]
print vol
eg.plugins.System.SetMasterVolume((vol), 0)
but still its not working :(

EDIT2:
Ok, i managed it by myself. I had to convert from unicode. i┬┤m shure there is a nicer way but due my lack of knowledge of Python i have to go step by step ;)

Code: Select all

str = eg.event.payload
vol = str[0]
mastervolnew = float(vol)
print "New MasterVolume = ", mastervolnew
eg.plugins.System.SetMasterVolume(mastervolnew, 0)
cfull1
Experienced User
Posts: 124
Joined: Thu Aug 19, 2010 4:52 am

Re: webserver plugin and eg.event.payload

Post by cfull1 »

Looks like you got it. It could combined to this

Code: Select all

eg.plugins.System.SetMasterVolume(float(eg.event.payload[0]), 0)
Didn't realize you had switched to System.SetMasterVolume until after I came up with this ha.
holle75
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: webserver plugin and eg.event.payload

Post by holle75 »

Hi cfull1 .... Your single line looks much nicer. I┬┤m still afraid to pack things together.

thank you

best

H.
Post Reply