openhab-scripting 2.25.0 → 2.25.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c6a3905160edfd4bf027cb1afbac0af180f0e79641b4558a875d0f89cc275f8
4
- data.tar.gz: 97bc0f35a27b2ccd0fdcac64bfa0e5228b89a68085d5bf8213514e38f33a2add
3
+ metadata.gz: 7226c1329289ce5ce0f85f552c091a6c5f89cb27427b9e6419d528c77a792239
4
+ data.tar.gz: e92ad134d92584fed6ddeeef98984cabc56355cd94f4d205a5228263ac2677d1
5
5
  SHA512:
6
- metadata.gz: 39c074134bcd470a537c57256c57203ad1b750daa7137feea17a18dbc457c990dea3b2a985d271a9d6f5d4f7ae9c215c2444cdd4745ca6ae51aee4eebba8ae0f
7
- data.tar.gz: a8d60e555d4dc743bfdcda7e222281cb40e5fcd4bbea970e0d5473791e1f5e4d2cc590fa8256ba7d60a88a0c661ec7fb13ddc458d923e91166f3228333669926
6
+ metadata.gz: '0519c68cec3b2316751c36ba27c208267ee86f76230a1722dcd3369d61e19da73a96b6616ed2a71838daf68beb3f64b88e1553f82f8cb00daec4de5c859ecb87'
7
+ data.tar.gz: f688f894e8a4bde1c3ee12facc846836a922cc7a1120ffd5d89ff41a6d6be1692608467265179543aaed1262394ea37aaa92d4bd5b03ad9eb33bcdd13b06c8dc
@@ -17,11 +17,13 @@ module OpenHAB
17
17
  class DateTimeItem
18
18
  extend Forwardable
19
19
  extend OpenHAB::DSL::Items::ItemDelegate
20
-
20
+ extend OpenHAB::DSL::Items::ItemCommand
21
21
  include Comparable
22
22
 
23
23
  def_item_delegator :@datetime_item
24
24
 
25
+ item_type Java::OrgOpenhabCoreLibraryItems::DateTimeItem
26
+
25
27
  #
26
28
  # Create a new DateTimeItem
27
29
  #
@@ -51,6 +51,21 @@ module OpenHAB
51
51
  end
52
52
  # rubocop:enable Style/HashEachMethods
53
53
  end
54
+
55
+ #
56
+ # Extract the accepted state and command types from the specified OpenHAB
57
+ # Item class and pass them to item_state/item_command
58
+ #
59
+ # @param [Java::JavaLang::Class] item_class a Class that implements Java::OrgOpenhabCoreItems::Item
60
+ #
61
+ def item_type(item_class)
62
+ item_class.field_reader(:ACCEPTED_DATA_TYPES)
63
+ item_class.field_reader(:ACCEPTED_COMMAND_TYPES)
64
+ item_class.ACCEPTED_DATA_TYPES.select(&:is_enum).grep_v(UnDefType).each { |type| item_state(type.ruby_class) }
65
+ item_class.ACCEPTED_COMMAND_TYPES.select(&:is_enum).grep_v(UnDefType).each do |type|
66
+ item_command(type.ruby_class)
67
+ end
68
+ end
54
69
  end
55
70
  end
56
71
  end
@@ -17,6 +17,7 @@ module OpenHAB
17
17
  # way of breaking it up into multiple classes
18
18
  class NumberItem < Numeric
19
19
  extend OpenHAB::DSL::Items::ItemDelegate
20
+ extend OpenHAB::DSL::Items::ItemCommand
20
21
 
21
22
  def_item_delegator :@number_item
22
23
 
@@ -25,6 +26,8 @@ module OpenHAB
25
26
  java_import 'tec.uom.se.format.SimpleUnitFormat'
26
27
  java_import 'tec.uom.se.AbstractUnit'
27
28
 
29
+ item_type Java::OrgOpenhabCoreLibraryItems::NumberItem
30
+
28
31
  #
29
32
  # Create a new NumberItem
30
33
  #
@@ -19,13 +19,7 @@ module OpenHAB
19
19
 
20
20
  def_item_delegator :@rollershutter_item
21
21
 
22
- java_import Java::OrgOpenhabCoreLibraryTypes::PercentType
23
- java_import Java::OrgOpenhabCoreLibraryTypes::UpDownType
24
- java_import Java::OrgOpenhabCoreLibraryTypes::StopMoveType
25
-
26
- item_command Java::OrgOpenhabCoreLibraryTypes::StopMoveType
27
- item_command Java::OrgOpenhabCoreLibraryTypes::UpDownType
28
- item_state Java::OrgOpenhabCoreLibraryTypes::UpDownType
22
+ item_type Java::OrgOpenhabCoreLibraryItems::RollershutterItem
29
23
 
30
24
  #
31
25
  # Creates a new RollershutterItem
@@ -13,7 +13,7 @@ module OpenHAB
13
13
  #
14
14
  class StringItem
15
15
  extend Forwardable
16
-
16
+ extend OpenHAB::DSL::Items::ItemCommand
17
17
  include Comparable
18
18
  extend OpenHAB::DSL::Items::ItemDelegate
19
19
 
@@ -23,6 +23,8 @@ module OpenHAB
23
23
 
24
24
  def_item_delegator :@string_item
25
25
 
26
+ item_type Java::OrgOpenhabCoreLibraryItems::StringItem
27
+
26
28
  #
27
29
  # Create a new StringItem
28
30
  #
@@ -25,7 +25,7 @@ module OpenHAB
25
25
 
26
26
  java_import Java::OrgOpenhabCoreLibraryTypes::OpenClosedType
27
27
 
28
- item_state Java::OrgOpenhabCoreLibraryTypes::OpenClosedType
28
+ item_type Java::OrgOpenhabCoreLibraryItems::ContactItem
29
29
 
30
30
  #
31
31
  # Compares contacts to OpenClosedTypes
@@ -30,8 +30,7 @@ module OpenHAB
30
30
  extend Forwardable
31
31
  extend OpenHAB::DSL::Items::ItemCommand
32
32
 
33
- item_state Java::OrgOpenhabCoreLibraryTypes::OnOffType
34
- item_command Java::OrgOpenhabCoreLibraryTypes::IncreaseDecreaseType
33
+ item_type Java::OrgOpenhabCoreLibraryItems::DimmerItem
35
34
 
36
35
  def_delegator :state, :to_s
37
36
 
@@ -23,8 +23,7 @@ module OpenHAB
23
23
 
24
24
  java_import Java::OrgOpenhabCoreLibraryTypes::OnOffType
25
25
 
26
- item_command Java::OrgOpenhabCoreLibraryTypes::OnOffType
27
- item_state Java::OrgOpenhabCoreLibraryTypes::OnOffType
26
+ item_type Java::OrgOpenhabCoreLibraryItems::SwitchItem
28
27
 
29
28
  alias truthy? on?
30
29
 
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '2.25.0'
8
+ VERSION = '2.25.1'
9
9
  end
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: 2.25.0
4
+ version: 2.25.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: 2021-02-24 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler