We have moved at community.getvera.com

Author Topic: Questions about plugins in Vera (??)  (Read 8301 times)

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Questions about plugins in Vera (??)
« on: March 27, 2011, 02:45:05 pm »
I am in the process of learning to create plugins for the Vera.
The plugin created for the Onkyo receiver, by Guessed (I think), is a good example to learn from but I have questions.....
Does this plugin use serial or Ethernet or either one based on the address you plug in?
I am trying to send binary data back and forth from Vera using standard TCP/IP calls. Is that what this plugin is doing if you are using an Ethernet connection?
Any simple plugin examples would really be appreciated.
Thanks for all who contribute!
Regards
Tim Alls
« Last Edit: May 27, 2011, 11:06:41 am by Daniel MCV »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Questions about plugins in Vera (??)
« Reply #1 on: March 27, 2011, 03:46:08 pm »
It uses Ethernet.  It theoretically can handle a direct connection also, but never completed that part of it (the eISCP over ethernet is slightly different if channelled over RS232)

It handles "raw" data as the other formatted types "CR", "STXETX" didn't work for this device.  If you have line-oriented content, change it to use "CR" instead, as it's more efficient.

It currently ignores any content coming back from the Receiver (the <incoming> block doesn't really do anything).  A bi-directional device would have some logic called from the <incoming> block to handle the data coming back.  See any of the Alarm Panel codebases for a more rich example.

Bottom line, you "write" data using luup.io.write(), and you get data back in "blocks" inside the <incoming> block.  The block size is either Raw (char-by-char), CR (line-by-line) or STXETX (wrapped in these bytes)

What Ethernet Enabled device are you trying to talk with?
« Last Edit: May 29, 2011, 06:38:29 pm by guessed »

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Re: Onkyo Media plugin
« Reply #2 on: March 27, 2011, 07:55:43 pm »
Thanks for the info Guessed
I am writing a generic plugin to communicate with a touchscreen PC running Labview. I am going to write a program in Labview to do the same thing on a PC that is done in mobile programs like SQ Remote. In addition it will take care of polling devices such as temperature sensors and create the logic behind the notifications that I want to add to our Yachts. By doing this I can keep Vera running as an event based machine and load up the PC with the repetitious tasks as well as give the user a very clean lighting controller Etc....
We are unique in that we have a 22 inch multitouch all in one computer embedded in the wall separating the galley and the salon. This gives us a spot to run the Sonos music system, access the Internet, and display our Labview monitoring system.
I have Labview talking to the Vera and running the lights....that was pretty easy once I learned the commands.
I am still weak in bringing data into the Vera. That is why I am studying everyone's code to see what they are doing. So.....a couple more questions.....
Does the input and output commands you are using in Mios code the data or just send and receive it in the raw? Binary arrays is what I mean by raw.
I don't like the way I am sending commands for lighting changes.......HTML out then XML files back....seems very inefficient. Is there a lower level functions for changing device settings?
Thanks for your responses.....I know I have a long way to go but I am working on it!
Regards
Tim Alls

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Questions about plugins in Vera (??)
« Reply #3 on: March 27, 2011, 08:20:08 pm »
For generic control of MiOS, the HTTP (in) and JSON (out) is the best way to do it.  It's the same mechanism that Vera itself uses for everything from the Dashboard control through to editing/additions to the system (Admin functions).

Also, it has an event-like mechanism that can be used to show you only the "changed" items, which is how the Control Points efficiently "poll" the MiOS unit, and know that you switched on a light etc.


If you wanted to, there's also a limited set of control available via the Leviton Emulator Plugin (Beta) from the Marketplace.  I haven't used this, but it's supposed to emulate the Leviton RS232 adapter so you can do some stuff through that:

   https://marketplace.mios.com/plugin.php?id=158

I haven't used it so cannot comment on it's completeness (etc).


You could also take the code and "extend" it with whatever wire protocol you wanted, so support stuff it doesn't already do.



The Onkyo plugin itself is just working with a [raw, byte-by-byte] stream of data.  At that level, you can do whatever you want, and can (if needed) encode the stream in any format you like (see the Leviton RZC0P emulator example above)
« Last Edit: May 29, 2011, 06:39:14 pm by guessed »

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Re: Onkyo Media plugin
« Reply #4 on: March 27, 2011, 09:48:37 pm »
Perfect.....I will study that one next. If the HTTP in and JSON out is the best way I will stick with it. It is so strange for me to use such long strings as a way to communicate, I am used to talking to devices where communication is clean and simple. It makes polling at high speeds work efficiently. I realize from studying the scripting languages that they do have their place.
Thanks for the tip.....I will check it out.
Another quick question.....the coding that is used with the returned JSON file ......do you know what the binary format looks like on the encoded JSON as well as the HTTP sentence sent out to command the Vera? I have been looking high and low to find out what the actual output is over the TCP/IP connection.
I think I understand the JSON coding but I would like to see a diagram of the byte stream sent and received so that I understand it completely!
Regards
Tim Alls
« Last Edit: March 27, 2011, 09:58:48 pm by TimAlls »

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Re: Onkyo Media plugin
« Reply #5 on: March 28, 2011, 12:10:51 am »
Well I am getting closer to figuring this out....the generic layout of an HTTP message looks like this:
Request Line
General Header
Request header
Etc. Etc
The request Line has starts with a "GET /............."

What I am trying to figure out is does the entire text following the HTTP: go after the GET statement...
Any ideas?

Regards
Tim

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Questions about plugins in Vera (??)
« Reply #6 on: March 28, 2011, 12:38:30 am »
If you've not seen the HTTP format before, the best way to learn it (besides reading tomes of w3c.org specs) is to run a tool like "Wireshark" and capture the packets from live requests between your PC and Vera as you interact with it using a standard Browser.

This tool will also break open the various Network Packets, and display them in a more readable (protocol specific) format.

For a slightly simpler, but not as detailed view, use Firefox with the "Firebug" extension.  It does something similar, in that it shows you what's in the Request and Response restructures - but it's not as detailed on things like CR vs CR-LF, and exact delimiters (like  HTTP Request/Response headers like   "Host: 192.168.1.80" )
« Last Edit: May 29, 2011, 06:40:25 pm by guessed »

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Re: Onkyo Media plugin
« Reply #7 on: March 28, 2011, 01:42:39 am »
That's a great idea. No, I have never seen this format explained.....it's all new to me.  I wish I had gone to school in my earlier years and learned all this, instead I am learning by doing! I started out writing assembly language for the 6502 processor back in the early days so I guess I am still more comfortable in dealing with byte streams than with higher level languages.
I will try your idea... Once I see the data format I can easily recreate it using TCP/IP connections and calls from Labview.
Thanks again for your help....this is probably programing 101 for you!
Regards
Tim

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Re: Onkyo Media plugin
« Reply #8 on: March 28, 2011, 09:36:00 pm »
The WireShark was all I needed! Thanks for the tip. I should be able to finish my code tomorrow. Thanks again.
Regards
Tim Alls

Offline kustominc

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: Onkyo Media plugin
« Reply #9 on: May 22, 2011, 10:53:43 pm »
Guessed can you message me. I have an editing question on the OnkyoReceiver plug in. I'm trying to add some stuff but after I do it says lua engine failed to load. I also need help with my itach getting it to work with my sq remote. Thanks

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Questions about plugins in Vera (??)
« Reply #10 on: May 22, 2011, 11:48:16 pm »
@kustominc,
You'll need to post your stuff publicly.  You won't have the ability to PM until you get more posting cred.

If it's about the Onkyo plugin itself, you can use this thread to discuss what you're adding to it:
    http://forum.micasaverde.com/index.php?topic=6367.0

If you're editing the file on Windows, make sure you're using a pure-text editor (not Word, Wordpad, etc) as we've seen some screwy behavior lately when people use those.


On the iTach's, I don't have one of these.  API wise, they're supposed to be a lot like a GC100, so you can probably start with that codebase for making additions/alterations.  You should start a thread for that discussion, either here (Plugins & Dev) or under the SQRemote area.


@TimAlls, can you re-title this thread, as it's gone in a different way than the title leads you to believe ;)
« Last Edit: May 29, 2011, 06:37:23 pm by guessed »

Offline huogas

  • Sr. Member
  • ****
  • Posts: 301
  • Karma: +0/-0
plugin
« Reply #11 on: May 23, 2011, 12:21:41 pm »
@TimAlls, can you re-title this thread, as it's gone in a different way than the title leads you to believe ;)

I second... :)
« Last Edit: May 27, 2011, 04:51:32 pm by huogas »
Vera2 UI4(1.1.1245/3.2), Kwikset x1, HM-DW001 x1, ZRP100 x1, HA-04WD x1, ZDP100 x6, HSM100 x2, VRI06-1LX x8, ZW5301 x1, HM-FS001 x2, ZRW103W x1, GE 45606 x2, HA05C x1, TED5000 x1

