Notifications for AndroidTV

Hi,

I am using https://home-assistant.io/components/notify.nfandroidtv/10 and it works great so far.

The app needed on the TV is https://play.google.com/store/apps/details?id=de.cyberdream.androidtv.notifications.google&hl=en7. It seems that you can also send pictures: “Forward notifications from your mobile device immediately to your TV screen using Android TV. Including application logo and images contained in the notification.”

https://home-assistant.io/components/notify.nfandroidtv/10 does automatically send the Home Assistant icon, but there is no way to also add pictures to be sent to the TV.

Will there be an update to HA to also support this?

Thanks!

With the last update it was planned to support custom icons. I however had trouble with using the, IIRC, is_allowed_path that’s required to not unintentionally leak sensitive data.
Of course anyone can give it a try. Here’s the code with dynamic icons that didn’t meet the standards: https://github.com/home-assistant/home-assistant/pull/10798/commits/98bec40d4847756809774dc0152e51380471f942

Just wanna make sure that we are talking about the same …
Including application logo and images contained in the notification”. I was talking about an image to be sent. You were talking about the icon, right?

speaking of the icon, I am not sure what happened but the home assistant icon has been missing on the notification. not sure where it went but havent seen it in a month or so.

Ok, then we’re talking of something different. I wasn’t aware that it’s now possible to send images, except when using them as an icon. Good to know.

@dshokouhi
Yes, what once was the Home Assistant logo has been replaced by a transparent pixel. That what I was referring to with the pull request mentioned above. The architecture of Home Assistant has slightly changed internally, which lead to some trouble. In the end I had problems making my code work with the security-requirements that restrict which files can be accessed. To get it working quickly (the platform was broken with the original image file not being where it used to be) we’ve decided to just hardcode the transparent pixel.

1 Like

I have updated the platform and it will support sending images as soon as it gets released (don’t know which HASS release that will be, I think 0.79). Here’s the PR: https://github.com/home-assistant/home-assistant/pull/16565

2 Likes

Amazing! Thank you! :+1:

Hi,
I tried to send a notification with an image. It work with an url image takne somewhere on internet but it does not display a camera image from HA.
Do you know a way to do that ?

Thank you and great job !

Depending on your camera you should have a service called camera.snapshot, which you can call with the service-data {"entity_id":"camera.mycamera", "filename":"/path/to/targetfile.jpg"}.
Once you have done that you can use that path for the notification you want to send to your TV. I have not tried if this really works, but I don’t see a reason why it shouldn’t.

Thanks for the info ! I will try this tonight !
Previously, I tried to use the url of the image directly (ie https://myhomeassistabnturl/api/camera_proxy/mycameraentityid ) but this not work

Did you ever get this to work? Text works for me, but I tried with no success to get the picture working.
It would be ideal to be able to show a shot of a security camera with the notification.

I have it like this and it works perfectly:

  action:
    - service: notify.nfabcd
      data:
        message: "Some message"
        data:
          duration: 5
          fontsize: small
          file:
            url: http://snapshot-url.of.my/camera
            username: user
            password: secret

This of course requires a camera that provides an URL where a still image can be fetched. If you have your camera in Home Assistant you can also use the snapshot service to save the snapshot and use a file location when calling the notification service.

I’ll have to play with it some more. I finally did get it to work using the snapshot URL from my blue iris install, but was trying to get it to work with the HA camera proxy…which I couldn’t do.
This is what didn’t work for me:
http://192.168.0.111:8123/api/camera_proxy/camera.driveway

Thanks for answering!

I don’t know much about the camera proxy, but I assume it outputs MJPEG. And the mechanism of how the notification platform grabs the image is to download it. Which won’t work with a stream because it’s endless. So ideally the camera proxy should be extended to also provide a still image via some url. But that’s unrelated to this platform.

Thanks for this!
Got this to work easily for sending text messages. :slight_smile:

For sending images it was a bit more work. Here is what I came across:

  • If you have images in <HAconfigDir>/www/images/X.jpg then specifying a path of /local/images/X.jpg doesn’t work. You’ll get an error about the file is not secure to load data from! You’ll need to specify the full path name <HAconfigDir>/www/images/X.jpg.

  • If the image is rather large, it won’t work with the default timeout. I get a requests.exceptions.ReadTimeout sending to the FireTV. The solution is to increase the timeout to around 10 to 20 seconds. Note: This also applied to using a URL to get to my IP camera which generates a rather large image.

@wmaker Can you provide details of your automation.yaml? I’m trying to get this to work on RP3 running latest version of HASSIO for sending a text with image to my Android device. Can’t seem to get image to send

Here is the config:

      notify:
        - platform: nfandroidtv
          name: Kitchen          #service will be notify.kitchen
          host: 192.168.1.12     #FireTV IP address
          timeout: 10            #larger timeout needed for large images.

Here is an automation example:

  - alias: Test
    trigger:
      platform: state
      entity_id: input_boolean.test
    action:
      - service: notify.kitchen
        data:
          message: "Message Text!"
          title: "My Notification"
          data:
            duration: 10
            position: center
            file:
              path: "/home/USERNAME/.homeassistant/www/FILENAME.jpg"
1 Like

@wmaker thanks for sharing your setup. I think my path is different for HASSOS. Using “/home/USERNAME/.homeassistant/www/images/FILENAME.jpg” gives an error in my home-assistant.log file of “Can’t write /home/USERNAME/.homeassistant/www/images/Den.jpg, no access to path!” Using “/config/www/images/Den.jpg” gives no error in the log file but I still can’t get the image to send to text message. I even increased the duration to 20 and still no luck… Not sure why this won’t work.

My automation looks like:

  alias: Send SMS on Den Motion
  description: Sends SMS and pic of den on motion detected and not home.
  trigger:
  - entity_id: binary_sensor.nyce_3041_0a8d8350_1_1280
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: device_tracker.my_wrkph
    state: not_home
  action:
  - data:
      entity_id: camera.Den
      filename: /config/www/images/Den.jpg
    service: camera.snapshot
  - data:
      data:
        duaration: 20
        file:
          path: /config/www/imagesZ/Den.jpg
        fontsize: small
      message: 'Motion detected: Den20'
    service: notify.sms_alert

The file gets saved as expected, but it won’t send the file.

1 Like

What does your configuration.yaml look like for notify?
Its not the duration in the service call, its the timeout in the configuration that needs to be increased.