So I wanted to share something I couldn’t find fully completed, and is a pretty cool feature I’ve been wanting myself: whenever I connect a new device to the network (e.g. smart wifi device, rpi, etc) I receive a notification on the HA companion app.
Previously I had to log in to the router or HA to see the device’s IP, thats sooo 2020.
An added bonus is the added feeling of security of getting a notification when a new device connects.
(improvement would be to add actionable notifications with block/allow option)
This automation notifies on new device_tracker
entries in the registry and sends a notification when its a creation. In my situation, my device_trackers are added via MIkrotik Router integration and the attributes ip
and host_name
are automatically added. I can imagine other router integrations can also do this. YMMV
alias: Send notification of new network device
trigger:
- platform: event
event_type: entity_registry_updated
event_data:
action: create
condition:
- condition: template
value_template: '{{trigger.event.data.entity_id.split(''.'')[0] == ''device_tracker'' }}'
action:
- service: notify.mobile_app_sm_g973f
data:
title: >-
devie added to network:
{{state_attr(trigger.event.data.entity_id,"host_name")}}
message: >-
Host [{{state_attr(trigger.event.data.entity_id,"host_name")}}] with IP
[{{state_attr(trigger.event.data.entity_id,"ip")}}] was added to the network
initial_state: true
mode: parallel