openhab-scripting 5.19.1 → 5.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openhab/core/actions.rb +64 -10
- data/lib/openhab/core/items/call_item.rb +29 -0
- data/lib/openhab/core/items/generic_item.rb +32 -2
- data/lib/openhab/core/items/item.rb +1 -0
- data/lib/openhab/core/items/persistence.rb +16 -4
- data/lib/openhab/core/types/date_time_type.rb +4 -1
- data/lib/openhab/core/types/string_list_type.rb +55 -0
- data/lib/openhab/core/types/string_type.rb +1 -2
- data/lib/openhab/core/types/time_series.rb +1 -1
- data/lib/openhab/core_ext/ruby/time.rb +5 -0
- data/lib/openhab/dsl/items/builder.rb +2 -0
- data/lib/openhab/dsl/rules/builder.rb +14 -10
- data/lib/openhab/dsl/sitemaps/builder.rb +28 -7
- data/lib/openhab/dsl/version.rb +1 -1
- data/lib/openhab/rspec/openhab/core/actions.rb +30 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 756e126e160f646932df226702f4174537f335211766d9eba33c2d44cf1c1c70
|
4
|
+
data.tar.gz: 6afda8cddcc7a0fd916fe061a2eb2dab4621d46cdcef75138b4c524db05b669d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c57f40667e47bacb3c2a2cc62f6fce829413cf832502e1f743cb82fbbc0e5a962800907b27261bea5513020612a8f7652378a7817aa6b0d924c88220ccca7328
|
7
|
+
data.tar.gz: 769878c8db809e0ed1815605551fc964de147329209e89517cab012a782b84e8a21e46fa445f3167723eea4f2454bd290a767991e39cfdb6495c742c874d295e
|
data/lib/openhab/core/actions.rb
CHANGED
@@ -51,31 +51,85 @@ module OpenHAB
|
|
51
51
|
module_function
|
52
52
|
|
53
53
|
#
|
54
|
-
# Send a notification
|
54
|
+
# Send a notification using
|
55
|
+
# {https://next.openhab.org/addons/integrations/openhabcloud/#cloud-notification-actions
|
56
|
+
# openHAB Cloud Notification Action}.
|
55
57
|
#
|
56
58
|
# @param msg [String] The message to send.
|
57
|
-
# @param email [String, nil] The email address to send to. If `nil`,
|
58
|
-
#
|
59
|
-
#
|
60
|
-
# @param severity [String, Symbol, nil]
|
59
|
+
# @param email [String, nil] The email address to send to. If `nil`, the message will be broadcast.
|
60
|
+
# @param icon [String, Symbol, nil] The icon name
|
61
|
+
# (as described in {https://next.openhab.org/docs/configuration/items.html#icons Items}).
|
62
|
+
# @param severity [String, Symbol, nil] A description of the severity of the incident.
|
63
|
+
# @param title [String, nil] The title of the notification.
|
64
|
+
# When `nil`, it defaults to `openHAB` inside the Android and iOS apps.
|
65
|
+
# @param on_click [String, nil] The action to be performed when the user clicks on the notification.
|
66
|
+
# Specified using the {https://next.openhab.org/addons/integrations/openhabcloud/#action-syntax action syntax}.
|
67
|
+
# @param attachment [String, nil] The URL of the media attachment to be displayed with the notification.
|
68
|
+
# This URL must be reachable by the push notification client.
|
69
|
+
# @param buttons [Array<String>, Hash<String, String>, nil] Buttons to include in the notification.
|
70
|
+
# - In array form, each element is specified as `Title=$action`, where `$action` follows the
|
71
|
+
# {https://next.openhab.org/addons/integrations/openhabcloud/#action-syntax action syntax}.
|
72
|
+
# - In hash form, the keys are the button titles and the values are the actions.
|
73
|
+
#
|
74
|
+
# The maximum number of buttons is 3.
|
61
75
|
# @return [void]
|
62
76
|
#
|
77
|
+
# @note The parameters `title`, `on_click`, `attachment`, and `buttons` were added in openHAB 4.2.
|
78
|
+
#
|
79
|
+
# @see https://www.openhab.org/addons/integrations/openhabcloud/
|
80
|
+
#
|
63
81
|
# @example Send a broadcast notification via openHAB Cloud
|
64
|
-
# rule
|
82
|
+
# rule "Send an alert" do
|
65
83
|
# changed Alarm_Triggered, to: ON
|
66
|
-
# run { notify
|
84
|
+
# run { notify "Red Alert!" }
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# @example Provide action buttons in a notification
|
88
|
+
# rule "Doorbell" do
|
89
|
+
# changed Doorbell, to: ON
|
90
|
+
# run do
|
91
|
+
# notify "Someone pressed the doorbell!",
|
92
|
+
# title: "Doorbell",
|
93
|
+
# attachment: "http://myserver.local/cameras/frontdoor.jpg",
|
94
|
+
# buttons: {
|
95
|
+
# "Show Camera" => "ui:/basicui/app?w=0001&sitemap=cameras",
|
96
|
+
# "Unlock Door" => "command:FrontDoor_Lock:OFF"
|
97
|
+
# }
|
98
|
+
# end
|
67
99
|
# end
|
68
100
|
#
|
69
|
-
def notify(
|
101
|
+
def notify(
|
102
|
+
msg,
|
103
|
+
email: nil,
|
104
|
+
icon: nil,
|
105
|
+
severity: nil,
|
106
|
+
title: nil,
|
107
|
+
on_click: nil,
|
108
|
+
attachment: nil,
|
109
|
+
buttons: nil
|
110
|
+
)
|
70
111
|
unless Actions.const_defined?(:NotificationAction)
|
71
112
|
raise NotImplementedError, "NotificationAction is not available. Please install the openHAB Cloud addon."
|
72
113
|
end
|
73
114
|
|
115
|
+
args = []
|
74
116
|
if email
|
75
|
-
|
117
|
+
args.push(:send_notification, email)
|
76
118
|
else
|
77
|
-
|
119
|
+
args.push(:send_broadcast_notification)
|
78
120
|
end
|
121
|
+
args.push(msg.to_s, icon&.to_s, severity&.to_s)
|
122
|
+
|
123
|
+
# @!deprecated OH 4.1
|
124
|
+
if Core.version >= Core::V4_2
|
125
|
+
buttons ||= []
|
126
|
+
buttons = buttons.map { |title, action| "#{title}=#{action}" } if buttons.is_a?(Hash)
|
127
|
+
raise ArgumentError, "buttons must contain (0..3) elements." unless (0..3).cover?(buttons.size)
|
128
|
+
|
129
|
+
args.push(title&.to_s, on_click&.to_s, attachment&.to_s, buttons[0]&.to_s, buttons[1]&.to_s, buttons[2]&.to_s)
|
130
|
+
end
|
131
|
+
|
132
|
+
NotificationAction.__send__(*args)
|
79
133
|
end
|
80
134
|
end
|
81
135
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "generic_item"
|
4
|
+
|
5
|
+
module OpenHAB
|
6
|
+
module Core
|
7
|
+
module Items
|
8
|
+
java_import org.openhab.core.library.items.CallItem
|
9
|
+
|
10
|
+
#
|
11
|
+
# A {CallItem} identifies a telephone call by its origin and destination.
|
12
|
+
#
|
13
|
+
# @!attribute [r] state
|
14
|
+
# @return [StringListType, nil]
|
15
|
+
#
|
16
|
+
class CallItem < GenericItem
|
17
|
+
# @!visibility private
|
18
|
+
def format_type(command)
|
19
|
+
return command if command.is_a?(Types::StringListType)
|
20
|
+
return Types::StringListType.new(command.to_ary.map(&:to_s)) if command.respond_to?(:to_ary)
|
21
|
+
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# @!parse CallItem = OpenHAB::Core::Items::CallItem
|
@@ -134,7 +134,9 @@ module OpenHAB
|
|
134
134
|
#
|
135
135
|
# The similar method `command!`, however, will always send the command regardless of the item's state.
|
136
136
|
#
|
137
|
-
# @param [Command] command command to send to the item
|
137
|
+
# @param [Command, #to_s] command command to send to the item.
|
138
|
+
# When given a {Command} argument, it will be passed directly.
|
139
|
+
# Otherwise, the result of `#to_s` will be parsed into a {Command}.
|
138
140
|
# @return [self, nil] nil when `ensure` is in effect and the item was already in the same state,
|
139
141
|
# otherwise the item.
|
140
142
|
#
|
@@ -143,6 +145,17 @@ module OpenHAB
|
|
143
145
|
# @see OpenHAB::DSL.ensure_states! ensure_states!
|
144
146
|
# @see DSL::Items::Ensure::Ensurable#ensure ensure
|
145
147
|
#
|
148
|
+
# @example Sending a {Command} to an item
|
149
|
+
# MySwitch.command(ON) # The preferred method is `MySwitch.on`
|
150
|
+
# Garage_Door.command(DOWN) # The preferred method is `Garage_Door.down`
|
151
|
+
# SetTemperature.command 20 | "°C"
|
152
|
+
#
|
153
|
+
# @example Sending a plain number to a {NumberItem}
|
154
|
+
# SetTemperature.command(22.5) # if it accepts a DecimalType
|
155
|
+
#
|
156
|
+
# @example Sending a string to a dimensioned {NumberItem}
|
157
|
+
# SetTemperature.command("22.5 °C") # The string will be parsed and converted to a QuantityType
|
158
|
+
#
|
146
159
|
def command(command)
|
147
160
|
command = format_command(command)
|
148
161
|
logger.trace "Sending Command #{command} to #{name}"
|
@@ -165,10 +178,27 @@ module OpenHAB
|
|
165
178
|
#
|
166
179
|
# Send an update to this item
|
167
180
|
#
|
168
|
-
# @param [State] state
|
181
|
+
# @param [State, #to_s, nil] state the state to update the item.
|
182
|
+
# When given a {State} argument, it will be passed directly.
|
183
|
+
# Otherwise, the result of `#to_s` will be parsed into a {State} first.
|
184
|
+
# If `nil` is passed, the item will be updated to {NULL}.
|
169
185
|
# @return [self, nil] nil when `ensure` is in effect and the item was already in the same state,
|
170
186
|
# otherwise the item.
|
171
187
|
#
|
188
|
+
# @example Updating to a {State}
|
189
|
+
# DoorStatus.update(OPEN)
|
190
|
+
# InsideTemperature.update 20 | "°C"
|
191
|
+
#
|
192
|
+
# @example Updating to {NULL}, the two following are equivalent:
|
193
|
+
# DoorStatus.update(nil)
|
194
|
+
# DoorStatus.update(NULL)
|
195
|
+
#
|
196
|
+
# @example Updating with a plain number
|
197
|
+
# PeopleCount.update(5) # A plain NumberItem
|
198
|
+
#
|
199
|
+
# @example Updating with a string to a dimensioned {NumberItem}
|
200
|
+
# InsideTemperature.update("22.5 °C") # The string will be parsed and converted to a QuantityType
|
201
|
+
#
|
172
202
|
def update(state)
|
173
203
|
state = format_update(state)
|
174
204
|
logger.trace "Sending Update #{state} to #{name}"
|
@@ -27,8 +27,7 @@ module OpenHAB
|
|
27
27
|
#
|
28
28
|
# @example Comparison using Quantity
|
29
29
|
# # Because Power_Usage has a unit, the return value
|
30
|
-
# # from average_since is a QuantityType
|
31
|
-
# # compared against a string with quantity
|
30
|
+
# # from average_since is a QuantityType
|
32
31
|
# if Power_Usage.average_since(15.minutes.ago) > 5 | "kW"
|
33
32
|
# logger.info("The power usage exceeded its 15 min average)
|
34
33
|
# end
|
@@ -429,7 +428,7 @@ module OpenHAB
|
|
429
428
|
# @overload persist(timestamp, state, service = nil)
|
430
429
|
# Persists a state at a given timestamp
|
431
430
|
# @param [#to_zoned_date_time] timestamp The timestamp for the given state to be stored
|
432
|
-
# @param [Types::State] state The state to be stored
|
431
|
+
# @param [Types::State, #to_s] state The state to be stored
|
433
432
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
434
433
|
# @return [void]
|
435
434
|
# @since openHAB 4.2
|
@@ -508,7 +507,20 @@ module OpenHAB
|
|
508
507
|
# @see last_update
|
509
508
|
# @since openHAB 4.2
|
510
509
|
|
511
|
-
|
510
|
+
# @!method last_change(service = nil)
|
511
|
+
# Returns the time the item was last changed.
|
512
|
+
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
513
|
+
# @return [ZonedDateTime, nil] The timestamp of the last update
|
514
|
+
# @since openHAB 4.2
|
515
|
+
|
516
|
+
# @!method next_change(service = nil)
|
517
|
+
# Returns the first future change time of the item.
|
518
|
+
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
519
|
+
# @return [ZonedDateTime, nil] The timestamp of the next update
|
520
|
+
# @see last_update
|
521
|
+
# @since openHAB 4.2
|
522
|
+
|
523
|
+
%i[last_update next_update last_change next_change].each do |method|
|
512
524
|
# @deprecated OH 4.1 remove this guard when dropping OH 4.1
|
513
525
|
next unless Actions::PersistenceExtensions.respond_to?(method)
|
514
526
|
|
@@ -80,7 +80,10 @@ module OpenHAB
|
|
80
80
|
# @param value [#to_zoned_date_time, #to_time, #to_str, #to_d, nil]
|
81
81
|
#
|
82
82
|
def initialize(value = nil)
|
83
|
-
if value.
|
83
|
+
if value.nil?
|
84
|
+
super()
|
85
|
+
return
|
86
|
+
elsif value.respond_to?(:to_zoned_date_time)
|
84
87
|
super(value.to_zoned_date_time)
|
85
88
|
return
|
86
89
|
elsif value.respond_to?(:to_time)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
require_relative "type"
|
6
|
+
|
7
|
+
module OpenHAB
|
8
|
+
module Core
|
9
|
+
module Types
|
10
|
+
StringListType = org.openhab.core.library.types.StringListType
|
11
|
+
|
12
|
+
# {StringListType} can be used for items that are dealing with telephony functionality.
|
13
|
+
#
|
14
|
+
# The entries can be accessed like an array.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# string_list = StringListType.new("a", "b", "c")
|
18
|
+
# logger.info "first entry: #{string_list.first}" # => "a"
|
19
|
+
# logger.info "second entry: #{string_list[1]}" # => "b"
|
20
|
+
# logger.info "last entry: #{string_list.last}" # => "c"
|
21
|
+
# logger.info "length: #{string_list.size}" # => 3
|
22
|
+
#
|
23
|
+
class StringListType
|
24
|
+
extend Forwardable
|
25
|
+
|
26
|
+
field_reader :typeDetails
|
27
|
+
|
28
|
+
# @!parse include Command, State
|
29
|
+
|
30
|
+
# @!visibility private
|
31
|
+
def inspect
|
32
|
+
"#<OpenHAB::Core::Types::StringListType #{to_a.inspect}>"
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Array<String>] the values as an array
|
36
|
+
def to_a
|
37
|
+
typeDetails.to_a
|
38
|
+
end
|
39
|
+
|
40
|
+
# @!visibility private
|
41
|
+
def ==(other)
|
42
|
+
return super if other.is_a?(StringListType)
|
43
|
+
return to_a == other.to_a if other.respond_to?(:to_a)
|
44
|
+
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
# any method that exists on Array gets forwarded to states
|
49
|
+
delegate (Array.instance_methods - instance_methods) => :to_a
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# @!parse StringListType = OpenHAB::Core::Types::StringListType
|
@@ -18,7 +18,7 @@ module OpenHAB
|
|
18
18
|
# @since openHAB 4.1
|
19
19
|
#
|
20
20
|
# @example
|
21
|
-
# time_series = TimeSeries.new # defaults to :
|
21
|
+
# time_series = TimeSeries.new # defaults to :replace policy
|
22
22
|
# .add(Time.at(2), DecimalType.new(2))
|
23
23
|
# .add(Time.at(1), DecimalType.new(1))
|
24
24
|
# .add(Time.at(3), DecimalType.new(3))
|
@@ -1283,6 +1283,8 @@ module OpenHAB
|
|
1283
1283
|
# @param [Object] attach Object to be attached to the trigger
|
1284
1284
|
# @return [void]
|
1285
1285
|
#
|
1286
|
+
# @see at
|
1287
|
+
#
|
1286
1288
|
# @example
|
1287
1289
|
# rule "Daily" do
|
1288
1290
|
# every :day, at: '5:15'
|
@@ -1297,7 +1299,13 @@ module OpenHAB
|
|
1297
1299
|
# run { Light.on }
|
1298
1300
|
# end
|
1299
1301
|
#
|
1300
|
-
# @example
|
1302
|
+
# @example Trigger at the time portion of a DateTime Item
|
1303
|
+
# rule "Every day at sunset" do
|
1304
|
+
# every :day, at: Sunset_Time
|
1305
|
+
# run { logger.info "It's getting dark" }
|
1306
|
+
# end
|
1307
|
+
#
|
1308
|
+
# @example Specific day of the week
|
1301
1309
|
# rule "Weekly" do
|
1302
1310
|
# every :monday, at: '5:15'
|
1303
1311
|
# run do
|
@@ -1305,7 +1313,7 @@ module OpenHAB
|
|
1305
1313
|
# end
|
1306
1314
|
# end
|
1307
1315
|
#
|
1308
|
-
# @example
|
1316
|
+
# @example Symbolic interval
|
1309
1317
|
# rule "Often" do
|
1310
1318
|
# every :minute
|
1311
1319
|
# run do
|
@@ -1321,7 +1329,7 @@ module OpenHAB
|
|
1321
1329
|
# end
|
1322
1330
|
# end
|
1323
1331
|
#
|
1324
|
-
# @example
|
1332
|
+
# @example Duration interval
|
1325
1333
|
# rule "Often" do
|
1326
1334
|
# every 5.minutes
|
1327
1335
|
# run do
|
@@ -1329,18 +1337,12 @@ module OpenHAB
|
|
1329
1337
|
# end
|
1330
1338
|
# end
|
1331
1339
|
#
|
1332
|
-
# @example
|
1340
|
+
# @example MonthDay
|
1333
1341
|
# rule 'Every 14th of Feb at 2pm' do
|
1334
1342
|
# every '02-14', at: '2pm'
|
1335
1343
|
# run { logger.info "Happy Valentine's Day!" }
|
1336
1344
|
# end
|
1337
1345
|
#
|
1338
|
-
# @example
|
1339
|
-
# rule "Every day at sunset" do
|
1340
|
-
# every :day, at: Sunset_Time
|
1341
|
-
# run { logger.info "It's getting dark" }
|
1342
|
-
# end
|
1343
|
-
#
|
1344
1346
|
def every(value, at: nil, attach: nil)
|
1345
1347
|
return every(java.time.MonthDay.parse(value), at: at, attach: attach) if value.is_a?(String)
|
1346
1348
|
|
@@ -1735,6 +1737,8 @@ module OpenHAB
|
|
1735
1737
|
# @param [Item, String, Symbol] item The item (or its name)
|
1736
1738
|
# @return [void]
|
1737
1739
|
#
|
1740
|
+
# @see every
|
1741
|
+
#
|
1738
1742
|
# @example
|
1739
1743
|
# rule "say hello when the kids get home from school" do
|
1740
1744
|
# at HomeFromSchool_Time
|
@@ -288,7 +288,8 @@ module OpenHAB
|
|
288
288
|
# If an array is given:
|
289
289
|
# - Scalar elements define the command, and the label is the same as the command.
|
290
290
|
# - Array elements contain the command, label, and optional third element for the icon.
|
291
|
-
# - Hash elements contain the command, label
|
291
|
+
# - Hash elements contain the `command`, `release` (optional), `label`, and `icon` (optional)
|
292
|
+
# defined by the corresponding keys.
|
292
293
|
#
|
293
294
|
# @since openHAB 4.1 added support for icons
|
294
295
|
#
|
@@ -314,6 +315,12 @@ module OpenHAB
|
|
314
315
|
# {command: "auto", label: "Auto"} # no icon
|
315
316
|
# ]
|
316
317
|
#
|
318
|
+
# @example Since openHAB 4.2, `release` is also supported in the array of hashes
|
319
|
+
# # when `release` is specified, `command` will be sent on press and `release` on release
|
320
|
+
# switch mappings: [
|
321
|
+
# {label: "On", command: ON, release: OFF, icon: "f7:power"}
|
322
|
+
# ]
|
323
|
+
#
|
317
324
|
# @return [Hash, Array, nil]
|
318
325
|
# @see LinkableWidgetBuilder#switch
|
319
326
|
# @see https://www.openhab.org/docs/ui/sitemaps.html#mappings
|
@@ -334,8 +341,9 @@ module OpenHAB
|
|
334
341
|
widget = super
|
335
342
|
mappings&.each do |cmd, label, icon|
|
336
343
|
mapping = SitemapBuilder.factory.create_mapping
|
337
|
-
cmd, label, icon = cmd.values_at(:command, :label, :icon) if cmd.is_a?(Hash)
|
344
|
+
cmd, release_cmd, label, icon = cmd.values_at(:command, :release, :label, :icon) if cmd.is_a?(Hash)
|
338
345
|
mapping.cmd = cmd.to_s
|
346
|
+
mapping.release_cmd = release_cmd.to_s unless release_cmd.nil?
|
339
347
|
mapping.label = label&.to_s || cmd.to_s
|
340
348
|
# @deprecated OH 4.1 the if check is not needed in OH4.1+
|
341
349
|
mapping.icon = icon if icon
|
@@ -395,32 +403,44 @@ module OpenHAB
|
|
395
403
|
# @return [true, false, nil]
|
396
404
|
# @note This parameter only works on Android
|
397
405
|
attr_writer :switch
|
406
|
+
# Only send the command when the slider is released
|
407
|
+
# @return [true, false, nil]
|
408
|
+
attr_writer :release_only
|
398
409
|
|
399
410
|
# (see SetpointBuilder#initialize)
|
400
|
-
# @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, range: nil, step: nil, switch: nil, frequency: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
|
411
|
+
# @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, range: nil, step: nil, switch: nil, frequency: nil, release_only: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
|
401
412
|
# @param switch [true, false, nil]
|
402
413
|
# A short press on the item toggles the item on or off (see {SliderBuilder#switch=})
|
403
414
|
# @param frequency [Numeric, nil]
|
404
415
|
# How often to send requests (in seconds) (see {SliderBuilder#frequency})
|
416
|
+
# @param release_only [true, false, nil]
|
417
|
+
# Only send the command when the slider is released (see {SliderBuilder#release_only=})
|
405
418
|
# @!visibility private
|
406
|
-
def initialize(type, builder_proxy, switch: nil, frequency: nil, **kwargs, &block)
|
419
|
+
def initialize(type, builder_proxy, switch: nil, frequency: nil, release_only: nil, **kwargs, &block)
|
407
420
|
super(type, builder_proxy, **kwargs, &block)
|
408
421
|
|
409
422
|
@switch = switch
|
410
423
|
@frequency = frequency
|
411
|
-
@
|
424
|
+
@release_only = release_only
|
412
425
|
end
|
413
426
|
|
414
427
|
# (see #switch=)
|
415
428
|
def switch?
|
416
|
-
@
|
429
|
+
@switch
|
430
|
+
end
|
431
|
+
|
432
|
+
# (see #release_only=)
|
433
|
+
def release_only?
|
434
|
+
@release_only
|
417
435
|
end
|
418
436
|
|
419
437
|
# @!visibility private
|
420
438
|
def build
|
421
439
|
widget = super
|
422
|
-
widget.switch_enabled = switch?
|
440
|
+
widget.switch_enabled = switch? unless @switch.nil?
|
423
441
|
widget.send_frequency = (frequency * 1000).to_i if frequency
|
442
|
+
# @deprecated OH 4.1 remove the version check when dropping OH 4.1 support
|
443
|
+
widget.release_only = release_only? if OpenHAB::Core.version >= OpenHAB::Core::V4_2 && !@release_only.nil?
|
424
444
|
widget
|
425
445
|
end
|
426
446
|
end
|
@@ -936,6 +956,7 @@ module OpenHAB
|
|
936
956
|
# step: nil,
|
937
957
|
# switch: nil,
|
938
958
|
# frequency: nil,
|
959
|
+
# release_only: nil,
|
939
960
|
# label_color: nil,
|
940
961
|
# value_color: nil,
|
941
962
|
# icon_color: nil,
|
data/lib/openhab/dsl/version.rb
CHANGED
@@ -5,10 +5,37 @@ module OpenHAB
|
|
5
5
|
module Actions
|
6
6
|
# redefine these to do nothing so that rules won't fail
|
7
7
|
|
8
|
-
|
8
|
+
class NotificationAction
|
9
|
+
class << self
|
10
|
+
def send_notification(
|
11
|
+
email,
|
12
|
+
msg,
|
13
|
+
icon,
|
14
|
+
severity,
|
15
|
+
title = nil,
|
16
|
+
on_click = nil,
|
17
|
+
attachment = nil,
|
18
|
+
button1 = nil,
|
19
|
+
button2 = nil,
|
20
|
+
button3 = nil
|
21
|
+
)
|
22
|
+
logger.debug("send_notification: #{email}, #{msg}, #{icon}, #{severity}, #{title}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}") # rubocop:disable Layout/LineLength
|
23
|
+
end
|
9
24
|
|
10
|
-
|
11
|
-
|
25
|
+
def send_broadcast_notification(
|
26
|
+
msg,
|
27
|
+
icon,
|
28
|
+
severity,
|
29
|
+
title = nil,
|
30
|
+
on_click = nil,
|
31
|
+
attachment = nil,
|
32
|
+
button1 = nil,
|
33
|
+
button2 = nil,
|
34
|
+
button3 = nil
|
35
|
+
)
|
36
|
+
logger.debug("send_broadcast_notification: #{msg}, #{icon}, #{severity}, #{title}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}") # rubocop:disable Layout/LineLength
|
37
|
+
end
|
38
|
+
end
|
12
39
|
end
|
13
40
|
|
14
41
|
class Voice
|
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.
|
4
|
+
version: 5.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian O'Connell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -263,6 +263,7 @@ files:
|
|
263
263
|
- lib/openhab/core/events/timer_event.rb
|
264
264
|
- lib/openhab/core/items.rb
|
265
265
|
- lib/openhab/core/items/accepted_data_types.rb
|
266
|
+
- lib/openhab/core/items/call_item.rb
|
266
267
|
- lib/openhab/core/items/color_item.rb
|
267
268
|
- lib/openhab/core/items/contact_item.rb
|
268
269
|
- lib/openhab/core/items/date_time_item.rb
|
@@ -348,6 +349,7 @@ files:
|
|
348
349
|
- lib/openhab/core/types/refresh_type.rb
|
349
350
|
- lib/openhab/core/types/rewind_fastforward_type.rb
|
350
351
|
- lib/openhab/core/types/stop_move_type.rb
|
352
|
+
- lib/openhab/core/types/string_list_type.rb
|
351
353
|
- lib/openhab/core/types/string_type.rb
|
352
354
|
- lib/openhab/core/types/time_series.rb
|
353
355
|
- lib/openhab/core/types/type.rb
|
@@ -485,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
485
487
|
- !ruby/object:Gem::Version
|
486
488
|
version: '0'
|
487
489
|
requirements: []
|
488
|
-
rubygems_version: 3.5.
|
490
|
+
rubygems_version: 3.5.14
|
489
491
|
signing_key:
|
490
492
|
specification_version: 4
|
491
493
|
summary: JRuby Helper Libraries for openHAB Scripting
|