I have an automation that works, but it is malformed when I save it.
I enter it like this:
service: input_number.set_value
data_template:
entity_id: input_number.nextdns_delta
value: "{{ (states('sensor.nextdns_dns_queries') | float - states('input_number.nextdns_previous_value') | float) | string }}"
and it runs fine, but after I save my automation, it turn into this:
service: input_number.set_value
data_template:
entity_id: input_number.nextdns_delta
value: >-
"{{ (states('sensor.nextdns_dns_queries') | float -
states('input_number.nextdns_previous_value') | float) | string }}"
and it won’t work anymore.
This is the complete automation:
alias: NextDNS update monthly limit
description: ""
trigger:
- platform: state
entity_id:
- sensor.nextdns_dns_queries
action:
- service: input_number.set_value
data_template:
entity_id: input_number.nextdns_delta
value: >-
"{{ (states('sensor.nextdns_dns_queries') | float -
states('input_number.nextdns_previous_value') | float) | string }}"
- service: input_number.set_value
data_template:
entity_id: input_number.nextdns_previous_value
value: "{{ states('sensor.nextdns_dns_queries') | float }}"
- service: input_number.set_value
data_template:
entity_id: input_number.nextdns_monthly_limit
value: >-
"{{ (states('input_number.nextdns_monthly_limit') | float +
states('input_number.nextdns_delta') | float) | string }}"
- service: input_number.set_value
data:
entity_id: input_number.nextdns_delta
value: 0
The last step isn’t really necessary, but that way I can see that it’s been triggered