Help with code - Notification

Trying to get a notification when a user access their dashboard (fixed on their mobile phone). It just don’t work, no notification to my phone:

alias: Notify on Freds Dashboard Access
description: Triggers when the Fred dashboard is viewed
triggers:
  - trigger: event
    event_type: browser_mod.navigation
conditions:
  - condition: template
    value_template: "{{ trigger.event.data.path is search('dashboard-fred') }}"
  - condition: template
    value_template: "{{ trigger.event.context.user_id == 'xxxxxxxxxxxxxxxxxxxxxx39bba7c' }}"
actions:
  - action: notify.mobile_app_pixel
    data:
      title: Fred is using HA
      message: Fred just accessed his dashboard.

Any help appreciated, thanks folks.

Are the notifications working in general? Have you tried a simple trigger here? Or is it just that the notifications aren’t working in this particular case?

All other notifications are working fine, this is a new one.

Tried many ways but to no avail. Tried logging into different browsers and devices but still no notification.

The issue is probably not notify.mobile_app_pixel. (but try a simple test notification to it via developer tools: actions)

Your automation only fires if browser_mod.navigation actually happens and the path matches exactly. So the likely problem is that opening the dashboard on the phone is not triggering that Browser Mod event, or the path is different from what you expect.

To test it, remove the conditions and log the event data first:

alias: Test browser_mod navigation
triggers:
  - trigger: event
    event_type: browser_mod.navigation
actions:
  - action: system_log.write
    data:
      level: warning
      message: "{{ trigger.event.data | tojson }}"

Then open the dashboard and check the logs.

If nothing appears, Browser Mod is not sending the event from that device.
If it does appear, check the actual path value because it may not be exactly dashboard-fred.

So in short:

  • notification service looks fine
  • trigger is the likely issue
  • verify Browser Mod is registered on that device and confirm the real event data first
1 Like