Hi everybody,
I created notification when a device is offline. I want to add a link to the device that trigged.
Exemple:
https://[ha_base_url]/config/devices/device/[device_unique_id]
What is the simplest way to do it ?
Hi everybody,
I created notification when a device is offline. I want to add a link to the device that trigged.
Exemple:
https://[ha_base_url]/config/devices/device/[device_unique_id]
What is the simplest way to do it ?
With a template.
Post the automation you created.
For now i just add one trigger per device.
alias: offline
description: ''
trigger:
- device_id: 3d81b9f6690f61f729ff2b683eb81d17
domain: zha
platform: device
type: device_offline
subtype: device_offline
[...]
- device_id: 9dd9b53c56fda413825edcd8803595b1
domain: zha
platform: device
type: device_offline
subtype: device_offline
condition: []
action:
- service: notify.mobile_app_fp2
data:
message: offline
- service: notify.persistent_notification
data:
message: offline {{trigger.to_state.name}}
mode: single
Is there a way to get the external url in template ? I prefer not hardcoded it in my automation.
Is there a way to automatically get the url to the device config page ?
action:
- service: notify.persistent_notification
data:
title: offline
message: >-
offline {{trigger.to_state.name}}
https://[my_ha_url]/config/devices/device/{{device_id(trigger.to_state.entity_id)}}
Are you asking how to get the host’s name or IP address for [my_ha_url]
? I don’t believe there’s a way to get that information in templating.
The host name. Data set in Settings > System > Network > External URL.
Not accessible in a template.