First, thank you for sharing this. I was just beating my head against the wall trying to get off of using only binding (I know the value for redundancy but for a variety of reasons I prefer to use HA)
Second, just for anyone else who can be an idiot like me, when it comes to adding the sensor it goes under “mqtt:” not under template or sensors or whatever else. I don’t have any other custom MQTT devices so it threw me off for a bit trying to find where it went. Also from what I know, unique_id can be whatever as long as it’s unique.
Here’s an example of a complete setup in your HA config file:
mqtt:
- sensor:
- name: "Dining Room Switch K MQTT"
unique_id: "1958669490006"
state_topic: "zigbee2mqtt/Dining Room Switch K"
value_template: "{{ value_json.action }}"
json_attributes_topic: "zigbee2mqtt/Dining Room Switch K"
json_attributes_template: "{{ value_json | tojson }}"