halinuxcompanion icon indicating copy to clipboard operation
halinuxcompanion copied to clipboard

[BUG] Special 'clear_notification' pseudo-notification is shown as a regular notification

Open jpbaril opened this issue 11 months ago • 3 comments

Describe the bug Home assistant can send some special "pseudo-notifications" with pre-defined message content to act as commands on the target device.

One of these is a "clear_notification" notification/command that will clear a previously sent persistent notification. https://companion.home-assistant.io/docs/notifications/notifications-basic/#clearing

The issue is that halinuxcompanion will show that special 'clear_notification' pseudo-notification as a regular notification with 'clear_notification' as the notification's body content.

To Reproduce

  1. Send a persistent notification to the device with some message.
  2. Send a second notification to the device with special 'clear_notification' message.

Expected behavior That second special "pseudo-notification" should not appear and simply make the persistent first one to disappear.

jpbaril avatar Jan 12 '25 20:01 jpbaril

This is implemented and it works on my install.

Here's the implementation:

https://github.com/muniter/halinuxcompanion/blob/master/halinuxcompanion%2Fnotifier.py#L285-L288

Can you share the payloads you are using from homeassistant to send the notifications.

muniter avatar Jan 13 '25 02:01 muniter

Notify group:

notify:
  - platform: group
    name: "All my devices"
    unique_id: all_my_devices
    services:
      - action: mobile_app_pixel_8a
      - action: mobile_app_tab_s3
      - action: mobile_app_blackbox_ng

Original permanent notification:

action: notify.all_my_devices
metadata: {}
data:
  message: Someone rang
  title: Doorbell 🔔
  data:
    ttl: 0
    priority: high
    channel: intercom
    importance: high
    persistent: true
    tag: intercom
    image: /api/camera_proxy/camera.reolink_rlc_81ma_zoom_snapshots_clear
    actions:
      - action: intercom_ignore
        title: Ignore ✖
      - action: intercom_open
        title: Unlock door 🔓
enabled: true

Clearing notification:

action: notify.all_my_devices
data:
  message: clear_notification
  data:
    tag: intercom

jpbaril avatar Jan 13 '25 03:01 jpbaril

Did you get a chance to look at that? I also tested as a call to an individual device (and not to a group) and I get same result. And obviously I used latest code for my tests.

BTW, is it possible to attach an image to a notification? As you can I see I'm trying to send as the notification a capture of a surveillance camera, but it's not working on my Ubuntu desktop.

jpbaril avatar Jan 31 '25 04:01 jpbaril