You’re welcome!
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
For more information about the Solution tag, refer to guideline 21 in the FAQ.
I suggest you copy-paste your version into the Template Editor and observe the result of each variable you created. Experimentation in the Template Editor is a good way to learn.
Not sure about that one. It appears that the card you’re using demands a numeric value and the referenced entity’s value isn’t numeric. You can embed the card into a Conditional card and configure it to hide everything if the referenced entity is unknown or unavailable.