I would not do this, if you want to change anyway. Just use the publish service and the discovery way) to avoid all the yaml-loads, etc. Put it in a script, run it once (!) and you have all the entities and on top a device (which is not possible with yaml config). Here my config.
alias: MQTT Discovery Huqvarna Automower 330x
sequence:
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_gps_breitengrad/config
retain: true
payload: |
{
"state_topic": "automower/gps/latitude",
"name": "Mähroboter GPS Breitengrad",
"unique_id": "unique_id_mahroboter_gps_breitengrad",
"object_id": "mahroboter_gps_breitengrad",
"icon": "mdi:crosshairs-gps",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_gps_langengrad/config
retain: true
payload: |
{
"state_topic": "automower/gps/longitude",
"name": "Mähroboter GPS Längengrad",
"unique_id": "unique_id_mahroboter_gps_langengrad",
"object_id": "mahroboter_gps_langengrad",
"icon": "mdi:crosshairs-gps",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_gps_anzahl_satelliten/config
retain: true
payload: |
{
"state_topic": "automower/gps/satellites",
"name": "Mähroboter GPS Anzahl Satelliten",
"unique_id": "unique_id_mahroboter_gps_anzahl_satelliten",
"object_id": "mahroboter_gps_anzahl_satelliten",
"icon": "mdi:crosshairs-gps",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_luftfeuchte/config
retain: true
payload: |
{
"state_topic": "automower/health/climate/humidity",
"name": "Mähroboter Luftfeuchte",
"unique_id": "unique_id_mahroboter_luftfeuchte",
"object_id": "mahroboter_luftfeuchte",
"device_class": "humidity",
"state_class": "measurement",
"unit_of_measurement": "%",
"icon": "mdi:water-percent",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_temperatur/config
retain: true
payload: |
{
"state_topic": "automower/health/climate/temperature",
"name": "Mähroboter Temperatur",
"unique_id": "unique_id_mahroboter_temperatur",
"object_id": "mahroboter_temperatur",
"device_class": "temperature",
"state_class": "measurement",
"unit_of_measurement": "°C",
"icon": "mdi:thermometer",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_batteriespannung/config
retain: true
payload: |
{
"state_topic": "automower/health/voltage/batt",
"name": "Mähroboter Batteriespannung",
"unique_id": "unique_id_mahroboter_batteriespannung",
"object_id": "mahroboter_batteriespannung",
"device_class": "voltage",
"state_class": "measurement",
"unit_of_measurement": "V",
"icon": "mdi:sine-wave",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_betriebsspannung_maher/config
retain: true
payload: |
{
"state_topic": "automower/health/voltage/ext33",
"name": "Mähroboter Betriebsspannung Mäher",
"unique_id": "unique_id_mahroboter_betriebsspannung_maher",
"object_id": "mahroboter_betriebsspannung_maher",
"device_class": "voltage",
"state_class": "measurement",
"unit_of_measurement": "V",
"icon": "mdi:sine-wave",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_betriebsspannung_robonect/config
retain: true
payload: |
{
"state_topic": "automower/health/voltage/int33",
"name": "Mähroboter Betriebsspannung Robonect",
"unique_id": "unique_id_mahroboter_betriebsspannung_robonect",
"object_id": "mahroboter_betriebsspannung_robonect",
"device_class": "voltage",
"state_class": "measurement",
"unit_of_measurement": "V",
"icon": "mdi:sine-wave",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_batterie/config
retain: true
payload: |
{
"state_topic": "automower/mower/battery/charge",
"name": "Mähroboter Batterie",
"unique_id": "unique_id_mahroboter_batterie",
"object_id": "mahroboter_batterie",
"device_class": "battery",
"state_class": "measurement",
"unit_of_measurement": "%",
"icon": "mdi:battery",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_messertage/config
retain: true
payload: |
{
"state_topic": "automower/mower/blades/days",
"name": "Mähroboter Messertage",
"unique_id": "unique_id_mahroboter_messertage",
"object_id": "mahroboter_messertage",
"unit_of_measurement": "Tage",
"icon": "mdi:terraform",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_messerstunden/config
retain: true
payload: |
{
"state_topic": "automower/mower/blades/hours",
"name": "Mähroboter Messerstunden",
"unique_id": "unique_id_mahroboter_messerstunden",
"object_id": "mahroboter_messerstunden",
"unit_of_measurement": "Stunden",
"icon": "mdi:terraform",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_messerqualitat/config
retain: true
payload: |
{
"state_topic": "automower/mower/blades/quality",
"name": "Mähroboter Messerqualität",
"unique_id": "unique_id_mahroboter_messerqualitat",
"object_id": "mahroboter_messerqualitat",
"unit_of_measurement": "%",
"icon": "mdi:terraform",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_fehlercode/config
retain: true
payload: |
{
"state_topic": "automower/mower/error/code",
"name": "Mähroboter Fehlercode",
"unique_id": "unique_id_mahroboter_fehlercode",
"object_id": "mahroboter_fehlercode",
"icon": "mdi:alert-circle",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_fehlernachricht/config
retain: true
payload: |
{
"state_topic": "automower/mower/error/message",
"name": "Mähroboter Fehlernachricht",
"unique_id": "unique_id_mahroboter_fehlernachricht",
"object_id": "mahroboter_fehlernachricht",
"icon": "mdi:alert-circle",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_betriebsstunden/config
retain: true
payload: |
{
"state_topic": "automower/mower/statistic/hours",
"name": "Mähroboter Betriebsstunden",
"unique_id": "unique_id_mahroboter_betriebsstunden",
"object_id": "mahroboter_betriebsstunden",
"unit_of_measurement": "Stunden",
"icon": "mdi:timer-sand",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_status_raw/config
retain: true
payload: |
{
"state_topic": "automower/mower/status",
"name": "Mähroboter Status Raw",
"unique_id": "unique_id_mahroboter_status_raw",
"object_id": "mahroboter_status_raw",
"icon": "mdi:list-status",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_im_aktuellen_status/config
retain: true
payload: |
{
"state_topic": "automower/mower/status/duration",
"name": "Mähroboter Zeit im aktuellen Status",
"unique_id": "unique_id_mahroboter_im_aktuellen_status",
"object_id": "mahroboter_im_aktuellen_status",
"unit_of_measurement": "Minuten",
"icon": "mdi:timer",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_status_plain/config
retain: true
payload: |
{
"state_topic": "automower/mower/status/plain",
"name": "Mähroboter Status Plain",
"unique_id": "unique_id_mahroboter_status_plain",
"object_id": "mahroboter_status_plain",
"icon": "mdi:list-status",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_substatus_raw/config
retain: true
payload: |
{
"state_topic": "automower/mower/substatus",
"name": "Mähroboter Substatus Raw",
"unique_id": "unique_id_mahroboter_substatus_raw",
"object_id": "mahroboter_substatus_raw",
"icon": "mdi:list-status",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_substatus_plain/config
retain: true
payload: |
{
"state_topic": "automower/mower/substatus/plain",
"name": "Mähroboter Substatus Plain",
"unique_id": "unique_id_mahroboter_substatus_plain",
"object_id": "mahroboter_substatus_plain",
"icon": "mdi:list-status",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_nachster_start_datum/config
retain: true
payload: |
{
"state_topic": "automower/mower/timer/next/date",
"name": "Mähroboter Nächster Start Datum",
"unique_id": "unique_id_mahroboter_nachster_start_datum",
"object_id": "mahroboter_nachster_start_datum",
"icon": "mdi:calendar",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_nachster_start_uhrzeit/config
retain: true
payload: |
{
"state_topic": "automower/mower/timer/next/time",
"name": "Mähroboter Nächster Start Uhrzeit",
"unique_id": "unique_id_mahroboter_nachster_start_uhrzeit",
"object_id": "mahroboter_nachster_start_uhrzeit",
"icon": "mdi:calendar",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_nachster_start_timestamp/config
retain: true
payload: |
{
"state_topic": "automower/mower/timer/next/unix",
"name": "Mähroboter Nächster Start Timestamp",
"unique_id": "unique_id_mahroboter_nachster_start_timestamp",
"object_id": "mahroboter_nachster_start_timestamp",
"icon": "mdi:calendar",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_strecke_bis_startpunkt/config
retain: true
payload: |
{
"state_topic": "automower/mower/distance",
"name": "Mähroboter Strecke bis Startpunkt",
"unique_id": "unique_id_mahroboter_strecke_bis_startpunkt",
"object_id": "mahroboter_strecke_bis_startpunkt",
"icon": "mdi:map-marker-distance",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_modus_raw/config
retain: true
payload: |
{
"state_topic": "automower/mower/mode",
"name": "Mähroboter Modus Raw",
"unique_id": "unique_id_mahroboter_modus_raw",
"object_id": "mahroboter_modus_raw",
"icon": "mdi:state-machine",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_gestoppt/config
retain: true
payload: |
{
"state_topic": "automower/mower/stopped",
"name": "Mähroboter gestoppt",
"unique_id": "unique_id_mahroboter_gestoppt",
"object_id": "mahroboter_gestoppt",
"icon": "mdi:octagon",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_passage_geoffnet/config
retain: true
payload: |
{
"state_topic": "automower/passage/open",
"name": "Mähroboter Passage geöffnet",
"unique_id": "unique_id_mahroboter_passage_geoffnet",
"object_id": "mahroboter_passage_geoffnet",
"icon": "mdi:fence",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_wetterstop_aktiv/config
retain: true
payload: |
{
"state_topic": "automower/weather/data/break",
"name": "Mähroboter Wetterstop aktiv",
"unique_id": "unique_id_mahroboter_wetterstop_aktiv",
"object_id": "mahroboter_wetterstop_aktiv",
"icon": "mdi:stop",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_wifi_signal/config
retain: true
payload: |
{
"state_topic": "automower/wlan/rssi",
"name": "Mähroboter Wifi-Signal",
"unique_id": "unique_id_mahroboter_wifi_signal",
"object_id": "mahroboter_wifi_signal",
"device_class": "signal_strength",
"state_class": "measurement",
"unit_of_measurement": "dBm",
"icon": "mdi:wifi",
"device": {
"identifiers": ["330x"],
"name": "Husqvarna Automower 330x",
"model": "330x",
"manufacturer": "Husqvarna",
"sw_version": "4.05.00"
}
}
mode: single