After spending 2 nights of trying - what feels like - a thousand different combinations and reading just as much different websites, I just can’t get the following to work.
My attempt is to append the content of a variable to a text file.
When I set up this:
shell_command:
shell1: "echo this is a first reminder > ~/.homeassistant/tts/reminders.txt"
shell2: "echo this is a second reminder >> ~/.homeassistant/tts/reminders.txt"
And then use it in the action section of my automation like this:
action:
- service: shell_command.shell1
- service: shell_command.shell2
This all works. The file gets created with the 1st line and the 2nd line gets added.
I differentiate between > and >> because sometimes I need the system to start with a fresh empty file, sometimes it needs to append.
However, as soon as I try the same thing with variables, it doesn’t work anymore.
What I want is the attribute of an entity to be added.
shell_command:
shell1: "echo {{ states.calendar.google_reminder.attributes.message }} > ~/.homeassistant/tts/reminders.txt"
shell2: "echo {{ states.calendar.google_reminder.attributes.message }} >> ~/.homeassistant/tts/reminders.txt"
In the automation, I tried calling the shell_command both through service:
and through service_template:
but no luck, the file doesn’t get created and nothing gets added.
I then started experimenting:
shell_command:
shell1: "echo '{{ states.calendar.google_reminder.attributes.message }}' > ~/.homeassistant/tts/reminders.txt"
shell2: 'echo "{{ states.calendar.google_reminder.attributes.message }}" >> ~/.homeassistant/tts/reminders.txt'
shell3: echo '{{ states.calendar.google_reminder.attributes.message }} >> ~/.homeassistant/tts/reminders.txt
shell4: echo "{{ states.calendar.google_reminder.attributes.message }}" >> ~/.homeassistant/tts/reminders.txt
However, all with the same result (none). I don’t think it is the entity_id that causes the issue because when I try to send the same variable to Telegram, it works fine:
action:
- service: notify.telegram
data_template:
message: "{{ states.calendar.google_reminder.attributes.message }}"
This send very nicely the content to my Telegram Bot.
I also tried by first creating template sensors and then having the shell_command call the template sensor, however without success neither…
I looked in the logging but couldn’t find anything neither…
What could this be ?