webserver plugin and eg.event.payload

Questions and comments specific to a particular plugin should go here.

webserver plugin and eg.event.payload

Postby holle75 » Thu Apr 19, 2012 6:03 pm

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)
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: webserver plugin and eg.event.payload

Postby cfull1 » Tue Apr 24, 2012 6:27 pm

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.
cfull1
Experienced User
 
Posts: 99
Joined: Thu Aug 19, 2010 4:52 am

Re: webserver plugin and eg.event.payload

Postby holle75 » Tue Apr 24, 2012 6:57 pm

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

thank you

best

H.
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm


Return to Plugin Support

Who is online

Users browsing this forum: Google Adsense [Bot] and 5 guests