PiPup - Android TV app for notifications

I’ve been using this for my video feeds and it’s been working great most of the time. There are times where a white box pops up instead of the video feed. I’m trying to debug it but was wondering if anybody else has run into a similar issue with it.

It seems like a reboot will fix it. I’ve heard that it may be an issue with webview but don’t know much more than that.

Thanks!

1 Like

Can I ask you to share your PIPUP-config? which TV are you using?

Thanks

A bit late but yes currently HTTPS is required because of Androids default policies. You can alter the manifest to allow HTTP though… perhaps I should change that as I also ran into this issue myself :slight_smile:

2 Sony TVs ( one running with a Shield )

1 Like

Are there plans to release a non-beta version in the Play Store? I might want to take a look at creating an Home Assistant Notify integration for this.

I initially looked at the nfandroidtv, but the App has an issue where it seems to delay the popup for a few secons.

I suspect we’ve already got what we need from the rest platform… I did a quick test with the following configuration;

- platform: rest
  name: pipup_living_room_tv
  resource: !secret living_room_android_tv_pipup_host
  method: POST_JSON
  headers:
    Content-Type: application/json
  message_param_name: message
  title_param_name: title
  data_template:
    duration: >
      {{ states("input_number.pipup_living_room_tv_duration")|int }}
    position: >-
      {%- set map = {
        'Top left': 1,
        'Top right': 0,
        'Bottom left': 3,
        'Bottom right': 2,
        'Center': 4,
      } -%}
      {{ map[states("input_select.pipup_living_room_tv_position")]|int }}
    titleColor: >
      {{ states("input_text.pipup_living_room_tv_title_color") }}
    titleSize: >
      {{ states("input_number.pipup_living_room_tv_title_size")|int }}
    messageColor: >
      {{ states("input_text.pipup_living_room_tv_message_color") }}
    messageSize: >
      {{ states("input_number.pipup_living_room_tv_message_size")|int }}
    backgroundColor: >
      {{ states("input_text.pipup_living_room_tv_background_color") }}

    # This is where I ran in to trouble, though..
    # How do we properly render the values from i.e. `data.image.uri` passed in with the service call here?
    media:
      image:
        uri: '{{ value }}'
        width: '{{ value }}'

… and the input helpers, for anyone interested;

##
input_number:
  - pipup_living_room_tv_duration:
      name: Varighet
      min: 1
      max: 60
      step: 1
      icon: mdi:timelapse
      unit_of_measurement: s
  - pipup_living_room_tv_title_size:
      name: Tekststørrelse tittel
      min: 5
      max: 40
      step: 1
      icon: mdi:format-size
      unit_of_measurement: pt
  - pipup_living_room_tv_message_size:
      name: Tekststørrelse melding
      min: 5
      max: 40
      step: 1
      icon: mdi:format-size
      unit_of_measurement: pt

##
input_text:
  - pipup_living_room_tv_title_color:
      name: Tittelfarge
      icon: mdi:format-color-text
      min: 7
      max: 9
      pattern: ^((0x){0,1}|#{0,1})([0-9A-F]{8}|[0-9A-F]{6})$
  - pipup_living_room_tv_message_color:
      name: Meldingsfarge
      icon: mdi:format-color-text
      min: 7
      max: 9
      pattern: ^((0x){0,1}|#{0,1})([0-9A-F]{8}|[0-9A-F]{6})$
  - pipup_living_room_tv_background_color:
      name: Bakgrunnsfarge
      icon: mdi:format-color-fill
      min: 7
      max: 9
      pattern: ^((0x){0,1}|#{0,1})([0-9A-F]{8}|[0-9A-F]{6})$

##
input_select:
  - pipup_living_room_tv_position:
      name: Posisjon
      icon: mdi:dots-grid
      options:
      - 'Top left'
      - 'Top right'
      - 'Bottom left'
      - 'Bottom right'
      - 'Center'

… and the lovelace card to configure the helpers and test it out:

type: 'custom:vertical-stack-in-card'
cards:
  - type: picture-entity
    entity: camera.living_room_tv_snapshot
    show_state: false
    show_name: false
  - type: entities
    show_header_toggle: false
    entities:
      - entity: input_select.pipup_living_room_tv_position
        tap_action:
          action: none
      - entity: input_number.pipup_living_room_tv_duration
        tap_action:
          action: none
      - type: section
        label: Farger
      - entity: input_text.pipup_living_room_tv_title_color
        name: Tittel
        tap_action:
          action: none
      - entity: input_text.pipup_living_room_tv_message_color
        name: Melding
        tap_action:
          action: none
      - entity: input_text.pipup_living_room_tv_background_color
        name: Bakgrunn
        tap_action:
          action: none
      - type: section
        label: Tekststørrelse
      - entity: input_number.pipup_living_room_tv_title_size
        name: Tittel
      - entity: input_number.pipup_living_room_tv_message_size
        name: Melding
      - type: section
      - type: button
        name: ' '
        icon: 'mdi:send-circle-outline'
        action_name: Forhåndsvisning
        tap_action:
          action: call-service
          service: notify.pipup_living_room_tv
          service_data:
            title: Test
            message: Dette er en test av innstillingene!
1 Like

This looks really awesome but sadly I can’t get it to work.
I installed the app from the Play Store and can connect to it (invalid request: invalid method in the browser).

I then tried send a simple POST, which gives me a 200 return code and this response:

PopupProps(duration=30, position=TopRight, backgroundColor=#CC000000, title=Hello, titleSize=16.0, titleColor=#ffffff, message=There, messageSize=16.0, messageColor=#ffffff, media=null)

So the communication with the app appears to be OK but nothing is showing up on the TV itself sadly. I restarted the TV and have the app open.

Anything else I can try? Do I need to give it permissions somewhere? It’s a Sony XH90 TV.

EDIT: got it working by going into the TV to Apps > Special Apps permissions at the botttom > Show before other apps and there enable PIPup. (Mine is in Dutch so I don’t have the exact translation)

2 Likes

It’s a shame this doesn’t support RTMP/RTSP. I intended to use it to send a security camera stream when Frigate’s person detection triggered. Currently, I’m opening VLC when the TV is on standby, and using PiPup to send a snapshot if not. Not ideal, but a good opportunity for me to learn how to configure Home Assistant.

Here’s my rest command configuration:

  pipup:
    url: !secret pipup_host
    content_type: 'application/json'
    verify_ssl: false
    method: 'post'
    timeout: 20
    payload: >
      {
      "duration": "{{ duration }}",
      "position": "{{ position }}",
      "title": "{{ title }}",
      "titleColor": "{{ titleColor }}",
      "titleSize": "{{ titleSize }}",
      "message": "{{ message }}",
      "messageColor": "{{ messageColor }}",
      "messageSize": "{{ messageSize }}",
      "backgroundColor": "{{ backgroundColor }}",
      "media": { "{{ mediaType }}": {
        "uri": "{{ uri }}", "width": "{{ width }}"
      }}
      }

Here’s the automation I described above:

  - alias: "Person Detected"
    trigger:
      platform: mqtt
      topic: frigate/events
    action:
      - choose:
        - alias: "If Standby, VLC"
          conditions:
            - condition: state
              entity_id: media_player.tv
              state: "standby"
          sequence:
            - service: androidtv.adb_command
              data:
                entity_id: media_player.tv
                command: >-
                  input keyevent KEYCODE_WAKEUP
            - service: androidtv.adb_command
              data:
                entity_id: media_player.tv
                command: >-
                  am start -a android.intent.action.VIEW -d
                  <RTSP_URL> -n
                  org.videolan.vlc/.gui.video.VideoPlayerActivity
        default:
          - service: rest_command.pipup
            data:
              title: "Home Assistant"
              message: "A {{trigger.payload_json['after']['label']}} was seen in {{trigger.payload_json['after']['camera']}}."
              backgroundColor: "#DD000000"
              duration: 10
              messageColor: "#FFFFFF"
              messageSize: 10
              position: 2
              titleColor: "#50BFF2"
              titleSize: 15
              mediaType: "image"
              uri: "https://<HA_URL>/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/thumbnail.jpg"
              width: 640
2 Likes

I have a Shield TV running Android 9, and I installed PiPup using the playstore and then adb the system alert permission (I dont have the apk).
Working well for everything, except I can’t display http images from my local network, which would be quite useful :yum:
How is it possible to edit the manifest.xml ? I should take the sources and build the apk from it ? If yes, should I use Android Studio or some ?
Also, what should be changed to allow no secured http connections ?

1 Like

thanks but why image local dont work?
only full path external internet work
please help

i have mi box androaid 9

How did you get this to work with the link to the HA api? I cannot get it to authorize when I try this.

I don’t use the same setup and this is a different method, but I get my frigate notifications sent by looking at this:

file: /config/www/tmp/frigate_driveway_car.jpg

YMMV, but maybe this is an alternative method to try.

Thanks for the alternative method. I am using the nest integration that saves the file to /config/nest/event_media and I don’t know if it is possible to change the file save location to the /config/www folder, but it is worth looking into.

You could just change the call in the automation to where you are already saving the file.

this works great with frigate and Sony tv on android 11! thanks! Is there a way to preview the live stream?

So I have PiPup installed on my Hisense TV and I have the rest command above setup however when I call the rest service, only the text shows up. No image. I can browse the image url just fine on a browser. I also tried the Nabu Case external URL but still no image. Any advice?

It looks OK apart from the non-standard width dimension (try using 480) so try using the example code from Github to test. This will pull a TV test pattern from the Internet. I use Postman to do all my testing as it’s much easier than starting HA all the time after making tweaks.

I also thought it was the 480 dimension but that wasnt it. Someone also said to use https but that didnt work as well.

I have never used Postman but I will see if I can figure out how to use it because I am getting tired of restart HA all the time lol

I took your code and paste it into Postman at my end and it works on my TV.

Did you do both of these things from the website?

Important: after installation / updating it is currently adviced to restart your TV and open the application once to make sure the background-service is running
Sideloading:

On Android TV (8.0+), when sideloading, you will need to set the permission for SYSTEM_ALERT_WINDOW manually (using adb) as there is no interface on Android TV to do this.

To give the application the required permission to draw overlays you will need to run:

adb shell appops set nl.rogro82.pipup SYSTEM_ALERT_WINDOW allow