Open digitaldan opened 5 days ago
Does iOS limit the number of actions? Buttons in Android are limited to a maximum of 3, FWIW, so if iOS has a similar limitation, we may want to state that in the documentation of the feature. Also the action text must be way shorter on Android (one word essentially), but I guess the users will figure that one out.
Its a good question, a quick search shows that its also 3 for IOS , not sure what happens when you try adding more then that, guess i'll test, but yes thats a good point, and will need to document.
~FYI, i have a central issue to centralize our discussions, https://github.com/openhab/openhab-addons/issues/16934~ Edited : Sorry thought this comment was on a different thread !
If we get the required change to the openHAB Cloud Connector add-on done before the feature freeze, it would be possible to roll out the new notifications after the 4.2.0 release as we then only need to change cloud and the apps.
I had a similar thought, I think its very possible, I have the work half done, its actually not all that much to change, just adding a new overloaded method with the new fields. I can at least try to get something ready for review today or tomorrow and see how close we are. The cloud code is done, and i plan on pushing that out soon.
What I would love to see is the possibility to cancel or retract notifications!
Use case(s): Retract an open door notification when it is closed. Or whenever something that passed a threshold value is reduced below the threshold again like power usage, temperature, humidity etc.
In rules, our send notification looks like this:
public static void sendNotification(String userId, String message, @Nullable String icon,
@Nullable String severity)
I was thinking to extend it to this, especially now that i know there is a max of 3 action buttons you can add on IOS/Android, notice that many parameters are optional (null)
public static void sendNotification(String userId, String message, @Nullable String icon, @Nullable String severity,
@Nullable String onClickAction, @Nullable String mediaAttachmentURl, @Nullable String actionButton1,
@Nullable String actionButton2, @Nullable String actionButton3) {
an action button String would have the following format ButtonTitle=Action
, for example Turn Kitchen Lights ON=command:KitchenLightst:ON
Alternatively, we could have one actionButton string which ,
delimits actions, so ButtonTitle=Action,ButtonTitle=Action
, but i kinda like having the 3 since it makes it clearer as @maniac103 pointed out.
I can at least try to get something ready for review today or tomorrow and see how close we are.
Great!
What I would love to see is the possibility to cancel or retract notifications!
Yeah, that would be absolutely amazing, but I think if we are able to ship the actions and images to openHAB 4.2.0 we already have a big improvement, but this would be a nice improvement for openHAB 4.3.0.
In rules, our send notification looks like this:
I like that proposal, makes IMO more sense than the single, big string.
The JS and Ruby helper libraries could create a builder around this method to allow easier usage of it.
I like that proposal, makes IMO more sense than the single, big string.
Excellent, I'll go with that then and work on this tonight. Thanks for the feedback !
So i have a version of the cloud binding working and ready for a review. Just FYI, I'll probably give it a once over tomorrow, but its working nicely on my system so far. See #16938
BTW I have already created a WIP PR for a notification builder for the openHAB JavaScript library: https://github.com/openhab/openhab-js/pull/351.
@mueller-ma @maniac103 quick question, right now notifications have a single message. In IOS notifications have both a Title
and Body
, we set the Title
to openHAB
and Body
to the value of the message. Should we allow the user to optionally set the Title as well (but would default to openHAB if not set) . Hoping for a quick answer here, would be a small thing to add, but i want to do this (or not) before we merge anything.
Edit, actually IOS we don't set the title, so it defaults to the App name, which is fine if its not set. I updated the cloud code to support this, and the IOS app should respect it, regardless if we add it to the binding or not.
Actually i think we should support Title, lets make Notifications as powerful as possible, and i don't want to have to come back and create another overloaded method just to support this in the future.
It's similar to Android: Right now we don't set a title, but only a summary (probably what body is on iOS). Adding an optional title should be fine 👍
Great, thanks for the quick feedback. I just updated the binding PR to support this and was able to test end to end with a IOS client.
What about allowing an Image or Video Item name as value for media-attachment-url?
What about allowing an Image or Video Item name as value for media-attachment-url?
I was also thinking to allow relative paths like /static/html/....
and we would try hitting the user's openHAB instance. The IOS client code right now is very simple and is just making a dumb http request, i need to implement using the remote/local connection info so we can use myopenhab if needed for proxing this connection .
But this should be client code, not cloud connector, so we should be able to merge the openHAB server changes now.
@florian-h05 correct, binding and cloud code should not care. I think we can detect url patterns , maybe even item://imageItem or something like that for advanced use of pulling of images from items from clients.
btw, cloud code is deployed, so the binding should work in production
maybe even item://imageItem or something like that for advanced use of pulling of images from items from clients
The item://
prefix should be required when the client handles it like this:
if value startsWith "/" -> relative url
else if value startsWith "http(s);//" -> absolute url
else -> item
So I started to actually use this feature on my home system, very very cool
@digitaldan it's a great development, I've been wanting to get rich notifications for a long time.
I don't know if you're aware or remember, but I made an implementation of the Web Push API for HABot (see here). Depending on the browser and OS it can also display an image and action buttons in some cases:
https://developer.mozilla.org/en-US/docs/Web/API/Notification/image https://developer.mozilla.org/en-US/docs/Web/API/Notification/actions
My main problem at the time was the authentication - since the web push notification feature didn't need openHAB Cloud at all it was difficult to get more than a basic notification because it would require authenticated access to your instance to get the image or perform the actions.
I wonder if it's the right time to resuscitate this web push thing, only in the main UI, with possibly rich notifications? On mobile you would be better served with the apps, of course, but this could introduce notifications for your desktop or laptop computer as well.
Edit: this Medium article shows how web push notifications with an image and/or actions would look on different environments: https://leemunroe.medium.com/the-state-of-push-notification-design-in-2021-21e2ab7aab5e
@ghys i'll definitely read up on browser notifications, its an area i know very little about, but it does sound like an awesome feature, especially if there might be a way to tie it in or unify it with mobile push.
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/jruby-scripting-official-helper-library/145072/15
Suggestion: for action, add two more:
http|https://xxxxxx
- open the given url (using a built in browser? or launch default system browser?). This allows us to open e.g. Frigate's UI to show the full camera interfaceapp:appid
- launch the given app id - but this would not be the same between android vs ios, so might be tricky.Ruby support has been merged https://github.com/openhab/openhab-jruby/pull/285
notify "Someone pressed the doorbell!",
title: "Doorbell",
attachment: "http://myserver.local/cameras/frontdoor.jpg",
buttons: {
"Show Camera" => "ui:/basicui/app?w=0001&sitemap=cameras",
"Unlock Door" => "command:FrontDoor_Lock:OFF"
}
@jimtng those sound like good ideas. The way IOS works, for http(s):
i think we would need to bring the app to the foreground first (like we do with ui:
) , then we could either launch an external web browser or the internal one. And would be similar for app:
as well. I think on IOS, apps need to register themselves to be opened via a URL , so like myApp://somePath?foo=bar
, on Android i thought apps are launched via their bundle id, like com.openhab.app
, but its been awhile since i have looked into it.
Thanks for getting the ruby support in so quick!
when using image items for the media-attachment-url
, how about using item:myItemName
? This can still be parsed as a valid URI in both Swift and Kotlin for easy parsing
Kotlin , when using a URI object, would see this as
Scheme: item
Host: null
Path: null
Query: null
Port: -1
Scheme Specific Part: myItemName
the item name would be located at uri.schemeSpecificPart
So the IOS app now supports using the item:itemName
format for media attachments, i'm waiting on testflight to approve our initial build so we can start getting users on it to test. Once that happens I'll update the IOS readme with the new App link and we can coordinate some messaging on the forums to point users to it.
I updated the actions description to include http/https links in actions , this has also been added to the IOS client.
Please update https://github.com/openhab/openhab-addons/blob/main/bundles/org.openhab.io.openhabcloud/README.md as that's my source of reference for this :)
I'll update the docs today, i don't think it should affect the rule libraries other then documentation ? This was strictly a mobile client side implementation.
It is only a documentation update (in case of JS Scripting I just add a link to the new section for the media attachment url in the cloud add-on docs).
Mobile Notification Enhancements
Using this ticket to coordinate changes between our various projects to support new notifications features. This includes:
Message Payload Keys (Proposal)
title
- Title of the notificationon-click
- Click Action (see action format)actions
- Button Actions["title1" : "action", "title2" : "action",...]
action
media-attachment-url
- URL of media (must be reachable by device)Action Format
An action can be either a
command
,ui
,http
orhttps
action.Command Action
command:itemName:commandString
Example:
command:KitchenLights:ON
UI Action
ui:$itemCommandSyntax
where
$itemCommandSyntax
is the same syntax as defined at https://next.openhab.org/docs/mainui/about.html#ui-command-itemExample
ui:navigate:/page/my_custom_page
ui:popup:$target
(where $target is "page: + a page ID", or "widget: + a widget ID", etc...)ui:sheet:$target
OR
ui:$path
where
$path
is either/basicui/app?.....
for sitemaps (native sitemap renderer will be used) or/some/absolute/path
for navigating the view.$path
in either case starts with a/
Example
ui:/basicui/app?w=0000&sitemap=main
(use the WebUI to get sitemap URL locations)ui:/page/page1
(will force the browser to go to this page)http | https action
https://openhab.org
This will open the link in a embedded browser, and is meant for loading external web pages.
Sample Payload
This is what may be sent from the binding to openHAB Cloud
Associated Tickets
Android: https://github.com/openhab/openhab-android/issues/3193 (original discussion here) IOS: https://github.com/openhab/openhab-ios/pull/764 Cloud: https://github.com/openhab/openhab-cloud/pull/462 MainUI: https://github.com/openhab/openhab-webui/pull/2622 Cloud Addon: #16938 openhab-js: https://github.com/openhab/openhab-js/pull/351 Docs: #16941 and https://github.com/openhab/openhab-docs/pull/2320
TODO
Checklist for implementation:
Notify maintainers of other UIs: @openhab/webui-maintainers @openhab/android-maintainers @openhab/ios-maintainers
Sample Screen Shot (IOS)![IMG_5C6672F754A4-1](https://github.com/openhab/openhab-addons/assets/1903737/62d47c3e-14f6-4d32-9272-3f99e3b30256)