Update notifications (Core, OS, Addons, HACS, etc)

@CentralCommand It’s working like a charm, thank you again.

I have not seen that myself but it looks like you’re hitting this issue. Fortunately this PR went in to fix it about 10 hours ago. Unfortunately that was too late for 2022.4.3 so I would look for a 2022.4.4 to fix it most likely. It doesn’t say so on the PR right now but my guess is that will get cherry-picked for the next patch.

Oh i checked for issues yesterday and nothing was raised, and now i was paranoid but didn’t check again. Thanks for the investigation.

Another suggestion Mike, not a deal breaker, just not great UX i feel.

The icon used for the notification package-up, i would personally suggest to either revert to default, the HA icon, or provide an icon picker field (not sure if it was made available in such use case) or an input field.

My reasoning behind this is that the user loses the app author that sent notifications, especially when in the top bar only. See some screenshots, alongside your old package for comparison.


Don’t get me wrong, i fully understand what you have tried to achieve, but i just feel it distances the notification from the authoring app. Maybe the user input is the best of all worlds, leaves the choice to thr user.

Hope this feedback helps

Makes sense, I can add that.

I find the icon change really handy personally since I usually have a bunch of HA notifications in my bar and can tell without expanding the bar whether its something I should look at immediately or not. That was actually my most missed feature when I switched from html5 notifications to the android companion app ones a long time ago. Well besides actions but I just refused to switch until those were added. So I guess you could say its my most missed feature that I was willing to live without :slight_smile:

It was only added (relatively) recently which is why it was missing from the update notifications package.

1 Like

@robertalexa added an option to change the status bar icon.

1 Like

You are an absolute gentleman!

LE: this whole thing motivated me to review and visually improve all my notifications - i kept saying i will do it, well, tonight was the night :smiley:

To give back, i’ve had a look into the 2nd desired Improvement, and i think i might have a solution. Though i have not tested it and today has been a long day. Happy to have a go at it tomorrow if you don’t make it work by then :smiley:

  1. Use an input for mobile_app_devices that supports multiple: true, like the entity one.
  2. Change your &send-to-mobile-devices sequence to a repeat along these lines (over simplified and not accounting for the Apple check):
- &send-to-mobile-devices
  repeat:
    # Get total number of devices in list and repeat that many times
    count: '{{ !input mobile_app_devices | count }}'
    sequence:
      # Get device in loop number - 1 (as arrays start at position 0)
      device_id: '{{ !input mobile_app_devices[repeat.index - 1] }}'
      domain: mobile_app
      type: notify
      title: "{{ title | default('') }}"

This might not be a plug and play answer, and again, forgive me for not testing something for you, but today’s day already melted my brain. I do however thing that this is on the right track, and should get what you want :slight_smile:

Hope this helps, at least slightly (from an inspiration perspective if not much else)

Rob

Unfortunately that won’t work. I tried it actually :slight_smile:

So first, a small note, you can’t use !input in a template like that. You have to stick it in a variable and then use the variable instead. Like this:

- variables:
    devices: !input mobile_app_devices
- repeat:
    count: '{{ devices | count }}'
    ...

But the real problem is the second part, the actual notify action, here:

device_id: '{{ devices[repeat.index - 1] }}'
domain: mobile_app
type: notify
title: "{{ title | default('') }}"
...

This won’t work because the device_id field does not accept templates. Give it a shot, just make a quick script. Try this below and you’ll see what happens (replace device_tracker.my_phone with whatever you call your phone’s device tracker):

- variables:
    id: "{{ device_id('device_tracker.my_phone') }}"
- device_id: '{{ id }}'
  domain: mobile_app
  type: notify
  title: Hi
  message: Hi

You get this:
Screen Shot 2022-04-13 at 7.08.00 PM

It doesn’t say it there but what’s actually happening is its trying to literally use the text {{ id }} as the ID. It’s not processing it as a template.

The other option I tried was just to provide a list of device IDs for device_id. That works for entity_id so seemed like you should be able to just do this for device_id:

- device_id: !input mobile_app_devices
  ...

Where mobile_app_devices has multiple: true. That doesn’t work either though, lists aren’t accepted.

That’s where I ran out of ideas. I looked around and it seemed like other blueprints are doing a fixed amount of mobile_device_# inputs so I did that too. But it definitely bugs me.

No Error anymore. Great work! :grinning:
Thanks a lot!

Hm… i see. Thanks for your well documented answer.

Am i right in assuming that the same sort of problems are to be expected if we change the notify sequence for a notify service call? e.g. service: notify.rob where the notify services are pre-defined in the config? And instead of the user choosing mobile app devices, they choose from a list of previously defined notification services?

In my case:
configuration.yaml

