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.
“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.
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.
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.
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.
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.
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.
Dear gents, first of all great effort to all the programming, well done!!
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.
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.
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!