Hello! I just figured out how to parse the NetAlertX json correctly when using a webhook and wanted to share my automation for those who are using NetAlertX and want notifications for new devices that connect to their networks. This automation only looks for new devices and is not designed for every event that happens within NetAlertX. The automation also includes a disabled persistent notification that can be enabled to debug the json payload.
alias: Notify - NetAlertX Notifications
description: ""
triggers:
- trigger: webhook
allowed_methods:
- POST
- PUT
- GET
local_only: true
webhook_id: "your_secret_webhook_id"
conditions: []
actions:
- action: persistent_notification.create
metadata: {}
data:
title: Webhook Data
message: "{{ trigger.json }}"
enabled: false
- variables:
payload: "{{ trigger.json.attachments[0].text | from_json }}"
- action: notify.mobile_app_your_device
metadata: {}
data:
title: "NetAlertX Notice:"
message: |
{% if payload.new_devices | length > 0 %}
{% for device in payload.new_devices %}
MAC: {{ device.MAC }}
Time: {{ device.Datetime }}
IP: {{ device.IP }}
Device Name: {{ device["Device name"] | default("Unknown") }}
{% if not loop.last %}--------------------{% endif %}
{% endfor %}
{% else %}
No new devices detected.
{% endif %}
enabled: true
mode: single
I knew Home Assistant’s “Choose” action was awesome, as I’ve used it with trigger ID’s. I didn’t know just how awesome it is until I learned that it can be used to parse specific json attributes as a condition. Holy cow… Here is the final result of my automation. This version will notify you regarding new devices, down devices, and when down devices reconnect. Make sure in NetAlertX you go to Settings > Notification Processing > Notify on and have “new_devices”, “down_devices”, and “down_reconnected” selected.