Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Error when using semantic model #636

Open
boc-tothefuture opened this issue Sep 5, 2022 · 3 comments
Open

Error when using semantic model #636

boc-tothefuture opened this issue Sep 5, 2022 · 3 comments

Comments

@boc-tothefuture
Copy link
Owner

      Office.equipments(Semantics::Receiver)
      .members
      .points(Semantics::Switch, Semantics::Power).first

results in:

2022-09-05 14:08:21.380 [ERROR] [obj.OpenHAB.DSL.Rules.AutomationRule] - undefined method `<=' for nil:NilClass (NoMethodError)
In rule: Render Sitemap
/etc/openhab/automation/lib/ruby/gem_home/gems/openhab-scripting-4.44.1/lib/openhab/dsl/items/semantics.rb:222:in `block in points'
org/jruby/RubyArray.java:4686:in `all?'
/etc/openhab/automation/lib/ruby/gem_home/gems/openhab-scripting-4.44.1/lib/openhab/dsl/items/semantics.rb:221:in `block in points'
org/jruby/RubyArray.java:2746:in `select'
/etc/openhab/automation/lib/ruby/gem_home/gems/openhab-scripting-4.44.1/lib/openhab/dsl/items/semantics.rb:220:in `points'
/etc/openhab/automation/jsr223/ruby/personal/sitemap.rb:40:in `sitemap'

@boc-tothefuture
Copy link
Owner Author

Added a bit of debug to where it has an error:

 select do |point|
      logger.debug("Looking at point class(#{point.class}) value(#{point})")
      point.point? && point_or_property_types.all? do |tag|
        (tag < OpenHAB::DSL::Items::Semantics::Point && point.point_type <= tag) ||
          (tag < OpenHAB::DSL::Items::Semantics::Property && point.property_type&.<=(tag))
      end
    end

This is the point that makes it error out.

2022-09-05 14:21:15.982 [DEBUG] [n.jruby.sitemap.render_sitemap.Array] - Looking at point class(Java::OrgOpenhabCoreLibraryItems::DimmerItem) value(35%)

@boc-tothefuture
Copy link
Owner Author

Root cause was that I had "SetPoint" instead of "Setpoint".. Should we potentially have a more friendly error?

@ccutrer
Copy link
Collaborator

ccutrer commented Dec 15, 2022

Can you elaborate more an how exactly you caused this error? The exception looks like point.point_type returned nil, but we just checked if it was a point, so point_type should never return nil. AFAICT it's possible to have a property_type of nil if it's a point, but not possible to have a point_type of nil if it's a point. In fact, if it's not a point, property_type is guaranteed to be nil, even if it has a property tag on it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants