Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddonInfo extensions #3865

Merged
merged 11 commits into from
Dec 5, 2023
Merged

AddonInfo extensions #3865

merged 11 commits into from
Dec 5, 2023

Conversation

andrewfg
Copy link
Contributor

@andrewfg andrewfg commented Nov 6, 2023

This PR contains core extensions to the AddonInfo class as foundation work to in order to support the discovery of addons to be suggested to be installed on setup.

Changes in AddonInfo

  • The AddonInfo DTO has been extended to include fields for ‘discovery-methods’ which identify the mechanisms by which an addon could be discovered. And sub- DTOs for ‘discovery-methods’ and ‘match-properties’ have been added.
  • The XML schema for AddonInfo has been extended accordingly.
  • The XML de-serializer for AddonInfo has been extended accordingly. With additional sub- DTO de-serializers for ‘discovery-methods’ and ‘match-properties’.
  • An additional DTO has been defined to contain a List<AddonInfo>
  • An additional XML de-serializer has been created for loading a List<AddonInfo> DTO.
  • The XML schema for AddonInfoList has been added.
  • Junit tests have been adapted/added for the above.

Other Changes in this PR

  • This PR also includes an 'AddonsInfoProvider' component that implements the AddonInfoProvider interface and contains the addon.xml information for all addons which it gets by reading all *.xml files which will have been installed in the /userdata/adddons/ folder.

Depends on openhab/openhab-addons#15780
Pre requisite for #3806

PR with documentation changes openhab/openhab-docs#2150

Signed-off-by: Andrew Fiddian-Green [email protected]

Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg andrewfg requested a review from a team as a code owner November 6, 2023 16:54
@andrewfg
Copy link
Contributor Author

andrewfg commented Nov 6, 2023

@mherwege ping.

@mherwege
Copy link
Contributor

mherwege commented Nov 7, 2023

@andrewfg Based on the discussion in the addon PR, I think you can ommit the AddonInfoProviderInstaller. But you should bring most of the code from the addon PR in here, i.e. read an addons.xml file from userdata/etc and make it available through a specific AddonInfoProvider.

Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg
Copy link
Contributor Author

andrewfg commented Nov 9, 2023

@andrewfg
Copy link
Contributor Author

andrewfg commented Nov 9, 2023

@J-N-K @mherwege @kaikreuzer just so you know: I have tested this PR by manually putting an 'addons.xml' file in the '/userdata/addons' folder, and I can confirm that its respective AddonInfoProvider does indeed load and parse the file and produce the necessary AddonInfo results.

And furthermore when my AddonSuggestionFinderService component is instantiated and queried from the Rest API, it indeed finds all thirteen of my addons that I would expect it to find..

[
  {
    "id": "homeconnect",
    "type": "binding",
    "uid": "binding-homeconnect",
    "name": "Home Connect Binding",
    "description": "The binding integrates the Home Connect (https://www.home-connect.com/) system into openHAB. It connects to household devices from brands like Bosch and Siemens.",
    "connection": "cloud",
    "countries": [],
    "serviceId": "binding.homeconnect",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_homeconnect._tcp.local."
      }
    ]
  },
  {
    "id": "ipp",
    "type": "binding",
    "uid": "binding-ipp",
    "name": "IPP Binding",
    "description": "This is the binding for the Internet Printing Protocol (IPP). You can show how many jobs are done/waiting on an IPP/CUPS Printer",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.ipp",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_ipp._tcp.local."
      }
    ]
  },
  {
    "id": "hue",
    "type": "binding",
    "uid": "binding-hue",
    "name": "Hue Binding",
    "description": "The Hue Binding integrates the Philips Hue system. It allows to control Hue bulbs.",
    "connection": "hybrid",
    "countries": [],
    "serviceId": "binding.hue",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_hue._tcp.local."
      },
      {
        "serviceType": "upnp",
        "matchProperties": [
          {
            "name": "modelName",
            "regex": "Philips hue bridge.*"
          }
        ]
      }
    ]
  },
  {
    "id": "oppo",
    "type": "binding",
    "uid": "binding-oppo",
    "name": "Oppo Blu-ray Player Binding",
    "description": "Controls Oppo UDP-203/205 and BDP-83/93/95/103/105 Blu-ray Players",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.oppo",
    "discoveryMethods": [
      {
        "serviceType": "upnp",
        "matchProperties": [
          {
            "name": "manufacturer",
            "regex": "(?i)OPPO"
          },
          {
            "name": "deviceType",
            "regex": ".*MediaRenderer.*"
          }
        ]
      }
    ]
  },
  {
    "id": "hdpowerview",
    "type": "binding",
    "uid": "binding-hdpowerview",
    "name": "Hunter Douglas PowerView Binding",
    "description": "The Hunter Douglas PowerView binding provides access to the Hunter Douglas line of PowerView shades.",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.hdpowerview",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_powerview-g3._tcp.local."
      },
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_powerview._tcp.local."
      }
    ]
  },
  {
    "id": "yamahareceiver",
    "type": "binding",
    "uid": "binding-yamahareceiver",
    "name": "YamahaReceiver Binding",
    "description": "For all network enabled Yamaha receivers.",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.yamahareceiver",
    "discoveryMethods": [
      {
        "serviceType": "upnp",
        "matchProperties": [
          {
            "name": "manufacturer",
            "regex": "(?i).*YAMAHA.*"
          },
          {
            "name": "deviceType",
            "regex": ".*MediaRenderer.*"
          }
        ]
      }
    ]
  },
  {
    "id": "tado",
    "type": "binding",
    "uid": "binding-tado",
    "name": "tado° Binding",
    "description": "Binding for tado° devices",
    "connection": "cloud",
    "countries": [],
    "serviceId": "binding.tado",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_hap._tcp.local.",
        "matchProperties": [
          {
            "name": "name",
            "regex": "tado.*"
          }
        ]
      }
    ]
  },
  {
    "id": "velux",
    "type": "binding",
    "uid": "binding-velux",
    "name": "@text/addon.velux.name",
    "description": "@text/addon.velux.description",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.velux",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_http._tcp.local.",
        "matchProperties": [
          {
            "name": "name",
            "regex": "(?i)VELUX.KLF.LAN.*"
          }
        ]
      }
    ]
  },
  {
    "id": "hpprinter",
    "type": "binding",
    "uid": "binding-hpprinter",
    "name": "HP Printer Binding",
    "description": "Binding for HP Printers with Embedded Web Servers",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.hpprinter",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_printer._tcp.local.",
        "matchProperties": [
          {
            "name": "rp",
            "regex": ".*"
          },
          {
            "name": "ty",
            "regex": "(?i)HP .*"
          }
        ]
      },
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_ipp._tcp.local.",
        "matchProperties": [
          {
            "name": "rp",
            "regex": ".*"
          },
          {
            "name": "ty",
            "regex": "(?i)HP .*"
          }
        ]
      }
    ]
  },
  {
    "id": "sonyaudio",
    "type": "binding",
    "uid": "binding-sonyaudio",
    "name": "SonyAudio Binding",
    "description": "This is the binding for SonyAudio products (Receivers and wireless speakers).",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.sonyaudio",
    "discoveryMethods": [
      {
        "serviceType": "upnp",
        "matchProperties": [
          {
            "name": "manufacturer",
            "regex": "(?i).*SONY.*"
          },
          {
            "name": "deviceType",
            "regex": ".*MediaRenderer.*"
          }
        ]
      }
    ]
  },
  {
    "id": "neohub",
    "type": "binding",
    "uid": "binding-neohub",
    "name": "NeoHub Binding",
    "description": "This is the binding for Heatmiser NeoHub devices",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.neohub",
    "discoveryMethods": [
      {
        "serviceType": "mdns",
        "mdnsServiceType": "_hap._tcp.local.",
        "matchProperties": [
          {
            "name": "name",
            "regex": "Heatmiser neoHub"
          }
        ]
      }
    ]
  },
  {
    "id": "upnpcontrol",
    "type": "binding",
    "uid": "binding-upnpcontrol",
    "name": "UPnP Control Binding",
    "description": "This binding acts as a UPnP Control Point that can query media server content directories and serve content to media renderers.",
    "connection": "local",
    "countries": [],
    "configDescriptionURI": "binding:upnpcontrol",
    "serviceId": "binding.upnpcontrol",
    "discoveryMethods": [
      {
        "serviceType": "upnp",
        "matchProperties": [
          {
            "name": "deviceType",
            "regex": ".*MediaRenderer.*"
          }
        ]
      },
      {
        "serviceType": "upnp",
        "matchProperties": [
          {
            "name": "deviceType",
            "regex": ".*MediaServer.*"
          }
        ]
      }
    ]
  },
  {
    "id": "harmonyhub",
    "type": "binding",
    "uid": "binding-harmonyhub",
    "name": "HarmonyHub Binding",
    "description": "The HarmonyHub Binding integrates Logitech Harmony hubs and remotes.",
    "connection": "local",
    "countries": [],
    "serviceId": "binding.harmonyhub",
    "discoveryMethods": [
      {
        "serviceType": "upnp",
        "matchProperties": [
          {
            "name": "modelName",
            "regex": "Harmony Hub"
          }
        ]
      }
    ]
  }
]

@@ -24,16 +24,16 @@
<attribute name="annotationpath" value="target/dependency"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm. Not sure. I think Eclipse did it automagically when I wrote a new JUnit test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you simply revert the changes so that this PR leaves the file untouched?

@andrewfg
Copy link
Contributor Author

So I did a full build of everything incorporating both of my PRs in openhab-core, plus my PR in openhab-addons plus both of @J-N-K 's PRs in openhab-addons and openhab-distro, plus the PR of @mherwege in openhab-webui; (it took absolutely ages on my (old) PC); however .. it works!!

Following is a screenshot from the OH startup screen ..
Note: there is obviously a text localisation issue concerning e.g. the Velux binding

image

@andrewfg
Copy link
Contributor Author

^
And here is what I see in the Add-on Store..

image

Signed-off-by: Andrew Fiddian-Green <[email protected]>
@mherwege
Copy link
Contributor

LGTM

@mherwege
Copy link
Contributor

Depends on #3806

@andrewfg Does it depend on it, or is it a pre-requisite? I believe it is just a pre-requisite.

Apart from being a pre-requisite, the big added value of this PR (combined with openhab/openhab-addons#15870 and openhab/openhab-distro#1604) is that it makes all distribution add-on info available before installation of the add-on. This potentially allows extending the UI to filter on more add-on attributes.

@openhab/maintainers This PR and the 2 related ones are a foundation for making add-on selection easier or automatic. They don't do it by themselves, but collect all the necessary information. There is no code in here that would start discovery processes. Would it be possible to review and merge these as a start?
#3806 can be reviewed as a second step, considering also the debate about enabling/disabling finders.
I think another PR for the UI could be created to allow filtering add-ons in the store on attributes once this has been merged and is available.

@andrewfg
Copy link
Contributor Author

andrewfg commented Nov 30, 2023

Does it depend on it, or is it a pre-requisite? I believe it is just a pre-requisite.

It is indeed only a pre-requisite.

@kaikreuzer
Copy link
Member

Many thanks for all your efforts @andrewfg and @mherwege! I'm very happy to see this feature being implemented, especially as I was the one formulating the initial issue about it.
I've started reviewing this PR and will come back with feedback very soon. The plan is definitely to get this into 4.1!

@andrewfg
Copy link
Contributor Author

andrewfg commented Dec 3, 2023

@kaikreuzer I appreciate your support. This PR is only a part step, and #3806 contains the full set.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!
I have only a few minor comments/questions, see below.

*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.addon.infoproviders;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use singular for package names.
But does this really need a separate package? And does it have to be a public one or could it be moved to org.openhab.core.addon.internal.xml?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I am not sure if it needs to be public; maybe #3806 needs it? But I will move it to internal here, and we could eventually move it back in #3806..

@@ -24,16 +24,16 @@
<attribute name="annotationpath" value="target/dependency"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you simply revert the changes so that this PR leaves the file untouched?

bundles/org.openhab.core.config.core/.classpath Outdated Show resolved Hide resolved
@andrewfg andrewfg requested a review from kaikreuzer December 5, 2023 12:33
Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the prompt updates!

@kaikreuzer kaikreuzer merged commit cc9b705 into openhab:main Dec 5, 2023
3 checks passed
@kaikreuzer kaikreuzer added this to the 4.1 milestone Dec 5, 2023
@kaikreuzer
Copy link
Member

FTR: I have deployed the updated XSDs on our website, see openhab/website@74e3185.

@mherwege
Copy link
Contributor

mherwege commented Dec 5, 2023

@andrewfg @kaikreuzer Thank you for the work and the review.

@andrewfg
Copy link
Contributor Author

andrewfg commented Dec 5, 2023

@mherwege and thank you too!!

@andrewfg
Copy link
Contributor Author

andrewfg commented Dec 5, 2023

have deployed the updated XSDs on our website

@kaikreuzer Cool. Thank you. I have openhab/openhab-addons#15817 building now. The first few bindings already passed the schema verification. :)

EDIT: they all passed the verification :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants