home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.03k stars 2.76k forks source link

Actionable notifications support inside Persistent Notifications #4411

Closed SeanPM5 closed 2 years ago

SeanPM5 commented 4 years ago

Currently persistent notifications in Home Assistant just have a single "DISMISS" button no matter what. Not too useful and it feels like a waste of the available space.

Open the demo site for example and look at the demo notification there - it says that motion was detected in the backyard. Chances are you'd wanna check that out immediately, but all you get is a dismiss button. Wouldn't it be cooler if there was a button to show the camera.backyard stream? Or a button to navigate directly to your "Backyard" Lovelace view so you could turn on the lights and scare off any intruders?

In my opinion, if something is important enough to want a notification for, it's usually something important enough to either look at or act upon in some fashion. So why not make that super easy with Actionable Notifications. iOS app has these (docs), HTML5 notify and I believe Telegram integration does as well.

Below are some mockups and examples of how this could be beneficial.

Core System Examples

This first mockup just shows a handful of ideas on how these can be used to notify of core system stuff.

mockup-system

Other ideas not in these mockups:

User Created Automation Examples

I think the above examples already justify this, but it also would be great in user-created automations. You might want to be reminded when a door was left open or unlocked too long, with an actionable button to take care of that. Or be reminded to take your medications which could toggle an input_boolean on. Maybe a parent wants to know when their kid is playing too much video games and have a button to pause WiFi on their consoles. There's lots of possibilities.

mockup-automations

And then of course there's update alert notifications. I have two automations that are very similar to these mockups below, but I had to add the links as Markdown to the message: portion instead. Would look a lot cleaner if they could be actual buttons.

mockup-updates

YAML Config

Below is how the YAML config could potentially look. Would be very similar to Lovelace tap_action config, so it should be familiar to users and easy for them to adopt. And hopefully easier to implement too?

This example would display three buttons underneath the notification text - View Camera, Turn on Lights, and Dismiss.

- service: persistent_notification.create
  data:
    title: Motion Detected in Backyard!
    message: Motion detected and no one is home.
    actions:
      - action_name: "View Camera"
        type: more-info
        service_data:
          entity_id: camera.backyard
      - action_name: "Turn on Lights"
        type: call-service
        service: light.turn_on
        service_data:
          entity_id: light.exterior_lights
      - action_name: "Dismiss"
        type: dismiss

I'm not too sure about the Dismiss part - my thought process was that whenever actions: are defined it'd replace that bottom button row completely, so the user has more space for their own custom actions. They'd still be able to add Dismiss back manually like in the example. But maybe Dismiss should just be forced and always show?

But I think this would be super cool and make Home Assistant notifications 1000x more useful.

iantrich commented 4 years ago

Might want to move this to the arch repo as this is not just frontend work