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.

Trigger Event From Volume Level?

If you have a question or need help, this is the place to be.
hotbuddha
Experienced User
Posts: 99
Joined: Tue Mar 29, 2011 5:14 am

Re: Trigger Event From Volume Level?

Post by hotbuddha »

I tested, the new OSD macros worked for me except looks like your original code did not call System.MuteOn() correctly (in a python command or action you have to give the full method path). Here is the fix for that plus formatted so you can easily cut/paste into EG...

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1544">
    <Folder Name="test">
        <Macro Name="Decrease Volume">
            <Event Name="Lirc.Samsung_BN59-00861A:Sam.Vol-" />
            <Action>
                System.ChangeMasterVolumeBy(-0.5, 0)
            </Action>
            <Action>
                EventGhost.PythonCommand(u'print (int(round(eg.result,1)))')
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.0, 0.20000000000000001, 0.0, 0.59999999999999998)
            </Action>
        </Macro>
        <Macro Name="Show OSD with AutoMute">
            <Event Name="System.Volume" />
            <Action Name="Trigger Event based on if">
                EventGhost.PythonScript(u'if eg.event.payload < 1:\n    eg.plugins.System.MuteOn(0)\n    eg.StopMacro()')
            </Action>
            <Action>
                EventGhost.ShowOSD(u'Volume {int(round(eg.event.payload))}%', u'0;-32;0;0;0;700;0;0;0;0;3;2;1;34;BenguiatGot Bk BT', (0, 255, 0), (0, 0, 0), 5, (0, 35), 0, 3.0, False)
            </Action>
        </Macro>
        <Macro Name="Show OSD for Mute">
            <Event Name="System.Mute" />
            <Action>
                EventGhost.ShowOSD(u'Mute On', u'0;-32;0;0;0;700;0;0;0;0;3;2;1;34;BenguiatGot Bk BT', (0, 255, 0), (0, 0, 0), 5, (0, 35), 0, 3.0, False)
            </Action>
        </Macro>
        <Macro Name="Show OSD for UnMute">
            <Event Name="System.UnMute" />
            <Action>
                EventGhost.ShowOSD(u'Mute Off', u'0;-32;0;0;0;700;0;0;0;0;3;2;1;34;BenguiatGot Bk BT', (0, 255, 0), (0, 0, 0), 5, (0, 35), 0, 3.0, False)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
User avatar
aireca
Posts: 14
Joined: Fri Mar 18, 2011 11:45 am

Re: Trigger Event From Volume Level?

Post by aireca »

i still have error codes with that print (int(round(eg.result,1))) the first time is used shows this:

Code: Select all

      print (int(round(eg.result,1)))
         Error in Action: "print (int(round(eg.result,1)))"
         Traceback (most recent call last) (1544):
           File "<string>", line 1, in <module>
         TypeError: a float is required

:(

i have trouble with the decimal volume values (System.Volume 0.49750185571610928), value never is the same
is there anyway to use wilcards on events? or round the volume values or something like that?


sorry if im asking like so much stuff, but I am a super newbie on python like you probably already noticed :oops: , i just know basic stuff that i readed from the help, eventghost its very easy to use, but you need to know terms, to me is trial and error


With the volume osd that way, its just displayed after the button is released, wich is not very useful
./)_/). o O ( ? )
( O.o')
( > < )
^^^^^
hotbuddha
Experienced User
Posts: 99
Joined: Tue Mar 29, 2011 5:14 am

Re: Trigger Event From Volume Level?

Post by hotbuddha »

I made a fat finger mistake in the __init__.py file. Fixed on in the new zip.
Last edited by hotbuddha on Tue Feb 21, 2012 11:47 pm, edited 2 times in total.
hotbuddha
Experienced User
Posts: 99
Joined: Tue Mar 29, 2011 5:14 am

Re: Trigger Event From Volume Level?

Post by hotbuddha »

aireca wrote: I have trouble with the decimal volume values (System.Volume 0.49750185571610928), value never is the same
is there anyway to use wilcards on events? or round the volume values or something like that?
There is two parts to System.Volume 0.49750185571610928, the first part is the actual event name System.Volume which is stored in eg.event.string, the second 0.49750185571610928 which is the payload and is stored in eg.event.payload. So you can't trigger on the full "System.Volume 0.49750185571610928", you just trigger on System.Volume and then check or use what is inside of eg.event.payload.
aireca wrote:sorry if im asking like so much stuff, but I am a super newbie on python like you probably already noticed :oops: , i just know basic stuff that i readed from the help, eventghost its very easy to use, but you need to know terms, to me is trial and error
That's ok, you'll learn, meanwhile you are doing valuable testing.

aireca wrote:With the volume osd that way, its just displayed after the button is released, wich is not very useful
Do you mean that it does not display anything until after you have held down the volume control of the remote for an extended period and then released it?

The behavior is due to the use of auto repeat, which is encapsulated into your macro so nothing happens in eg while you are holding the button down.
User avatar
aireca
Posts: 14
Joined: Fri Mar 18, 2011 11:45 am

Re: Trigger Event From Volume Level?

Post by aireca »

I said that last part because if i place Show OSD: Volume {int(round(eg.event.payload))}% outside the System.Volume macro gives the same float error which i dont know what to do

Code: Select all

      Show OSD: Volume {int(round(eg.event.payload))}%
         Error in Action: "Show OSD: Volume {int(round(eg.event.payload))}%"
         Traceback (most recent call last) (1544):
           File "C:\Program Files (x86)\Utilidades\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
             return self(*args)
           File "C:\Program Files (x86)\Utilidades\EventGhost\plugins\EventGhost\ShowOSD.py", line 385, in __call__
             osdText = eg.ParseString(osdText)
           File "C:\Program Files (x86)\Utilidades\EventGhost\eg\Utils.py", line 204, in ParseString
             res = eval(word, {}, eg.globals.__dict__)
           File "<string>", line 1, in <module>
         TypeError: a float is required



Show OSD: Volume {int(round(eg.result))}% :

Code: Select all

      Show OSD: Volume {int(round(eg.result))}%
         Error in Action: "Show OSD: Volume {int(round(eg.result))}%"
         Traceback (most recent call last) (1544):
           File "C:\Program Files (x86)\Utilidades\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
             return self(*args)
           File "C:\Program Files (x86)\Utilidades\EventGhost\plugins\EventGhost\ShowOSD.py", line 385, in __call__
             osdText = eg.ParseString(osdText)
           File "C:\Program Files (x86)\Utilidades\EventGhost\eg\Utils.py", line 204, in ParseString
             res = eval(word, {}, eg.globals.__dict__)
           File "<string>", line 1, in <module>
         TypeError: a float is required
./)_/). o O ( ? )
( O.o')
( > < )
^^^^^
hotbuddha
Experienced User
Posts: 99
Joined: Tue Mar 29, 2011 5:14 am

Re: Trigger Event From Volume Level?

Post by hotbuddha »

Update, volume event files and code can be found in this thread now: viewtopic.php?f=10&t=3744&p=21003#p21003

I fixed some bugs and reworked the events a little. I think you will like this version ;) Updates in the zip file again, and new code for the Volume OSD below...

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1544">
    <Folder Name="Vista Volume OSD" Expanded="True">
        <Macro Name="Increase Volume">
            <Event Name="Lirc.Samsung_BN59-00861A:Sam.Vol+" />
            <Action>
                System.ChangeMasterVolumeBy(0.5, 0)
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.0, 0.20000000000000001, 0.0, 0.59999999999999998)
            </Action>
        </Macro>
        <Macro Name="Decrease Volume">
            <Event Name="Lirc.Samsung_BN59-00861A:Sam.Vol-" />
            <Action>
                System.ChangeMasterVolumeBy(-0.5, 0)
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.0, 0.20000000000000001, 0.0, 0.59999999999999998)
            </Action>
        </Macro>
        <Macro Name="Show OSD with AutoMute">
            <Event Name="System.Volume" />
            <Action>
                EventGhost.ShowOSD(u'Volume {round(eg.event.payload,1)}%', u'0;-32;0;0;0;700;0;0;0;0;3;2;1;34;BenguiatGot Bk BT', (0, 255, 0), (0, 0, 0), 5, (0, 35), 0, 3.0, False)
            </Action>
        </Macro>
        <Macro Name="Show OSD for Mute">
            <Event Name="System.Mute" />
            <Action>
                EventGhost.ShowOSD(u'Mute {round(eg.event.payload,1)}%', u'0;-32;0;0;0;700;0;0;0;0;3;2;1;34;BenguiatGot Bk BT', (0, 255, 0), (0, 0, 0), 5, (0, 35), 0, 3.0, False)
            </Action>
        </Macro>
        <Macro Name="Show OSD for UnMute">
            <Event Name="System.UnMute" />
            <Action>
                EventGhost.ShowOSD(u'Unmute {round(eg.event.payload,1)}%', u'0;-32;0;0;0;700;0;0;0;0;3;2;1;34;BenguiatGot Bk BT', (0, 255, 0), (0, 0, 0), 5, (0, 35), 0, 3.0, False)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Last edited by hotbuddha on Sun Feb 26, 2012 3:01 pm, edited 1 time in total.
