A device is something that is created through integrations that use config flow. And if the device supports more then one function, it can have several entities attached to it.
If you know the device_id, you can use it to find device_attributes, like what area it’s in, what integration it comes from, if it needs a firmware update. All done through templates. Otherwise it’s a identifier for the device so home assistant knows how to get it’s own stored information about said device.
Actually, I was wrong.
Technically, you just define an additional property on the entity, but the doc says it’s only effectively used for config_flow enabled integrations.