openhab-scripting 4.39.0 → 4.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/openhab/dsl/items/group_item.rb +1 -0
 - data/lib/openhab/dsl/items/semantics.rb +157 -170
 - data/lib/openhab/dsl/rules/triggers/cron/cron.rb +3 -3
 - data/lib/openhab/dsl/states.rb +2 -2
 - data/lib/openhab/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3ec5b89b1270a09daed465179e9643c559c51491d030f5b6b53431f942d026fb
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 292889a440bfc0f08d091fe5eb31894ca78654cabd5d9684d8b803d2840dd75d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 30e263e6eec5bf3f0258b198817d68f5ca6d31fbca7bb7ac0187601cbd07a91122daa52991e61615003db5a6e308574136d1b1045ad288329539be3e30b0ff28
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0e00529a2b6cc75a4e33a44d97623abf2144e38e637d7a3d70bd6a68f8acd19cf7de18811d8306ee9e35effd3756ae4eb53c032106e68d47e122231bb9cc590f
         
     | 
| 
         @@ -4,168 +4,167 @@ require_relative 'semantics/enumerable' 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            module OpenHAB
         
     | 
| 
       6 
6 
     | 
    
         
             
              module DSL
         
     | 
| 
       7 
     | 
    
         
            -
                 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                   
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
      
 7 
     | 
    
         
            +
                module Items
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # Module for implementing semantics helper methods on [GenericItem]
         
     | 
| 
      
 9 
     | 
    
         
            +
                  #
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # Wraps https://www.openhab.org/javadoc/latest/org/openhab/core/model/script/actions/semantics,
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # as well as adding a few additional convenience methods.
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # Also includes Classes for each semantic tag.
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #
         
     | 
| 
      
 14 
     | 
    
         
            +
                  # Be warned that the Semantic model is stricter than can actually be
         
     | 
| 
      
 15 
     | 
    
         
            +
                  # described by tags and groups on an Item. It makes assumptions that any
         
     | 
| 
      
 16 
     | 
    
         
            +
                  # given item only belongs to one semantic type (Location, Equipment, Point).
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #
         
     | 
| 
      
 18 
     | 
    
         
            +
                  # See https://github.com/openhab/openhab-core/blob/main/bundles/org.openhab.core.semantics/model/SemanticTags.csv
         
     | 
| 
      
 19 
     | 
    
         
            +
                  module Semantics
         
     | 
| 
      
 20 
     | 
    
         
            +
                    # @!visibility private
         
     | 
| 
      
 21 
     | 
    
         
            +
                    # import the actual semantics action
         
     | 
| 
      
 22 
     | 
    
         
            +
                    SemanticsAction = org.openhab.core.model.script.actions.Semantics
         
     | 
| 
      
 23 
     | 
    
         
            +
                    private_constant :SemanticsAction
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    # import all the semantics constants
         
     | 
| 
      
 26 
     | 
    
         
            +
                    [org.openhab.core.semantics.model.point.Points,
         
     | 
| 
      
 27 
     | 
    
         
            +
                     org.openhab.core.semantics.model.property.Properties,
         
     | 
| 
      
 28 
     | 
    
         
            +
                     org.openhab.core.semantics.model.equipment.Equipments,
         
     | 
| 
      
 29 
     | 
    
         
            +
                     org.openhab.core.semantics.model.location.Locations].each do |parent_tag|
         
     | 
| 
      
 30 
     | 
    
         
            +
                      parent_tag.stream.for_each do |tag|
         
     | 
| 
      
 31 
     | 
    
         
            +
                        const_set(tag.simple_name.to_sym, tag.ruby_class)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      end
         
     | 
| 
       31 
33 
     | 
    
         
             
                    end
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                  # put ourself into the global namespace, replacing the action
         
     | 
| 
       35 
     | 
    
         
            -
                  ::Semantics = self # rubocop:disable Naming/ConstantName
         
     | 
| 
       36 
34 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                     
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
                    # put ourself into the global namespace, replacing the action
         
     | 
| 
      
 36 
     | 
    
         
            +
                    ::Semantics = self # rubocop:disable Naming/ConstantName
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                    # Checks if this Item is a Location
         
     | 
| 
      
 39 
     | 
    
         
            +
                    #
         
     | 
| 
      
 40 
     | 
    
         
            +
                    # This is implemented as checking if the item's semantic_type
         
     | 
| 
      
 41 
     | 
    
         
            +
                    # is a Location. I.e. an Item has a single semantic_type.
         
     | 
| 
      
 42 
     | 
    
         
            +
                    #
         
     | 
| 
      
 43 
     | 
    
         
            +
                    # @return [true, false]
         
     | 
| 
      
 44 
     | 
    
         
            +
                    def location?
         
     | 
| 
      
 45 
     | 
    
         
            +
                      SemanticsAction.location?(self)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
       46 
47 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
                    # Checks if this Item is an Equipment
         
     | 
| 
      
 49 
     | 
    
         
            +
                    #
         
     | 
| 
      
 50 
     | 
    
         
            +
                    # This is implemented as checking if the item's semantic_type
         
     | 
| 
      
 51 
     | 
    
         
            +
                    # is an Equipment. I.e. an Item has a single semantic_type.
         
     | 
| 
      
 52 
     | 
    
         
            +
                    #
         
     | 
| 
      
 53 
     | 
    
         
            +
                    # @return [true, false]
         
     | 
| 
      
 54 
     | 
    
         
            +
                    def equipment?
         
     | 
| 
      
 55 
     | 
    
         
            +
                      SemanticsAction.equipment?(self)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
       56 
57 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
                    # Checks if this Item is a Point
         
     | 
| 
      
 59 
     | 
    
         
            +
                    #
         
     | 
| 
      
 60 
     | 
    
         
            +
                    # This is implemented as checking if the item's semantic_type
         
     | 
| 
      
 61 
     | 
    
         
            +
                    # is a Point. I.e. an Item has a single semantic_type.
         
     | 
| 
      
 62 
     | 
    
         
            +
                    #
         
     | 
| 
      
 63 
     | 
    
         
            +
                    # @return [true, false]
         
     | 
| 
      
 64 
     | 
    
         
            +
                    def point?
         
     | 
| 
      
 65 
     | 
    
         
            +
                      SemanticsAction.point?(self)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    end
         
     | 
| 
       66 
67 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
                    # Checks if this Item has any semantic tags
         
     | 
| 
      
 69 
     | 
    
         
            +
                    # @return [true, false]
         
     | 
| 
      
 70 
     | 
    
         
            +
                    def semantic?
         
     | 
| 
      
 71 
     | 
    
         
            +
                      !!semantic_type
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
       72 
73 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 74 
     | 
    
         
            +
                    # Gets the related Location Item of this Item.
         
     | 
| 
      
 75 
     | 
    
         
            +
                    #
         
     | 
| 
      
 76 
     | 
    
         
            +
                    # Returns +self+ if this Item is a Location. Otherwise, checks ancestor
         
     | 
| 
      
 77 
     | 
    
         
            +
                    # groups one level at a time, returning the first Location Item found.
         
     | 
| 
      
 78 
     | 
    
         
            +
                    #
         
     | 
| 
      
 79 
     | 
    
         
            +
                    # @return [GenericItem, nil]
         
     | 
| 
      
 80 
     | 
    
         
            +
                    def location
         
     | 
| 
      
 81 
     | 
    
         
            +
                      SemanticsAction.get_location(self)
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
       82 
83 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
      
 84 
     | 
    
         
            +
                    # Returns the sub-class of [Location] related to this Item.
         
     | 
| 
      
 85 
     | 
    
         
            +
                    #
         
     | 
| 
      
 86 
     | 
    
         
            +
                    # In other words, the semantic_type of this Item's Location.
         
     | 
