IOT Link - Windows Management using MQTT

Sure. I use these in combination with FreePBX and IoTLink to mute/unmute my phone depending on whether or not I’m on the phone. But you could easily adapt them to do all sorts.

C:\volmax.exe

IniRead, OutputVar, C:\Users\%A_UserName%\volume.ini, volume, key
SoundSet, %OutputVar%
IniRead, OutputVar, C:\Users\%A_UserName%\volume.ini, volume, key
If (OutputVar==0)   
SoundSet, 100
Else 
SoundSet, %OutputVar%

c:\Volmin.exe

SoundGet, master_volume
IniWrite, %master_volume%, C:\Users\%A_UserName%\volume.ini, volume, key
SoundSet, Mute

Listener

if (!A_IsAdmin)
{
    Run % "*RunAs " DllCall("GetCommandLine", "Str")
    ExitApp
}


#NoEnv
#Persistent
#SingleInstance Force
DetectHiddenWindows, On
SetTimer Check,2000
flag:=0
Return

Check:
SoundGet, master_volume
If (master_volume<=0) {  
			If (flag == 0) {
			Gui, Font, cBlack
			Gui, +LastFound +AlwaysOnTop +Caption +ToolWindow -SysMenu
			Gui, Font, cBlack 
			Gui, Font, s34
			Gui, Add, Button, Default   gMute,  UNMUTE?
			Gui, Color, EEAA99
			Gui +LastFound  
			WinSet, TransColor, EEAA99
			Gui, Show, x1000 y55, ,
			Gui -Caption 
		    flag:=1
 }			
 		}
If (master_volume>=10) {  
    Gui, Destroy
	flag:=0
 		}		
Return


Mute:
	Run, "C:\volmax.exe"
	Gui, Destroy
	flag:=0
Return

I just stumbled upon this and would like to try it but I am stuck here Download the provided Installer for your system from the Releases tab.. What Releases tab? Where??

https://iotlink.gitlab.io/downloads.html

but I would strongly suggest you give HASS workstation service a go instead as that is actively being developed whereas the last update on iotlink is 2 1.5 years old now and there are known bugs you will need to work around.

2 Likes

Thank you! That’s pretty slick!

Interesting project. How is it working out for you a year later? Profitable?

I use this to very handy application to start my PC in ‘gaming mode’. Ideally I would be able to run a .exe file (some keystrokes compiled with autoit) on the windows logon screen to switch users, but that doesn’t seem to work.

Is IOT link able to run .exe files on the logon screen and am I doing something wrong, or is it a limitation of IOT link or Windows?

This might also be an alternative?

1 Like

Hi all! I have IOTLink running and connected to my HASS instance but I’m having problems getting the commands integration to run a windows program. I’ve been testing with just running notepad remotely with this configuration:

        ´tap_action: 
          action: call-service
          service: mqtt.publish
          service_data:
            topic: "iotlink/masfunke/isakbox/commands/run"
            payload: '{ "command": "C:\\Windows\\System32\\notepad.exe", "args": "", "path": "C:\\Users\\Nacho\\Desktop", "user": "", "visible": true, "fallback": true }'

which is coupled to a button in lovelace. I can see in the windows machine the MQTT message arriving and the spinning wheel in Windows starts but notepad never opens. I assume it is something with how I write the command and its arguments but I have tried double //, single and all possible combinations without any luck. Anyone has an example of running an arbitrary command via IOTLink? Or any tips on what i wrong?

Thanks!
/Nacho

Has anyone been able to use TTS? Could you share an example? Thanks!

hi all
how can completely uninstall/remove iotlink from my pc and HA?

Hi guys! just started learing about IoT Link. I was able to execute a bat file using the code below but it works only if connected via rdp…any ideas?

Thanks

service: mqtt.publish
data:
  topic: iotlink/workgroup/win-mapv2tue7m7/commands/run
  payload: >-
    { "command": "C:\\windows\\AION.bat", "path": "C:\\windows", "user": system "",
    "visible": false, "fallback": true }

Well just unistall it from windows using the unistaller and manually remove all the entities from HA I’m guessing…

1 Like

I am trying to remove iot link completely from HA. I had connected 4-5 laptops. I have uninstalled iot link from windows control panel and I have removed the entities from HA. However when I still get the below message

What more should I do?

We control the brightness of the screen on the monitor using IO Link. Read more details here

To adjust the brightness, we use the following command

service: mqtt.publish
data:
  topic: iotlink/workgroup/livingroom/commands/run
  payload: >-
    { "command": "C:\\Windows\\System32\\cmd.exe", "args":"/k
    %LOCALAPPDATA%\\Microsoft\\WindowsApps\\Monitorian.exe /set 40", 
    "path": "C:\\Windows\\System32","user": "", "visible": false, "fallback":
    true }

We use a variable to adjust the brightness

service: mqtt.publish
data:
  topic: iotlink/workgroup/livingroom/commands/run
  payload: >-
    { "command": "C:\\Windows\\System32\\cmd.exe", "args":"/k
    %LOCALAPPDATA%\\Microsoft\\WindowsApps\\Monitorian.exe /set 
    {{states("input_number.pc_livingroom_monitor_brightness")|round(0)}}", 
    "path": "C:\\Windows\\System32","user": "", "visible": false, "fallback":
    true }
Текст на русском (Text in Russian)

Управляем яркостью экрана на мониторе с помощью IOTLink. Более подробно читаем здесь

Для регулировки яркости используем такую команду

service: mqtt.publish
data:
  topic: iotlink/workgroup/livingroom/commands/run
  payload: >-
    { "command": "C:\\Windows\\System32\\cmd.exe", "args":"/k
    %LOCALAPPDATA%\\Microsoft\\WindowsApps\\Monitorian.exe /set 40", 
    "path": "C:\\Windows\\System32","user": "", "visible": false, "fallback":
    true }

Используем переменную для регулировки яркости

service: mqtt.publish
data:
  topic: iotlink/workgroup/livingroom/commands/run
  payload: >-
    { "command": "C:\\Windows\\System32\\cmd.exe", "args":"/k
    %LOCALAPPDATA%\\Microsoft\\WindowsApps\\Monitorian.exe /set 
    {{states("input_number.pc_livingroom_monitor_brightness")|round(0)}}", 
    "path": "C:\\Windows\\System32","user": "", "visible": false, "fallback":
    true }

Hotlink sensors are sometimes unavailable. To fix this, I restart the IOTLink service and the sensors start working again. This happens quite often and I was thinking about automatically restarting the IOTLink service. The IOTLink service itself works and standard sensors do not fail. It is user sensors that fail, for example Process Monitor. I created a batnik and run it to restart the IOTLink service, but I ran into a problem. Elevated permissions are required to run the batnik.

In c:\ProgramData\IOTLink\Addons\ProcessMonitor\apps\Games.yaml I added the following

processes:
  - ACValhalla.exe
  - DOOMEternalx64vk.exe
  - HorizonZeroDawn.exe
  - HaloInfinite.exe
  - RAGE2.exe
  - GoW.exe
  - MetroExodus.exe
windows:
classnames:
configs:
  enabled: true
  discoverable: true
  advancedMode: false
  displayName: Games
  cacheable: true
  grouped: true
  compareType: 0
  interval: 10

I wrote a batnik that restarts the IOTLink service, but there is a problem, the batnik does not start, since elevated rights and UAC bypass are required. I found an option and wrote it like this, the option is below

This batnik cannot start because administrator rights are required

@echo off
net stop IOTLink
rem
net start IOTLink

This batnik runs with administrator rights via IOTLink, but does not bypass UAC, you have to turn off UAC.


@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"



@echo off
net stop IOTLink
rem
net start IOTLink

Tried using runas, also doesn’t help

runas /user:user "c:\scripts\iotlink_reboot.bat" 

Running the script via IOTLink looks like this

service: mqtt.publish
data:
  topic: iotlink/workgroup/livingroom/commands/run
  payload: >-
    { "command": "C:\\scripts\\iotlink_reboot.bat", "path": "C:\\scripts",
    "user": "", "visible": false, "fallback": true }

I just run iotlink as a Windows service and force it to restart every few hour with task scheduler.

The problem is that the IOTLink service does not hang and the rest of the sensors, except for custom ones, hang after restarting the Home Assistant or after some time. The task scheduler does not suit me for the reason that the sensor may freeze, and the scheduler will restart in a few hours, and at this time, for example, I started the game and Home Assistant does not launch this or that function. I have a very closely intertwined Home Assistant and computer. I need constant monitoring of sensors that show which game is running, which program is running, player or game. And now it also adjusts the brightness of my monitor, which I implemented today. Therefore, it is unacceptable for the Home Assistant to miss the moment that the IOTLink service does not work correctly.

Control of custom RGB backlight on the computer. We control the voice through Alice. IOTLink shows which game is running and its own effect is set for each game

Operation of the backlight on the monitor. IOTLink sees that the game is running and launches Hyperion and also monitors Hyperion. If Hyperion is not running, then run it

Automating Hyperion. Thanks to IOTLink, the Home Assistant understands that a game, a movie is running in the player or in the browser or youtube is running

As an option, I implemented such a scheme. Made automation that tracks IOTLink sensors. If the game sensor is not available, a script will run that will restart the service. While a window will pop up and ask you to allow the script to run. Maybe later there will be a solution how to bypass UAC

alias: 'System: IOTLink. Monitoring. Reboot'
description: >-
  We monitor IOTLink sensors. If the sensors are unavailable,
  a script will be run that will restart the IOTLink
trigger:
  - platform: state
    entity_id:
      - binary_sensor.livingroom_games
    to: unknown
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - platform: time_pattern
    minutes: /5
condition:
  - condition: template
    value_template: '{{ is_state("switch.pc_livingroom", "on") }}'
  - condition: template
    value_template: '{{ is_state("binary_sensor.livingroom_games", "unknown") }}'
action:
  - service: script.livingroom_computer_iotlink_restart
    data: {}
mode: single

The script itself script.livingroom_computer_iotlink_restart

alias: 'Living room: Computer. Restart the Hotlink'
sequence:
  - service: mqtt.publish
    data:
      topic: iotlink/workgroup/livingroom/commands/run
      payload: >-
        { "command": "C:\\Scripts\\iotlink_reboot.bat", "path": "C:\\Scripts",
        "user": "", "visible": false, "fallback": true }
mode: single
icon: mdi:desktop-mac

Ah well if you require that kind of precision perhaps one of the programs will be better.
There are a couple around.

There is another one called eventghost
http://www.eventghost.net/

I haven’t used either as a restart of iotlink covers my needs

I’m just probing her today during the day :smiley:. While this program causes mixed feelings, I just got used to IOTLink and then, if I switch to HASS Agent, I will have to redo a lot. What I don’t like about HASS Agent is that I need to create several games with the same name Games so that the Games sensor is only on\off, and it’s more convenient in IOTLink in this regard, I added the name of the game to the config and that’s it. For now, IOTLink remains the best choice for me, and then we’ll see. While studying the possibilities of the program



Iotlink is without a developer for a long time. So there won’t be any improvements that will solve your sensor problems…