Use value obtained in an earlier action of automation

Just discovered this thread: Custom component to declare/set variables

It may be exactly what I’m looking for.