| 
      
 87 
     | 
    
         
            +
                    #
         
     | 
| 
      
 88 
     | 
    
         
            +
                    # @return [Class]
         
     | 
| 
      
 89 
     | 
    
         
            +
                    def location_type
         
     | 
| 
      
 90 
     | 
    
         
            +
                      SemanticsAction.get_location_type(self)&.ruby_class
         
     | 
| 
      
 91 
     | 
    
         
            +
                    end
         
     | 
| 
       91 
92 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
      
 93 
     | 
    
         
            +
                    # Gets the related Equipment Item of this Item.
         
     | 
| 
      
 94 
     | 
    
         
            +
                    #
         
     | 
| 
      
 95 
     | 
    
         
            +
                    # Returns +self+ if this Item is an Equipment. Otherwise, checks ancestor
         
     | 
| 
      
 96 
     | 
    
         
            +
                    # groups one level at a time, returning the first Equipment Item found.
         
     | 
| 
      
 97 
     | 
    
         
            +
                    #
         
     | 
| 
      
 98 
     | 
    
         
            +
                    # @return [GenericItem, nil]
         
     | 
| 
      
 99 
     | 
    
         
            +
                    def equipment
         
     | 
| 
      
 100 
     | 
    
         
            +
                      SemanticsAction.get_equipment(self)
         
     | 
| 
      
 101 
     | 
    
         
            +
                    end
         
     | 
| 
       101 
102 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
      
 103 
     | 
    
         
            +
                    # Returns the sub-class of [Equipment] related to this Item.
         
     | 
| 
      
 104 
     | 
    
         
            +
                    #
         
     | 
| 
      
 105 
     | 
    
         
            +
                    # In other words, the semantic_type of this Item's Equipment.
         
     | 
| 
      
 106 
     | 
    
         
            +
                    #
         
     | 
| 
      
 107 
     | 
    
         
            +
                    # @return [Class]
         
     | 
| 
      
 108 
     | 
    
         
            +
                    def equipment_type
         
     | 
| 
      
 109 
     | 
    
         
            +
                      SemanticsAction.get_equipment_type(self)&.ruby_class
         
     | 
| 
      
 110 
     | 
    
         
            +
                    end
         
     | 
| 
       110 
111 
     | 
    
         | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 112 
     | 
    
         
            +
                    # Returns the sub-class of [Point] this Item is tagged with.
         
     | 
| 
      
 113 
     | 
    
         
            +
                    #
         
     | 
| 
      
 114 
     | 
    
         
            +
                    # @return [Class]
         
     | 
| 
      
 115 
     | 
    
         
            +
                    def point_type
         
     | 
| 
      
 116 
     | 
    
         
            +
                      SemanticsAction.get_point_type(self)&.ruby_class
         
     | 
| 
      
 117 
     | 
    
         
            +
                    end
         
     | 
| 
       117 
118 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 119 
     | 
    
         
            +
                    # Returns the sub-class of [Property] this Item is tagged with.
         
     | 
| 
      
 120 
     | 
    
         
            +
                    # @return [Class]
         
     | 
| 
      
 121 
     | 
    
         
            +
                    def property_type
         
     | 
| 
      
 122 
     | 
    
         
            +
                      SemanticsAction.get_property_type(self)&.ruby_class
         
     | 
| 
      
 123 
     | 
    
         
            +
                    end
         
     | 
| 
       123 
124 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
      
 125 
     | 
    
         
            +
                    # Returns the sub-class of [Tag] this Item is tagged with.
         
     | 
| 
      
 126 
     | 
    
         
            +
                    #
         
     | 
| 
      
 127 
     | 
    
         
            +
                    # It will only return the first applicable Tag, preferring
         
     | 
| 
      
 128 
     | 
    
         
            +
                    # a sub-class of [Location], [Equipment], or [Point] first,
         
     | 
| 
      
 129 
     | 
    
         
            +
                    # and if none of those are found, looks for a [Property].
         
     | 
| 
      
 130 
     | 
    
         
            +
                    # @return [Class]
         
     | 
| 
      
 131 
     | 
    
         
            +
                    def semantic_type
         
     | 
| 
      
 132 
     | 
    
         
            +
                      SemanticsAction.get_semantic_type(self)&.ruby_class
         
     | 
| 
      
 133 
     | 
    
         
            +
                    end
         
     | 
| 
       133 
134 
     | 
    
         | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
      
 135 
     | 
    
         
            +
                    # Return the related Point Items.
         
     | 
| 
      
 136 
     | 
    
         
            +
                    #
         
     | 
| 
      
 137 
     | 
    
         
            +
                    # Searches this Equipment Item for Points that are tagged appropriately.
         
     | 
| 
      
 138 
     | 
    
         
            +
                    #
         
     | 
| 
      
 139 
     | 
    
         
            +
                    # If called on a Point Item, it will automatically search for sibling Points
         
     | 
| 
      
 140 
     | 
    
         
            +
                    # (and remove itself if found).
         
     | 
| 
      
 141 
     | 
    
         
            +
                    #
         
     | 
| 
      
 142 
     | 
    
         
            +
                    # @example Get all points for a TV
         
     | 
| 
      
 143 
     | 
    
         
            +
                    #   eGreatTV.points
         
     | 
| 
      
 144 
     | 
    
         
            +
                    # @example Search an Equipment item for its switch
         
     | 
| 
      
 145 
     | 
    
         
            +
                    #   eGuestFan.points(Semantics::Switch) # => [GuestFan_Dimmer]
         
     | 
| 
      
 146 
     | 
    
         
            +
                    # @example Search a Thermostat item for its current temperature item
         
     | 
| 
      
 147 
     | 
    
         
            +
                    #   eFamilyThermostat.points(Semantics::Status, Semantics::Temperature)
         
     | 
| 
      
 148 
     | 
    
         
            +
                    #   # => [FamilyThermostat_AmbTemp]
         
     | 
| 
      
 149 
     | 
    
         
            +
                    # @example Search a Thermostat item for is setpoints
         
     | 
| 
      
 150 
     | 
    
         
            +
                    #   eFamilyThermostat.points(Semantics::Control, Semantics::Temperature)
         
     | 
| 
      
 151 
     | 
    
         
            +
                    #   # => [FamilyThermostat_HeatingSetpoint, FamilyThermostat_CoolingSetpoint]
         
     | 
| 
      
 152 
     | 
    
         
            +
                    # @example Given a A/V receiver's input item, search for its power item
         
     | 
| 
      
 153 
     | 
    
         
            +
                    #   FamilyReceiver_Input.points(Semantics::Switch) # => [FamilyReceiver_Switch]
         
     | 
| 
      
 154 
     | 
    
         
            +
                    #
         
     | 
| 
      
 155 
     | 
    
         
            +
                    # @param [Class] point_or_property_types
         
     | 
| 
      
 156 
     | 
    
         
            +
                    #   Pass 1 or 2 classes that are sub-classes of [Point] or [Property].
         
     | 
| 
      
 157 
     | 
    
         
            +
                    #   Note that when comparing against semantic tags, it does a sub-class check.
         
     | 
| 
      
 158 
     | 
    
         
            +
                    #   So if you search for [Control], you'll get items tagged with [Switch].
         
     | 
| 
      
 159 
     | 
    
         
            +
                    # @return [Array<GenericItem>]
         
     | 
| 
      
 160 
     | 
    
         
            +
                    def points(*point_or_property_types)
         
     | 
| 
      
 161 
     | 
    
         
            +
                      return members.points(*point_or_property_types) if equipment? || location?
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                      # automatically search the parent equipment (or location?!) for sibling points
         
     | 
| 
       162 
164 
     | 
    
         
             
                      result = (equipment || location)&.points(*point_or_property_types) || []
         
     | 
| 
       163 
165 
     | 
    
         
             
                      # remove self. but avoid state comparisons
         
     | 
| 
       164 
166 
     | 
    
         
             
                      result.delete_if { |item| item.eql?(self) }
         
     | 
| 
       165 
     | 
    
         
            -
                      return result
         
     | 
| 
       166 
167 
     | 
    
         
             
                    end
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
                    members.points(*point_or_property_types)
         
     | 
| 
       169 
168 
     | 
    
         
             
                  end
         
     | 
| 
       170 
169 
     | 
    
         
             
                end
         
     | 
| 
       171 
170 
     | 
    
         
             
              end
         
     | 
| 
         @@ -175,7 +174,9 @@ end 
     | 
|
| 
       175 
174 
     | 
    
         
             
            module Enumerable
         
     | 
| 
       176 
175 
     | 
    
         
             
              # Returns a new array of items that are a semantics Location (optionally of the given type)
         
     | 
| 
       177 
176 
     | 
    
         
             
              def sublocations(type = nil)
         
     | 
| 
       178 
     | 
    
         
            -
                 
     | 
| 
      
 177 
     | 
    
         
            +
                if type && !(type < OpenHAB::DSL::Items::Semantics::Location)
         
     | 
| 
      
 178 
     | 
    
         
            +
                  raise ArgumentError, 'type must be a subclass of Location'
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
       179 
180 
     | 
    
         | 
| 
       180 
181 
     | 
    
         
             
                result = select(&:location?)
         
     | 
| 
       181 
182 
     | 
    
         
             
                result.select! { |i| i.location_type <= type } if type
         
     | 
| 
         @@ -188,7 +189,9 @@ module Enumerable 
     | 
|
| 
       188 
189 
     | 
    
         
             
              # @example Get all TVs in a room
         
     | 
| 
       189 
190 
     | 
    
         
             
              #   lGreatRoom.equipments(Semantics::Screen)
         
     | 
| 
       190 
191 
     | 
    
         
             
              def equipments(type = nil)
         
     | 
| 
       191 
     | 
    
         
            -
                 
     | 
| 
      
 192 
     | 
    
         
            +
                if type && !(type < OpenHAB::DSL::Items::Semantics::Equipment)
         
     | 
| 
      
 193 
     | 
    
         
            +
                  raise ArgumentError, 'type must be a subclass of Equipment'
         
     | 
| 
      
 194 
     | 
    
         
            +
                end
         
     | 
| 
       192 
195 
     | 
    
         | 
| 
       193 
196 
     | 
    
         
             
                result = select(&:equipment?)
         
     | 
| 
       194 
197 
     | 
    
         
             
                result.select! { |i| i.equipment_type <= type } if type
         
     | 
| 
         @@ -205,36 +208,20 @@ module Enumerable 
     | 
|
| 
       205 
208 
     | 
    
         
             
                  raise ArgumentError, "wrong number of arguments (given #{point_or_property_types.length}, expected 0..2)"
         
     | 
| 
       206 
209 
     | 
    
         
             
                end
         
     | 
| 
       207 
210 
     | 
    
         
             
                unless point_or_property_types.all? do |tag|
         
     | 
| 
       208 
     | 
    
         
            -
                         tag < OpenHAB::DSL::Semantics::Point || tag < OpenHAB::DSL::Semantics::Property
         
     | 
| 
      
 211 
     | 
    
         
            +
                         tag < OpenHAB::DSL::Items::Semantics::Point || tag < OpenHAB::DSL::Items::Semantics::Property
         
     | 
| 
       209 
212 
     | 
    
         
             
                       end
         
     | 
| 
       210 
213 
     | 
    
         
             
                  raise ArgumentError, 'point_or_property_types must all be a subclass of Point or Property'
         
     | 
| 
       211 
214 
     | 
    
         
             
                end
         
     | 
