openhab-scripting 5.41.0 → 5.42.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6920b2ea75f2c8d7e849173181ebbcd05d40006c2cd70785b119b8645e34032e
4
- data.tar.gz: 91cd7e588646072b2cd82ffece697dc8d74b8ddad377575e88748adac7325b63
3
+ metadata.gz: 73d44fb2a401e3ffc950a2d19ca59000005bf77cbb891e9e94287b8f0909adb1
4
+ data.tar.gz: a7c690eb7003d86678ad9a3a5310eb3566a6f77d11fd984049f825959f5c4346
5
5
  SHA512:
6
- metadata.gz: 9e330a848117416e972df7b10e9735e27c20d71a622242a12d4e4dba7401ce9eb4b9e82171830d328d282d852d4e68e9d11d7ed16e495743658f14d0a6e8ea3a
7
- data.tar.gz: 367be6bb928558652035129c6ec0d8c372ab6cedcc04a914d247a9cf3421830c1a5a188197361a7334c0036f813553ed0168df71a5e74e7d4be7920e51a90485
6
+ metadata.gz: 1517830917a483f391f14fc45ad281e2f04165797a1f13a65b543d6cd89d1196f5312b605312e41733de73012282bf474c77bd261574ba226b6bd6df62055a5e
7
+ data.tar.gz: d0c83fdf5d653c0e548a7de8d0035e0b2beefa3963d963ef20d51b3ed01ffc585b9085124b0dc2dfb0eef6ae2e3848c44958cb6a7dc7d346dd45f94f568a96eb
@@ -39,7 +39,7 @@ module OpenHAB
39
39
  #
40
40
  # Returns the event payload as a Hash.
41
41
  #
42
- # @return [Hash, nil] The payload object parsed by JSON. The keys are symbolized.
42
+ # @return [Hash, String, nil] The payload object parsed by JSON. The keys are symbolized.
43
43
  # `nil` when the payload is empty.
44
44
  #
45
45
  def payload
@@ -48,6 +48,8 @@ module OpenHAB
48
48
  original_verbose = $VERBOSE
49
49
  $VERBOSE = nil
50
50
  @payload ||= JSON.parse(get_payload, symbolize_names: true) unless get_payload.empty?
51
+ rescue JSON::ParserError
52
+ get_payload
51
53
  ensure
52
54
  $VERBOSE = original_verbose
53
55
  end
@@ -91,20 +91,30 @@ module OpenHAB
91
91
  label || name
92
92
  end
93
93
 
94
- # @!attribute [r] formatted_state
94
+ # @!attribute [r] display_state
95
95
  #
96
96
  # Format the item's state according to its state description
97
97
  #
98
- # This may include running a transformation.
98
+ # This may include running a transformation, if one is defined in the
99
+ # state description's pattern, otherwise it will format according to the
100
+ # pattern. If no state description is defined, the state will simply
101
+ # be returned as a string.
102
+ #
103
+ # @note While this method is also aliased to `#transformed_state` to
104
+ # match the field available in the openHAB REST API, unlike the API it
105
+ # will always return a value even if the state description has no
106
+ # transformation.
99
107
  #
100
108
  # @return [String] The formatted state
101
109
  #
102
110
  # @example
103
- # logger.info(Exterior_WindDirection.formatted_state) # => "NE (36°)"
111
+ # logger.info(Exterior_WindDirection.display_state) # => "NE (36°)"
104
112
  #
105
- def formatted_state
113
+ def display_state
106
114
  Item.item_states_event_builder.get_display_state(self)
107
115
  end
116
+ alias_method :transformed_state, :display_state
117
+ alias_method :formatted_state, :display_state
108
118
 
109
119
  #
110
120
  # Send a command to this item
@@ -1804,6 +1804,7 @@ module OpenHAB
1804
1804
  # end
1805
1805
  #
1806
1806
  def event(topic, source: nil, types: nil, attach: nil)
1807
+ types ||= org.openhab.core.events.EventSubscriber::ALL_EVENT_TYPES
1807
1808
  types = types.join(",") if types.is_a?(Enumerable)
1808
1809
  trigger("core.GenericEventTrigger",
1809
1810
  topic:,
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.41.0"
7
+ VERSION = "5.42.1"
8
8
  end
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: 5.41.0
4
+ version: 5.42.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell