I am trying to have a script that dynamically calls a notifer based on a field but I am getting the following error.
Error executing script script.notify_battery. Invalid data for call_service at pos 1: Service notify. does not match format <domain>.<name>
Automation
- alias: Notify Phone Battery
trigger:
platform: numeric_state
entity_id:
- sensor.battery_chi
- sensor.battery_bea
below: 20
action:
service: script.notify_battery
data:
variables:
notifier: "telegram_{{ trigger.entity_id.split('_')[-1] }}"
battery_value: "{{ states('trigger.entity_id') }}"
Script
notify_battery:
alias: 'Notify battery'
description: 'Send notification on battery low'
fields:
notifier:
description: 'The notifier to send too'
example: 'telegram_chi'
battery_value:
description: 'The value of the battery'
example: '20'
sequence:
- service_template: >
notify.{{ notifier }}
data_template:
title: 'You should think about charging your phone!'
message: 'The battery has dropped to {{ battery_value }}%'