| 
       212 
     | 
    
         
            -
                if point_or_property_types.count { |tag| tag < OpenHAB::DSL::Semantics::Point } > 1 ||
         
     | 
| 
       213 
     | 
    
         
            -
                   point_or_property_types.count { |tag| tag < OpenHAB::DSL::Semantics::Property } > 1
         
     | 
| 
      
 215 
     | 
    
         
            +
                if point_or_property_types.count { |tag| tag < OpenHAB::DSL::Items::Semantics::Point } > 1 ||
         
     | 
| 
      
 216 
     | 
    
         
            +
                   point_or_property_types.count { |tag| tag < OpenHAB::DSL::Items::Semantics::Property } > 1
         
     | 
| 
       214 
217 
     | 
    
         
             
                  raise ArgumentError, 'point_or_property_types cannot both be a subclass of Point or Property'
         
     | 
| 
       215 
218 
     | 
    
         
             
                end
         
     | 
| 
       216 
219 
     | 
    
         | 
| 
       217 
     | 
    
         
            -
                 
     | 
| 
       218 
     | 
    
         
            -
                  . 
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
                      (tag < OpenHAB::DSL::Semantics::Property && point.property_type&.<=(tag))
         
     | 
| 
      
 220 
     | 
    
         
            +
                select do |point|
         
     | 
| 
      
 221 
     | 
    
         
            +
                  point.point? && point_or_property_types.all? do |tag|
         
     | 
| 
      
 222 
     | 
    
         
            +
                    (tag < OpenHAB::DSL::Items::Semantics::Point && point.point_type <= tag) ||
         
     | 
| 
      
 223 
     | 
    
         
            +
                      (tag < OpenHAB::DSL::Items::Semantics::Property && point.property_type&.<=(tag))
         
     | 
| 
       222 
224 
     | 
    
         
             
                  end
         
     | 
| 
       223 
225 
     | 
    
         
             
                end
         
     | 
| 
       224 
226 
     | 
    
         
             
              end
         
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
              #
         
     | 
| 
       227 
     | 
    
         
            -
              # Select the elements where the given block returns true.
         
     | 
| 
       228 
     | 
    
         
            -
              # If the block returns false but the element is a GroupItem with members,
         
     | 
| 
       229 
     | 
    
         
            -
              # merge its members into the result and filter them using the same block
         
     | 
| 
       230 
     | 
    
         
            -
              #
         
     | 
| 
       231 
     | 
    
         
            -
              # @param [Block] &block A block that returns true for the elements and members to be included in the result
         
     | 
| 
       232 
     | 
    
         
            -
              #
         
     | 
| 
       233 
     | 
    
         
            -
              # @return [Array] The resulting array
         
     | 
| 
       234 
     | 
    
         
            -
              #
         
     | 
| 
       235 
     | 
    
         
            -
              # !@visibility private
         
     | 
| 
       236 
     | 
    
         
            -
              def filter_with_members(&block)
         
     | 
| 
       237 
     | 
    
         
            -
                selected, others = partition(&block)
         
     | 
| 
       238 
     | 
    
         
            -
                others.members.select(&block).concat(selected)
         
     | 
| 
       239 
     | 
    
         
            -
              end
         
     | 
| 
       240 
227 
     | 
    
         
             
            end
         
     | 
| 
         @@ -35,7 +35,7 @@ module OpenHAB 
     | 
|
| 
       35 
35 
     | 
    
         
             
                    #
         
     | 
| 
       36 
36 
     | 
    
         
             
                    # @param [String] expression OpenHAB style cron expression
         
     | 
| 
       37 
37 
     | 
    
         
             
                    # @param [Object] attach object to be attached to the trigger
         
     | 
| 
       38 
     | 
    
         
            -
                    # @param [Hash]  
     | 
| 
      
 38 
     | 
    
         
            +
                    # @param [Hash] fields cron expression elements (second, minute, hour, dom, month, dow, year)
         
     | 
| 
       39 
39 
     | 
    
         
             
                    #
         
     | 
| 
       40 
40 
     | 
    
         
             
                    def cron(expression = nil, attach: nil, **fields)
         
     | 
| 
       41 
41 
     | 
    
         
             
                      if fields.any?
         
     | 
| 
         @@ -124,7 +124,7 @@ module OpenHAB 
     | 
|
| 
       124 
124 
     | 
    
         
             
                      #
         
     | 
| 
       125 
125 
     | 
    
         
             
                      # Create a cron map from a MonthDay
         
     | 
| 
       126 
126 
     | 
    
         
             
                      #
         
     | 
| 
       127 
     | 
    
         
            -
                      # @param [Java::JavaTime::MonthDay]  
     | 
| 
      
 127 
     | 
    
         
            +
                      # @param [Java::JavaTime::MonthDay] monthday a {MonthDay} object
         
     | 
| 
       128 
128 
     | 
    
         
             
                      # @param [Object] at TimeOfDay or String representing time of day
         
     | 
| 
       129 
129 
     | 
    
         
             
                      #
         
     | 
| 
       130 
130 
     | 
    
         
             
                      # @return [Hash] map describing cron expression
         
     | 
| 
         @@ -152,7 +152,7 @@ module OpenHAB 
     | 
|
| 
       152 
152 
     | 
    
         
             
                      #
         
     | 
| 
       153 
153 
     | 
    
         
             
                      # Create a cron map from cron elements
         
     | 
| 
       154 
154 
     | 
    
         
             
                      #
         
     | 
| 
       155 
     | 
    
         
            -
                      # @param [Hash]  
     | 
| 
      
 155 
     | 
    
         
            +
                      # @param [Hash] fields Cron fields (second, minute, hour, dom, month, dow, year)
         
     | 
| 
       156 
156 
     | 
    
         
             
                      #
         
     | 
| 
       157 
157 
     | 
    
         
             
                      # @return [Hash] map describing cron expression
         
     | 
| 
       158 
158 
     | 
    
         
             
                      #
         
     | 
    
        data/lib/openhab/dsl/states.rb
    CHANGED
    
    | 
         @@ -33,7 +33,7 @@ module OpenHAB 
     | 
|
| 
       33 
33 
     | 
    
         
             
                  # Check if all the given items have a state (not UNDEF or NULL)
         
     | 
| 
       34 
34 
     | 
    
         
             
                  #
         
     | 
| 
       35 
35 
     | 
    
         
             
                  # @param [Array] items whose state must be non-nil
         
     | 
| 
       36 
     | 
    
         
            -
                  # @param [<Type>]  
     | 
| 
      
 36 
     | 
    
         
            +
                  # @param [<Type>] things when true, also ensures that all linked things are online
         
     | 
| 
       37 
37 
     | 
    
         
             
                  #
         
     | 
| 
       38 
38 
     | 
    
         
             
                  # @return [Boolean] true if all the items have a state, false otherwise
         
     | 
| 
       39 
39 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -51,7 +51,7 @@ module OpenHAB 
     | 
|
| 
       51 
51 
     | 
    
         
             
                    #
         
     | 
| 
       52 
52 
     | 
    
         
             
                    # Create a StateStorage object that stores the states of the given items
         
     | 
| 
       53 
53 
     | 
    
         
             
                    #
         
     | 
| 
       54 
     | 
    
         
            -
                    # @param [Array<Item>]  
     | 
| 
      
 54 
     | 
    
         
            +
                    # @param [Array<Item>] items A list of items
         
     | 
| 
       55 
55 
     | 
    
         
             
                    #
         
     | 
| 
       56 
56 
     | 
    
         
             
                    # @return [StateStorage] A state storage object
         
     | 
| 
       57 
57 
     | 
    
         
             
                    #
         
     | 
    
        data/lib/openhab/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: openhab-scripting
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4.39. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.39.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Brian O'Connell
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-04-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |