Skip to content

Cloud Notification: support enhanced notification#285

Merged
ccutrer merged 1 commit intoopenhab:mainfrom
jimtng:enhanced-notify
Jun 28, 2024
Merged

Cloud Notification: support enhanced notification#285
ccutrer merged 1 commit intoopenhab:mainfrom
jimtng:enhanced-notify

Conversation

@jimtng
Copy link
Contributor

@jimtng jimtng commented Jun 28, 2024

add title, on_click, attachment, and buttons

See openhab/openhab-addons#16938

@jimtng jimtng added the enhancement New feature or request label Jun 28, 2024
@jimtng jimtng force-pushed the enhanced-notify branch 4 times, most recently from 51d2b1f to 5662d8e Compare June 28, 2024 04:08
@jimtng jimtng requested a review from ccutrer June 28, 2024 04:12
end

if email
# @!deprecated OH 4.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the 4 branches here, I'd suggest building up the args list dynamically:

args = []
if email
  args.push(:send_notification, email)
else
  args.push(:send_broadcast_notification)
end
args.push(msg.to_s, icon&.to_s, severity&.to_s)

if Core.version >= Core::V4_2
  buttons ||= []
  buttons = buttons.map { |title, action| "#{title}=#{action}" } if buttons.is_a?(Hash)
  raise ArgumentError, "buttons must contain (0..3) elements." unless (0..3).cover?(buttons.size)

  args.push(on_click&.to_s, attachment&.to_s, buttons[0]&.to_s, buttons[1]&.to_s, buttons[2]&.to_s)
end

NotificationAction.__send__(*args)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So elegant! Thanks, master!

add title, on_click, attachment, and buttons

Signed-off-by: Jimmy Tanagra <[email protected]>
@jimtng jimtng force-pushed the enhanced-notify branch from 5662d8e to f7d5b42 Compare June 28, 2024 14:40
@ccutrer ccutrer merged commit a4d4d5e into openhab:main Jun 28, 2024
@jimtng jimtng deleted the enhanced-notify branch June 28, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants