One of my scripts as an example:
scriptmyautodiscovery:
sequence:
# - service: mqtt.publish
# data:
# retain: true
# topic:
# payload:
- service: mqtt.publish
data:
retain: true
topic: homeassistant/binary_sensor/garagedoor/config
payload: '{"name": "garagedoor", "device_class": "garage_door", "state_topic": "sensor/garagedoor", "unique_id": "garagedoor", "off_delay": 30, "device": {"identifiers": ["rfbridge_564886"],"name": "garagedoor", "model": "Digoo door sensor", "manufacturer": "Digoo"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/binary_sensor/sensortvboven/config
payload: '{"name": "sensorTVboven", "device_class": "plug", "state_topic": "sensor/tvboven", "unique_id": "sensortvboven", "device": {"identifiers": ["sensorTVboven"],"name": "sensorTVboven", "model": "Action Switches", "manufacturer": "Action"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/binary_sensor/sensorproximusboven/config
payload: '{"name": "sensorProximusboven", "device_class": "plug", "state_topic": "sensor/proximusboven", "unique_id": "sensorproximusboven", "device": {"identifiers": ["sensorproximusboven"],"name": "sensorProximusboven", "model": "Action Switches", "manufacturer": "Action"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/binary_sensor/sensorfanboven/config
payload: '{"name": "sensorfanboven", "device_class": "plug", "state_topic": "sensor/fanboven", "unique_id": "sensorfanboven", "device": {"identifiers": ["sensorfanboven"],"name": "sensorfanboven", "model": "Action Switches", "manufacturer": "Action"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/binary_sensor/sensorrflinkboven/config
payload: '{"name": "sensorrflinkboven", "device_class": "plug", "state_topic": "sensor/rflinkboven", "unique_id": "sensorrflinkboven", "device": {"identifiers": ["sensorrflinkboven"],"name": "sensorrflinkboven", "model": "Action Switches", "manufacturer": "Action"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/binary_sensor/sensorpirtrap/config
payload: '{"name": "sensorPirtrap", "device_class": "motion", "state_topic": "sensor/pirboven", "unique_id": "sensorpirtrap", "off_delay": 90, "device": {"identifiers": ["sensorpirtrap"],"name": "sensorpirtrap", "model": "Digoo Pir", "manufacturer": "Digoo"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/binary_sensor/sensorvoordeur/config
payload: '{"name": "voordeur", "device_class": "door", "state_topic": "sensor/voordeur", "unique_id": "voordeur", "device": {"identifiers": ["voordeur"],"name": "voordeur", "model": "Digoo door sensor", "manufacturer": "Digoo"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/sensor/xiron_3201/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.TEMP }}","state_class": "measurement","state_topic":"rflink/Xiron-3201","name":"eetkamer_temperature","unique_id":"eetkamer_temperature","device":{"identifiers":["xiron_3201"],"name":"xiron_3201","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain: true
topic: homeassistant/sensor/xiron_3201/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-3201","name":"eetkamer_humidity","unique_id":"eetkamer_humidity","device":{"identifiers":["xiron_3201"],"name":"xiron_3201","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_4503/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.TEMP }}","state_class": "measurement","state_topic":"rflink/Xiron-4503","name":"boven_temperature","unique_id":"Xiron_4503_temp","device":{"identifiers":["xiron_4503"],"name":"xiron_4503","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_4503/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-4503","name":"boven_humidity","unique_id":"boven_humidity","device":{"identifiers":["xiron_4503"],"name":"xiron_4503","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_2f02/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.TEMP }}","state_class": "measurement","state_topic":"rflink/Xiron-2F02","name":"zitkamer_temperature","unique_id":"Xiron_2f02_temp","device":{"identifiers":["xiron_2f02"],"name":"xiron_2f02","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_2f02/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-2F02","name":"zitkamer_humidity","unique_id":"Xiron_2f02_humidity","device":{"identifiers":["xiron_2f02"],"name":"xiron_2f02","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_4e01/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.TEMP }}","state_class": "measurement","state_topic":"rflink/Xiron-4E01","name":"outside_temperature","unique_id":"Xiron_2e01_temp","device":{"identifiers":["xiron_4e01"],"name":"xiron_4e01","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_4e01/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-4E01","name":"outside_humidity","unique_id":"Xiron_4e01_humidity","device":{"identifiers":["xiron_4e01"],"name":"xiron_4e01","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_2202/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ ((value_json.TEMP | float) + 0.7)|round(2) }}","state_class": "measurement","state_topic":"rflink/Xiron-2202","name":"garage_temperature","unique_id":"Xiron_2202_temp","device":{"identifiers":["xiron_2202"],"name":"xiron_2202","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_2202/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-2202","name":"garage_humidity","unique_id":"Xiron_2202_humidity","device":{"identifiers":["xiron_2202"],"name":"xiron_2202","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_1701/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ ((value_json.TEMP | float) - 0.4)|round(2) }}","state_class": "measurement","state_topic":"rflink/Xiron-1701","name":"badkamer_temperature","unique_id":"Xiron_1701_temp","device":{"identifiers":["xiron_1701"],"name":"xiron_1701","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_1701/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-1701","name":"badkamer_humidity","unique_id":"Xiron_1701_humidity","device":{"identifiers":["xiron_1701"],"name":"xiron_1701","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_4B01/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ ((value_json.TEMP | float) - 0.4)|round(2) }}","state_class": "measurement","state_topic":"rflink/Xiron-4B01","name":"kamerdestiny_temperature","unique_id":"Xiron_4B01_temp","device":{"identifiers":["xiron_4B01"],"name":"xiron_4B01","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_4B01/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-4B01","name":"kamerdestiny_humidity","unique_id":"Xiron_4B01_humidity","device":{"identifiers":["xiron_4B01"],"name":"xiron_4B01","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_3002/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.TEMP }}","state_class": "measurement","state_topic":"rflink/Xiron-3002","name":"bovengang_temperature","unique_id":"Xiron_3002_temp","device":{"identifiers":["xiron_3002"],"name":"xiron_3002","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_3002/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-3002","name":"bovengang_humidity","unique_id":"Xiron_3002_humidity","device":{"identifiers":["xiron_3002"],"name":"xiron_3002","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_6402/temperature/config
payload: '{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.TEMP }}","state_class": "measurement","state_topic":"rflink/Xiron-6402","name":"kleineslaapkamer_temperature","unique_id":"Xiron_6402_temp","device":{"identifiers":["xiron_6402"],"name":"xiron_6402","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/sensor/xiron_6402/humidity/config
payload: '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_class": "measurement","state_topic":"rflink/Xiron-6402","name":"kleineslaapkamer_humidity","unique_id":"Xiron_6402_humidity","device":{"identifiers":["xiron_6402"],"name":"xiron_6402","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'
- service: mqtt.publish
data:
retain : true
topic: homeassistant/binary_sensor/waterkraan/config
payload: '{"name": "waterkraan", "device_class": "moisture", "state_topic": "sensor/waterkraan", "unique_id": "waterkraan_binary_sensor", "device": {"identifiers":["20067C"]}}'