Author Topic: How to trigger personal event from kodi to Voxcommando  (Read 5717 times)

0 Members and 1 Guest are viewing this topic.

PegLegTV

  • $upporter
  • Hero Member
  • *****
  • Posts: 500
  • Karma: 43
    • View Profile
How to trigger personal event from kodi to Voxcommando
« on: November 10, 2015, 01:21:48 PM »
UPDATE:: jitterjames did like he always does and went Way above and beyond,  ::banana and built in an extra way to communicate from Kodi to Voxcommando check it out below


ORIGINAL POST:

I'm looking for something similar to "Xbmc Python Script for VoxCommando"

What I'm looking for is the ability to trigger an event from Kodi to VC,

as of now I'm using exe files that I created using autohotkey to trigger an event in VC, I'm using advanced launcher to launch the exe files so it creates an unwanted delay, and popup window in kodi,

I tried using the JsonRPC.NotifyAll command but with no luck (If I understand the purpose of this action It should work) I asked for help on the kodi forums but I haven't had any luck My Kodi Forum post

does anyone know of another method or maybe even the correct format for Jsonrpc.NotifyAll
« Last Edit: November 13, 2015, 11:47:48 AM by PegLegTV »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #1 on: November 10, 2015, 10:10:09 PM »
I'm looking into this but I haven't figured out too much yet.

PegLegTV

  • $upporter
  • Hero Member
  • *****
  • Posts: 500
  • Karma: 43
    • View Profile
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #2 on: November 10, 2015, 11:16:31 PM »
Sounds great thanks,

when I started looking, I came across this at homeseer http://forums.homeseer.com/showthread.php?t=161852 but I don't know anything about HomeSeer, and I didn't have any luck finding the "simplescript" it was referencing

Thanks for helping  ;D

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #3 on: November 11, 2015, 11:43:58 AM »
OK.  Got an easy fix.  You just need to set the sender to xbmc.

VC checks for this when validating the message.  I guess this is wrong but when I wrote the code I thought this was the only possible sender.  I should probably change it but for your purposes it doesn't matter at the moment, as long as you use xbmc for the sender.

I may make some adjustments to how this works in the future.  For one thing, right now all the data is being put into a payload for the event which is generated in the form of a json string.  I might break this up into individual payloads in the future.  Or I might make it so that you can notify in specific ways other than generating a generic event.

examples:

1: trigger an action directly from Kodi
Code: [Select]
... "sender":"xbmc","message":"action","data":"tts.speak&&hahaha" ...
or 2: trigger a specific event with payloads instead of an XBMC event.

Code: [Select]
... "sender":"xbmc","message":"event","data":"myEventName.Subname&&EventPayload1&&EventPayload2" ...

PegLegTV

  • $upporter
  • Hero Member
  • *****
  • Posts: 500
  • Karma: 43
    • View Profile
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #4 on: November 11, 2015, 01:03:38 PM »
Sweet  :yay ::bow ::bow

after trying what you posted it looks like in order to use it with Aeon Nox 5: SiLVO  5.7.4-2.0.7 I will have to go to:

System >> Appearance >> Skin >> Settings >> Setup the Aeon Nox Main Menu >> select the menu item I want to use >> Default Select Action >> Custom shortcut

then I need to use:
Code: [Select]
XBMC.NotifyAll(xbmc, hello)this will give me an event that looks like this:

XBMC.Other.hello
{1}=
Code: [Select]
{
 "data":null,
 "sender":"xbmc"
}

I tried multiple different ways to add in payloads but no luck, this is what I tried:

XBMC.NotifyAll(xbmc, hello&&payload)

XBMC.NotifyAll(xbmc, hello\x26\x26payload)

XBMC.NotifyAll(xbmc, hello, payload)

XBMC.NotifyAll(xbmc, hello)&&payload

XBMC.NotifyAll(xbmc, hello)\x26\x26payload

XBMC.NotifyAll(xbmc, hello)payload

XBMC.NotifyAll(xbmc, hello.payload)

XBMC.NotifyAll(xbmc, hello, "payload")

XBMC.NotifyAll(xbmc, hello)(payload)

but for now I don't need  Payloads, but I could definitely see it being beneficial.

now I can use this to launch Netflix  ::banana  ::wiggle ::banana ::wiggle

 





jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #5 on: November 11, 2015, 03:55:07 PM »
Kodi does not really provide much in the way of documentation for either their json api or their built in commands, but it appears that the built in command "XBMC.NotifyAll" does not allow you to use the 3rd parameter "data".  In order to use the data parameter which is where I would put the payloads etc. you will probably need to use the actual json call which probably means using Python.  I'm not well versed in customizing the main menu in general and don't use Aeon Nox either so I don't know how much I can help there.