User avatar
aireca
Posts: 14
Joined: Fri Mar 18, 2011 11:45 am

Re: Trigger Event From Volume Level?

Post by aireca »

Thank you very much, now the old code is working too

I still cannot find a good way to use the new osd (System.Volume plus Show OSD: Volume {round(eg.event.payload,1)}%) with the Lirc remote because of the delay on event ghost, but the old code works anyway

The volume macro uses 39 % of CPU (Quad Core Q8400 OC @ 3.6 Ghz) i think thats why the delay its unavoidable, but its not your plugin, was the same before, after all from 0% to 100% there is 200 repeats & i need the .5% volume changes because im controlling big hometheater speakers

with the Show OSD: Volume {int(round(eg.result))}% before the autorepeat there is no delay since its done with the volume change



You think there is some way to show the System.Volume X.XXXXXXXXX events between the repeats? :oops:


This is how event Ghost log looks when i change volume:

Code: Select all


Lirc.Samsung_BN59-00861A:Sam.Vol-
   Decrease Volume
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
      Autorepeat current macro: 0.0
      Change Master Volume: -0.50 %
Main.System.Volume 9.9999994039535522
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 9.4999976456165314
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 9.4999976456165314
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 8.9999966323375702
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 8.9999966323375702
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 8.499995619058609
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 8.499995619058609
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 7.9999946057796478
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 7.9999946057796478
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 7.4999935925006866
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 7.4999935925006866
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 6.9999925792217255
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 6.9999925792217255
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 6.4999915659427643
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 6.4999915659427643
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 5.9999912977218628
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 5.9999912977218628
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 5.4999910295009613
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 5.4999910295009613
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 4.9999907612800598
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 4.9999907612800598
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 4.4999901205301285
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 4.4999901205301285
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 3.9999894797801971
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 3.9999894797801971
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 3.4999888390302658
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 3.4999888390302658
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 2.9999880120158195
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 2.9999880120158195
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 2.4999875575304031
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 2.4999875575304031
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 1.9999869167804718
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 1.9999869167804718
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 1.4999863691627979
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 1.4999863691627979
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 0.99998600780963898
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 0.99998600780963898
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 0.49998569302260876
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 0.49998569302260876
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
System.Volume 0.0
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
Main.System.Volume 0.0
   Show OSD with AutoMute
      Show OSD: Volume {round(eg.event.payload,1)}%
............etc....

./)_/). o O ( ? )
( O.o')
( > < )
^^^^^
hotbuddha
Experienced User
Posts: 99
Joined: Tue Mar 29, 2011 5:14 am

Re: Trigger Event From Volume Level?

Post by hotbuddha »

Maybe I'll take a peak at the logic for autorepeat at some point. Could be possible to either enhance or make a new version that is similar and allows events to occur in between repeats.
User avatar
aireca
Posts: 14
Joined: Fri Mar 18, 2011 11:45 am

Re: Trigger Event From Volume Level?

Post by aireca »

I have noticed this plugin has been added recently to eventghost, also i want to report that i have noticed a slowdown compared to the original VistaVolume, im surprised nobody noticed the slowdown with volume handling :(, anyway thank you very much for adding this feature to the main event ghost code :D

i also want to request a on-off option for the volume events log, will be useful when my computer have high load (encoding videos, playing games, etc), could be even better to be this his own volume plugin instead of stay inside the main system code... i mean to handle the plugin by myself without editing the whole file.
./)_/). o O ( ? )
( O.o')
( > < )
^^^^^
Post Reply