I’m using IoT Link to send HA status messages, ie. SessionUnlock, etc. The problem I’m running into is when I first boot into Windows, the VM hassio is installed on is not running yet, hence, HA is not active to receive the payload from IoT Link.
Best thing I can think of is to use Windows Task Manager to send an appropriate payload to HA in X mins. However, I cannot find any instruction on how to send it via BAT file, or similar. Suggestions on how to do that, or a completely different way of tackling this?
Thanks for the reply, though I think it’s the opposite. IoT Link is installed on my Windows host PC.
When my host loads the Windows Session, IoT Link, via mqtt, sends out a payload (SessionUnlock) for which HA has a sensor listening for that payload. Upon host initial boot and login, my HA guest VM has not started yet… It’s not active to sense the payload sent out by IoT Link, so the payload never gets reacted to by HA.
Note, it all works fine when my host is already running and say I Lock and/or Unlock the Windows Session. Payloads are responded to accordingly.
Ah, I understand now, thanks. So what must be occurring in my case is IoT Link starts the message, but there’s no mqtt broker to send it on. By the time HA is started, or actually restored from a saved state in my case, I’m guessing there’s no longer a message to send.
I’m using hyper-v; they already auto-start. In my case, HA doesn’t know it’s being restored, at least none of the possible commands/sensors I’ve tried in HA fire off upon restoring. HA Start sensor works when HA is started fresh, but not from a VM restore.
I say the above as there’s nothing HA can sense to fire my Session-related script I do have in HA.
I see 3 possible options…
If I had a way to send a mqtt payload via BAT file, I could schedule it to run X mins upon boot and initial login.
The other option may be to react to the VM being restored, but not certain how to use the hyper-v manager to determine this.
Install mqtt broker on host, though not sure how to handle the cert-related steps.
Decoupling the MQTT broker requires shutting down the HA broker (or I guess you could use a different port) then installing only the MQTT integration in HA, at this point HA becomes only a client and not the broker. Then installing and setting up on Windows.
Edit: The username & password are for the broker.
I have no experience setting up certs for encrypted MQTT coms (some of my devices can’t use it). I only have Auth. set to username and password which there are easy to follow instructions on how to do this on line (check link below).
json, look at my example.
I wouldn’t remove the HA broker until you have the new network up and running. Just shut it down and don’t allow it to restart.
Thanks for the input and help links. I’ve got it installed, running w / user/pass, and connects in MQTT Explorer.
In running the ‘re-configure mqtt’ option in my original mqtt integration, I receive a ‘Failed to connect’ error message. Assuming I’m to place my Windows host PC IP address here, I’m wondering if it’s because it is not secured. My HA runs behind a proxy and think the mqtt would need SSL in order to connect?
It’s the HA integration for mqtt, but there’s an option to re-configure the existing. The broker field is not accepting my IP. I’m thinking I need to have mqtt secured in order to communicate thru the nginx proxy.
Could you help me with this. I’m not understanding the syntax of the code. Ultimately, I’m trying to… Publish a topic & payload from IoT Link to HA. I’m not certain how to do this.
@ECHO ON
setlocal EnableDelayedExpansion
SET MOS="C:\Program Files\mosquitto\mosquitto_pub.exe"
%MOS% -h 10.9.8.1.22 -t homeassistant/ -u user -P pass
Where did you learn/find how to form a message for mqtt to send? I get how it looks like in HA, but don’t understand how to form the topic and payload in the mqtt message.
Below is json for a script and sensor of Session Status