Android actionable notifications

notification
Tags: #<Tag:0x00007f4809c593a8>

#121

I haven’t used tasker in a long time. A quick search found that you can’t add the headers in the tasker app alone. But if you install RESTask it looks like it handles it. The JSON with the action, type, and token are put into the body. Hopefully that’ll get you going in the right direction.


#122

Thanks for the guide!

Managed to get it working:

my_script:
  sequence:
    - service: notify.android
      data:
        message: my message
        data:
          actions:
            - action: my_action
              title: my_title
          tag: 1
    - delay: '00:00:10'
    - service: notify.android
      data:
        message: my message
        data:
          tag: 1
          dismiss: true

#123

@poebae Welcome mate

@Crewski
Sorry my friend I still can’t seem to get this to work.

Here’s what I’ve put into the header

val dataJSON = JSONObject()
dataJSON.put("action", clicktest)
dataJSON.put("type", "clicked")
dataJSON.put("token", FirebaseInstanceId.getInstance(). TOKEN_GOES_HERE)

I also put " https://yourhaurl.com:8123/api/notify.fcm-android/callback" in the host field
and I’m still confused about where to put “x-ha-access: myAPIpassword”. RESTask has 2 fields for the header, “name” and “value” Does it go into the header name?

Please fool check the code as I’m still very new to any form of coding and my spacing and " could be way off :slight_smile:


#124

The x-ha-access is the name and your api_password is the value. These are for the header. The host is your URL with the /api/notify.fcm-android/callback at the end of it. Then you need to enable custom body and out the JSON into the body.


#125

hi i cant manage to show the image on my notifications, here is my config

- alias: image
  trigger:
    platform: time
    hours: 23
    minutes: 00
    seconds: 0
  action:
    service: notify.android
    data:
#      title: Home Assistant
      message: Buenas Noches
      data:
        image: "https://i.postimg.cc/nrDq5Xtd/143f80314780ccaa7c4132a46fe5145b.jpg"

#126

Looks like you are missing a “-” for the service. I tested it in a script and it worked fine. Try this:

- alias: image
  trigger:
    platform: time
    hours: 23
    minutes: 00
    seconds: 0
  action:
  - service: notify.android
    data:
#      title: Home Assistant
      message: Buenas Noches
      data:
        image: "https://i.postimg.cc/nrDq5Xtd/143f80314780ccaa7c4132a46fe5145b.jpg"

#127

I change it, but the image don’t show up only the text
Edit: it’s working now, I was on a older version off the custom component, thank you


#128

You’re the master of disaster! works great
Tasker custom commands to HA will be very handy… Thank you so much!


#129

Is there a way to send a local image file in the notification, instead of an online one via a URL?


#130

The way I handle it for camera snapshots is save them into the config/www folder. Then it’s accessible as /local in the URL.

So /config/www/image.jpg can be viewed at https://yourhaurl.com:8123/local/image.jpg


#131

Thanks for responding. Does that mean that the image is publicly accessible?


#132

Yeah, it would be publicly accessible. I don’t know how to send a local file through FCM.


#133

Hi, following automation is not working:

  • alias: ‘Bedroom light is OFF’
    trigger:
    platform: state
    entity_id: light.bed_light
    to: ‘off’
    action:
    service: notify.android
    data:
    title: Hello!
    message: Beddroom light is OFF

#134

Please use the code tags so we can see your formatting. Thanks. Did you try to manually trigger the automation?


#135

I’m getting below error

image

config:

- id: '1510934330380'
  alias: Test android notification
  trigger:
  - entity_id: light.gateway_light_7811adfdf7238
    from: 'off'
    platform: state
    to: 'on'
  action:
    service: notify.android
    data:
      message: 'Gateway light is ON' 

current version of Hass.io 0.80.0 (HassOS installed on Raspberry Pi 3 B+ 32bit)


#136

yes, i tried this:

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

and here is my automation:

  - alias: 'Bedroom Light is OFF'
    trigger:
      platform: state
      entity_id: light.garage
      to: 'off'
    action:
      service: notify.android
      data:
        title: Hello!
        message: Beddroom Light is OFF

#137

So neither of your examples work, right? Do you see any errors in your log related to fcm-andriod? What is in your configuration.yaml file to set it up?

Since you are just sending a regular notification there shouldn’t be an issue with ports, nginx, or anything like that.


#138

I assume your home assistant has access to the internet, right? How did you upload the fcm-android.py file? Was it uploading the actual file or just copy/paste the code?


#139

Yes, it has internet access and just copy/past.


#140

@mudasar8k Let’s go through the steps and then let me know which step doesn’t work for you.

  1. Make sure to copy the “raw” code into your fcm-android.py file. The raw code can be found here https://raw.githubusercontent.com/Crewski/HANotify/master/fcm-android.py
  2. Setup the fcm-android platform in your configuration.yaml file
  3. Reboot. After the reboot you should see something in the log about fcm-android custom component not being tested with Home Assistant.
  4. Install the app on your phone
  5. Fill out the URL and password, then click register. A toast message should appear saying you are registered.
  6. Back in home assistant, there should now be a fcm_android_registrations.conf file in config/. Open it up and make sure there is at least one entry in there with a token.
  7. Try sending your test notification via the services tab.
  8. Try your automation again.

Please let me know which step fails or you have a problem with. Then we can start narrowing down the issue. Thanks.