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

AI Motion description (automation.ai_motion_description) has an unknown action #121

Open
rappazzo opened this issue Dec 10, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@rappazzo
Copy link
Contributor

AI Motion description (automation.ai_motion_description) has an unknown action

Bug Description

I setup the blueprint to try to notify on my cell, and it is giving me this error whenever it triggers

The automation "AI Motion description" (automation.ai_motion_description) has an unknown action: notify.mobile_app_mikes_cell_receiver_2023.

I'm only able to select "Mike's Cell Receiver 2023" from the notify devices drop down

Version: 1.3.1

Service Call

alias: AI Motion description
description: ""
use_blueprint:
  path: valentinfrlch/event_summary.yaml
  input:
    mode: Frigate
    important: true
    remember: true
    notify_device:
      - 8f68633393b61575ad9f63a8dcc30103
    camera_entities:
      - camera.front_flood
    preview_mode: Snapshot
    provider: 01JDSKTAAJ2N4BD93K25XH7Q6K
    temperature: 0.6
    tap_navigate: /ccab4aaf_frigate-proxy/ingress
    cooldown: 0
    model: gemini-1.5-flash-latest

Logs

From the general Logs (not debug enabled):

AI Motion description: Error executing script. Service not found for choose at pos 3: Action notify.mobile_app_mikes_cell_receiver_2023 not found
AI Motion description: Already running
AI Motion description: Choose at step 3: choice 1: Send instant notification to notify devices: Error executing script. Service not found for call_service at pos 1: Action notify.mobile_app_none not found
AI Motion description: Choose at step 3: choice 1: Error executing script. Service not found for repeat at pos 1: Action notify.mobile_app_none not found
AI Motion description: Error executing script. Service not found for choose at pos 3: Action notify.mobile_app_none not found

Additional context

I tried to change the notify_device to the value that I use in my other automations (mobile_app_mike_s_cell_receiver_2023), but that didn't seem to work either. Also, when I returned to edit the blueprint, it blanked out the drop down when I tried that value.

@rappazzo rappazzo added the bug Something isn't working label Dec 10, 2024
@valentinfrlch
Copy link
Owner

There is a bug right now that occurs when the entity_id of the phone contains "invalid characters". This post in the forum might help: https://community.home-assistant.io/t/camera-frigate-intelligent-ai-powered-notifications/785335/87?u=valentinfrlch.

@rappazzo
Copy link
Contributor Author

rappazzo commented Dec 10, 2024

I've submitted a pull request to adjust the blueprint. It is tested and working on my HA instance.

@sorenbache
Copy link

How much is this really fixed? It seems to fix the issue around using ' (apostrophe) but not 'special characters'? If you e.g. have special characters like é or æøå it does not work still as I see it. Should this be handled as a new bug?

My phone is called 'Sørens iPhone', that is translated into 'srens_iphone' and not 'sorens_iphone':

Error: Action notify.mobile_app_srens_iphone not found

@rappazzo
Copy link
Contributor Author

rappazzo commented Dec 30, 2024

Just googling jinja, it looks like if you add on | unidecode to the end of that in the blueprint. So, this:

  device_name_map: >
    {% set ns = namespace(device_names=[]) %}
    {% for device_id in notify_devices %}
      {% set device_name = device_attr(device_id, "name") %}
      {% set sanitized_name = "mobile_app_" + device_name | lower | regex_replace("[' -]", "_") | regex_replace("[^a-z0-9_]", "") | unidecode %}
      {% set ns.device_names = ns.device_names + [sanitized_name] %}
    {% endfor %}
    {{ ns.device_names }}

Maybe you could try that out? To alter the blueprint, open it in either 'file editor' (if you have that add-on), or use the samba add-on to access it remotely. The path to that file is config/blueprints/automation/valentinfrlch/event_summary.yaml. Of course, you'll probably want to backup the original file before editing.

@sorenbache
Copy link

Thanks for the suggestion. As a first step I just tried this in the developer tools for Templates:

{% set device_name = "Sørens iPhone" %}
{% set sanitized_name = "mobile_app_" + device_name | lower | regex_replace("[' -]", "_") | regex_replace("[^a-z0-9_]", "") | unidecode %}
{{ sanitized_name }}

But I get "TemplateAssertionError: No filter named 'unidecode'." - so apparently this is not included.

BTW a workaround for me personally is this - but obviously not a good general solution :-)

{% set sanitized_name = "mobile_app_" + device_name | lower | regex_replace("[ø]", "o") | regex_replace("[' -]", "_") | regex_replace("[^a-z0-9_]", "") %}

@rappazzo
Copy link
Contributor Author

rappazzo commented Dec 31, 2024

Some more in-depth google searching pointed me to the templating documentation for HA, and in there I found slugify. That seems to do the trick:

{## Imitate available variables: ##}
{% set name = "søren's" %}

Name: '{{ name }}' becomes '{{ name | slugify }}'.

Result:

Name: 'søren' becomes 'soren_s'.

I bet that we could clean up some of the rest of that regex replace with that function too. I am busy for the new year, but I can take a look later this week if no one else can.

(edit: changed example to søren's)

@valentinfrlch
Copy link
Owner

Thank you, this seems exactly what we need! I think the HA dev docs mentioned "slugify" at some point, but I didn't know that there was a Jinja filter too. I'll take a look at it tomorrow.

@valentinfrlch valentinfrlch reopened this Dec 31, 2024
valentinfrlch added a commit that referenced this issue Jan 1, 2025
…n.ai_motion_description) has an unknown action #121)
@valentinfrlch
Copy link
Owner

It seems to work! I pushed it to main. @sorenbache if you could test and give feedback, that'd be amazing!
Thanks @rappazzo for the fix!

@sorenbache
Copy link

Seems to work just fine! Thanks.

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

3 participants