Android App: Send pop-up notification from app to the phone notification screen when item state changes?

You can already send notifications via a rule.
Create a rule, triggered by item change and send a notification.

Some links to read, have a play as you can do it with openHAB’s built in actions…

Actions | openHAB

Android Notification Category (e.g. to override the phone’s DND status) - Tutorials & Examples / Solutions - openHAB Community

You then also have telegram which is great as it can offer you switches and other controls to do stuff back at your home in response to the message sent to your phone.

1 Like

Thanks @matt1, Your suggestion requires myopenhab.org registration. I am thinking that the openHAB app running local should be able to send local notifications to the device on which it is running :thinking:

And, yes, I know about the option with Telegram but this is also an approach that requires an additional app and communication via cloud. I was wondering if a local notification would not be just easier :slight_smile:

Thanks @mueller-ma,
I checked this and it currently looks to me that the popup notification is sent within the app to the UI and I am not sure if such a popup will be seen outside of the app and appear on the notification tab of the smartphone or tablet. I will check this with @digitaldan.

I agree fully local is better but you also have to factor in that volunteers do not want to code multiple ways when one will cover all use cases.
You can host your own openhab cloud inside your own network and that may work fully. Local but I am not expert in that area.

Its possible that there is a way that is easy to setup, you just need to wait for someone to suggest it.

Hi @matt1,

but isn’t this a bit bizarre that you have to run a myopenHAB instance (either locally or leverage the cloud) to send a notification from a locally running app on your smartphone or tablet to the screen of this device ? :thinking:

This is not meant as a negative criticism or as an offense at all. I am simply asking if leveraging a local API in Android would not make it easier for notification that is visible independent id the app is running in fore- or backgound :slight_smile:

Totally understandable. Basically at the moment this feature doesn’t exist.

Others were simply suggesting some workaround so you can reach your end goal whilst using what’s currently available.

There were even links to what’s coming, I think above.

It’s easy to create a notification locally on the device. The problem is getting the content of the notification: this requires a connection to the OH server. Getting a permanent server connection for background apps is really hard, and becomes harder with each new Android version due to additional limitations for background apps being put in place. The official stance of Google (as voiced in the Android API docs) is to use FCM to generate the notifications, and exactly that is what the OH app is doing.

You can do this with MQTT and the following two apps. MQTT Client and Tasker.

First you need to subscribe to a topic on MQTT Client.

Then create a new profile in tasker.

Event > Plugin > MQTT Client > Message Arrived.

Then pick the topic you created and you should be good to go.

You can then use tasker to create a notification or a popup action.

It’s long but possible

I’m running notification on my mobile to get a WhatsApp Message when a status, or whatever on my OH4 systems changes.
This is done via an classic rule, which e.g. sends me an email AND / OR a WhatsApp to my mobile.
As service I use the mail binding, and also the HTTP Binding in combination with an WhatsApp API service from callmebot.com. They have examples how to implement this in OH.

This is very reliable e.g. to get a message when the power from the fixed line if off, and the UPS is in use.
Or to to get a message, when the windsensor close my patio awning.
Nice is also to get a warning message when my battery used Shelly Button1’s are under 20%. So that I can recharge them.

So all in all the best solution for my use-cases.

I do not need an myopenHAB instance.

Have fun with it…

A couple years ago I tried this exact set up. What I found was that it worked very reliably sending a mqtt message from my phone to openHAB. Getting openHAB to send the phone a message however did not work reliably. MQTT client would not reliably receive messages from the broker. MQTT client and tasker have probably improved since then so maybe it works better now.

You’re replacing the OH → myOH → FCM → OH app Hain with a OH → callmebot → WhatsApp server → FCM → WhatsApp app communication chain though, so it’s probably not a viable solution for tbe people who don’t want to use myOH because of it being a cloud service though.

My knowledge in this regard is very limitrd, but can android integrate website notifications (browser notifications) with system? Maybe the ultimate work around is doing this through UI?

Yes, I see that the use-case should only be a local notification.
Nice, if something like this would possible.
If, there is no other solution is needed, fine.

