You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
POST-ing to /rest/addons to install a marketplace add-on will always return 200 (OK) with an empty body, no matter what parameters are passed. Also when installing an already installed add-on, it gives the same result.
I would expect a 404 if it gets passed a non-existing add-on.
This is a simple script (rule) I use to install marketplace addons during startup:
rule"InstallMarketAddons"dodescription"Install marketplace add-ons at system start"on_startat_level: 80delay20.seconds# Let OH core do its magic firstrundo# Extract the marketplace add-ons line from `conf/services/addons.cfg`cfgLines=IO.readlines('{{ openhab_conf_dir }}/services/addons.cfg')iflineIndex=cfgLines.index{ |line| line =~ /marketplace/}thenlogger.info"Install Marketplace addons defined in addons.cfg at system start"addons=cfgLines[lineIndex].split('=')[1].strip# Loop through each addonaddons.split(",").eachdo |addon|
addonName,addonId=addon.split(":")#TODO: Check for ill-formatted entrieslogger.info"Install addon #{addonName} (#{addonId}) from marketplace"# Create the HTTP objecturi=URI.parse("{{ openhab_api_url }}/addons/marketplace:#{addonId}/install?serviceId=marketplace")header={'Content-Type': 'text/plain','Accept': '*/*','X-OPENHAB-TOKEN': '{{ openhab_api_token }}'}http=Net::HTTP.new(uri.host,uri.port)request=Net::HTTP::Post.new(uri.request_uri,header)request.body="id=#{addonId}"# Send the requestresponse=http.request(request)# Note: The API always returns 200 with an empty body, so actually no use logging itlogger.debug"Result #{response.code} (#{response.body}) - installing marketplace addon #{addonName} (#{addonId})"end# of loop through each entryend# ifendend
There are two Ansible variables in the script to specify the base URL of the API endpoint and the token.
The script works by reading a line starting with marketplace= and extracting the add-on id's to install.
By specifying a non-exsitings binding the reported behaviour can be reproduced.
Your Environment
Debian 12.
OpenHAB 4.1.0 using the official OH container image.
The text was updated successfully, but these errors were encountered:
The reason is that the installation is asynchronous. The response is create when the add-on service exists and the command to install has been successfully send. We can probably improve that with an additional check if the service supports that add-on.
Thanks for your quick response.
I understand that the installation is asynchronous - like just about everything in an event-driven system like OpenHBA - and there is no callback mechanism to get the actual result. So, to check if an add-on is installed would require a (delayed/retried) GET to /rest/addons/{addend}.
My main point is that it accepts non-existing add-ons and like you said that could be improved. :o)
The documentation states that a 404 can be returned, but it looks like that will never happen with the current implementation.
POST-ing to /rest/addons to install a marketplace add-on will always return 200 (OK) with an empty body, no matter what parameters are passed. Also when installing an already installed add-on, it gives the same result.
I would expect a 404 if it gets passed a non-existing add-on.
This is a simple script (rule) I use to install marketplace addons during startup:
There are two Ansible variables in the script to specify the base URL of the API endpoint and the token.
The script works by reading a line starting with
marketplace=
and extracting the add-on id's to install.By specifying a non-exsitings binding the reported behaviour can be reproduced.
Your Environment
Debian 12.
OpenHAB 4.1.0 using the official OH container image.
The text was updated successfully, but these errors were encountered: