I hope everyone is having a wonderful holiday. Thank you to everyone who has provided kind words and encouragement for the JRuby scripting library, it is very much appreciated.
I have released version 1.0.0 with an update to support ‘received_command’.
Please do not associate the large jump in version number as any indication of completion or readiness for production. This project follows semver and the jump to 1.x occured because of a breaking change between ‘commanded’ and ‘received_command’.
Changelog
Latest Documentation
I went back and forth on how to handle commands. I initially pushed a version using commanded
but as I was building it, I didn’t like it and after I pushed it I changed it to received_command
which flowed better.
One other area of concern is writing text based code is not the only way to write rules. If this is going to be fully supportable by openHAB it also needs to support the UI rules approach where all the rule
stuff is already handled and the scripting is sued as one option for Conditions (i.e. only run this rule if this script evaluates to true) and Actions (when triggered, if the Conditions are true, run this script).
It’s not clear to me that is going to be the case here which means, if this plug-in is installed users will see “jRuby” listed as an option for these in the UI but won’t actually be able to use it because stuff that is required to support your approach is not available.
@rlkoshak That is a valid concern to have. Nothing I have done should prevent this from working any differently in that context than any other scripting language we have.
- The part that would ever go in the core just make JRuby available, prevents the File class from being overwritten and makes the OpenHAB elements that are global, available globally.
- User are free to pull in my helper library with the
require openhab
line, if they don’t they get base JRuby with the changes noted in point 1.
- All of the code for sending commands, updating items, etc all works outside of the run block, so if they choose to import the helper library they get that and are not forced to use the run block syntax.
I can’t actually speak to what the maintainers will and will not accept to add to the baseline. But I do fear that the farther you deviate from the other languages in how interact with openHAB and present openHAB concepts I fear the likelihood of acceptance will go down, feelings get hurt and it ends up being a bad experience all the way around.
@rikoshk I appreciate the help and concern. Are we talking about the core maintainers here or the openhab-scripters maintainers? The only thing in the core is making JRuby available. All of my changes/enhancements are to the scripting library, not the core. As far as I know the core doesn’t contain any helper libraries.
One thing that we might want to look into is some additional (utility) functions these libraries add. If such functionality would be implemented in Java and/or added to core all libraries and possible ui rules can also use them and not every helper library would reinvent the wheel. If I have a concern it’s all these helper libraries added lots of features that also need to be maintained. The jruby variant here looks nice though.
@hilbrand This is certainly a valid concern that we have lots of different implementations with different features scattered across the ecosystem. I think there are two ways to evolve this. One is that we first put things into the core and all systems get them. The downside of this approach is that it is (and should be) difficult to add things to the core. It is a large commitment and we are taking a guess that it is worth it, that users will use the new features, etc. The second possibility is we distribute the innovation to the helper libraries and raise up what it is successful to the core. If some of the features here are broadly used (and useful), then it is worth the investment to get it in the core.
It is a balancing act with, in my opinion, no clear answer at this point.
Opinions were asked for and I gvae mine. If my advice and fore warnings are not wanted I’ll with hold them. I just would hate all this effort to become either marginalized or not added to OH itself.
I never said it wouldn’t work. Clearly it already works. Is it a bad fit, I think so.
I’ll stop. Just don’t be surprised if there is trouble later on.
I certainly value your opinion, no one that I have seen spends more time supporting users on this forum than you do. Without your support I am not sure we would have the large user base we have today.
We may have different opinions. However, I believe in the end, we both want the same thing, which is to make OpenHAB as good as possible.
I welcome your continued feedback.
I wonder if you can make it look like `item XXX received command" much like RulesDSL?
@jimtng there is an issue open in GitHub to perform the text processing to mimic the RulesDSL. There were be some tradeoffs, you will lose syntax highlighting and other enhancements.
Also, from skimming your very detailed docs, I didn’t see a way to postUpdate() to an item.
@jimtng The most recent docs are linked at the very top of it this. You can just use
Item.update <VALUE>
or
Item.postUpdate <Value>
All the java methods that you get in the DSL and in Python for the items exist. The Ruby additions either extend (monkey patch actually) or delegate to the underlying Java objects. I don’t have a lot of test cases to prove it, but most of the standard java/jython syntax should work for the Ruby versions.