After reading the spec several times, I used a MQTT tool like https://mqtt-explorer.com/ to get a better feel for ‘real’ usage (would need SetOption19 1
now for Tasmota), then experimented with mosquitto_pub
to manually send test discovery settings until they worked enough to code up (in this case Python).
My test was something like this… (not tested - copied from partial notes)
mosquitto_pub -d -h HOSTNAME --username 'USER' --pw "PASS" -t 'homeassistant/switch/grow-1_pump/config' --retain -m '{ "name":"glz-rpi-grow Water 1", "stat_t":"tele/glz-rpi-grow/PUMP/1",
"avty_t":"tele/glz-rpi-grow/LWT", "pl_avail":"Online", "pl_not_avail":"Offline", "cmd_t":"cmnd/glz-rpi-grow/PUMP/1", "pl_off":"OFF", "pl_on":"ON", "val_tpl":"{{value_json.POWER}}", "uniq_id":"glz-rpi-grow_pump1", "dev": { "ids": ["glz-rpi-grow"], "name": "glz-rpi-grow", "mf": "Pimoroni", "mdl": "Grow", "sw": "0.2", "sa": "Conservatory" }, "icon": "mdi:watering-can", "expire_after": "1200", "frc_upd": "true" }'
The device should appear immediately, and use MQTT Explorer to delete the retained topics to remove it.
A simple button is pretty easy - advertise a switch, then set it back to OFF in code. There’s bound to be a way to get a push button rather than a faked-toggle.
If this helps, this post!