Items missing in blockly

  • Platform information:
    • Hardware: x86_64
    • OS: Ubuntu server 20.04.1 in an lxd container
    • Java Runtime Environment: zulu11
    • openHAB version: openHAB 3.0.0.RC1
  • Issue of the topic: Can’t add items to blockly

Hello,

I’m playing around with OpenHAB 3 and try to test the new rule engine.
I want to write a rule with if/else conditions. I can do that using “execute a given script”. I’m trying out blockly, but i can’t figure out how to add items.

Can anybody help?

Greetings
Marcus

What do you want to do with an Item?

image

“Add an Item” doesn’t really say anything. You don’t just add an Item to a script. You do something with it, such as comparing it to another value or send a command to it or the like.

image

1 Like

Is it possible in the future to create complete rules with Blockly? with e.g. trigger, timer, other “send” options and much more.

Why can’t the item search be as simple as when creating the rule, but you have to go the way via “Pick from Model”?

Trigger is outside the Script Action. You define that separately.

I imagine that access to other openHAB Actions will be added over time. But at some point users will grow out of what Blockly can provide and will need to transition to actual text based script actions using one of the other languages. Note that Blockly saves as JavaScript and you can see the JavaScript that it generates on the Code tab.

What other “send” options?

Because it was implemented this way. I suspect the idea is that if the users is non-technical as evidenced by the fact they are using Blockly, they will be more likely to find and understand what Item they want by it’s location in the model.

As with anything, if you think you have a better way an issue should be filed.

Are the triggers always defined outside?

what is the “best” method to create rules?
java Script (ECMA) or Rule DSL
With which one can I define more functions, even if it becomes more extensive or do I always have to resort to all of them (depending on the application)?

sendNotification, sendWakeOnLanPacket, sendHttpGetRequest etc.

I think so too.

Yes, if you create a rule through the UI you create the Triggers, Actions, and Conditions completely separately.

Those are all Actions and some of them depend on specific bindings being installed. I imagine they are planned to be supported. It might be a bit of a challenge to support them though because I don’t think the API is such that they get properly exposed in a way that the UI can understand. However, if you need to call these, you can do so in a Script Action. If you choose Rules DSL v1 as the language, any example you see on this forum for calling those will work. There should be more and more JavaScript examples (i.e. ECMAScript) as time passes.

I will also show examples of calling actions like these in the Getting Started tutorial.

thank you, i will try a little bit and see what is the best way for me

Thanks Rick. You solved my problem. I did not understand that the items are hidden behind the puzzle “item MyItem” in the sectin “opoenHAB”. I know that now. Many Thanks.
Shame on me. :slight_smile:

That just means the UI is not that intuitive.

I’m not as stupid as I thougth! Look at this:
Bildschirmfoto von 2020-12-16 20-57-23

I started a new rule with blockly. There’s no “item MyItem” puzzle to add.

What version of OH are you running? Any version from RC1 or later should look like my screenshot. Earlier versions of the Blockly implementation were more incomplete.

That could be an idea - something that lets you take over the code that Blockly generated (with a warning that you can’t go back).

This was indeed added recently. These “item” blocks are only outputting strings with the name of the item, in fact, so you can replace them with the literal string from the Text tab (the one with quotes). It just helps you with that name by opening the “pick from model” window when you click, so you don’t have to type it yourself.

I intend on mentioning just that in the getting started tutorials. These past couple of weeks shows me we need:

  • no code
  • blockly
  • script actions

examples. right now we have no code and your script action in the comprehensive example. I want to add a blockly tutorial too.

That actually addresses an earlier question in the thread, finding a way that is less awkward than needing to pick from the list.

Dear gents, first of all great effort to all the programming, well done!! :clap:
I think it is great pity, if Blockly won’t be able to get same “working content” as I did see in example at iobroker.
I am really not that much familiar with programming, JavaScripting is somehow for me horrible and it took me many bloody lesson to fix items, failures. Finally I run Rules, but many times with big support of my friends. Finally, why do I still stick to OpenHab, STABILITY. With Debian, it runs!

Do you see any chances to have such Blockly updates like “Trigger”; “Date / Time” and other nice commands? That would be really great!
Regards Gerd

I suspect that Blockly will be improved over time. As with everything in OH, it requires someone to volunteer the time to implement it. But you will never see a trigger in Blockly. Blockly is only available for UI created rules and triggers are created outside the code in the UI.

Hi to all!
i’m a new users to open hab. I have used domoticz in the last 2 years only because domoticz has blockly.
Now I have tested openhab3 with blockly and i’m very happy of this choice!

In domoticz there are others componenets that i’d like to have in OpenHab 3 ( in “logic” there are the SET function and more, in addiction the “Time” section and “Messages”, avaiable in Domoticz’sblockly, are not avaiable ).
Time section is very useful for condition creation.

Will be implemented in the future?

i’m using the stable version of opehab3 on Debian 10
(I’m very happy of my new experience with openhab ) :wink:

But you have to realize, Blockly is just a think veneer over a text based programming language. In openHAB’s case it’s JavaScript. And most of what you will be doing with Blockly will be done through interacting with openHAB. So have domoticz or any other system that uses Blockly does is no where near as relevant to what is or can be done in openHAB as one might think.

I don’t have understood well your response. I think that for a NON PROGRAMMER using Blockly it’s a great point in favor. I have tested NodeRed for example and even if it’s look like Blockly as first seen… it’s very difficult in implementation for me or for a NON PROGRAMMER. The visual/block coding it’s very very attractive.
I hope for a continuous improvement of this programming graphics.
:+1:

My phone really mangled that. Let’s try again.

Just because Blockly can do something in domoticz does not mean that the same thing is possible or even makes sense in openHAB. Blockly is just a way to show code graphically, but underneath it’s still code. And that code is tied to the system it is integrating with.

You are right. Sure. In fact will be “my problem” to approach better to javascript world.
But please, don’t tell me that blockly project will not be implemented better in the future!
Let me dream a little!
:sweat_smile: