I ran into an odd issue while trying to use a template sensor, home assistant gave me an error that I needed to have a unique id in order to use the sensor. Luckily, this is surprisingly simple to add.

It really is just a one line addition to the yaml for the sensor to add a unique ID. You can also use an online generator to create the ID to make sure conflicts are avoided.
- sensor:
unique_id: asdf
name: a_to_b