From a0922fae84b963f350e5828f34ae01be8ff156e4 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 8 Aug 2023 08:48:44 +0200 Subject: [PATCH] Improve MQTT switch example (#28495) * Improve MQTT switch example * Tiny tweaks --------- Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> --- source/_integrations/switch.mqtt.markdown | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/_integrations/switch.mqtt.markdown b/source/_integrations/switch.mqtt.markdown index aa911fd80e9..525977b99e4 100644 --- a/source/_integrations/switch.mqtt.markdown +++ b/source/_integrations/switch.mqtt.markdown @@ -248,7 +248,19 @@ mqtt: retain: true ``` -For a check, you can use the command line tools `mosquitto_pub` shipped with `mosquitto` to send MQTT messages. This allows you to operate your switch manually: +For a check, you can use the command line tools `mosquitto_pub` shipped with `mosquitto` to send MQTT messages. This allows you to operate your switch manually. First, we can simulate the availability message sent for the switch: + +```bash +mosquitto_pub -h 127.0.0.1 -t home/bedroom/switch1/available -m "online" +``` + +We can simulate the switch being turned on by publishing the "ON" command message: + +```bash +mosquitto_pub -h 127.0.0.1 -t home/bedroom/switch1/set -m "ON" +``` + +Finally, we can simulate the switch reporting back the changed state to Home Assistant: ```bash mosquitto_pub -h 127.0.0.1 -t home/bedroom/switch1 -m "ON"