Manually Creating MQTT Entities
While the “One-Click” Discovery is recommended for most users, some Home Assistant enthusiasts prefer the precise control afforded by manual YAML configuration. This method allows you to define unique IDs, specific icons, and custom availability logic directly in your configuration files.
❗ Advanced Users Only
Manually creating MQTT entities requires a solid understanding of Home Assistant’s YAML structure and MQTT integration. If you are not comfortable editingconfiguration.yaml, it is highly recommended to use the Automatic Discovery instead.
YAML Example: Auto-Dimming Switch
If you choose the manual path, you must ensure your topics match the Publish and Subscribe topics defined in your MQTT Settings.
Below is an example of how the Auto-Dimming entity might be defined in your Home Assistant configuration.
Note: This example assumes your chosen topic is bedlamp.
mqtt:
- switch:
unique_id: bedlamp_autodim
name: "Auto Dimming"
state_topic: "stat/bedlamp/autodim"
command_topic: "cmnd/bedlamp/autodim"
availability:
- topic: "stat/bedlamp/display/status"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true
Further Reference
Because the Home Assistant environment evolves frequently, the firmware is designed to follow standard MQTT conventions. For a comprehensive guide on creating lights, binary sensors, and buttons via YAML, please refer to the official documentation: