How to create a device ?

Sorry for the dummy question but I think a simple guide could help a lot of noob like me to jump into device creation.

What are the step needed to create a device ? Of course it depends of what kind of device it is.
In my case, I’ve installed xbmc on an old laptop and also want to controle an ardruino robot.
These case are similar as they will probably both send http request trough the LAN.
But I think their are different because the xbmc is a know type of device (media player) and the ardruino is not.

I will try to wrote a guide on how I achieve these two plugin/device. But I will need some help.

Can someone please try to resume the file required/optional for user creation.
A short descritption of D_ , I_ and S_ files would be very cool.

Thank you !

http://wiki.micasaverde.com/index.php/Luup_Plugins_ByHand

Other than that, find the source for another plugin that is close to what you want, at code.mios.com, and read it.

Thanks for the reply and the link… That’s exactly what I already did… But without success (see here : [url=http://forum.micasaverde.com/index.php/topic,9680.msg73904.html#msg73904]http://forum.micasaverde.com/index.php/topic,9680.msg73904.html#msg73904[/url]).

I will try to read this guide again…

Ah, sorry, I didn’t make the connection. You absolutely have to be watching the LuaUPnP.log file and hit reload, and pay attention to the error messages. Otherwise you are flying totally blind. Luup plugins are very, very unforgiving of typos.

For errors in the Static JSON file you should use a JavaScript debugger like FireBug, and watch for errors.

Will do that ! Thanks for the tips !

Next update in a few day as I don’t have time to test right now.

Have fun with your HA project :wink:

Hello,
Sorry I didn’t made any progress on that project. Probably I’m working on too many domo-project in addition to my day to day job.
Now with friend, we jumped into an Arduino project. It’s very exciting to see all what you can do with this Vera box !

Of course, I want the Vera communicate with the Arduino… We can do Telnet as described here
http://forum.micasaverde.com/index.php/topic,10422.msg71883.html#msg71883
but we want to use SSH and we didn’t found any example.

We also wondering what’s the best (and more easy) way for realtime / dual way communication ?
Is it acceptable to keep the telnet/ssh connexion open or is it better to listen for notification from the Arduino ?

Thank you for your time.

Hi,
Forget the post above, I first need to understand the basics.
So now I’m back trying to send basic HTTP commands to an xbmc computer.
By basic, I mean just up, down and mute (even if xbmc don’t handle up and down).

Now when trying to list action in advanced tab of scene creation their is an error message : error in Json file.
I’ve used “generic_device.json” in the D_file because I don’t know what to put.
In the “Luup plugin by hand” guide and the “somfy walkthrough” guide, there is no mention of “json”.

Any help will be apreciated

D_file
[tt]<?xml version="1.0" encoding="utf-8"?>


1
0


urn:schemas-upnp-org:device:MediaRenderer:1
generic_device.json
XBMX Media Player


urn:micasaverde-com:service:Volume:1
urn:micasaverde-com:serviceId:Volume1
S_Volume1.xml



[/tt]

I_file
[tt]<?xml version="1.0" encoding="utf-8"?>


function lug_startup(lul_device)

lug_startup


urn:micasaverde-com:service:Volume:1
Down
luup.inet.wget(“http://” … luup.devices[lul_device].ip … “/xbmcCmds/xbmcHttp?command=Mute”, 5, “xbmc”, “xbmc”)


urn:micasaverde-com:service:Volume:1
Mute
luup.inet.wget(“http://192.168.117.8/xbmcCmds/xbmcHttp?command=Mute”, 5, “xbmc”, “xbmc”)


urn:micasaverde-com:service:Volume:1
Up
luup.inet.wget(“http://” … luup.devices[lul_device].ip … “/xbmcCmds/xbmcHttp?command=Mute”, 5, “xbmc”, “xbmc”)


[/tt]

Maybe you may wish to have a look in apps.mios.com and you should find that is still under development for this function.

Viewing source code of existing/working plugins will help a lot. Small differences in the code can make a large difference in whether your device works or doesn’t.

For now, leave out anything to do with JSON configuration, since you’re a ways from that right now.

Look at the code of the Panasonic TV for a starting place since it’s fairly close in what it’s doing:
http://code.mios.com/trac/mios_panasonic-tv/browser/trunk

A few quick items:
a) check, exactly, the serviceId strings you’re using. The don’t look right.
b) you have a function block, but the function declaration isn’t complete for lug_startup.
Minimally, put an “end” on it, so it can be an empty implementation.
c) while building a plugin, use SSH into Vera and tail the LuaUPnP.log file for details on what’s failing.

Thank you for taking the time to reply !

@Brientim : Not sure to understand what you mean.
I know that there is already more efficient people already working on the xbmc project, but I choose it because it doesn’t require special hardware.
I’ve looked at apps.mios.com butt didn’t found any xbmc pluggin or http sender.
At code.mios.com, I found plenty of code but was a bit confused when trying to found the more similar.

@guessed
Thanks for the tips !

  • Ok, so I’ve removed the section linking to JSON file.
  • I’ve tripple checked the serviceID but can’t see what’s wrong. They look the same as in the Panasonic files.
    [tt]
    urn:micasaverde-com:service:Volume:1
    urn:micasaverde-com:serviceId:Volume1
    S_Volume1.xml
    [/tt]
  • Corrected the “function” section by adding a log line and the “end” command.
  • In fact, when looking at the logs I think I found where’s my problem.

[tt]JobHandler_LuaUPnP::Run device 137 _Temperature Sensor room 0 type urn:schemas-micasaverde-com:device:TemperatureSensor:1 id e3 parent 134/0xc15f38 upnp: 0 <0x2ba40000>
JobHandler_LuaUPnP::Run device 138 test2 room 9 type id parent 0/0xc17360 upnp: 0 <0x2ba40000>
JobHandler_LuaUPnP::Run device 81 TV room 0 type urn:schemas-micasaverde-com:device:IrDevice:1 id parent 0/0xbd9490 upnp: 0 <0x2ba40000>[/tt]

I tried to change 3 times the urn but still same symptoms

[tt]urn:schemas-upnp-org:device:MediaRenderer:1
urn:schemas-micasaverde-com:device:tv:1
urn:toto.com:device:toto:1[/tt]

I really appreciate your help.

a) check, exactly, the serviceId strings you're using. The don't look right.
Sorry, this comment was in relation to the I_*.xml file. I should have been more specific.

Run your Vera in Debug mode, and look at all of the logs (from startup) to see what comes up to be fixed. If a device isn’t loading correctly, for example, it’ll show why in the logs … but they scroll by quickly :wink:

There does look to be an app on the MIOS market place, you will need to login and then choose ‘View Plugin Details’ that will give you a list of 21 pages of apps, all in various status’s a quick look shows there is an xmbc app icon, not sure what it does, but it might be of use/interest.

@parkerc
Wow, thanks for the “view plugin details” tips… looks like there is some good plugins there.

@guessed
In fact Verbose logging is very talkative… It seems it doesn’t like something with my D_ file.
But online xml validator saw no errors[tt]
Device_LuaUPnP::LoadDeviceDoc 138 file D_xbmc-byTom2.xml size 696 result 106 <0x2b006000>
Device_LuaUPnP::LoadDeviceDoc ixmlParseBufferEx /etc/cmh-ludl//D_xbmc-byTom2.xml size 696 ret 106 <0x2b006000>
JobHandler_LuaUPnP::CreateDevice_LuaUPnP failed to load 138/D_xbmc-byTom2.xml so device 138 is offline <0x2b006000>
[/tt]

Thanks again for your support.

It may be easier to take a working one, like the Panny:
http://code.mios.com/trac/mios_panasonic-tv/browser/trunk/D_PanasonicVieraTV1.xml

and strip it down to the bits you need. Be absolutely sure not to use Windows7 Notepad as the editor. It’s adding a few extra bytes to the front of the file.

In your case, these bytes are:

    0xbb 0xef

and Vera will not like this, so it won’t read the file at all.

[quote=“Thomasss, post:10, topic:171892”]@Brientim : Not sure to understand what you mean.
I know that there is already more efficient people already working on the xbmc project, but I choose it because it doesn’t require special hardware.
I’ve looked at apps.mios.com butt didn’t found any xbmc pluggin or http sender.
At code.mios.com, I found plenty of code but was a bit confused when trying to found the more similar.[/quote]

Sorry I missed this response but I see @parkerc responded and cleared up how view details.
apps.mios.com has some very good information and usefullness; however, it is not well known or documented.

For example forcing an update or reveiwing plugin changes over time.

Goto apps.mios.com login and then select your unit if presented with muliple units.
From the My Account select View Plugin Details
Identify the plugin you wish to update and open it by either clicking in the Plugin Name or View located on the right side.
Click on Plugin Files located on the top right of the screen to display the file and previous versions of it.

To force a plugin update or to rollback to a previous version.
Click on Versions located on the top right of the screen to display the version history sceen.
Under Actions click on Install for the version you wish to install.

Insignificant XBMX Media Player

Good luck and well done for getting into it… I know there are a lot of people on this forum looking for an XBMC plugin.

Thank you all for the replies.

@guessed
Again, thanks for the tips. Don’t think I’m used Notepad. I’m using Notepad++ (under Win7).
I will continue tonight to debug my pluggin from scratch but if I don’t make any progress I will do what you suggest : Start from the Pannasonic and keep only what (I think) I need.
But thanks to your support I convinced I’m approaching the goal.

@Brientim
Thanks too for the help. Your intrusctions about apps.mios usage are very usefull. I was wondering whats the best way for long.
Will fix the XBMX issue in the next release of my pre-alpha plugin :slight_smile:

Have a nice week.

Even that editor variant is writing the leading bytes into the file, which is what is making it unreadable to Vera.

You can instruct Notepad++ to save without writing the Byte Order Mark. See: http://npp-community.tuxfamily.org/documentation/notepad-user-manual/document-properties/encoding

Thanks to your help , huge step forward (for my point of view) ! Mute command was successfully sent through HTTP :slight_smile: !

Converting xml files from utf8 to ascii helped a lot (Thanks to futzle and guessed). There was a last tipo in I_file but then it worked.

Now, gonna try to add a second ServiceID like mediaNavigation in addition to volume.
I’m also wondering how to make up and down work. This require to know the actual volume state… Will keep that for later :slight_smile:

But I had to hardcode the user and pass inside de I_ file ; which is not nice.
How can I add custom fields during object creation ? Or even after. I’ve tried the add button at the end of the advanced tab of object edition but can find what to put. Tested : New services and/or New variables=user & value=xbmc but.

Would like to put something like that in startup function :
[tt]lug_username = luup.devices[lul_device].user
lug_password = luup.devices[lul_device].pass[/tt]

And use it under the action part :
[tt]luup.inet.wget(“http://” … luup.devices[lul_device].ip … “/xbmcCmds/xbmcHttp?command=Pause”, 5, lug_username, lug_password)[/tt]

Once again, thank you for your help !

Config Parameters are usually done through Service variables. You can get/set these with [tt]luup.variable_get/luup.variable_set[/tt], and you’ll see examples all over the place in the plugin examples on code.mios.com

Eventually, when you do the JSON part of this, you’ll see that it binds the various UI controls to these named service variables.