openhab-scripting 5.20.0 → 5.21.0
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:
|
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
|
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-06-
|
13
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|