Android actionable notifications

I’m wondering if anyone is going to work on a native andoid app?

I hope so! I have 2 apps that people made installed on my phone to try out. I think the connection of websockets happens faster than going through the website.

One is Home Assist…though I prefer a UI that matches the website. I know not everyone feels the same way.

The other is Home Assistant. I prefer this one since it matches the website, but it still needs development because it’ll only show what you have in a group.

1 Like

One thing I have noticed is that if you are using customUI tiles they won’t show up in the mobile view. I am hoping it will be addressed in a mobile app.

Hey @Crewski. One last question: Is there a away to dismiss notifications directly from homeassistant so that they stop appearing on Android? That way one could make something like location based notification. I do have motion sensors in every room. If I’d walk in the kitchen where my Alexa is I could get a notification with options for flashbriefing or weather report. If i walk into the living room it could dismiss the former notification from the kitchen and instead show light scenes or offer to turn on the Playstation. You get the idea?

@jones, I think we could figure something out. Android notifications all get a unique id. The app just randomly generates this number right now. We could probably pass an ID in the notification and then just use that number (if its supplied). Then if another notification comes in with the same ID, it would dismiss the current one then generate a new one. Only issue off the top of my head is that the user would have to keep track of these IDs.

That is exactly the way I handle it with persistent notifications and it works just as expected. I use them to generate reports about my plants/flowers that need water. When they are all watered I dismiss this notification automatically. To dismiss them you have to address them with a unique ID.

Can someone please share the code - and where to add the code? I got into a bit of trouble

Yes, i was talking about translating it into another language. I don’t know how to do it, I’ve translated a few thinks and i was given a file with strings to translate…

@Crewski I downloaded the app and put in my HA duckdns address and app password but it doesn’t like it straight away throws “something went wrong”

Any idea what’s going on?

@bachoo786 did you install the fcm-android.py component into your custom_components/notify and reboot first? The component creates the Rest API endpoint for the app to communicate with, so that needs to be done first.

1 Like

@Abeksis All of the code is in the github link in the OP. What kind of problems are you having?

Where I put the following code:

  • alias: TEST RESPONSE
    trigger:
    • event_data:
      action: open_door
      event_type: fcm_android_notifications.clicked
      platform: event
      condition: []
      action:
    • data:
      entity_id: light.front_door
      service: light.turn_on

@Abeksis That is an example of the callback from pressing on a notification action. That would go into the automations.yaml file. Where you able to get everything else setup properly? Where you able to register the app without a “something went wrong” error?

Everything is fine. Even after I installed the app on my cell phone, I saw that there is a new file fcm_android_registrations.conf and inside there is the tocken.

I tried to add my code:

  • alias: TEST RESPONSE
    trigger:
    • event_data:
      action: open_door
      event_type: fcm_android_notifications.clicked
      platform: event
      condition: []
      action:
    • data:
      entity_id: light.laundry
      service: light.turn_on

And I do not get messages

That is the automation for the response from the app. First you need to send the notification. As part of an automation, the “action” would need to look like:

- service: notify.android
  data:
    message: Anne has arrived home
    data:
      actions:
        - action: open
          title: Open Home Assistant
        - action: open_door
          title: Open door 

If you wanted to test it out from the services tab (the little phone looking one) you can select your notify.android (or whatever you called it in your configuration.yaml) and put the following for the service data:

{
  "message": "Anne has arrived home",
  "data": {
    "actions": [
      {
        "action": "open_door",
        "title": "Open door"
      }
    ]
  }
}

Then if you click the Open Door button on your phone it would trigger your automation to turn on your light.laundry.

1 Like

@Crewski Right I set up everything and have got everything working. However when I use the handling callback I get in my log WARNING (MainThread) [custom_components.notify.fcm-android] Callback event payload is not valid: required key not provided @ data['token']. Got None Is that normal?

I am using it to notify me when my kitchen lights are turned on and I am able to turn them off via the callback i.e. when I click “turn off kitchen lights” on my phone. I also get this message on my phone event: clicked status: ok Is that normal as well?

@bachoo786 Thanks for point out that warning message. I just need to remove that part of the criteria as I check the token but don’t actually put it in the event payload. Easy fix.

The toast message you get is just the response from Home Assistant acknowledging that you clicked the button and everything worked out.

Ok perfect thanks a lot.

@Crewski Just a quick one. It seems like this notify platform does not like any scalar i.e. ' or " in the message section.

Is that correct?

@bachoo786 do you have an example of what’s giving you an issue? I just tried out an automation with ’ and " which seemed to work. If putting it into JSON, you have to escape the quotation marks with backslash like \"

He is what I tried and it gave me the proper notification…it does look funny in yaml though

- alias: Send escaped characters
  trigger: []
  action:
  - service: notify.android
    data:
      message: I'll have just "one" more
      title:  Beer me