Blockly HTTP section missing

Hi there!

Sry for this stupid question, but what do I need to do to get HTTP support for Blockly as described here: https://www.openhab.org/docs/configuration/blockly/rules-blockly-http.html

I don’t have a HTTP section at the left bar:

I am running openHAB 4.2.1 on Ubuntu 24.04 from repository https://openhab.jfrog.io/artifactory/openhab-linuxpkg

Thanks, Tippi

The HTTP section gives you access to the actions defined in the HTTP binding. So you must have the binding installed.

I don’t think that’s correct. The sendHttpXRequest actions are provided by core, not the HTTP binding. At least that’s the way it used to be.

I have one OH instance that doesn’t have the HTTP binding installed and I have the HTTP section in Blockly.

This is a 4.2.1 instance.

Is this a recently updated OH? Maybe you need to force a refresh of the browser?

1 Like

Is this a recently updated OH? Maybe you need to force a refresh of the browser?

Yes, it is, but I made a reboot after update from openHAB itself and also refreshed my browser.
I just tested with another browser in privacy mode and still no HTTP block :frowning:

For completeness I also installed openhab-addons but no change. HTTP section still missing.

I know that I can use the classic way like here: HTTP Post using blockly
Or just run a bash script with curl and get the result … Have to think about it.

PS: HTTP binding is installed, shouldn’t be the problem.

It wouldn’t be the problem anyway. I confirmed that the HTTP actions are implemented by core and the HTTP entry should just be there all the time.

Go to Help & About, click “Technical Information”, “View Details” and paste the text here. Code fences are not required but would make it easier to read.

```
code goes here
```

Thanks for your help, here as requested:

runtimeInfo:
  version: 4.2.1
  buildString: Release Build
locale: de-DE
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 17.0.12
  javaVendor: Ubuntu
  osName: Linux
  osVersion: 6.6.0-odroid-arm64
  osArchitecture: aarch64
  availableProcessors: 4
  freeMemory: 108896712
  totalMemory: 312475648
  uptime: 557
  startLevel: 100
addons:
  - binding-http
  - binding-icalendar
  - binding-ipcamera
  - binding-openweathermap
  - binding-smartmeter
  - binding-weathercompany
  - persistence-influxdb
  - persistence-jdbc-postgresql
  - persistence-rrd4j
  - transformation-jsonpath
  - ui-basic
  - ui-habpanel
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    pixelRatio: 1.5
    prefersColorScheme: dark
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 16
    language: de-DE
    languages:
      - de-DE
      - de
      - en-US
      - en
    onLine: true
    platform: Linux x86_64
  screen:
    width: 2048
    height: 1280
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
    blocklyRenderer: null
  userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
    Gecko) Chrome/126.0.0.0 Safari/537.36
timestamp: 2024-08-14T17:26:04.612Z

I don’t see anything weird there. Have you tried in a different browser (for example, if you are using Chrome have you tried Firefox?)

You’ve not installed any jar or kar files to the add-ons folder?

Do you have any block libraries installed?

I don’t see anything weird there. Have you tried in a different browser (for example, if you are using Chrome have you tried Firefox?)

This is exactly what I did. My standard browser is vivaldi and for test I used Firefox in private mode. No HTTP section.

You’ve not installed any jar or kar files to the add-ons folder?

Didn’t know that this is possible until know. No, did not change anything. Here is my folder (right one?):

root@odroid:/usr/share/openhab/addons# l
total 422M
drwxr-xr-x 2 openhab openhab 4,0K Aug 14 19:13 ./
drwxr-xr-x 4 openhab openhab 4,0K Aug 13 16:27 ../
-rw-r--r-- 1 openhab openhab 422M Aug  9 15:36 openhab-addons-4.2.1.kar
-rw-r--r-- 1 openhab openhab   70 Aug  9 15:35 README

Do you have any block libraries installed?

Not sure what block libraries are. I only use a standard openHAB installation with no extras except for smart meter read out and display.

But as we speak my installation has one “special feature”.
I own an Odroid M1 and it runs with an eMMC. For backup reasons, some folders of openHAB are outsourced to a build-in SSD. I read in a thread that I can use symlinks to do this.
Here are the folders that are symlinked:

root@odroid:/# l /etc/openhab
lrwxrwxrwx 1 root root 29 Jul 22 09:11 /etc/openhab -> /mnt/nvme/openhab/etc/openhab/
root@odroid:/# l /var/lib/openhab
lrwxrwxrwx 1 root root 33 Jul 22 09:14 /var/lib/openhab -> /mnt/nvme/openhab/var/lib/openhab/
root@odroid:/# l /var/log/openhab
lrwxrwxrwx 1 root root 33 Jul 22 09:14 /var/log/openhab -> /mnt/nvme/openhab/var/log/openhab/

Folders are chowned to openhab and everything else is running fine, so I wouldn’t expect that this could be a problem.

Yes, that;s the right one but based on the file name the .kar file that’s there matches the version number so everything should be OK.

But you can move that .kar file out of that folder, stop OH, clear the cache, and start OH again. Watch the logs for the add-ons to be reinstalled then check again.

Obvisouly that will only work if the machine can access the internet.

This shouldn’t be a problem but I can’t figure out what would be.

Add-on Store → Automation → Block Libraries

These are community authored blocks that can be installed and made available to you to create rules.

I don’t think any of those folders would be relevant to this behavior.

As far as I can tell you are running an older version of MainUI and I’m trying to narrow down all the obvious reasons for how that could be before I pull in the developers.

But you can move that .kar file out of that folder, stop OH, clear the cache, and start OH again. Watch the logs for the add-ons to be reinstalled then check again.

I will try it tomorrow, but I don’t have much hope. The kar file is probably only there because of the openhab-addons package I just installed.

It’s good to know that there are already ready-made application examples. I’ll have a look.

As I said, in worst-case there is still bash I’m familiar with :slight_smile:

I don’t see JSScripting listed in the addons here.

I’m surprised that in 4.2.X it doesn’t need to be installed for blockly in the first place, but looking at the html block definition it does appear to be required for that block:

Your browser console (ctrl + shft + k in firefox), is probably showing the above highlighted error when you load the blockly editor.

Try installing the JSScripting automation add-on to see if that works.

2 Likes

Good catch!

Indeed, Blockly shouldn’t even show up as an option if JS Scripting is not installed. I just assumed it was since Blockly showed up. Maybe this rule was created when JS Scripting was installed and since the mime type said it was Blockly it brought up the Blockly editor perhaps.

Maybe there’s a bug here? Or at least maybe there should be a more obvious error to show without needing to go to the console?

1 Like

Your browser console (ctrl + shft + k in firefox), is probably showing the above highlighted error when you load the blockly editor.

Try installing the JSScripting automation add-on to see if that works.

I’m sorry, but no luck.

First I uninstalled the manually installed openhab-addons. My odroid is connected to internet, so installation of addons is no problem.

Reboot.

After that I installed JavaScript Scripting from addons section, details:

addons:
  - automation-jsscripting
  - binding-http
  - ...

Reboot, new browser and so on.

But still no HTTP section in Blockly.
And there is no error in den web browser console. Only some verbose messages, no errors except
Error: Promised response from onMessage listener went out of scope
(only shown in Firefox, not Vivaldi)

I will make some more tests. My installation was initially on openHAB 3.x (not sure which number exactly) and all updates where made in-place (without stopping openHAB, but reboot at end).

Update: I made a test in a virtual machine.

Installed fresh openhab 3.3.0-1.
No HTTP section in blockly (obviously :wink: ).
Updated directly (with running openhab) to 4.2.1-1.
Reboot.
Same browser and as expected, HTTP section appeared.

And the only addons installed are these here:

addons:
  - persistence-rrd4j
  - ui-basic
  - ui-habpanel

So in a standard case everything is working.
But not in my case :sob:

Without JS Scripting installed you shouldn’t even see Blockly as an option anywhere in OH 4.2. In OH 3 Blockly used Nashorn JS which doesn’t need to be separately installed. So the fact that you are seen anything Blockly related in 4.2 is weird.

Maybe if you have created a rule in 3.3, upgraded, and then opened the same rule after upgrading to 4.2 that might trick it to showing Blockly for that rule. But in a new rule you shouldn’t have Blockly as an option to select from when creating an Inline Script.

What happens if you restore a backup of your current OH 4.2 configs that are not showing the HTTP category to this test OH that is showing the HTTP category?

If that works maybe you can just start over with a fresh install of OH 4.2 on your production OH instance.

Maybe if you have created a rule in 3.3, upgraded, and then opened the same rule after upgrading to 4.2 that might trick it to showing Blockly for that rule. But in a new rule you shouldn’t have Blockly as an option to select from when creating an Inline Script.

Yes and no.

First: I didn’t create a rule, I only tested with scripts directly. I want to reference later to this scripts.

Now it was getting strange (tests done in my vm):

I created a script with openhab 3.3.
If I open it now with 4.2.1, I can see HTTP section! At top of the screen, directly under the name of the script, there is the hint “application/javascript”

If I create now a new script, I can choose “Design with blockly” and in the new view, there is no HTTP section and at the top is the hint “application/javascript;version=ECMAScript-5.1”.

So there must be a difference between the scripts.

But If I create a rule and add a “Then action”, choose inline script, choose “Design with Blockly”, then there is a script window with HTTP section and “application/javascript”.
Very strange, that a new rule doesn’t behave like a new script?!

Next test:
Installled JavaScript Scripting automation, created a new script, “Design with Blockly” and now there is a HTTP section and “application/javascript” at top.
(No change for a new rule, same as above.)

This gave me the idea to test with a new rule AFTER installing JavaScript Scripting on my openhab production environment. Sry, didn’t do this before, shame on me :roll_eyes:
And a new rule or new script has now the HTTP section. But not the existing ones, also created with 4.2.1. Very odd, but no problem!

What happens if you restore a backup of your current OH 4.2 configs that are not showing the HTTP category to this test OH that is showing the HTTP category?

If that works maybe you can just start over with a fresh install of OH 4.2 on your production OH instance.

Good idea, but no longer necessary.
Big thanks for your help!! :smiley:

A Script is a rule.

This is as expected.

You shouldn’t have the option to Design with blockly" without the JS scripting add-on installed.

That mime type is referencing Nashorn JS which is the version of JS that comes with OH 3.x but requires a separate add-on to be installed in OH 4+. Why it’s showing that older mime type is a mystery because in OH 4 Blockly only uses JS Scripting, not Nashorn.

And in OH 4, the mime types were changes so that “application/javascript” means JS Scripting.

That helps to narrow down the problem some I think. And I think it has to do with the fact that you’ve created a rule using Blockly in OH 3 (which uses Nashorn) and then tried to open in after upgrading in OH 4 without installing the required JS Scripting add-on.

Note that the requirement to install the JS Scripting add-on first, and then open and save all your Blockly rules is covered in the release notes for OH 4 in detail as one of the breaking changes.

See above, among the breaking changes between OH 3 and OH 4 is a requirement that you open and save all of your existing Blockly rules so they can be recompiled and adjusted to JS Scripting.

I think the root of the problem is not doing that step wihch left MainUI confused.

1 Like

As far as I know, Blockly should be available with jsscripting as well as with Nashorn. But there are blocks that do not work with Nashorn and therefore are not available when the scripting engine is Nashorn, specifically the HTTP blocks.
Blockly rules may need to be resaved because the Blockly version got upgraded, so even if you stick with Nashorn, or were already on jsscripting, you may still have to do it.

1 Like

There are a lot more differences than that. Even how JS Scripting gets the state of Items is different from how Nashorn does it (Nashorn can use items[ItemName] which returns the raw Java State Object whereas JS Scripting uses items[itemName].state which returns a String representation of the Item). I would not expect the Nashorn JS generated by a Blockly script created in OH 3.x to work in OH 4.x. But that’s why the breaking changes and instructions for upgrading Blockly involves opening the scripts and saving them which causes Blockly to regenerate the code as JS Scripting.

As far as I know, OH 4 does not support Blockly using anything other than JS Scripting. And that’s why I would not expect to see Blockly as an option unless the JS Scripting add-on is installed. But even if it were possible to use Nashorn JS with Blockly on OH 4, the Nashorn JS extension wasn’t installed either.

And that’s the issue. OP had neither Nashorn nor the JS Scripting add-on installed and yet were able to create a new Blockly Script in OH 4, only the Blockly options didn’t include the HTTP category for some reason. I’m saying that if the JS Scripting add-on isn’t installed, you should be able to see and select “Deisgn with Blockly” in MainUI when creating a new rule.

I’m not sure what should happen for an already existing rule but would expect at least a warning or something saying “this script won’t work until you install the JS Scripting add-on”.

First, I don’t think the issue here has anything to do with Nashorn vs jsscripting. I don’t know what it is and it can well be a bug.
Second, the Blockly generation code checks for the scripting engine and will generate Nashorn code or jsscripting code, depending on what is installed. That is still the case for OH4. Both can still work. Certain blocks are only available with jsscripting (the HTTP blocks), no Nashorn can be generated. These blocks should not be visible when no jsscripting is installed, but Nashorn is.
If you used Blockly before with Nashorn and upgrade to jsscripting, you indeed need to open and save all Blockly rules to generate the new code.