Send MQTT payload from IoT Link to HA via Windows CMD

What ended up working for me…

Message via CMD/BAT:

"C:\Program Files\mosquitto\mosquitto_pub.exe" -h localhost -t iotlink/home/haf922/windows-monitor/status -m SessionUnlock -u user -P pass -q 2 -r

Sensor:

  - platform: mqtt
    unique_id: session_status
    name: "My Computer - Session Status"
    state_topic: "iotlink/home/haf922/windows-monitor/status"
    icon: mdi:account
    value_template: "{{ value }}"

Fantastic!

Regarding retained messages… As I was working on another project, in mqtt explorer, I noticed…

  1. There’s no ‘retained messages’ section under IoT Link nor ‘homeassistant’, only under the SSYS section

  2. ‘retained messages’ under SSYS only shows ‘count’.

I suspect, at least 1 of these needs to be added/configured in order for HA to actually see any retained messages?

If you’re sending the message via command line with mosquitto_pub.exe, then you should be able to set both the QOS and Retained status.

Ah, okay, I’ll try that… Thanks.