This code in an automation yaml snippet runs fine:
alias: test automation 2
description: Test automation for learning trigger variables even better
trigger:
- entity_id:
- sensor.random_sensor
above: 5
trigger: numeric_state
below: 10
conditions: []
actions:
- action: persistent_notification.create
metadata: {}
data:
title: Value between thresholds
notification_id: value_between
message: >
{{ trigger.entity_id }} is above {{ trigger.above }} and below {{ trigger.below }}( {{ states("sensor.random_sensor") }} )
mode: single
but when removing the > so that the message is on one line in the editor I get a red line on the left in the editor and the following error when pressing the Save button: Error in parsing YAML: bad indentation of a mapping entry (line: 16, column: 40)
Your suggestion gave and error message when saving:
Message malformed: template value should be a string for dictionary value @ data[‘actions’][0][‘data’]
In python and in this case in yaml whitespace infront of the first command really matters. It is a weird design concept of the language. Some love it, some hate it. But you absolutely need the right amount of spaces.