How to invoke DLNA Plugin Actions?

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 :slight_smile: 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 :frowning:

@macfly92,
In the current version you have to create an Item declaration, with a [tt]command[/tt] 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:

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,

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 [tt]OH/configurations/transform/miosDLNASelectDMRDevice.map[/tt]

_defaultCommand=urn:dlna-org:serviceId:DLNAMediaController1/SelectDMRDevice(URL=??)

and in the Rule, it’ll be something like…

... 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… :frowning:

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 [tt]callMios()[/tt])

I can add service defaults as well, they just need to be in this (example) format:

service/urn\:upnp-org\:serviceId\:AVTransport/TransportState=command:MAP(miosUPnPTransportStatePlayModeCommand.map)

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 …

@macfly92,
How did you get on with this?

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 (DLNA / UPNP binding - #26 by MacFly - Bindings - openHAB Community) 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.

Here is my work wih MiosAction at the moment :

From the MiOS Action doc (MiOS Action · openhab/openhab1-addons Wiki · GitHub)

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

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 :

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 !

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)

Hi guessed ! Happy new year ! :slight_smile:

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 :

[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.

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?

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.

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.