Sending notifications to iOS App without using a cloud account

  • Platform information:
    • Hardware: Raspberry Pi 4b with 8 GB RAM
    • OS: Debian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 3.0.0 release build
  • Issue of the topic:
    Hello Looking at various topics and discussions it seems that it is not possible to send notifications to the iOS app without using an openhab cloud account. In fact the basic reason for me using something like openhab was to get around proprietary services in the first place, and openhab seemed well fitted to do just that.
    Is there really no way to use notifications the private way? Publishing my data to a cloud service is a no go. Thanks for your time!

You can use the selfhosted openhab cloud: GitHub - openhab/openhab-cloud: Cloud companion for openHAB instances :slight_smile:

1 Like

There are no way to do push notifications to a mobile phone (iOS or Android) that doesn’t require some sort of cloud service in between the sender and the receiver. Even if you host your own openHAB Cloud server, I think it’s not possible to send push notifications to the phones that way.

So if you want push notifications, you’ll have to establish your own cloud services. And if I’m remembering correctly, you’ll have to set up some other self hosted service to implement the push notifications and make that service accessible over the Internet.

Hi rlkoshak,
thanks for your reply. I have made it to a working connection between myopenhab.org and my local instance. Test notifications from myopenhab.org are successfully sent to my mobile (iOS app). However, when I try to send a notification from a rule or a script within a rule, it does not work. I can see the following log entry:

2021-01-09 20:29:50.929 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'abe656cdf9' failed: ReferenceError: "sendNotification" is not defined in <eval> at line number 1

What am I missing here? It sounds like there is some reference to a library missing or the method cannot be executed from the given context. Do I need to do some other declarations or imports in my script before I can call the sendNotification(string email, string text) method?

In the code pane my rule just contains the following:

triggers:
  - id: "1"
    configuration:
      itemName: BadezimmerTemperatursensor_BadezimmerTemperatursensorLuftfeuchtigkeit
    type: core.ItemStateUpdateTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: |-
        sendNotification("myemail@server.de", "Luftfeuchtigkeit zu hoch!")
        sendLogNotification("Test")
    type: script.ScriptAction

You are using JavaScript as the language so you need to reference the Actions in a way that is supported by JavaScript.

Actions — openHAB Helper Libraries documentation shows how to do it using the Helper Libraries (I don’t know if these have been updated to work with OH 3 yet or not though.

I think it’s done like this:

var NotificationAction = org.openhab.io.openhabcloud.NotificationAction;
NotificationAction.sendNotification("email@gmail.com", "This is a directed notification");
NotificationAction.sendNotification("email@gmail.com", "This is a detailed directed notification", "light", "WARN"); // TODO what is severity? "light" is the icon
NotificationAction.sendBroadcastNotification("This is a broadcast test");
NotificationAction.sendBroadcastNotification("This is a detailed brodcast test", "light", "WARN")
NotificationAction.sendLogNotification("This is a log notification");
NotificationAction.sendLogNotification("This is a detailed log notification", "light", "WARN");

I’ve not tested notifications yet. Note, I’ve since answered the question in the comment, it’s the name of an Icon that will be used in the notification.

Thanks a lot for the information! That was what I needed. It works fine now. :slightly_smiling_face: