Author Topic: Pass payload to serial plugin?  (Read 2894 times)

0 Members and 2 Guests are viewing this topic.

aalmans

  • $upporter
  • Jr. Member
  • *****
  • Posts: 2
  • Karma: 0
    • View Profile
Pass payload to serial plugin?
« on: February 26, 2012, 11:18:07 AM »
Hi,

I am using VoxCommando to send events to EG and this works really well. This way i control my LG TV with specific serial commands such as:

ka 0 1\r (serial write command to turn on the TV from standby)

The question i have is how to pass variables from  VoxCommando to EG. I would like to use this to set the volume to a specific level. I can generate an event in EG such as:

Broadcast.tv-setvol '10'

I just don't know how to pass the variable "10" to the serial command:

kf 0 {eg.event.payload}\r

What do i need to replace {eg.event.payload} with to have the variable "10" passed on to this serial command so it reads: kf 0 10\r  ??

Thanks for your help!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Pass payload to serial plugin?
« Reply #1 on: February 26, 2012, 12:27:30 PM »
Hi aalmans.  Welcome to VoxCommando.

{eg.event.payload} is correct.  If you try it with EventGhost's osd action it should work.

The problem is that the plugin you are using is probably just passing the {eg.event.payload} as a literal string instead of replacing it with its value.

To solve this you should be able to write a single line of python script like this:

eg.plugins.Serial.Write('kf 0 '+{eg.event.payload}+'\r')

you can paste the following code into your eventGhost tree to test it:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1544">
    <Macro Name="Python Script" Expanded="True">
        <Action>
            EventGhost.PythonScript(u"eg.plugins.Serial.Write('kf 0 '+{eg.event.payload})+'\\r')")
        </Action>
    </Macro>
</EventGhost>
« Last Edit: February 26, 2012, 05:55:59 PM by jitterjames »

aalmans

  • $upporter
  • Jr. Member
  • *****
  • Posts: 2
  • Karma: 0
    • View Profile
Re: Pass payload to serial plugin?
« Reply #2 on: February 26, 2012, 04:55:35 PM »
Thanks jitterjames!

Cannot try if it actually works as i am still waiting for my USB-to-RS232 cable to arrive but thanks for the help so far! Didn't realize you could also write python scripts. Good to know...