Looking for simple push notification example

I want to exercise a simple push notification from a local oh3 server to an android phone
I have an oh3 local server on 192.168.1.75:8080
In my oh3 settings:

  • I have a virtual switch and MQTT binding that sends on/off mqtt message
  • I verified that the mqtt message can be seen by an external mqtt client (MQTT-Explorer)
    (see here for details)

I installed openHAB from the GoogleApp store and connected to the local server.
I now want to send a notification to an Android phone.

I found the pushover binding Pushover - Bindings | openHAB

  • Is this the correct binding to use? Are there other bindings?
  • Is there any tutorial that can help with a simple example on how to send notification?

I’m operating within my home local network. To keep things simple, I prefer to not use the cloud service myopenhab.org.
Is it possible to send push notification within my local network only?

Thanks,
Avi

There are several possibilities and you can find examples for all of them here on the forums and in the binding docs.

  1. External service: Pushover is a popular option, so is the Telegram binding and app (telegram requires following all the steps in the docs carefully to setup a telegram bot, but then offers bi-directional communication: you can gets push notifications and your OH can also take actions based on your repsonse), Push Bullet is another. You’ll have to learn about these services to know if each one is close to what you want. Each of these will easily give you notifications both when you are connected and locally and you are away.

  2. As you already have Mqtt set up, there are mqtt clients for android phones. You can configure a topic for just for notifications and subscribe to it from the phone. This will only work locally unless you configure remote access to your mqtt server which is not recommended, it also will not have quite the response time of true push notifications but close depending on your configuration.

  3. Use the openhab cloud connector with your local OH instance (you can use a cloud server already running such as myopenhab.org or try to set up your own OH cloud server). Once you register a device with the cloud server then you can easily send push notifications to the openhab app on that device.

1 Like

Ok, I want to use an external service: popover - via the popover binding.

  • step1 - Sign-up to pushover service
    I signed-up to pushover service in here and received an email with a user key:
    ...
    To start using those applications and services to receive notifications, you'll need to supply them with your Pushover user key:
    ..........................3f96
  • step2 - Create New API Token
    In oh3, to add the pushover Thing. I’m required to provide: User / Group Key
    Required Your user key or group key (USER_KEY) to which you want to push notifications.
    So I went back and created a token by clicking on the user → Create New API Token
    (see snapshot1, snapshot2)
    I verified that the account is registered by going to https://pushover.net/ (unrelated to oh3) and sending a test notification which appeared in the mobile phone as expected.

  • step3 - Create new Thing
    Settings -> Things -> + -> Pushover Binding -> Pushover Account

    • In “API Token / Key” - I fill in the Pushover user key (…3f96)
    • In “User / Group Key” - I fill in the token that I created in step2
      oh.token2.Yw4..........................................................................ln3A
      (see snapshot3)

After I click on Create Thing I get an error for Pushover Account Thing: ERROR:CONFIG
(see snapshot4)

strong textHow can I add a pushover thing?
Thanks,
Avner

snapshot1 - step2 - create token

snapshot2 - step2 - token is created

snapshot3 - step3 - create new Thing

snapshot4 - Getting an error for Pushover Account Thing: ERROR:CONFIG

Dose it show the error in the logs? You may get more information from the logs

The log files (I see 3 log files) show:

tail -f /var/log/openhab/audit.log
Nothing is specified 
tail -f /var/log/openhab/openhab.log 
Nothing is specified 
sudo tail -f /var/log/openhab/events.log 
...
account:68e0274f7a' changed from UNINITIALIZED to INITIALIZING
2021-04-12 01:07:55.100 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'pushover:pushover-account:68e0274f7a' changed from INITIALIZING to UNKNOWN
2021-04-12 01:07:55.278 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'pushover:pushover-account:68e0274f7a' changed from UNKNOWN to OFFLINE (CONFIGURATION_ERROR): ["application token is invalid"]

I ended up using option3 i.e. by using myopenhab.org (thanks @JustinG)

The steps I did are:

  • added openhab cloud connector (Settings → Misc (in Add-ons section))
    (after this openhab cloud connector shows up in Settings → Other services → openhabCloud)
  • signed up to myopenhab.org, and populated the uuid and secret from
    /var/lib/openhab/uuid
    /var/lib/openhab/openhabcloud/secret
  • connected from my mobile phone to myopenhab.org:
    • installed the OpenHAB app (version 2.16.0) from Google Play
    • In Server OpenHAB filled the field Remote Server URL with https://myopenhab.org/
      (note: initially I filled https://myopenhab.org/443/ which cause connection failure. I had to omit the 443/ )

After doing this, I was able to:

  • connect from the mobile phone (Android Pixel3) into myopenhab.org and see the Openhab Basic UI (with a single virtual switch)
  • verify that things are working by:
    • turning on/off the virtual switch in BasicUI, from the phone:
    • checking the state in an third party utility, that runs on my PC, and that is external to openhab (MQTT-explorer)
      MQTT-explorer listens to mqtt events that are triggered when changing the switch between off/on.
      MQTT-explorer responds to the changes in the switch as expected.
1 Like

@Avner a clarification. you arent using push notifications though right? you are accessing the device remotely?

did you ever setup anything push? (vs email notificaitons) i.e. say door opens and an alarm sensor sees it, can you get a notification popping up on your phone?