You can always use the event name itself and then parse it for the extra data.  For example you could generate an event that ends up looking like XBMC.Other.Volume=50 and just use RegEx on the {LastEvent} variable to get the part after the equals sign (50).
« Last Edit: November 11, 2015, 03:59:30 PM by jitterjames »

PegLegTV

  • $upporter
  • Hero Member
  • *****
  • Posts: 500
  • Karma: 43
    • View Profile
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #6 on: November 11, 2015, 04:56:31 PM »
that's exactly what I was thinking too,

I don't have a need for payloads with what I'm using it for, but I thought I would test it out,

I saw in the Kodi Forum that when using python it needs to be converted to hex, I'm not sure if that is just for the plugin they are talking about or if it's for passing data with NotifyAll, either way it wouldn't be to practical
« Last Edit: November 13, 2015, 11:52:44 AM by PegLegTV »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #7 on: November 11, 2015, 10:14:02 PM »
Maybe you could make a request that the powers that be add the data parameter to the xbmc.notifyall function.  Probably a long shot but you never know.

PegLegTV

  • $upporter
  • Hero Member
  • *****
  • Posts: 500
  • Karma: 43
    • View Profile
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #8 on: November 11, 2015, 11:58:17 PM »
Done!!! ;D


trying to get data added to XBMC.NotifyAll builtin action in Kodi so we can add payloads to the action, show your support at: http://forum.kodi.tv/showthread.php?tid=247378
« Last Edit: November 12, 2015, 10:29:27 AM by PegLegTV »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #9 on: November 12, 2015, 07:28:14 AM »
Maybe post a link here so we can add our +1s?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: looking for something similar too "Xbmc Python Script for VoxCommando"
« Reply #10 on: November 13, 2015, 11:24:34 AM »
I saw in the Kodi Forum that when using python it needs to be converted to hex, I'm not sure if that is just for the plugin they are talking about or if it's for passing data with NotifyAll, either way it wouldn't be to practical

I'm not sure what they were doing there but you don't need to convert anything to hex for our purposes.

Anyway you inspired me.  I've updated the plugin and the addon and now you can send any kind of action, event, or voice emulation text to VC8)

NOTE: addon update instructions are only for those using the VoxTools addon that came with VC versions earlier than 2.2.1.3.

First step is to update your VoxTools Addon.  Unfortunately, the repository I was using was on Google Code and of course they pulled the plug on that free service as they do with all of their free services eventually so I've had to move the repo to GitHub.

- First you'll need to uninstall both
    - uninstall the VoxTools addon from Kodi
    - uninstall the VC Repo from Kodi.
- Then install the new repo from zip (attached to this post)
- Then install the VoxTools addon.

You should end up with VoxTools version 0.2.0 and when you try to run it directly from Kodi's "programs" menu, instead of an error you should get a popup message with the title "no parameters".

- Next step is to update to the new xJson addon (also attached).
   - Be sure to overwrite the original XJson.dll while VC is closed, and unblock the dll if necessary before restarting VC.

Now you can create your custom menu actions in Aeon using the following types of commands
Code: [Select]
XBMC.RunScript(script.voxtools,type=vcaction,data=tts.speak&&Hi there)

XBMC.RunScript(script.voxtools,type=vcevent,data=test.event&&payload1&&payload2)

XBMC.RunScript(script.voxtools,type=vcemulate,data=pay attention)

.dll removed, get the latest version of VC instead.
« Last Edit: September 20, 2016, 12:09:40 PM by jitterjames »

PegLegTV

  • $upporter
  • Hero Member
  • *****
  • Posts: 500
  • Karma: 43
    • View Profile
Re: How to trigger personal event from kodi to Voxcommando
« Reply #11 on: November 13, 2015, 11:42:22 AM »
Wow!!   :hugs :bignod :yay :clap ::bow ::bow ::antlers ::xmasbounce :xmasgrin ::banana ::wiggle ::wiggle

that works Great!!

you always go above and beyond!!

I'll have to re-Edit my first post, lol, I'll add a link to your post instead


Thank you

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: How to trigger personal event from kodi to Voxcommando
« Reply #12 on: November 13, 2015, 01:00:41 PM »
With the new xJson plugin you can use any sender. (It no longer needs to be 'xbmc'.)

Here is a command with 3 test actions to show how you would call the plugin using NotifyAll.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.1-->
<command id="303" name="kodi notify all tests" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>JSONRPC.NotifyAll</param>
      <param>"sender":"anysender","message":"action","data":"tts.speak&amp;&amp;ha ha ha"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>JSONRPC.NotifyAll</param>
      <param>"sender":"anysender","message":"event","data":"myevent.one&amp;&amp;p1"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>JSONRPC.NotifyAll</param>
      <param>"sender":"anysender","message":"emulate","data":"ignore me"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

The second action won't work in the current version of VC (2.2.0.9 or earlier) because of the && in the parameter but in the next version of VC it will. ;)
« Last Edit: November 13, 2015, 01:52:00 PM by nime5ter »