Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate legacy notification to new format #989

Open
2 tasks done
xhemp opened this issue Jul 6, 2024 · 21 comments
Open
2 tasks done

Migrate legacy notification to new format #989

xhemp opened this issue Jul 6, 2024 · 21 comments
Labels
bug Something isn't working

Comments

@xhemp
Copy link

xhemp commented Jul 6, 2024

Checklist

  • I am using the latest version of Alarmo (latest version can be found here)
  • I checked for similar existing requests (both open and closed) before posting.

Alarmo Version

v1.10.4

HA Version

2024.7.1

Bug description

0758f9bf553523e177c625406c4c826028b2a760

(Ignore the notify.energy above, just got an example of the message which shows on HA).

I use the notification to write which sensor has been tripped and then it calls my phone using an Asterisk server.
I tried to write the notification on yaml but it doesn’t allow me to save it on Alarmo.
Am I mixing things up or is this genuine?

This is what I have on the notify bit inside Alarmo:

service: notify.me_asterisk
data:
  message: "House alarm has been triggered! Cause: {{open_sensors|format=short}}."
  title: ""

And this is what I tried which errors out:

service: notify.send_message
target:
  entity_id: notify.me_asterisk
data:
  message: "House alarm has been triggered! Cause: {{open_sensors|format=short}}."
  title: ""

Steps to reproduce

Just try to send a notification on Actions - Notification on Alarmo

Relevant log output

No response

@xhemp xhemp added the bug Something isn't working label Jul 6, 2024
Copy link

github-actions bot commented Aug 6, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Aug 6, 2024
@nielsfaber
Copy link
Owner

Do you have any link to information about this migration? I’m not aware of any recent changes in HA regarding this.

@JBlohm
Copy link

JBlohm commented Aug 12, 2024

New notify entity platform
https://developers.home-assistant.io/blog/2024/04/10/new-notify-entity-platform/

The change to an entity-based notification service in Home Assistant was introduced in April 2024. This update shifted the notification platform from using the traditional notify.notify service to a new entity-based model. The new notify.send_message service became the core of this update, allowing users to target multiple notification entities simultaneously. This change means that automations using the old service will need to be updated, as the legacy service is being phased out.

In May 2024, additional enhancements were made, including the introduction of a title option in the send_message service, enabling more integrations to be migrated to this new platform.

@github-actions github-actions bot removed the Stale label Aug 13, 2024
@michaelblaas
Copy link

Any update on this issue?

If I try to convert the old format to the new format (as shown by topic starter) I get an error when testing or saving:

"Actie notify/send_message kon niet worden uitgevoerd. must contain at least one of entity_id, device_id, area_id, floor_id, label_id."

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Oct 11, 2024
@Schermbecker
Copy link

Schermbecker commented Oct 16, 2024

Any update on this issue?

If I try to convert the old format to the new format (as shown by topic starter) I get an error when testing or saving:

"Actie notify/send_message kon niet worden uitgevoerd. must contain at least one of entity_id, device_id, area_id, floor_id, label_id."

Same here: I use Alarmo notifications also to notify mobile devices and if there are bypassed_sensors, I put them into these notificiations aswell. This worked pretty good but since last HA updates the IF stuff is printed into the notification.
While searching for a reason I came across the deprecated notify.send_message topic and finally landed here ;-)

This code does not work anymore (and can't be edited as required in Alarmo):

{% if bypassed_sensors | length > 0 %}
Sensors ignored: {{bypassed_sensors}}
{% endif %}

I would highly appreciate a fix for that. I by the way love Alarmo!

The topic I found:
https://community.home-assistant.io/t/notify-send-message-in-2024-6/737177/17

@nielsfaber
Copy link
Owner

I am not sure what is requested here, but I will try summarize it in my own words, hope anyone could confirm/correct me.

If I understand correctly, the migration is about replacing the 'legacy' service format:

service: notify.<my_device_name>
data:
  ...

with the 'new' service format

service: notify.send_message
target:
  entity_id: notify.<my_device_name>
data: 
  ...

For me, only the 'legacy' format works, the second one fails.
There are no notify entities in my configuration, but I do have some notify services available.
From this I can only conclude that the migration is not yet completed on the side of HA, at least not for the notify platforms I am using (such as mobile_app and persistent_notification).
It could be that some platforms already implement the new format, but not all.
Hence the switch to the new format can also not (yet) be done from Alarmo's side.
The architecture discussion about this seems pretty much dead since May, so there doesn't seem to be any steps taken in completing the migration.

My conclusion is that the current situation is a bit of a mixup, some integrations use the 'legacy' format, others use the 'new' format.
From alarmo's side there is (AFAIK) no way to detect which platform uses which, so it's hard to create support for either format using the UI editor (which generates YAML underwater so should know about which format to use).
What I could do is that user can set up the new format in the YAML editor, without getting any error message.
Which is not really an ideal situation, but at least produces a working action.

@xhemp Could you share your views on this?

@Schermbecker
Copy link

@nielsfaber
That would be a great workaround if the yaml part could be changed to the "new" format without UI support. 👍👍

@xhemp
Copy link
Author

xhemp commented Oct 20, 2024

@nielsfaber I believe it sounds good if we can edit the yaml without any error message. As you said, even though it not ideal, we could be able to do it until this whole migration thing goes through.

@nielsfaber
Copy link
Owner

This should be resolved in the v1.10.6 release.

@xhemp
Copy link
Author

xhemp commented Nov 2, 2024

Juat wondering if anyone ( @Schermbecker @michaelblaas @JBlohm ) changed it on the YAML editor and is still getting an error?
When I change to notify.send_message I get a:

Required key 'service' is missing.

@Schermbecker
Copy link

Juat wondering if anyone ( @Schermbecker @michaelblaas @JBlohm ) changed it on the YAML editor and is still getting an error? When I change to notify.send_message I get a:

Required key 'service' is missing.

Actually I haven't changed anything.
I wait for the next update.

@xhemp
Copy link
Author

xhemp commented Nov 2, 2024

I just changed because I was testing my alarm yesterday and the notification was used then I got the warnings on HA about this being changed next month.

@Schermbecker
Copy link

I hope there will be an update of alarmo in time 😀
To be honest, I do not understand the workaround.
How do I have to proceed with current version?

@xhemp
Copy link
Author

xhemp commented Nov 2, 2024

I hope there will be an update of alarmo in time 😀 To be honest, I do not understand the workaround. How do I have to proceed with current version?

The workaround, as far as I understand, would allow us to use the new notification (notify.send_message) in the YAML editor without erroring out but it's not working for me.

@JBlohm
Copy link

JBlohm commented Nov 2, 2024

Juat wondering if anyone ( @Schermbecker @michaelblaas @JBlohm ) changed it on the YAML editor and is still getting an error? When I change to notify.send_message I get a:

Required key 'service' is missing.

Using this (new syntax) YAML:

target:
entity_id: notify.tibber
data:
message: Der Alarm ist auf {{arm_mode}} eingestellt

I get this error when saving:

Something went wrong!
Message format incorrect: string value is None for dictionary value @ data['actions'][0]['entity_id']

Response error: 400

Please report the bug.

As an example of a working automation that uses the new notification syntax I have included it here as a reference for you:

alias: alarmTreibhausTemperatur
description: ""
mode: single
triggers:
  - entity_id:
      - sensor.tele_tasmota_ble_atcb905b9_temperature
    above: 35
    for:
      hours: 0
      minutes: 5
      seconds: 0
    trigger: numeric_state
conditions: []
actions:
  - target:
      entity_id: notify.tibber
    data:
      message: Treibhaus Temp >35 Grad
    action: notify.send_message

@michaelblaas
Copy link

I still cannot use the new syntax...

It seams that the addition 'entity_id: null' wich I assume was introduced by the last Alarmo update suppresses the HA warning for now but parsing the new syntax is not working.

Notification after updating Alarmo:
image

New code should be (IMHO):
image

I've noticed that upon changing the first line to service: notify.send_message the TEST-button becomes greyed out and when saving I get tis error:

image

@xhemp
Copy link
Author

xhemp commented Nov 9, 2024

@nielsfaber Can you please have a look at this? It looks like it's still an issue.

@nielsfaber nielsfaber reopened this Nov 15, 2024
@nielsfaber
Copy link
Owner

@xhemp

Can you please have a look at this? It looks like it's still an issue.

I assume you refer to this issue?

When I change to notify.send_message I get a
Required key 'service' is missing.

First, please make sure that this issue is not due to browser caching. In the top-right corner of the alarmo configuration panel the version number is displayed, this should show v1.10.6.

I test this feature with the notify.notifier entity (which is provided by the demo integration of HA, otherwise I don't have any notify entities to test with).
I configure the notification like this:

When switching to UI mode it looks like this:

I can both test and save this notification, it does not give me any errors.
It's not clear for me what you are doing different than me, so please help me out here, so I can see if something is wrong on the side of Alarmo or its due to the usage.

To clarify a bit more on my previous statement:

What I could do is that user can set up the new format in the YAML editor, without getting any error message.
Which is not really an ideal situation, but at least produces a working action.

This statement is not true. Users can use the UI and should see their notify entities in the dropdown list with targets. The YAML code should be generated for you. The dropdown list will also still show the legacy notify services/actions, the YAML code is automatically adjusted to the correct format.

@michaelblaas Do not use the target selector. Alarmo doesn't support this. The entity_id must be provided directly (see added screenshot provided earlier in my post for example of the required format).

@michaelblaas
Copy link

@nielsfaber : As far as I can see I follow your instructions to the letter. See screenshot. Houwever it still raises the error message and the 'Try' option is greyed out. (Makes no difference if I use the notify.notifier entity).
Schermafbeelding 2024-11-15 093338

@olflo
Copy link

olflo commented Nov 21, 2024

This worked pretty good but since last HA updates the IF stuff is printed into the notification.

I have the same issue and it hasn't been fixed with 1.10.6 or 1.10.7 for me.
Should this be solved by now?

EDIT:
Example for current Version:
"Ein Alarm wurde ausgelöst: Wenn Bewegungsmelder im Flur Bewegung meldet."

Before it was like:
"Ein Alarm wurde ausgelöst: Bewegungsmelder im Flur erkennt Bewegung."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants