Marketplace versioning with embedded resource

I don’t know if this is the correct place to post this, so any moderator: feel free to move it to a more suitable location.

My question is simple: With custom widgets with embedded YAML on the Marketplace, how do one handle new versions? I understand how to handle the changelog part, but I mean the resource itself. I’d like to preserve the previous version if there’s something that worked better there for somebody, or if there’s a regression.

But, with several versions, the first post can become long and “difficult” to read, it can even exceed the 10000 characters limit. In addition, I want to make sure that the “automated parsing” done by OH will pick up the correct/latest version.

What is the “best practice” for how to handle this?

Instead of posting the resource inline you can post a reference to a URL somewhere that the resource gets pulled from. Most use Github but I’m sure any host will do so long as the URL is directly to the YAML in question.

But, if you want to make versioning available instead of just the latest version, one of the source control hosts a la Github, Gitlab, Bitbucket, Sourceforge, et al would be the way to go.

Due to the limitations of the forum and OH’s ability to parse the marketpalce entries, you really can only have the latest version posted in any one given marketpalce posting. When something big changes and you need to perhaps break between versions (e.g. between OH4 and OH5) you’d make a new post and limit who sees which version with the versioning.

Ok. I knew about GitHub etc., but I have a lot of repos there already and didn’t really feel for making yet another one just for widgets. Also, I think it’s too complicated for many to use Git to fetch/get a previous version if that’s what they want.

But I think I’ve seen some Marketplace posts with several links. Is there some system that the parser picks the first one for example, or is it then just “random” which one gets picked up as “the resource”? Maybe there could be a tag or prefix or some way to indicate which one was “the resource”?

It follows the template. Any deviation from the tempalte causes problems. If you have more URLs than expected, I would assume that the first URL is what gets used as the “latest”. But that’s not always the case. You’ll have to experiment to see what works, with the understanding that it may break in the future without notice.

There are usually several links expected for bundles. Those include a link to th resource and another for the license. For rule tempaltes, any more than one link has proved very problematic. I’ve never ventured outside the template for widgets or block libraries.

All things are potentially possible with code but that’s going to require a PR to openhab-core and MainUI to add features oir change the tempalte.

Yes, I’ve already touched at some of that code, although I didn’t study the parsing itself that closely, as I was after “the version range bug”:

I can study it a bit and see if I figure out the exact “rules”.

Note, the 10000 character limit comes from the forum, not OH. I’m not sure there is a way around that.

1 Like

It seems like the logic is relatively “rudimentary”. Basically, it requests a “normal” forum topic in “JSON form” (Accept = application/json), which makes the forum return something like this:

{
    "post_stream": {
        "posts": [
            {
                "id": 915487,
                "name": "Nadar",
                "username": "Nadahar",
                "avatar_template": "/user_avatar/community.openhab.org/nadahar/{size}/44246_2.png",
                "created_at": "2024-12-06T17:03:17.715Z",
                "cooked": "<p><img src=\"//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/7/d/7d45afed4a68750673b725367fb37e9f780d6a49.svg\" alt=\"logo\" data-base62-sha1=\"hScZfM1qVuc1EQSv1o96G5SPBgJ\" width=\"384\" height=\"175\"></p>\n<p>This binding integrates generation 3 <a href=\"https://millnorway.com/\" rel=\"noopener nofollow ugc\">Mill devices</a> using the local network only.</p>\n<p>Documentation can be found <a href=\"https://github.com/Nadahar/Mill-LAN-openHAB-Binding/blob/master/bundles/org.openhab.binding.milllan/README.md\" rel=\"noopener nofollow ugc\">here</a>.</p>\n<p>This binding has so far only been tested with Mill panel heaters. If you have access to generation 3 Mill devices of a different type and would like to help me verify that they work as intended, please open a <a href=\"https://github.com/Nadahar/Mill-LAN-openHAB-Binding/issues\" rel=\"noopener nofollow ugc\">GitHub issue</a> or tag me in a forum topic.</p>\n<h2><a name=\"p-915487-changelog-1\" class=\"anchor\" href=\"#p-915487-changelog-1\"></a>Changelog</h2>\n<h3><a name=\"p-915487-version-10-2\" class=\"anchor\" href=\"#p-915487-version-10-2\"></a>Version 1.0</h3>\n<ul>\n<li>initial release</li>\n</ul>\n<h2><a name=\"p-915487-resources-3\" class=\"anchor\" href=\"#p-915487-resources-3\"></a>Resources</h2>\n<p><a href=\"https://github.com/Nadahar/Mill-LAN-openHAB-Binding/releases/download/v1.0.0/org.openhab.binding.milllan-1.0.0.jar\" class=\"onebox\" target=\"_blank\" rel=\"noopener nofollow ugc\">https://github.com/Nadahar/Mill-LAN-openHAB-Binding/releases/download/v1.0.0/org.openhab.binding.milllan-1.0.0.jar</a></p>\n<aside class=\"onebox githubrepo\" data-onebox-src=\"https://github.com/Nadahar/Mill-LAN-openHAB-Binding\">\n  <header class=\"source\">\n\n      <a href=\"https://github.com/Nadahar/Mill-LAN-openHAB-Binding\" target=\"_blank\" rel=\"noopener nofollow ugc\">github.com</a>\n  </header>\n\n  <article class=\"onebox-body\">\n    <div class=\"github-row\" data-github-private-repo=\"false\">\n  <img width=\"690\" height=\"344\" src=\"https://opengraph.githubassets.com/7390dbc8fb81d819103b1ad81939aaae/Nadahar/Mill-LAN-openHAB-Binding\" class=\"thumbnail\">\n\n  <h3><a href=\"https://github.com/Nadahar/Mill-LAN-openHAB-Binding\" target=\"_blank\" rel=\"noopener nofollow ugc\">GitHub - Nadahar/Mill-LAN-openHAB-Binding</a></h3>\n\n    <p><span class=\"github-repo-description\">Contribute to Nadahar/Mill-LAN-openHAB-Binding development by creating an account on GitHub.</span></p>\n</div>\n\n  </article>\n\n  <div class=\"onebox-metadata\">\n    \n    \n  </div>\n\n  <div style=\"clear: both\"></div>\n</aside>\n",
                "post_number": 1,
                "post_type": 1,
                "updated_at": "2024-12-06T19:06:21.731Z",
                "reply_count": 0,
                "reply_to_post_number": null,
                "quote_count": 0,
                "incoming_link_count": 8,
                "reads": 27,
                "readers_count": 26,
                "score": 145.4,
                "yours": false,
                "topic_id": 160688,
                "topic_slug": "mill-lan-binding-4-1-0-0-5-0-0-0",
                "display_username": "Nadar",
                "primary_group_name": null,
                "flair_name": null,
                "flair_url": null,
                "flair_bg_color": null,
                "flair_color": null,
                "flair_group_id": null,
                "version": 4,
                "can_edit": false,
                "can_delete": false,
                "can_recover": false,
                "can_see_hidden_post": false,
                "can_wiki": false,
                "link_counts": [
                    {
                        "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding/blob/master/bundles/org.openhab.binding.milllan/README.md",
                        "internal": false,
                        "reflection": false,
                        "title": "Mill-LAN-openHAB-Binding/bundles/org.openhab.binding.milllan/README.md at master · Nadahar/Mill-LAN-openHAB-Binding · GitHub",
                        "clicks": 4
                    },
                    {
                        "url": "https://millnorway.com/",
                        "internal": false,
                        "reflection": false,
                        "clicks": 4
                    },
                    {
                        "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding",
                        "internal": false,
                        "reflection": false,
                        "title": "GitHub - Nadahar/Mill-LAN-openHAB-Binding",
                        "clicks": 3
                    },
                    {
                        "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding/releases/download/v1.0.0/org.openhab.binding.milllan-1.0.0.jar",
                        "internal": false,
                        "reflection": false,
                        "clicks": 1
                    },
                    {
                        "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding/issues",
                        "internal": false,
                        "reflection": false,
                        "title": "Issues · Nadahar/Mill-LAN-openHAB-Binding · GitHub",
                        "clicks": 1
                    }
                ],
                "read": true,
                "user_title": null,
                "bookmarked": false,
                "actions_summary": [
                    {
                        "id": 2,
                        "count": 3
                    }
                ],
                "moderator": false,
                "admin": false,
                "staff": false,
                "user_id": 36689,
                "hidden": false,
                "trust_level": 2,
                "deleted_at": null,
                "user_deleted": false,
                "edit_reason": null,
                "can_view_edit_history": false,
                "wiki": false,
                "can_accept_answer": false,
                "can_unaccept_answer": false,
                "accepted_answer": false,
                "topic_accepted_answer": false
            }
        ],
        "stream": [
            915487
        ]
    },
    "timeline_lookup": [
        [
            1,
            29
        ]
    ],
    "suggested_topics": [
        {
            "id": 156830,
            "title": "BTHome Binding [4.0.0.0;5.0.0.0)",
            "fancy_title": "BTHome Binding [4.0.0.0;5.0.0.0)",
            "slug": "bthome-binding-4-0-0-0-5-0-0-0",
            "posts_count": 2,
            "reply_count": 0,
            "highest_post_number": 2,
            "image_url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/b/ab89175812b590088328f0ebb779adcb1f007566.png",
            "created_at": "2024-06-22T18:42:37.226Z",
            "last_posted_at": "2024-06-25T19:44:40.768Z",
            "bumped": true,
            "bumped_at": "2024-06-25T19:44:40.768Z",
            "archetype": "regular",
            "unseen": false,
            "pinned": false,
            "unpinned": null,
            "visible": true,
            "closed": false,
            "archived": false,
            "bookmarked": null,
            "liked": null,
            "thumbnails": [
                {
                    "max_width": null,
                    "max_height": null,
                    "width": 868,
                    "height": 256,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/b/ab89175812b590088328f0ebb779adcb1f007566.png"
                },
                {
                    "max_width": 800,
                    "max_height": 800,
                    "width": 800,
                    "height": 235,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/a/b/ab89175812b590088328f0ebb779adcb1f007566_2_800x235.png"
                },
                {
                    "max_width": 600,
                    "max_height": 600,
                    "width": 600,
                    "height": 176,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/a/b/ab89175812b590088328f0ebb779adcb1f007566_2_600x176.png"
                },
                {
                    "max_width": 400,
                    "max_height": 400,
                    "width": 400,
                    "height": 117,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/a/b/ab89175812b590088328f0ebb779adcb1f007566_2_400x117.png"
                },
                {
                    "max_width": 300,
                    "max_height": 300,
                    "width": 300,
                    "height": 88,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/a/b/ab89175812b590088328f0ebb779adcb1f007566_2_300x88.png"
                },
                {
                    "max_width": 200,
                    "max_height": 200,
                    "width": 200,
                    "height": 58,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/a/b/ab89175812b590088328f0ebb779adcb1f007566_2_200x58.png"
                }
            ],
            "tags": [
                "binding",
                "published",
                "stable"
            ],
            "tags_descriptions": {},
            "like_count": 0,
            "views": 297,
            "category_id": 73,
            "featured_link": null,
            "has_accepted_answer": false,
            "posters": [
                {
                    "extras": "latest single",
                    "description": "Original Poster, Most Recent Poster",
                    "user": {
                        "id": 25408,
                        "username": "seime",
                        "name": "Arne S",
                        "avatar_template": "/user_avatar/community.openhab.org/seime/{size}/38320_2.png",
                        "trust_level": 2
                    }
                }
            ]
        },
        {
            "id": 153785,
            "title": "Radio Browser Binding [4.0.0;4.1.9]",
            "fancy_title": "Radio Browser Binding [4.0.0;4.1.9]",
            "slug": "radio-browser-binding-4-0-0-4-1-9",
            "posts_count": 21,
            "reply_count": 10,
            "highest_post_number": 21,
            "image_url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/3/b/3bcdc6663c231a91b969c9eb89a208feccc74dc8.png",
            "created_at": "2024-02-10T04:46:12.058Z",
            "last_posted_at": "2024-04-10T20:26:23.711Z",
            "bumped": true,
            "bumped_at": "2024-04-10T20:26:23.711Z",
            "archetype": "regular",
            "unseen": false,
            "pinned": false,
            "unpinned": null,
            "visible": true,
            "closed": false,
            "archived": false,
            "bookmarked": null,
            "liked": null,
            "thumbnails": [
                {
                    "max_width": null,
                    "max_height": null,
                    "width": 512,
                    "height": 512,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/3/b/3bcdc6663c231a91b969c9eb89a208feccc74dc8.png"
                },
                {
                    "max_width": 400,
                    "max_height": 400,
                    "width": 400,
                    "height": 400,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/3/b/3bcdc6663c231a91b969c9eb89a208feccc74dc8_2_400x400.png"
                },
                {
                    "max_width": 300,
                    "max_height": 300,
                    "width": 300,
                    "height": 300,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/3/b/3bcdc6663c231a91b969c9eb89a208feccc74dc8_2_300x300.png"
                },
                {
                    "max_width": 200,
                    "max_height": 200,
                    "width": 200,
                    "height": 200,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/3/b/3bcdc6663c231a91b969c9eb89a208feccc74dc8_2_200x200.png"
                }
            ],
            "tags": [
                "binding",
                "published",
                "beta"
            ],
            "tags_descriptions": {},
            "like_count": 13,
            "views": 1316,
            "category_id": 73,
            "featured_link": null,
            "has_accepted_answer": false,
            "posters": [
                {
                    "extras": "latest",
                    "description": "Original Poster, Most Recent Poster",
                    "user": {
                        "id": 1164,
                        "username": "matt1",
                        "name": "Skinah",
                        "avatar_template": "/user_avatar/community.openhab.org/matt1/{size}/19930_2.png",
                        "trust_level": 2
                    }
                },
                {
                    "extras": null,
                    "description": "Frequent Poster",
                    "user": {
                        "id": 42973,
                        "username": "Baschtlwaschtl",
                        "name": "Sebastian ",
                        "avatar_template": "/user_avatar/community.openhab.org/baschtlwaschtl/{size}/70481_2.png",
                        "trust_level": 2
                    }
                },
                {
                    "extras": null,
                    "description": "Frequent Poster",
                    "user": {
                        "id": 32410,
                        "username": "sebSmarthome",
                        "name": "Sébastien Fremion",
                        "avatar_template": "/user_avatar/community.openhab.org/sebsmarthome/{size}/112962_2.png",
                        "primary_group_name": "sustainingmembers",
                        "flair_name": "sustainingmembers",
                        "flair_url": "far-smile",
                        "flair_color": "FFAA00",
                        "flair_group_id": 45,
                        "trust_level": 2
                    }
                },
                {
                    "extras": null,
                    "description": "Frequent Poster",
                    "user": {
                        "id": 17972,
                        "username": "miwok",
                        "name": "ND",
                        "avatar_template": "/user_avatar/community.openhab.org/miwok/{size}/33858_2.png",
                        "trust_level": 2
                    }
                }
            ]
        },
        {
            "id": 153095,
            "title": "Manually install addons on Ubuntu",
            "fancy_title": "Manually install addons on Ubuntu",
            "slug": "manually-install-addons-on-ubuntu",
            "posts_count": 11,
            "reply_count": 6,
            "highest_post_number": 11,
            "image_url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/3/c/3ce0f37d40824aacd8fec11ca068c3d313590f15.png",
            "created_at": "2024-01-17T09:46:02.798Z",
            "last_posted_at": "2024-01-21T23:05:30.340Z",
            "bumped": true,
            "bumped_at": "2024-01-21T23:05:30.340Z",
            "archetype": "regular",
            "unseen": false,
            "pinned": false,
            "unpinned": null,
            "visible": true,
            "closed": false,
            "archived": false,
            "bookmarked": null,
            "liked": null,
            "thumbnails": [
                {
                    "max_width": null,
                    "max_height": null,
                    "width": 613,
                    "height": 102,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/3/c/3ce0f37d40824aacd8fec11ca068c3d313590f15.png"
                },
                {
                    "max_width": 600,
                    "max_height": 600,
                    "width": 600,
                    "height": 99,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/3/c/3ce0f37d40824aacd8fec11ca068c3d313590f15_2_600x99.png"
                },
                {
                    "max_width": 400,
                    "max_height": 400,
                    "width": 400,
                    "height": 66,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/3/c/3ce0f37d40824aacd8fec11ca068c3d313590f15_2_400x66.png"
                },
                {
                    "max_width": 300,
                    "max_height": 300,
                    "width": 300,
                    "height": 49,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/3/c/3ce0f37d40824aacd8fec11ca068c3d313590f15_2_300x49.png"
                },
                {
                    "max_width": 200,
                    "max_height": 200,
                    "width": 200,
                    "height": 33,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/3/c/3ce0f37d40824aacd8fec11ca068c3d313590f15_2_200x33.png"
                }
            ],
            "tags": [
                "binding",
                "beta"
            ],
            "tags_descriptions": {},
            "like_count": 0,
            "views": 606,
            "category_id": 73,
            "featured_link": null,
            "has_accepted_answer": true,
            "posters": [
                {
                    "extras": null,
                    "description": "Original Poster",
                    "user": {
                        "id": 44290,
                        "username": "DarkoG",
                        "name": "Darko",
                        "avatar_template": "/user_avatar/community.openhab.org/darkog/{size}/67359_2.png",
                        "trust_level": 2
                    }
                },
                {
                    "extras": "latest",
                    "description": "Most Recent Poster, Accepted Answer",
                    "user": {
                        "id": 33523,
                        "username": "jimtng",
                        "name": "jimtng",
                        "avatar_template": "/user_avatar/community.openhab.org/jimtng/{size}/98543_2.png",
                        "trust_level": 2
                    }
                },
                {
                    "extras": null,
                    "description": "Frequent Poster",
                    "user": {
                        "id": 23331,
                        "username": "Bigdesaster",
                        "name": "Chris",
                        "avatar_template": "/letter_avatar_proxy/v4/letter/b/b2d939/{size}.png",
                        "trust_level": 2
                    }
                }
            ]
        },
        {
            "id": 155227,
            "title": "Ephemeris Binding [4.0.0.0;4.2.0.0)",
            "fancy_title": "Ephemeris Binding [4.0.0.0;4.2.0.0)",
            "slug": "ephemeris-binding-4-0-0-0-4-2-0-0",
            "posts_count": 36,
            "reply_count": 28,
            "highest_post_number": 36,
            "image_url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/1/d/1d29a85573fc337f5f0306daebb0fa4a77e825c8.jpeg",
            "created_at": "2024-04-05T15:00:01.930Z",
            "last_posted_at": "2024-12-30T10:47:56.819Z",
            "bumped": true,
            "bumped_at": "2024-12-30T10:47:56.819Z",
            "archetype": "regular",
            "unseen": false,
            "pinned": false,
            "unpinned": null,
            "visible": true,
            "closed": false,
            "archived": false,
            "bookmarked": null,
            "liked": null,
            "thumbnails": [
                {
                    "max_width": null,
                    "max_height": null,
                    "width": 225,
                    "height": 225,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/1/d/1d29a85573fc337f5f0306daebb0fa4a77e825c8.jpeg"
                },
                {
                    "max_width": 200,
                    "max_height": 200,
                    "width": 200,
                    "height": 200,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/1/d/1d29a85573fc337f5f0306daebb0fa4a77e825c8_2_200x200.jpeg"
                }
            ],
            "tags": [
                "binding",
                "beta"
            ],
            "tags_descriptions": {},
            "like_count": 19,
            "views": 1476,
            "category_id": 73,
            "featured_link": null,
            "has_accepted_answer": false,
            "posters": [
                {
                    "extras": null,
                    "description": "Original Poster",
                    "user": {
                        "id": 302,
                        "username": "glhopital",
                        "name": "Gaël L'hopital",
                        "avatar_template": "/user_avatar/community.openhab.org/glhopital/{size}/91632_2.png",
                        "trust_level": 2
                    }
                },
                {
                    "extras": null,
                    "description": "Frequent Poster",
                    "user": {
                        "id": 10046,
                        "username": "LukaNoah",
                        "name": "Heiko Hegewald",
                        "avatar_template": "/letter_avatar_proxy/v4/letter/l/bc79bd/{size}.png",
                        "trust_level": 2
                    }
                },
                {
                    "extras": null,
                    "description": "Frequent Poster",
                    "user": {
                        "id": 6882,
                        "username": "dmartinpro",
                        "name": "David",
                        "avatar_template": "/user_avatar/community.openhab.org/dmartinpro/{size}/71639_2.png",
                        "trust_level": 2
                    }
                },
                {
                    "extras": null,
                    "description": "Frequent Poster",
                    "user": {
                        "id": 53759,
                        "username": "kmcbride3",
                        "name": "KM",
                        "avatar_template": "/letter_avatar_proxy/v4/letter/k/7ea924/{size}.png",
                        "trust_level": 1
                    }
                },
                {
                    "extras": "latest",
                    "description": "Most Recent Poster",
                    "user": {
                        "id": 37472,
                        "username": "laursen",
                        "name": "Jacob Laursen",
                        "avatar_template": "/letter_avatar_proxy/v4/letter/l/dfb087/{size}.png",
                        "primary_group_name": "maintainers",
                        "flair_name": "maintainers",
                        "flair_url": "fa-star",
                        "flair_color": "FF6600",
                        "flair_group_id": 42,
                        "trust_level": 3
                    }
                }
            ]
        },
        {
            "id": 159482,
            "title": "AquaTemp Binding [4.1.0.0;5.0.0.0)",
            "fancy_title": "AquaTemp Binding [4.1.0.0;5.0.0.0)",
            "slug": "aquatemp-binding-4-1-0-0-5-0-0-0",
            "posts_count": 1,
            "reply_count": 0,
            "highest_post_number": 1,
            "image_url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/6/c/6c999d0c2f272eeef05d24473fc0db8d41ab3115.png",
            "created_at": "2024-10-06T20:15:09.399Z",
            "last_posted_at": "2024-10-06T20:15:09.507Z",
            "bumped": true,
            "bumped_at": "2024-10-06T20:25:07.261Z",
            "archetype": "regular",
            "unseen": false,
            "pinned": false,
            "unpinned": null,
            "visible": true,
            "closed": false,
            "archived": false,
            "bookmarked": null,
            "liked": null,
            "thumbnails": [
                {
                    "max_width": null,
                    "max_height": null,
                    "width": 480,
                    "height": 480,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/6/c/6c999d0c2f272eeef05d24473fc0db8d41ab3115.png"
                },
                {
                    "max_width": 400,
                    "max_height": 400,
                    "width": 400,
                    "height": 400,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/6/c/6c999d0c2f272eeef05d24473fc0db8d41ab3115_2_400x400.png"
                },
                {
                    "max_width": 300,
                    "max_height": 300,
                    "width": 300,
                    "height": 300,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/6/c/6c999d0c2f272eeef05d24473fc0db8d41ab3115_2_300x300.png"
                },
                {
                    "max_width": 200,
                    "max_height": 200,
                    "width": 200,
                    "height": 200,
                    "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/6/c/6c999d0c2f272eeef05d24473fc0db8d41ab3115_2_200x200.png"
                }
            ],
            "tags": [
                "binding",
                "published",
                "stable"
            ],
            "tags_descriptions": {},
            "like_count": 0,
            "views": 47,
            "category_id": 73,
            "featured_link": null,
            "has_accepted_answer": false,
            "posters": [
                {
                    "extras": "latest single",
                    "description": "Original Poster, Most Recent Poster",
                    "user": {
                        "id": 20125,
                        "username": "rogrun",
                        "name": "Ronny Grun",
                        "avatar_template": "/user_avatar/community.openhab.org/rogrun/{size}/82027_2.png",
                        "trust_level": 2
                    }
                }
            ]
        }
    ],
    "tags": [
        "binding",
        "published",
        "stable"
    ],
    "tags_descriptions": {},
    "id": 160688,
    "title": "Mill LAN Binding [4.1.0.0;5.0.0.0)",
    "fancy_title": "Mill LAN Binding [4.1.0.0;5.0.0.0)",
    "posts_count": 1,
    "created_at": "2024-12-06T17:03:17.587Z",
    "views": 44,
    "reply_count": 0,
    "like_count": 3,
    "last_posted_at": "2024-12-06T17:03:17.715Z",
    "visible": true,
    "closed": false,
    "archived": false,
    "has_summary": false,
    "archetype": "regular",
    "slug": "mill-lan-binding-4-1-0-0-5-0-0-0",
    "category_id": 73,
    "word_count": 137,
    "deleted_at": null,
    "user_id": 36689,
    "featured_link": null,
    "pinned_globally": false,
    "pinned_at": null,
    "pinned_until": null,
    "image_url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/7/d/7d45afed4a68750673b725367fb37e9f780d6a49.svg",
    "slow_mode_seconds": 0,
    "draft": null,
    "draft_key": "topic_160688",
    "draft_sequence": null,
    "unpinned": null,
    "pinned": false,
    "current_post_number": 1,
    "highest_post_number": 1,
    "deleted_by": null,
    "actions_summary": [
        {
            "id": 4,
            "count": 0,
            "hidden": false,
            "can_act": false
        },
        {
            "id": 8,
            "count": 0,
            "hidden": false,
            "can_act": false
        },
        {
            "id": 10,
            "count": 0,
            "hidden": false,
            "can_act": false
        },
        {
            "id": 7,
            "count": 0,
            "hidden": false,
            "can_act": false
        }
    ],
    "chunk_size": 20,
    "bookmarked": false,
    "topic_timer": null,
    "message_bus_last_id": 0,
    "participant_count": 1,
    "show_read_indicator": false,
    "thumbnails": [
        {
            "max_width": null,
            "max_height": null,
            "width": 512,
            "height": 234,
            "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/7/d/7d45afed4a68750673b725367fb37e9f780d6a49.svg"
        },
        {
            "max_width": 400,
            "max_height": 400,
            "width": 400,
            "height": 182,
            "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/7/d/7d45afed4a68750673b725367fb37e9f780d6a49_2_400x182.svg"
        },
        {
            "max_width": 300,
            "max_height": 300,
            "width": 300,
            "height": 137,
            "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/7/d/7d45afed4a68750673b725367fb37e9f780d6a49_2_300x137.svg"
        },
        {
            "max_width": 200,
            "max_height": 200,
            "width": 200,
            "height": 91,
            "url": "//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/7/d/7d45afed4a68750673b725367fb37e9f780d6a49_2_200x91.svg"
        }
    ],
    "slow_mode_enabled_until": null,
    "details": {
        "can_edit": false,
        "notification_level": 1,
        "participants": [
            {
                "id": 36689,
                "username": "Nadahar",
                "name": "Nadar",
                "avatar_template": "/user_avatar/community.openhab.org/nadahar/{size}/44246_2.png",
                "post_count": 1,
                "primary_group_name": null,
                "flair_name": null,
                "flair_url": null,
                "flair_color": null,
                "flair_bg_color": null,
                "flair_group_id": null,
                "trust_level": 2
            }
        ],
        "created_by": {
            "id": 36689,
            "username": "Nadahar",
            "name": "Nadar",
            "avatar_template": "/user_avatar/community.openhab.org/nadahar/{size}/44246_2.png"
        },
        "last_poster": {
            "id": 36689,
            "username": "Nadahar",
            "name": "Nadar",
            "avatar_template": "/user_avatar/community.openhab.org/nadahar/{size}/44246_2.png"
        },
        "links": [
            {
                "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding/blob/master/bundles/org.openhab.binding.milllan/README.md",
                "title": "Mill-LAN-openHAB-Binding/bundles/org.openhab.binding.milllan/README.md at master · Nadahar/Mill-LAN-openHAB-Binding · GitHub",
                "internal": false,
                "attachment": false,
                "reflection": false,
                "clicks": 4,
                "user_id": 36689,
                "domain": "github.com",
                "root_domain": "github.com"
            },
            {
                "url": "https://millnorway.com/",
                "title": null,
                "internal": false,
                "attachment": false,
                "reflection": false,
                "clicks": 4,
                "user_id": 36689,
                "domain": "millnorway.com",
                "root_domain": "millnorway.com"
            },
            {
                "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding",
                "title": "GitHub - Nadahar/Mill-LAN-openHAB-Binding",
                "internal": false,
                "attachment": false,
                "reflection": false,
                "clicks": 3,
                "user_id": 36689,
                "domain": "github.com",
                "root_domain": "github.com"
            },
            {
                "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding/issues",
                "title": "Issues · Nadahar/Mill-LAN-openHAB-Binding · GitHub",
                "internal": false,
                "attachment": false,
                "reflection": false,
                "clicks": 1,
                "user_id": 36689,
                "domain": "github.com",
                "root_domain": "github.com"
            },
            {
                "url": "https://github.com/Nadahar/Mill-LAN-openHAB-Binding/releases/download/v1.0.0/org.openhab.binding.milllan-1.0.0.jar",
                "title": null,
                "internal": false,
                "attachment": false,
                "reflection": false,
                "clicks": 1,
                "user_id": 36689,
                "domain": "github.com",
                "root_domain": "github.com"
            }
        ]
    },
    "bookmarks": []
}

I don’t know if that JSON has been customized in any way, or if that’s just “standard Discourse”. The code then parses the links like this:

        if (topic.postStream.posts[0].linkCounts != null) {
            for (DiscoursePostLink postLink : topic.postStream.posts[0].linkCounts) {
                if (postLink.url.endsWith(".jar")) {
                    properties.put(JAR_DOWNLOAD_URL_PROPERTY, postLink.url);
                    id = determineIdFromUrl(postLink.url);
                }
                if (postLink.url.endsWith(".kar")) {
                    properties.put(KAR_DOWNLOAD_URL_PROPERTY, postLink.url);
                    id = determineIdFromUrl(postLink.url);
                }
                if (postLink.url.endsWith(".json")) {
                    properties.put(JSON_DOWNLOAD_URL_PROPERTY, postLink.url);
                }
                if (postLink.url.endsWith(".yaml")) {
                    properties.put(YAML_DOWNLOAD_URL_PROPERTY, postLink.url);
                }
            }
        }

…so it basically just filters out those links that ends with one of those extensions. These are then stored as properties in the Addon object. properties is a Map, so it can only hold one of each type/key, so it will probably keep whatever link is listed last in the first post for each extension. It doesn’t seem to me like the “Resources” heading is part of the parsing, but the convention makes sure that the “resources” are placed last.

“Code” sections are parsed like this (it seems like JSON and YAML are the ones that will potentially be used) from the cooked entry in the JSON:

    private static final Pattern CODE_MARKUP_PATTERN = Pattern.compile(
            "<pre(?: data-code-wrap=\"[a-z]+\")?><code class=\"lang-(?<lang>[a-z]+)\">(?<content>.*?)</code></pre>",
            Pattern.DOTALL);

        Matcher codeMarkup = CODE_MARKUP_PATTERN.matcher(detailedDescription);
        if (codeMarkup.find()) {
            properties.put(codeMarkup.group("lang") + CODE_CONTENT_SUFFIX,
                    unescapeEntities(codeMarkup.group("content")));
        }

So, in other words, the “language code” (e.g yaml) that is specified after the 3 backticks is used as the key, and then the content is just unescaped and stored as a string. It can keep one such “code block” per “language code”. But, the regex search doesn’t loop, it just runs once, so it will probably mean that opposite to with the links, the first code block is what will be stored. That’s regardless of what “language code” is used. As it will only do one “search” for embedded code, the first code fences better be “the resource”.

As a note, the parser seems to pull the whole topic when doing this. That can probably make for slow parsing if the Marketplace topics are long, and might be why I’ve seen some talk about not discussing the add-ons in the Marketplace topic.

I’ve tried to find a way to only request the first post, but I can’t seem to find it. If anybody knows a way to get Disourse to only show one post (without loading the others), it would probably be smart to implement this for the Marketplace parser.

I really scratch my head about why they don’t offer such basic functionality. I can’t find that there are any query parameters that can achieve this:

There is an endpoint where you can request a single post, but then you need to know the “post id” first… which is a unique across all posts - and I can’t find any way to just list the post ids of a topic without also pulling all the content. I took a look at the discourse forum, but it seems that this is an ideological issue for them and that they are opposed to all form of practicality. It’s all about that the “infinite scroll” is the future, and that everything else is just backwards. So, it might be intentionally left out, so that people can’t easily implement pagination (which you could if you could request n number of posts from a topic).

It’s really sad when “ideologists” get to make such decisions. Maybe OH could read out all the Marketplace topics centrally, filter out just what’s needed, and then have all the OH installations query that information instead of the forum directly. But, maybe I’m also obsessing over something nobody see as a problem :roll_eyes:

To keep the marketplace topic short, i always adk users not to discuss anything in that topic, but always have a separate one for discussion.

Yes, I’ve seen that, but is that because of parsing speed? Intuitively, the Marketplace topic is the most logical place to discuss it, which is why people tend to do it.

No, because I want to keep the marketplace
„clean“
I have already seen one topic in the addon store which does not lead to a widget, but to a discussion only.

I see - I was thinking about add-ons that were already published - and user feedback, “bug report” etc. for that add-on. Topics where the first post isn’t an add-on definitely should not be there.

I know, but i like to separate disccussions from the published widgets.
You can have a link to the discussion in the publishing topic, so it can easily be found.
But thats only my preference, not a must.

It should be moved out of the marketplace then. What’s the thread?

2 Likes

It is not set to published, but still does not belong there
How to set item[props.x].state from actionVariableValue? - Add-on Marketplace / UI Widgets - openHAB Community

I’ve moved it.

1 Like

It’s probably best if there are no additional posts in those topics anyway, as long as the parser has to fetch it all, every time.

1 Like

Do we know this is a problem or does it just feel icky? My Threshold Alert rule template has 145 posts and I notice no difference in load or install time from when it had just the one.

What I wish for OH5 is a new marketplace implementation that informs the user about updated versions and doesn’t rely on parsing Discourse threads ;).

… If you have time and energy @Nadahar :pray:

I was more worried about the load on the forum than on the time it would take for each installation. It first pulls all the topics by calling https://community.openhab.org/c/marketplace/69/l/latest and parsing all the results. I thought it then went on to pull all the topics to get the necessary information about the add-ons, but when I checked the code again now, it seems that’s not the case. When you browse the “add-on store”, it will only display information that is retrieved by pulling the list of topics, and the full topic is only pulled once you “enter” one of them.

So, the answer is probably: no. I misinterpreted what it did, and thought it pulled all the topics up-front. Since it seems to only pull the full topic once you enter it, it is “no worse” than when somebody browses the forum using a browser.