openhab-scripting 2.22.1 → 2.23.0

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: 854569a4ecda01dc3fb8dc2e12f66147248a2aafffdbbdbabe5d0e750b6849cc
4
- data.tar.gz: 1bf8451a6c8d1dd556472ffa0ceb210e34b9db1b0af6a652bdb336182abb7f20
3
+ metadata.gz: 3b38e635249a2d0e8633e75504eb3e42f79399d1e66b90f5242f3dc8062c711b
4
+ data.tar.gz: dcb573a627b8f93d5a4f6e1bbb8e9b8033f4765b33e49ab88d07414e055b5e7f
5
5
  SHA512:
6
- metadata.gz: 4cb862c98031f4d62d1366dbfaf4a9370103687ad06ab930db77dba32af5623337652d9264f09f28622c12b14314902d1a5ea3b58fffec4cfa2fdd086c3bab31
7
- data.tar.gz: 2044c8d3cee633c59b9368889c7995b4533b29add5d36e97dc3b8400706229c0afd133121b816fd8b4f53886b86e82b281f9dbe659e104c859bec212f6f5e1d8
6
+ metadata.gz: c6b8e1f865bf8912e0575495c0539e96acd5f7c8dc77582ab355bee6e5def4e45701cf159d77b12fe7975cb8493fafbcc0260706f2bd500fddeecf4a66683e5e
7
+ data.tar.gz: fb3c37bf6fdd9f9f95feb26e39e44cd336b7da07a4831e1d3b8079bcbac0f57c005c7324e683dbcb5baa67c60124e947e965edb88b3f8a43a51f03e29fa383a9
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'openhab/dsl/monkey_patch/events/item_state'
3
4
  require 'openhab/dsl/monkey_patch/events/item_state_changed'
4
5
  require 'openhab/dsl/monkey_patch/events/thing_status_info'
5
6
  require 'openhab/dsl/monkey_patch/events/item_command'
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'java'
4
+
5
+ module OpenHAB
6
+ module DSL
7
+ module MonkeyPatch
8
+ #
9
+ # Patches OpenHAB events
10
+ #
11
+ module Events
12
+ java_import Java::OrgOpenhabCoreItemsEvents::ItemStateEvent
13
+
14
+ #
15
+ # MonkeyPatch with ruby style accessors
16
+ #
17
+ class ItemStateEvent
18
+ alias state item_state
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -29,7 +29,7 @@ module OpenHAB
29
29
  def_delegator :@metadata, :value
30
30
 
31
31
  def initialize(metadata: nil, key: nil, value: nil, config: nil)
32
- @metadata = metadata || Metadata.new(key || MetadataKey.new('', ''), value, config)
32
+ @metadata = metadata || Metadata.new(key || MetadataKey.new('', ''), value&.to_s, config)
33
33
  super(@metadata&.configuration)
34
34
  end
35
35
 
@@ -60,9 +60,7 @@ module OpenHAB
60
60
  # @return [Java::Org::openhab::core::items::Metadata] the old metadata
61
61
  #
62
62
  def value=(value)
63
- raise ArgumentError, 'Value must be a string' unless value.is_a? String
64
-
65
- metadata = Metadata.new(@metadata&.uID, value, @metadata&.configuration)
63
+ metadata = Metadata.new(@metadata&.uID, value&.to_s, @metadata&.configuration)
66
64
  NamespaceAccessor.registry.update(metadata) if @metadata&.uID
67
65
  end
68
66
 
@@ -125,7 +123,7 @@ module OpenHAB
125
123
  meta_value, configuration = update_from_value(value)
126
124
 
127
125
  key = MetadataKey.new(namespace, @item_name)
128
- metadata = Metadata.new(key, meta_value, configuration)
126
+ metadata = Metadata.new(key, meta_value&.to_s, configuration)
129
127
  # registry.get can be omitted, but registry.update will log a warning for nonexistent metadata
130
128
  if NamespaceAccessor.registry.get(key)
131
129
  NamespaceAccessor.registry.update(metadata)
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '2.22.1'
8
+ VERSION = '2.23.0'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.22.1
4
+ version: 2.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
@@ -49,6 +49,7 @@ files:
49
49
  - lib/openhab/dsl/monkey_patch/actions/script_thing_actions.rb
50
50
  - lib/openhab/dsl/monkey_patch/events/events.rb
51
51
  - lib/openhab/dsl/monkey_patch/events/item_command.rb
52
+ - lib/openhab/dsl/monkey_patch/events/item_state.rb
52
53
  - lib/openhab/dsl/monkey_patch/events/item_state_changed.rb
53
54
  - lib/openhab/dsl/monkey_patch/events/thing_status_info.rb
54
55
  - lib/openhab/dsl/monkey_patch/items/contact_item.rb