I also wrote, that for my use-case the used solution is the best, because of my need for local and non-local notification.

Also an HW based local SMS Gateway could be used.

I think people are missing what @ohb1138 is actually asking:

As I read it, the question is not “how do I avoid using myopenHAB (or any cloud service)?” The question is, “can this all be done on the device without needing a cloud service, because that might be better/easier?”

(@ohb1138, please correct me if my interpretation is wrong.)

As @maniac103 noted:

…because if Android apps were freely allowed to maintain constant connections in the background, battery life would be measured in minutes, not hours. So, the openHAB app doesn’t constantly download data from the server–and without that data it can’t do anything.

This leaves two options for notifications:

You either use FCM to get real-time notifications, or you set a polling interval and accept that notifications will be delayed.

Perhaps it would be possible to earmark certain items to be monitored by the openHAB app (on a polling frequency), and then use those updates to trigger notifications locally. But then we’d just be moving the “trigger a notification” logic from the server to the openHAB app. Battery life would be worse due to the polling, and the app still wouldn’t be able to do anything if it can’t contact the server.

Great, I suspect some people could take it that way, we have to consider different cultures have different ways of expressing and receiving feedback and it takes longer to post in a sensitive way when we all lead busy lives… We have a local radio personality who likes to say and I’ll passphrase “(ig) Noble prizes are won, not on work done, but because the person asked a question. The question is what wins awards”. He went on to win an award for finding out why belly button fluff is mostly blue because he made an observation, and then asked the questions WHY? End of humour, but if you want to know the reason you can google it as its a true story…

Not bizarre at all and by asking a question you may find what is the road block and trigger its removal. I am not an expert and do not know all, I do not know if 1 such person exists. Someone does the research and learns, this could be you as you do not need to code to be able to read if an API allows something to happen. You can summarize and provide links and speed up development by doing so.

I try to post helpful info or links in case other people find the post in the future, or its about having a way that works, whilst a better way is developed or suggested. Thanks for your posting in this area as it sounds like you know way more about the challenges then I do.

@ohb1138
The makers of the phones do not want the owners getting annoyed (they want future sales of the next phone) with pop up messages if someone hacks the API or creates apps that end up causing the owner an issue, they wants long battery life, so they require certain hurdles if a local way was/is possible. I suspect it would have to be implemented into an app, so the best place to ask and look is what API documentation the openHAB app for your platform is using. It will then give details on what it can do and what the limitations are.

In case you had not seen it, there is now a way to send local messages, images and videos to your Android TV, not what your after, but you may be interested in it. You will also see that the TV blocks this kind of thing happening unless you unlock the features and give the apps permission. The same concept that they want people to not get annoyed and to buy the next TV, so they have restricted certain features to not be so simple as we may like them to be.

@ohb1138
I may have just stumbled onto something that will do this. disclaimer not my app, do your own research if this can be trusted. They have >30 github contributors and many downloads so this looks very good at first glance. Very active with code pushed last week. @riegelbrau posted 2 days ago they use this, any feedback on if this is suitable?

Install this app onto your phone:

and then you need to run their server which is located here:

You can then use curl to send messages to their server on your network, which will send it to the app on your phone hopefully still local (you need to look at how it works or try it with a firewall blocking internet traffic). Seems like this is a fully local way that will work.

Diagram showing the flow here:

By a quick look at the REST api they have published, it would be a quick thing to get get going.

EDIT: BY going down the rabbit hole a bit further it appears another one exists that supports APNS for ios and also GCM the android method. This may mean it does not work locally, not sure.

I use the Alexa App on my phone for this. You can send a text to the app. It even forwards it to the Fitbit on my Wrist. Use the Amazon Binding.

Does that still work when your internet is turned off? Some. People are lucky that they always have reliable internet, others do not.
Pushover
Pushbullet
Telegram
My openhab cloud

Plenty of ways but I believe they all will require a cloud and internet to work.

Requires Alexa cloud link, not Openhab Cloud.