Can I get HA version from within a Custom Component?

A recent change to a constant name has broken many custom components. UNIT_PERCENTAGE was changed to PERCENTAGE in 0.115. This is easy enough to fix but the fix will break the custom component for HA versions below 0.115. Is there a way for a custom component to get the current HA version so it can act appropriately in each case?


To answer your question:
from homeassistant.const import __version__ as ha_version

However, in your custom_components you should rather than importing this from homeassistant.*.const, you should just create your own and add what you need, that way you will not need to worry about constants changing in core.

Thanks. I took your advice and defined it in within the custom component.