IOT Link - Windows Management using MQTT

@kalyway101 I’ve been trying to do this but can’t get around the fact that it needs admin privileges to run. Do you have a step by step for this?

I have a batch file with
net stop iotlink && net start iotlink
and task created that runs on unlock.

If I manually run the task it works but it doesn’t work when I unlock the pc.
image

2 Likes

I have “Run whether user is logged on or not” instead of “Run only when user is logged on”. For my trigger, I chose it to be restarted “On workstation unlock of any user”.

I just have a button in the Lovelace UI that changes/lets me lock my PC via the MQTT commands so this setup works well for me

Same config I had but it didn’t work until I changed 2 settings after googling.
“Start In (optional)” had to be set and “Wake the computer to run this task”.
No clue why either of those would need to be set for this to work (especially since it worked fine when I manually ran the task) but I can’t complain since it now works :man_shrugging:

2 Likes

hi can somebody guide me with IOT Link installation? I have done everything but my mqtt is not integrating my PC

Is your MQTT broker running OK in home assistant ?
Do you have other MQTT devices that are working OK ?
Have you pointed IOTLink configuration to your MQTT broker ?

Have you checked the logs from IOT Link?

I have just installed IOT Link and I have all the sensors added in Home Assistant, however the one thing I wanted to report on was whether the PC was asleep or not.

There is a Power Status but when I set the PC to sleep the next time it refreshes all the statuses too Unavailable. It goes too unavailable when I power it off also. Perhaps I am misunderstanding the status.

Is there any way I can get the sensor to give the state SLEEP or OFF when the machine sleeps or is shut down?

I don’t believe there is a way to know if the pc is asleep or powered off. Since no services are running (including the IOT service) when the pc is asleep/off, there is no way to report status of any kind. This is why it goes to “unavailable”.

You could create your own template sensor and have it report “unavailable” as “asleep” or anything else you want…but again, there would be no way to distinguish “off” vs “sleep”.

1 Like

I was hoping that the service would publish its final power command as the PC was executing it, but perhaps that was wishful thinking. I will have a play with template sensors as I haven’t really used those.

Great app I Just find out about it, very usefull, but there’s a strange bug hapening to me, The mouse cursor keeps desapering and appearing and decending on screen, very annoying, when I stop The service The issue stops.

I have this issue too. Currently restarting the service on wake using Task Scheduler.

Opened an issue in gitlab: Disconnecting from MQTT server after sleep/wake. Not reconnecting. Having "MQTTClientManager::OnMQTTDisconnectedHandler() - DUPLICATED Disconnected Event" (#118) · Issues · IOT Link / IOT Link Service · GitLab
Please post your logs if you experience this issue too.

Perhaps this happens to machines with several network interface? I have this on a laptop that has both lan and wifi connected.

Hi all,
yesterday I successfully installed this integration for my 3 laptops.
Right now although 2 of them are on they are unavailable in HA?
What should I look for?
(yesterday all day all were working fine)

Stop the service and then start it gain, see if that makes them show up again. Were the laptops sleeping? If so read above there are issues with sleep mode some workarounds also above.

Yes, probably that was the problem. I tried to find a workaround but I couldn’t.
Today this is the case for 2/3 of the laptops in the house.

Workaround is use the windows task scheduler to restart the iot service on every resume

thanks! I will try to find out how to accomplish that.

hi
I found the following but it doesn’t seem to work. Do you or someone can tell me how I can schedule to restart the iot service on every resume?

 Begin the task: "On an event"

  Log: System

  Source: Power-Troubleshooter

  Event ID: 1

The trigger looks fine. This is what I use and it works. Do you actually see the event in the list in event viewer when you wake?

What is your action for the task?
Try:
powershell -command “Restart-Service IOTLink -Force”

Thanks I will try it in an hour when I return home. However I noticed in the morning when I manually clicked a the “start the windows service” my lapotp remained unavailable. It shouldn’t though, am I right?
What else could be my problem. The laptop becomes available after a restart only. (windows 10)

Is it possible to monitor applications with IOT-Link?

I wanna start some automations after starting an application,
Thanks!

1 Like