I have created this in the system boot proces rule:
// START Boot
On System#Boot do
TaskValueSet 11,1,0
TaskValueSet 11,2,0
TaskValueSet 11,4,0
GPIO,16,0
NeopixelAll,0,255,0
TimerSet,8,5
Endon
On Rules#Timer=8 do
GPIO,16,1
NeopixelAll,0,255,255
Publish homeassistant/switch/meek_switches/balcony/config,'{"name": "balcony","state_topic": "homeassistant/ha_switches/balcony","command_topic": "homeassistant/ha_switches/balcony","unique_id": "14685093-ad68-4e03-a978-6fb858e34390","device": {"identifiers": "meek_switches","name": "Meek switches","manufacturer": "Peter Oudenes"},"optimistic": "false","qos": "1","retain": "false","payload_on": "1","payload_off": "0","state_on": "1","state_off": "0","icon": "mdi:nintendo-switch"}'
Publish homeassistant/switch/meek_switches/dressoir/config,'{"name": "dressoir","state_topic": "homeassistant/ha_switches/dressoir","command_topic": "homeassistant/ha_switches/dressoir","unique_id": "14685093-ad68-4e03-a978-6fb858e34391","device": {"identifiers": "meek_switches","name": "Meek switches","manufacturer": "Peter Oudenes"},"optimistic": "false","qos": "1","retain": "false","payload_on": "1","payload_off": "0","state_on": "1","state_off": "0","icon": "mdi:nintendo-switch"}'
Endon
// END
Evertime my ESP needs to restart it will send this 2 Publish actions and the switches will be created.
Those topics are used inside the “Devices” the control switches based on MQTT topic input.
Work great for me. And never needed to create MQTT switches in Home Assistant again.