notify: !include includes/notify.yaml

notify.yaml

- name: rob
  platform: group
  services:
    - service: mobile_app_rob_s_phone
- name: steph
  platform: group
  services:
    - service: mobile_app_steph_s_phone
- name: both
  platform: group
  services:
    - service: mobile_app_rob_s_phone
    - service: mobile_app_steph_s_phone

Hey Mike,

When pressing the Update button for HA Core (the one presented above in the mobile screenshot), i get some errors in the HA log.

This line: Update Notifications Automation Blueprint · GitHub

That is… not how I thought default worked. Really thought it shortcircuited, apparently not. Just switched it up to use a proper if statement there, sorry about that.

1 Like

Actually other notification services (including notification groups) have a few more issues. felipecrs asked about that earlier, I explained the situation here.

The gist is this:

  1. There is no selector available for notification services.
  2. The only guaranteed input in a notification service is message and I have no way to tell what inputs any particular service allows beyond that. Sending other data to a random notification service risks creating an error.
1 Like

Mike, thanks for the blueprint.

I set my reminder hours to None. Now my log is showing this warning:

Template warning: ‘int’ got invalid input ‘None’ when rendering template ‘{{ _reminder_hours | default(0) | int }}’ but no default was specified. Currently ‘int’ will return ‘0’, however this template will fail to render…

Line 110 in the code has ‘int’ without a default.

1 Like

Should be fixed now :+1:

2 Likes

Is there a way to use this for notifications of core updates on a Container install? HA Container doesn’t provide any update entities by default.
I’ve installed the Version integration (I already use it for a basic update notification automation I wrote myself), but it also doesn’t provide an update entity. Instead, it provides a binary_sensor and a sensor. Is it possible to use one of those with this blueprint, or is there a better solution?

[rant] It still astounds me how complex HA manages to make something as simple as getting an update notification… In any other software it would be built in, yet HA decided to strip out what basic update notification functionality they use to have instead of improving it. [/rant]

1 Like

Unfortunately this blueprint can’t help you as it only works on update entities.

Your rant is fair IMO. As a supervisor user I was pretty happy about these new update entities and really didn’t care that updater was tossed. But container and core users only lost something in that exchange, they didn’t gain anything. Well at least not for core, can still make use of the HACS update entities.

The counter point though is that update entities are more then just notifiers. Like if you look at the update platform it’s more then just informational, each update entity also comes with an update.install service to actually execute the update. That’s the reason an update entity can’t be provided currently for core in core/container builds, there is no way for core to execute that update. The system administrator has to make the change to the docker compose file or the venv to make that hapen.

I don’t think I can easily update this blueprint to support something besides update entities as it would require a lot of changes. I think you’ll have to have your own automation for that. Although if you do have a way to execute a core update from within HA on your system you might want to consider making a feature request for a template update entity. That way you can make your two sensors and whatever service does the update into an update entity and use it as one.

Thanks for the reply @CentralCommand. Looks like I’ll have to stick with my own automation for now. Not a big deal now I have it set up, though it’s not nearly as full-featured as your blueprint.

Of course, as you say, updates are easy for Home Assistant OS users – clearly the team’s main focus. It’s just a pity Container users like me lost out in the process. Ideally HA would provide a built-in update entity for core, even if the install service doesn’t work on Container and Core installs. The rest of the functionality would still be useful. (I guess I should open a feature request for that if there isn’t one already.)

1 Like

Hi,

first I have to say, great work, works flawlessly!
However, one thing I noticed in the log and today I have only noticed that it is related to the blueprint.
The following error is displayed:

2022-05-05 12:09:25 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'homeassistant.helpers.template.Wrapper object' has no attribute 'icon_url' when rendering '{{ data if not (
      device_attr(mobile_app_device, 'manufacturer') == 'Apple' and data.icon_url
    ) else dict(data, image=data.icon_url) }}'

Apparently something with “apple” and the “icon_url” if I get it right. Unfortunately, I am not so experienced to be able to correct this myself.

Let’s say everyone had an Apple device. What should I remove from the script?
Or do you have another way to get rid of the warning?

I thank you

2 Likes

Fixed.

TBH I still have mixed feelings about Warn on undefined variables in templates by emontnemery · Pull Request #48140 · home-assistant/core · GitHub . I get why it was done and it has helped me locate issues in some of my own templates with unexpected undefined variables so that’s good. But I really wish it hadn’t removed the ability to do a simple “does it exist” check in an if statement like 'thing exists' if thing_that_may_not_exist else 'thing does not exist'. Now you always have to remember to add a test of some kind like 'thing exists' if thing_that_may_not_exist is string else 'thing does not exist'. Oh well.

2 Likes