We have moved at community.getvera.com

Author Topic: How to invoke DLNA Plugin Actions?  (Read 3694 times)

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
How to invoke DLNA Plugin Actions?
« on: January 14, 2015, 12:26:09 pm »
Hi guys !

I'm trying to use the Lolodomo's uPnP/DLNA Plugin from OpenHAB through Mios binding. Mainly because OpenHAB do not have a uPnP Media control binding ATM (as far as I know). and I use it a lot in my Home Automation.

In my Vera's script for playing a webradio, I must fetch the selected DescriptionURL and send a SelectDMRDevice with the DescriptionURL lul_arguments for "wake up" uPnP proxy and get the correct Device status (actually ON).

Here is the begining of my Lua Script :
[...]
local descriptionURL =  luup.variable_get("urn:dlna-org:serviceId:DLNAMediaController1", "DescriptionURL", 47)
local lul_arguments = {}
lul_arguments["URL"] = descriptionURL
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "SelectDMRDevice", lul_arguments, 47)
local lul_arguments = {}
lul_arguments["URI"] = radio_selected
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Play", lul_arguments, 47)

So ... My first step is to get the "DescriptionURL" into a Openhab String like this :

String  AUDIO_SLN_DESCR {mios:"unit:house,device:44/service/urn:dlna-org:serviceId:DLNAMediaController1/DescriptionURL" }

The second step is to send the SelectDMRDevice with the value of AUDIO_SLN_DESCR string but I don't know how to do it, and if is it possible to do ? something like this but how to pass the DescriptionURL ?

Switch  AUDIO_SLN_SELECT {mios:"unit:house,device:44/service/urn:dlna-org:serviceId:DLNAMediaController1/SelectDMRDevice" , autoupdate="false"}

Must I use a Mapping File ? maybe playing with the _defaultCommand ?

Same thing for the "Play" action, but one problem at a time :) My goal is to transfer all automations process out of my Vera to OpenHAB.

Thanks for reading, for this binding and sorry for my crappy English :(

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: How to invoke DLNA Plugin Actions?
« Reply #1 on: January 14, 2015, 01:03:52 pm »
@macfly92,
In the current version you have to create an Item declaration, with a command parameter that points to a MAP file.  Technically, I permit inline command declarations, but it's easier to use the MAP file since I can start to include a set of these into the Binding itself to make it easier for others.

The literal translation of this bit of Lua:
Code: [Select]
local lul_arguments = {}
lul_arguments["URL"] = descriptionURL
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "SelectDMRDevice", lul_arguments, 47)

is this in your Item declaration,
Code: [Select]
String  AUDIO_SLN_SELECT {mios:"unit:house,device:44/service/urn:dlna-org:serviceId:DLNAMediaController1/SelectDMRDevice,command:MAP(miosDLNASelectDMRDevice.map)" , autoupdate="false"}

along with this MAP Transformation file in OH/configurations/transform/miosDLNASelectDMRDevice.map
Code: [Select]
_defaultCommand=urn:dlna-org:serviceId:DLNAMediaController1/SelectDMRDevice(URL=??)

and in the Rule, it'll be something like...
Code: [Select]
...
AUDIO_SLN_SELECT.sendCommand(DescriptionURLItem.state as StringType)
...

For now, this is more complex than it needs to be because I don't have the openHAB Action binding yet, which would allow you to put that directly into the Rule... :(

PS: You're english is just fine!


@lolodomo: Do you want to build a set of MAP files for the DLNA and/or Sonos Bindings?  If you build them, and let me know the ServiceId defaults you want, I'll include them into the system to make it a little easier (at least until I create callMios())

I can add service defaults as well, they just need to be in this (example) format:
Code: [Select]
service/urn\:upnp-org\:serviceId\:AVTransport/TransportState=command:MAP(miosUPnPTransportStatePlayModeCommand.map)

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: How to invoke DLNA Plugin Actions?
« Reply #2 on: January 14, 2015, 02:08:41 pm »
Thanks you for this usefull informations.

I will give it a try ASAP, and I'll post my Lua Script and the converted OpenHAB stuff if it can help someone else.

Too bad that Openhab doesn't have such binding, and in addition, the existing Sonos binding must be pretty close to it. So we must stick with the excellent work of Lolodomo in the uPnP Plugin:)
If only I have more dev skill ...
« Last Edit: January 14, 2015, 02:16:23 pm by macfly92 »

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: How to invoke DLNA Plugin Actions?
« Reply #3 on: January 29, 2015, 12:00:15 pm »
@macfly92,
How did you get on with this?

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: How to invoke DLNA Plugin Actions?
« Reply #4 on: November 13, 2016, 07:07:54 am »
I'm back (from the futur) lol  ;D

Life forced me to put home automation on the side but now that I have little spare time, I'm trying to get back to work.
Very sorry to have let you down like this ...

I've seen that Lolodomo maybe looking to build a DNLA binding for openhab2 from the SONOS binding (https://community.openhab.org/t/dlna-upnp-binding/1790/26) but in mean time, I look also for our case.

Now I'm more familiar with mapping operation, etc. in Openhab.

You've said " this is more complex than it needs to be because I don't have the openHAB Action binding yet" but now I saw that there is a Mios Action Binding so I'm trying to figured out how it work to implement in rules.

Again thanks for your work.

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: How to invoke DLNA Plugin Actions?
« Reply #5 on: November 13, 2016, 09:54:36 am »
Here is my work wih MiosAction at the moment :

From the MiOS Action doc (https://github.com/openhab/openhab/wiki/MiOS-Action)

This is part of the result when I invoke http://<vera-IP>:3480/data_request?id=lu_invoke&DeviceNum=41 :

Code: [Select]
urn:dlna-org:serviceId:DLNAMediaController1
*Play (URI,Protocol,Volume,Duration)
*SearchAndSelectDMRDevice (Name,IP)
*StartDMSDiscovery
*BrowseDMS (DescriptionURL,ObjectID)
*PlayDMSMedia (DescriptionURL,ObjectID,Protocol)
*NotifyRenderingChange (LastChange)
*NotifyAVTransportChange (LastChange)
   -DMRDiscoveryResult
   -DMSDiscoveryResult
   -DescriptionURL
   -Online
   -ModelName
   -ProxyUsed
   -PluginVersion

Based on this, here is my configuration :

Items :
String  SDB_MUSIC_CTRL  "SDB - Controle Musique" (SDB)                  { mios="unit:house,device:41/service/DLNAMediaController1/Online" }
Switch SDB_Play_Radio "Radio dans la salle de bain" (AllSCENES)

Rules :
Code: [Select]
rule "SDB Play Radio"
        when
                Item SDB_Play_Radio changed
        then
                if ((SDB_Play_Radio.state == ON)) {
                        logInfo ("FILE", "#### Play SDB Music !")
                        sendMiosAction(SDB_MUSIC_CTRL, "urn:dlna-org:serviceId:DLNAMediaController1/SelectDMRDevice", newArrayList('URL' -> 'http://192.168.0.123:49494/description.xml'))
                        sendMiosAction(SDB_MUSIC_CTRL, "urn:dlna-org:serviceId:DLNAMediaController1/Play", newArrayList('URI' -> 'http://hd.lagrosseradio.info:8500'))
                } else if ((SDB_Play_Radio.state == OFF)) {
                        sendMiosAction(SDB_MUSIC_CTRL, "urn:upnp-org:serviceId:AVTransport/Stop")
                }
end

And it work like a charm !
« Last Edit: November 13, 2016, 10:42:44 am by macfly92 »

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: How to invoke DLNA Plugin Actions?
« Reply #6 on: November 25, 2016, 03:52:08 pm »
Good to see you got it going.

Let me know if there's extra stuff to add to the doc to make it easier for others, or feel free to edit the openHAB MIOS wiki pages directly (In its example pages, for example)

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: How to invoke DLNA Plugin Actions?
« Reply #7 on: January 12, 2017, 05:44:56 pm »
Hi guessed ! Happy new year !  :)

I using Mios Action since a while now but sometime the Mios Action just stop working. One time is because I restarted the vera but sometime it just stop without know reason.
When I rebooted the vera, the Mios Binding restarted the polling, but Mios Action did not resumed.
Here is what I saw in the logs when i try to use a rule with an Mios Action inside :

Code: [Select]
[ERROR] [nhab.action.mios.internal.MiosAction] - MiOS Service is not configured, Action for Item SDB_MUSIC_CTRL not queued.
java.lang.Exception: MiOS Service is not configured, Action for Item SDB_MUSIC_CTRL not queued.
        at org.openhab.action.mios.internal.MiosAction.getActionProviderInternal(MiosAction.java:103)
        at org.openhab.action.mios.internal.MiosAction.sendMiosActionInternal(MiosAction.java:149)
        at org.openhab.action.mios.internal.MiosAction.sendMiosActionInternal(MiosAction.java:124)
        at org.openhab.action.mios.internal.MiosAction.sendMiosAction(MiosAction.java:65)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_112]

On Karaf console, I tried to restart it with bundle:restart org.openhab.action.mios and even with a binding restart with bundle:restart org.openhab.binding.mios but only a full restart of openhab correctly reloaded it.

Do you have an idea ? let me know if I can provide you more information.

Thanks you.

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: How to invoke DLNA Plugin Actions?
« Reply #8 on: January 24, 2017, 12:06:13 pm »
That's odd.  I do push calls from the MiOS Action Binding to the MiOS Binding itself, so it's possible I'm missing a dependency there, and startup order is kicking in.

What version of openHAB are you running this under?  Have you tried it against the release version?

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: How to invoke DLNA Plugin Actions?
« Reply #9 on: January 24, 2017, 12:08:13 pm »
PS: I nearly missed this posting.  It'll be easier to have the discussion on https://community.openhab.org

That forum software is a lot newer, so you can @ me, and I'll get email notification (etc).  I also follow stuff that's been tagged _mios_ on that forum, so there are several ways to get my attention.

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: How to invoke DLNA Plugin Actions?
« Reply #10 on: January 25, 2017, 08:37:02 am »
Thanks for your answer, you're right, I'll post this one to the openhab comunity website with the infos you asked.
I will try to reproduce this with a controlled Vera restart to see if it hapend each time.
« Last Edit: January 25, 2017, 08:40:19 am by macfly92 »