[Windows] All OH logs stop when Jython is in the classpath

You may be right, I suspect the majority of users want to be able to edit simple scripts relatively easily, as long as it’s possible to basically: retrieve item states, send commands, do a little bit of math, string/date/time/array/object/UoM manipulations, logging, and eventually HTTP requests, parse JSON/XML, call actions, set timers… these cover most of the use cases I think.
I also added the ability to edit rules’ tags and already have some ideas to give them some meaning in various parts of the UI.

  • The schedule page will only display rules tagged with “Schedule” (that’s already done actually) so that technical rules running e.g. every minute don’t clutter the timeline;
  • A rule tagged with “Scene”, “LivingRoom” (semantic tag) and “Blue” will lead to a blue button in the card generated for that room on the Locations home page tab to launch that rule/scene.
  • Rules tagged with “Scene”, “Starred” (or similar), and a color (morning routine, going away, welcome home, bed time…) would be displayed prominently on the Overview home page tab as colored buttons.

Well, I had to try and sure enough… :laughing:

I’m especially interested in JRuby since it’s my go-to language for general scripting, just made some tests and it’s encouraging:

require 'java'
require 'net/http'

puts 'Hello from Ruby!'

events.sendCommand('DemoSwitch', 'OFF')
puts ir.getItem('GF_Living')

puts org.joda.time.DateTime.now
puts java.time.LocalDate.now
puts java.lang.System.getenv('OPENHAB_CONF')

uri = URI('http://www.google.com')
res = Net::HTTP.get_response(uri)
puts res.code, res.message

uri = URI('http://localhost:8080/rest/persistence')
puts "API call result: #{Net::HTTP.get(uri)}"

begin
  logger = org.slf4j.LoggerFactory.getLogger('jsr223.jruby')
  puts logger.methods
rescue => e
  puts e
end

begin
  http = org.eclipse.smarthome.io.net.http.HttpUtil
  puts http.methods
rescue => e
  puts e
end

results in:

Hello from Ruby!
GF_Living (Type=GroupItem, Members=5, State=NULL, Label=Living Room, Category=video, Tags=[LivingRoom], Groups=[gGF])
2019-10-04T08:59:34.308+02:00
2019-10-04
/home/ys/oh/conf
08:59:34.309 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'DemoSwitch' received command OFF
200
OK
API call result: [{"id":"rrd4j","label":"rrd4j","type":"Queryable"}]
missing class name (`org.slf4j.LoggerFactory')
missing class name (`org.eclipse.smarthome.io.net.http.HttpUtil')

I didn’t immediately manage to load slf4j and OH classes, as for the rest it’s working pretty well, including accessing scope objects, and interestingly requests made with the Ruby ‘net/http’ library, so that’s pretty neat. :smiley:
Maybe it’s related to the similar problem I have with Nashorn, I’ll open an issue.

1 Like