It would be great if newly created sensors could be added to an Area in HA automatically. I don’t think this is possible, but maybe a future update to the MQTT integration could have such functionality?
In one application that I am working on we have many smart marine sensors provided through MQTT. There is already metadata with the sensor that could be used to both create and assign an area. It is tedious to manually assign the area, and we also have new sensors created as they are deployed which could also automatically be assigned to an area or otherwise labeled.
For example the salinity sensor below is formatted as described in MQTT - Home Assistant and subsequently auto discovered by HA when the sensor is posted to mosquitto MQTT:
As you can see we already have a site attribute, a source attribute and a description attribute which are all suitable for label, area, or category.
The feature I am looking for would use an attribute as specified by the user to create if necessary a new area named in the attribute and then assign the sensor to the new area. This could be done when a config topic is received. So using the example in the current documentation for a config payload I have added the area
field below:
{
"device_class":"temperature",
"state_topic":"homeassistant/sensor/sensorBedroom/state",
"unit_of_measurement":"°C",
"value_template":"{{ value_json.temperature}}",
"unique_id":"temp01ae",
"device":{
"area": "Bedroom",
"identifiers":[
"bedroom01ae"
],
"name":"Bedroom",
"manufacturer": "Example sensors Ltd.",
"model": "K9",
"serial_number": "12AE3010545",
"hw_version": "1.01a",
"sw_version": "2024.1.0",
"configuration_url": "https://example.com/sensor_portal/config"
}
}
Could this be considered as a feature request for MQTT? Please?