MDNSDiscoveryParticipant not activating - new binding

I have a dumb question (or what feels like a dumb question). I’ve been attempting to add mdns discovery to the shieldtv binding for a few days now. I can’t for the life of me get it to activate when OH starts. I’ve tried everything from writing it directly (as per the guides) to copying from other bindings to see if I was screwing something up. The binding compiles, but it never kicks. I’ve enabled trace logging for MDNSDiscoveryParticipant and compared to others I never get the addMDNSDiscoveryParticipant messages. The only thing I can think of at this point is that I need to recompile the discovery bits in openhab-core so that they detect the MDNSDiscoveryParticipant during compile. Am I on the right track?

Code uploaded here: GitHub - morph166955/openhab-addons at shieldtv-mdns
Specifically openhab-addons/ShieldTVDiscoveryParticipant.java at shieldtv-mdns · morph166955/openhab-addons · GitHub

I’ll preface this with the fact that I’ve never implemented an MDNS discovery service… :wink:

Are you sure the service type is correct? I’m guessing that core uses that to match to your discovery service.

Is your Shield on a different network/subnet/VLAN from your openHAB instance. Perhaps the MDNS packets don’t route across networks/subnets/VLANs.

What do you see in the console when you run:

bundle:services org.openhab.binding.shieldtv

or

bundle:capabilities org.openhab.binding.shieldtv

Do you see the MDNSDiscoveryParticipant and your DiscoveryService?

Take a look at another binding that you use that uses MDNSDiscoveryParticipant (e.g. androiddebugbridge) as an example.

I based my code against the lutron, vizio, neeo, and adb bindings. I can’t find the differences. I copy/pasted from adb to see if it was a typo. The binding works perfectly fine minus mdns. I can manually add thing/items and it connects and does all of it’s things.

To compare the two (see below). Obviously ADB is showing the mdns and shieldtv isn’t. The question I can’t answer is why.

openhab> bundle:services org.openhab.binding.shieldtv

openHAB Add-ons :: Bundles :: ShieldTV Binding (235) provides:
--------------------------------------------------------------
[org.openhab.core.thing.binding.ThingHandlerFactory]
openhab> bundle:capabilities org.openhab.binding.shieldtv
org.openhab.binding.shieldtv_4.0.0.202212272047 [235] provides:
---------------------------------------------------------------
osgi.wiring.bundle; org.openhab.binding.shieldtv 4.0.0.202212272047 [UNUSED]
osgi.wiring.host; org.openhab.binding.shieldtv 4.0.0.202212272047 [UNUSED]
osgi.identity; org.openhab.binding.shieldtv 4.0.0.202212272047 [UNUSED]
osgi.service; objectClass:List<String>="org.openhab.core.thing.binding.ThingHandlerFactory"; uses:="org.openhab.core.thing.binding" [UNUSED]
service; [org.openhab.core.thing.binding.ThingHandlerFactory] with properties:
   service.id = 457
   service.bundleid = 235
   service.scope = bundle
   component.name = org.openhab.binding.shieldtv.internal.ShieldTVHandlerFactory
   component.id = 282
   Used by:
      org.openhab.core.thing_4.0.0.202212191857 [212]
      org.openhab.core.model.thing_4.0.0.202212191902 [206]
      org.openhab.core.config.discovery_4.0.0.202212191859 [162]


openhab> bundle:services org.openhab.binding.androiddebugbridge

openHAB Add-ons :: Bundles :: Android Debug Bridge Binding (236) provides:
--------------------------------------------------------------------------
[org.openhab.core.thing.type.DynamicCommandDescriptionProvider, org.openhab.binding.androiddebugbridge.internal.AndroidDebugBridgeDynamicCommandDescriptionProvider]
[org.openhab.core.thing.binding.ThingHandlerFactory]
[org.openhab.core.config.discovery.DiscoveryService]
[org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant]
[org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant]
openhab> bundle:capabilities org.openhab.binding.androiddebugbridge
org.openhab.binding.androiddebugbridge_4.0.0.202212200736 [236] provides:
-------------------------------------------------------------------------
osgi.wiring.bundle; org.openhab.binding.androiddebugbridge 4.0.0.202212200736 [UNUSED]
osgi.wiring.host; org.openhab.binding.androiddebugbridge 4.0.0.202212200736 [UNUSED]
osgi.identity; org.openhab.binding.androiddebugbridge 4.0.0.202212200736 [UNUSED]
osgi.service; objectClass:List<String>="org.openhab.binding.androiddebugbridge.internal.AndroidDebugBridgeDynamicCommandDescriptionProvider,org.openhab.core.thing.type.DynamicCommandDescriptionProvider"; uses:="org.openhab.binding.androiddebugbridge.internal,org.openhab.core.thing.type" [UNUSED]
osgi.service; objectClass:List<String>="org.openhab.core.config.discovery.DiscoveryService"; uses:="org.openhab.core.config.discovery" [UNUSED]
osgi.service; objectClass:List<String>="org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant"; uses:="org.openhab.core.config.discovery.mdns" [UNUSED]
osgi.service; objectClass:List<String>="org.openhab.core.thing.binding.ThingHandlerFactory"; uses:="org.openhab.core.thing.binding" [UNUSED]
service; [org.openhab.core.thing.type.DynamicCommandDescriptionProvider, org.openhab.binding.androiddebugbridge.internal.AndroidDebugBridgeDynamicCommandDescriptionProvider] with properties:
   service.id = 458
   service.bundleid = 236
   service.scope = bundle
   component.name = org.openhab.binding.androiddebugbridge.internal.AndroidDebugBridgeDynamicCommandDescriptionProvider
   component.id = 283
   Used by:
      org.openhab.core.thing_4.0.0.202212191857 [212]
      org.openhab.binding.androiddebugbridge_4.0.0.202212200736 [236]
service; [org.openhab.core.thing.binding.ThingHandlerFactory] with properties:
   service.id = 459
   service.bundleid = 236
   service.scope = bundle
   component.name = org.openhab.binding.androiddebugbridge.internal.AndroidDebugBridgeHandlerFactory
   component.id = 284
   Used by:
      org.openhab.core.thing_4.0.0.202212191857 [212]
      org.openhab.core.model.thing_4.0.0.202212191902 [206]
      org.openhab.core.config.discovery_4.0.0.202212191859 [162]
service; [org.openhab.core.config.discovery.DiscoveryService] with properties:
   service.id = 460
   service.bundleid = 236
   service.scope = bundle
   component.name = org.openhab.binding.androiddebugbridge.internal.discovery.AndroidDebugBridgeDiscoveryService
   component.id = 285
   Used by:
      org.openhab.core.config.discovery_4.0.0.202212191859 [162]
service; [org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant] with properties:
   service.id = 461
   service.bundleid = 236
   service.scope = bundle
   component.name = org.openhab.binding.androiddebugbridge.internal.discovery.AndroidTVMDNSDiscoveryParticipant
   component.id = 286
   Used by:
      org.openhab.core.config.discovery.mdns_4.0.0.202212191902 [163]
service; [org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant] with properties:
   service.id = 462
   service.bundleid = 236
   service.scope = bundle
   component.name = org.openhab.binding.androiddebugbridge.internal.discovery.FireTVStickMDNSDiscoveryParticipant
   component.id = 287
   Used by:
      org.openhab.core.config.discovery.mdns_4.0.0.202212191902 [163]

To compare, this is the ADB discovery:

Versus:

I built the code in your branch named shieldtv-mdns and dropped the jar into my OH4 instance.

When I run bundle:services org.openhab.binding.shieldtv, I see this.

openHAB Add-ons :: Bundles :: ShieldTV Binding (295) provides:
--------------------------------------------------------------
[org.openhab.core.thing.binding.ThingHandlerFactory]
[org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant]

And bundle:capabilities org.openhab.binding.shieldtv shows

org.openhab.binding.shieldtv_4.0.0.202212290321 [295] provides:
---------------------------------------------------------------
osgi.wiring.bundle; org.openhab.binding.shieldtv 4.0.0.202212290321 [UNUSED]
osgi.wiring.host; org.openhab.binding.shieldtv 4.0.0.202212290321 [UNUSED]
osgi.identity; org.openhab.binding.shieldtv 4.0.0.202212290321 [UNUSED]
osgi.service; objectClass:List<String>="org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant"; uses:="org.openhab.core.config.discovery.mdns" [UNUSED]
osgi.service; objectClass:List<String>="org.openhab.core.thing.binding.ThingHandlerFactory"; uses:="org.openhab.core.thing.binding" [UNUSED]
service; [org.openhab.core.thing.binding.ThingHandlerFactory] with properties:
   service.id = 2192
   service.bundleid = 295
   service.scope = bundle
   component.name = org.openhab.binding.shieldtv.internal.ShieldTVHandlerFactory
   component.id = 393
   Used by:
      org.openhab.core.config.discovery_4.0.0.202212191859 [162]
      org.openhab.core.model.thing_4.0.0.202212191902 [206]
      org.openhab.core.thing_4.0.0.202212191857 [212]
service; [org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant] with properties:
   service.id = 2193
   service.bundleid = 295
   service.scope = bundle
   component.name = org.openhab.binding.shieldtv.internal.discovery.ShieldTVDiscoveryParticipant
   component.id = 394
   Used by:
      org.openhab.core.config.discovery.mdns_4.0.0.202212191902 [163]

Note I don’t have a ShieldTV so I won’t be able to discover anything. However, I do see the MDNS service.

I’d try the binding in the house that has the Shield TV (I have an IPSEC tunnel between the two houses), but that house is running OH3 right now. And I wasn’t planning to upgrade to 4,0 until I was there in person.

Well thats interesting. I wonder if something in my dev instance is jammed up. What snapshot version are you running? Can you send me your jar for comparison? What command are you using to compile specifically?

I’m running build 3245.

I built it using mvn install

Here’s the jar.
https://drive.google.com/file/d/1DVwnu6qLbDCa7E7U_kYFP8TpPexacu0D/view?usp=share_link

Has to be something with my build environment. Your jar works perfectly. I’m on build 3243 for reference. THANK YOU! I was going insane.

1 Like

Sounds good. At least now you know it’s not the code. Of course, tracking down build environment issues can be even less fun than tracking down code issues. :rofl:

True! At least I know I’m not completely nuts though. I could not figure out what was wrong with the code.

Build environment fixed! Thanks @mhilbush for the help!

1 Like