Offline Daniel

  • Head of Customer Care
  • Administrator
  • Full Member
  • *****
  • Posts: 143
  • Karma: +2/-0
Re: Questions about plugins in Vera (??)
« Reply #12 on: May 27, 2011, 11:07:26 am »
@TimAlls, can you re-title this thread, as it's gone in a different way than the title leads you to believe ;)

I second... :)

Better now?
Daniel Stefan ▾ Head of Customer Care
Vera Control, Ltd. ▾ Smarter Home Control  ▾ support@getvera.com ▾www.getvera.com ▾ +1 (866) 966-2272

HOURS OF OPERATION for Customer Care Department - 24/7

Offline TimAlls

  • Hero Member
  • *****
  • Posts: 722
  • Karma: +0/-0
Re: Questions about plugins in Vera (??)
« Reply #13 on: May 27, 2011, 11:29:26 am »
@TimAlls, can you re-title this thread, as it's gone in a different way than the title leads you to believe ;)

I second... :)

Better now?
Thanks,

It is easy to lose track of these older posts.
Tim

Offline huogas

  • Sr. Member
  • ****
  • Posts: 301
  • Karma: +0/-0
Re: Questions about plugins in Vera (??)
« Reply #14 on: May 29, 2011, 03:25:19 pm »
@TimAlls, can you re-title this thread, as it's gone in a different way than the title leads you to believe ;)

I second... :)

Better now?

A lot better !  :)

(would again be better if Tim and Guessed change some of their post titles in this thread. Then the search tool would not target it when looking for Onkyo plugin discussions...)
Vera2 UI4(1.1.1245/3.2), Kwikset x1, HM-DW001 x1, ZRP100 x1, HA-04WD x1, ZDP100 x6, HSM100 x2, VRI06-1LX x8, ZW5301 x1, HM-FS001 x2, ZRW103W x1, GE 45606 x2, HA05C x1, TED5000 x1