Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A proposal for implementing RIVACmd on WebRIVA
#1
So there's always been this action command available:

IntfViewer::RIVACmd(cmd, val1, val2, val3)

The purpose of it is to pass through arbitrary commands to RIVA clients. The old 3rd party clients implemented it for a few things. WebRIVA doesn't so far. 

One thing we'd all obviously like is some open ended mechanism to use this command for variousthings. I'm proposing that we use the extension mechanism that WebRIVA has already. Under:

[cqc]\CQCData\HTMLRoot\WebRIVAExt

There are files in there that the WebRIVA client loads. The default ones that get put there upon installation are just do nothing implementations. That allows WebRIVA not to fail due to missing references, but they don't do anything. You put your own code into them to have them do what you want them to do.

So I'm proposing that we have a new extension file named RIVACmd.js and the content of the default file is:

Code:
RIVACmdFunc = function(cmd, v1, v2, v3) {
}

When the regular IV engine gets a RIVACmd action command, it just ignores it. When the WebRIVA engine gets one it will forward that to the appropriate WebRIVA client. The WebRIVA client will invoke RIVACmdFunc with the values that were originally passed to the RIVACmd action command.

You can then put anything in there you want, just looking at the cmd parameter to decide what to do. We can of course define a structure for cmd, with examples like:

/CQC/somecmd
/User/Bubba/somecmd
/Comm/JohnSmith/somecmd

Where /CQC/ means it's a command defined by us, /User/[name]/ means it's a user specific command, /Comm/[name]/ means it's not defined by us but is a well known community defined command. That allows us to avoid command name clashes. The handler code for these things would just be provided as javascript content you can paste into your extension file, so:

Code:
// Code provided by whoever defines /Comm/iOS/PushNot
DoPushNot(name, value) {
    // code would be here
}

RIVACmdFunc = function(cmd, v1, v2, v3) {
     // If it's the community defined iOS push notification command, call that
     if (cmd === "/Comm/iOS/PushNot") {
           DoPushNot(v1, v2);
     }
}


The function name DoPushNot is just arbitrary. You can change that name as required to avoid any clash with another handler you already have in your extension file. All that matters is the command name and the code that you invoke for it.

Does that sound reasonable?
Dean Roddey
Software Geek Extraordinaire
Reply
#2
So, just to provide a concrete example. Let's say we (CQSL) defined a standard command to invoke a URL in another tab. We would provide you with something like this:

Code:
RIVACmd Parameters:
   Cmd=/CQC/LoadURLToTab
   V1=URL to load

Code:
    // Pass the URL to load
    LoadURLToTab(valURL)  {
         window.open(valURL);
    }

And you would copy that code to your RIVACmd.js by just copying our provided code in, then adding a check for the documented command and passing along the right value, like this:

Code:
LoadURLToTab(valURL)  {
     window.open(valURL);
}

RIVACmdFunc = function(cmd, v1, v2, v3) {
     if (cmd === "/CQC/LoadURLToTab") {
           LoadURLToTab(v1);
     }
}

I know to pass v1 to the LoadURLToTab() function because the documentation indicates that the URL is v1, and the method indicates to pass the URL to load.


So basically we, or anyone, can provide a little text file with this type of info in it to do some particular useful thing. And you can just copy the function into your RIVACmd.js file and make the appropriate call to that function when cmd equals the associated command name.

Obviously for some very common and simple ones we could just include them in the default RIVACmd.js file so that they are always there. The invoking a URL one would be a good example. It's a trivial amount of code.
Dean Roddey
Software Geek Extraordinaire
Reply
#3
BTW, I should have mentioned that a very important aspect of doing it this way is that it allows for platform specific stuff. We can't have platform specific stuff in WebRIVA itself. It would get ugly fast. But this allows you to basically 'inject' your own code into WebRIVA on your own system.
Dean Roddey
Software Geek Extraordinaire
Reply
#4
OK, so I don't fully understand what you're saying here ...

Does this mean that we would have a method to have webRIVA clients react to things from CQC? Something like a doorbell ringing could open an overlay of an image from the front door camera. Or if I start the 'Watch TV' action via my Harmony in the master bedroom, the master bedroom IV could change to an overlay related to watching TV. Or at a specific time, the IV could change to often used things like a big icon for the porch light after dusk.

Or is this something else entirely and I've missed it?
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Netatmo / Brultech
Reply
#5
That's basically it. The RIVACmd is something that just passes the four values (command and optional parameters) to the WebRIVA client and it can act on it as it desires. We can build in some things of course, if they are portable. But this extension mechanism allows you to invoke your own Javascript in response to others that you can arbitrarily define.

For things like overlays or other widgets, you don't need this. You can already do similar sorts of things within the existing IV system, and it'll work the same on the WebRIVA client. This is for things outside of CQC, like invoking some kind of operating system specific push notification, loading a tab with a web camera URL, making the phone display some sort of notification or play a sound, stuff like that.
Dean Roddey
Software Geek Extraordinaire
Reply
#6
(02-22-2018, 04:46 PM)Dean Roddey Wrote: That's basically it. The RIVACmd is something that just passes the four values (command and optional parameters) to the WebRIVA client and it can act on it as it desires. We can build in some things of course, if they are portable. But this extension mechanism allows you to invoke your own Javascript in response to others that you can arbitrarily define.

For things like overlays or other widgets, you don't need this. You can already do similar sorts of things within the existing IV system, and it'll work the same on the WebRIVA client. This is for things outside of CQC, like invoking some kind of operating system specific push notification, loading a tab with a web camera URL, making the phone display some sort of notification or play a sound, stuff like that.

I didn't think webRIVA would respond to the same IV commands that the typical windows IV could handle.  

Since I am going all webRIVA, this will open up quite a bit to what I can do ... will make for a good spring project (if I can ever finish my winter projects).  Smile
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Netatmo / Brultech
Reply
#7
Oh, you mean sending remote commands to an IV? I was thinking more about triggered events in the templates. But no, you can't do PlayWAV and those sorts of commands, because there's no IV to talk to.
Dean Roddey
Software Geek Extraordinaire
Reply
#8
So this is also a way to get iOS notifications happening with the new iOS app. I'll ask about this and see how do-ale it is
Mykel Koblenz
Illawarra Smart Home
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  WebRIVA password special character issue? batwater 10 172 09-30-2018, 02:07 PM
Last Post: batwater
  Android and WebRIVA - working? batwater 9 160 09-30-2018, 01:44 PM
Last Post: Dean Roddey
  WebRiva and vpscale=? kblagron 1 167 08-28-2018, 08:12 AM
Last Post: Dean Roddey
  Is it possible to direct link with webriva? ghurty 1 251 07-24-2018, 05:04 PM
Last Post: Dean Roddey
  WebRiva on Android George M 20 1,208 07-22-2018, 09:07 AM
Last Post: Dean Roddey
  WebRiva, Android, scaling issue IVB 2 324 07-15-2018, 01:47 PM
Last Post: IVB
  HTML5 and Webriva and the Interface Veiwer ghurty 1 290 07-11-2018, 10:50 PM
Last Post: Dean Roddey
  How to tell WebRiva to rebuild itself ghurty 3 420 05-24-2018, 09:50 PM
Last Post: Dean Roddey
  Does anyone have a nice interface set up using the new webRiva system? ghurty 0 232 05-15-2018, 03:13 PM
Last Post: ghurty
  WebRIVA disconnect issue dlmorgan999 11 1,111 05-09-2018, 09:38 AM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)