I’m running Nmap and newly created entities are disabled by default. I have to activate them manually from the GUI.
I’m looking for a way to activate an entity with a script or automate.
All my research has led me down the wrong path, and I’m wondering if it’s technically possible.
If it’s not possible, maybe it’s a problem with the nmap integration. My initial problem was that entities created by nmap are not enabled by default ;-p
alias: Détection réseau
description: >-
Informe quand un nouveau device_tracker est créé.
Un délais de 90 secondes est mis pour laisser le temps à Nmap de finaliser son
scan réseau.
Par défaut les nouveau device_tracker créé avec Nmap ne sont pas activé.
L'activation d'entités est possible grâce à l'intégration Spook disponible sur
HACS.
Plus d'informations sur https://spook.boo/
trigger:
- alias: Une entité est créé
platform: event
event_type: entity_registry_updated
event_data:
action: create
condition:
- alias: L'entité est un device_tracker
condition: template
value_template: "{{trigger.event.data.entity_id.startswith('device_tracker')}}"
action:
- alias: Sauvegarde de l'entité device_tracker dans ENTITY
variables:
entity: |
{{trigger.event.data.entity_id}}
- alias: Activation de ENTITY
service: homeassistant.enable_entity
data:
entity_id:
- "{{entity}}"
- alias: Attendre le rafraîchissement de ENTITY
delay:
hours: 0
minutes: 1
seconds: 30
milliseconds: 0
- service: notify.persistent_notification
metadata: {}
data:
title: Nouvel appareil détecté
message: |-
Entité: {{entity}}
Host: {{state_attr(entity,'host_name')}}
Ip: {{state_attr(entity,'ip')}}
Mac-address: {{state_attr(entity,'mac')}}
mode: queued
max: 10