Device concept in HA

Hi All!
I’m struggling to understand how the devices are implemented in HA in several aspects:

  • how sensors are marked as belonging to some device
  • how the properties of the device are supposed to be exposed and used.
  • device/sensor location attribute?

Example. I have several wemos d1 with tasmota, each wemos is a device which has attributes like fw version, wifi signal, ip, battery level, + others. Where should those go? Is there a device entity that I can configure? and specify how to extract those attributes? Also those devices have sensors (temp + humidity, reed, may be others). Everything operates over mqtt.

The only mention of the device attributes is here
https://developers.home-assistant.io/docs/en/entity_index.html
And it says

device_state_attributes - it should not be static information like firmware version

Where do I put/get/assign fw version then? Atm I do it via separate mqtt sensor and I don’t see a way to somehow link it to other “attributes” of that device.

Ok, now I have 6 of such devices and I have 6 yaml files each having 10 mqtt sensors which are only different at the device name(sensor0, sensor1, sensor2). If I want to add another attribute, I add anther sensor in each of those files with same code and different device name. And then add friendly names to customize.yaml. Pain.