IOT Link - Windows Management using MQTT

I don’t see that listed as a separate entry in “programs and features”

ahh

post edit - thanks

The IOT Link Wiki states that there are media sensors, however I can’t see them in Home Assistant.
Everything else works great :slight_smile:

Moreover, in the Windows Monitor config, I don’t see an option for turning on the media sensors. Am I missing something?

Thanks in advance :+1:

EDIT: fixed it by adding the sensors myself. Would be great tho if it was automatic :wink:

I think they were removed in version 2.2.0 due to a memory leak in a library used. At least I think the media playing sensor (that I presume you’re interested in, this is what I was using at the time) was using this audio library too. See the developer’s comment here. Note that the media commands should still work as per his comment a bit further down.
The older versions are still up on the downloads page so you could try v2.1.1 or earlier, and maybe the service restart option also discussed in this thread (to deal with it becoming unavailable i think) might deal with the memory leaks too.

1 Like

Great work with this app, seriously. A quick question re: notifications in Windows 10 - has anyone been able to add IOTLink as a priority app in Focus Mode? In other words, when you go into the settings to choose which apps should come through when running in Focus Mode, I can’t select IOTLink from the available apps. This means that, when Focus Assist kicks in, Windows notifications won’t work.

Any suggestions?

When my computer goes offline (or off), all the sensors goes “Unavailable”.
Is there a way I can show “last state” in lovelace insted`? In this case “210GB”?

Anyone know if there is any way to mitigate this? IoTLink (presumably) flaking out but then not trying to revive itself?


[WORKGROUP\TERMINAL][2021-11-06 07:56:51 +00:00][VERBOSE][IOTLinkAPI.Configs.ConfigurationManager]: Setting up file system watcher: C:\ProgramData\IOTLink\Configs\configuration.yaml
[WORKGROUP\TERMINAL][2021-11-06 07:56:51 +00:00][DEBUG][IOTLinkAPI.Configs.ConfigurationManager]: Creating new watcher for C:\ProgramData\IOTLink\Configs\configuration.yaml
[WORKGROUP\TERMINAL][2021-11-06 07:56:51 +00:00][VERBOSE][IOTLinkService.Service.Engine.ServiceMain]: ServiceMain::OnSessionChange() - Session Changed
[WORKGROUP\TERMINAL][2021-11-06 07:56:53 +00:00][CRITICAL][IOTLink.Program]: Critical Unhandled Exception: System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at IOTLinkAPI.Configs.ConfigurationManager.GetConfiguration(String path, Boolean reload)
   at IOTLinkAPI.Configs.ConfigurationManager.GetConfiguration(String path)
   at IOTLinkAPI.Helpers.LoggerHelper.WriteLog(LogLevel logLevel, String messageTag, String message, Object[] args)
   at IOTLinkAPI.Helpers.LoggerHelper.Info(String message, Object[] args)
   at IOTLink.IOTLinkService.OnStart(String[] args)
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.ServiceProcess.ServiceBase.Run(ServiceBase[] services)
   at IOTLink.Program.Main(String[] args)

and then another error from another workstation

[MSHOME\PC][2021-11-09 08:33:07 +00:00][CRITICAL][IOTLink.Program]: Critical Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at IOTLinkAPI.Configs.ConfigurationManager.GetConfiguration(String path, Boolean reload)
   at IOTLinkAPI.Configs.ConfigurationManager.GetConfiguration(String path)
   at IOTLinkAPI.Helpers.LoggerHelper.WriteLog(LogLevel logLevel, String messageTag, String message, Object[] args)
   at IOTLinkAPI.Helpers.LoggerHelper.Info(String message, Object[] args)
   at IOTLink.IOTLinkService.OnStart(String[] args)
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.ServiceProcess.ServiceBase.Run(ServiceBase[] services)
   at IOTLink.Program.Main(String[] args)

Hello

Is it possible to monitor a network drive with this program?

Pretty sure the volume stuff got silently deprecated. @alexslx ?

Anyway I’ve come up with two autohotkey scripts. One which mutes the volume (but records what the volume was set to) and the other which restores it back to its former volume. Shout if interested in these.

I’ve made a autohotkey script that not only logs the state of the service but also restarts it if it falls over.

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}
#SingleInstance, force
SendMode Input  
SetWorkingDir %A_ScriptDir%  

iTC_imgName = IOTLinkService.exe

loop {
	
	Process, Exist, %iTC_imgName% ; check to see if IOTLink is running
	If (ErrorLevel = 0) ; If it is not running
	   {
		 Run %A_WinDir%\system32\net.exe start "IOTLink",, Hide
		 FormatTime, TimeString
		 FileAppend, %TimeString% Restarting .`n, C:\iotlinkrestartlog.txt
	   }
	Else 
	   {
		 FormatTime, TimeString
		 FileAppend, %TimeString% all OK .`n, C:\iotlinkrestartlog.txt
		 sleep 5
	   }
		 sleep 60000
}
1 Like

I wrote a MS Teams Addon for IoTLink if anyone is interested.
You can find it here: GitHub - ledhed-jgh/IoTLink-Addons: Addons for IoTLink

@alexslx Thanks for all the hard work you’ve put into IoTLink.

Tell me, I have Hyperion Server OS on Windows and I run Hyperion with this command.

It works successfully

service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "C:\\Program Files\\Hyperion\\bin\\hyperiond.exe",  "path":    
    "C:\\Program Files\\Hyperion", "user": "", "visible": true, "fallback": true
    }

And how do I close the Hyperion program? If I see taskkill /f /im through the console hyperiond.exe , then the Hyperion program will be closed, and through IoT I will not understand how I can close the hyperiond program. How can this be done?

I try this way and it doesn’t work

service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "‪C:\\Windows\\System32\\taskkill.exe", "args": "/f
    /IM hyperiond.exe", "path": "C:\\Windows\\system32\\", "user": "",
    "visible": true, "fallback": true }
service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "‪C:\\Windows\\System32\\taskkill.exe /f /im hyperiond.exe",
    "args": "", "path": "", "user": "", "visible": true, "fallback": true } }


For reference, maybe it will be useful to someone. Created the file Hyperion.yaml in folder C:\ProgramData\IOTLink\Addons\ProcessMonitor\apps and you can get the status of the Hyperion program

# Hyperion
processes:
  - hyperiond
windows:
classnames:
configs:
  enabled: true
  discoverable: true
  advancedMode: false
  displayName: Hyperion
  cacheable: true
  grouped: true
  compareType: 0
  interval: 10

image
image

Текст на русском (Text in Russian)

Скажите, на Windows у меня стоит Hyperion Server OS и я запускаю Hyperion вот такой командой.

Это работает успешно

service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "C:\\Program Files\\Hyperion\\bin\\hyperiond.exe",  "path":    
    "C:\\Program Files\\Hyperion", "user": "", "visible": true, "fallback": true
    }

А как мне закрыть программу Hyperion? Если я через консоль введу taskkill /f /im hyperiond.exe, то программа Hyperion будет закрыта, а через IoT я не пойму как мне закрыть программу hyperiond. Как это можно сделать?

Я пробую вот таким способом и это не работает

service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "‪C:\\Windows\\System32\\taskkill.exe", "args": "/f
    /IM hyperiond.exe", "path": "C:\\Windows\\system32\\", "user": "",
    "visible": true, "fallback": true }
service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "‪C:\\Windows\\System32\\taskkill.exe /f /im hyperiond.exe",
    "args": "", "path": "", "user": "", "visible": true, "fallback": true } }


Для справки, может кому то будет полезным. Создал файлик Hyperion.yaml в папке C:\ProgramData\IOTLink\Addons\ProcessMonitor\apps и можно получать статус программы Hyperion

# Hyperion
processes:
  - hyperiond
windows:
classnames:
configs:
  enabled: true
  discoverable: true
  advancedMode: false
  displayName: Hyperion
  cacheable: true
  grouped: true
  compareType: 0
  interval: 10

image
image

I have found a solution and I will answer my own question, but I will be grateful if you show me other options on how to close the program.

I resorted to nircmd. You can download nircmd-x64 for Windows 10 x64 here. Unpacked to an arbitrary folder, in my example, this is the Distributiv folder and specified the path to nircmd

service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "c:\\Distributiv\\nircmd\\nircmd.exe", "args": "nircmd
    killprocess hyperiond.exe", "path": "c:\\Distributiv\\nircmd\\", "user": "",
    "visible": true, "fallback": true }

Created an MQTT switch

switch:
  - platform: mqtt
    unique_id: switch livingroom wled monitor hyperion
    name: "WLED Monitor. Hyperion"
    command_topic: "iotlink/workgroup/home/commands/run"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/hyperion/state"
    payload_on: '{ "command": "C:\\Program Files\\Hyperion\\bin\\hyperiond.exe", "path": "C:\\Program Files\\Hyperion", "user": "", "visible": true, "fallback": true }'
    payload_off: '{ "command": "C:\\Distributiv\\nircmd\\nircmd.exe", "args": "nircmd killprocess hyperiond.exe", "path": "C:\\Distributiv\\nircmd\\", "user": "", "visible": true, "fallback": true }'
    state_on: 'ON'
    state_off: 'OFF'
    optimistic: false
    qos: 0
    retain: true
    icon: mdi:television-ambient-light
Текст на русском (Text in Russian)

Я нашел решение и отвечу сам на свой вопрос, но буду благодарен, если вы покажете другие варианты, как можно закрыть программу.

Я прибегнул к nircmd. Скачать nircmd-x64 для Windows 10 x64 можно здесь. Распаковал в произвольную папку, в моем примере, это папка Distributiv и указал путь к nircmd

service: mqtt.publish
data:
  topic: iotlink/workgroup/home/commands/run
  payload: >-
    { "command": "c:\\Distributiv\\nircmd\\nircmd.exe", "args": "nircmd
    killprocess hyperiond.exe", "path": "c:\\Distributiv\\nircmd\\", "user": "",
    "visible": true, "fallback": true }

Создал MQTT выключатель

switch:
  - platform: mqtt
    unique_id: switch livingroom wled monitor hyperion
    name: "WLED Монитор. Hyperion"
    command_topic: "iotlink/workgroup/home/commands/run"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/hyperion/state"
    payload_on: '{ "command": "C:\\Program Files\\Hyperion\\bin\\hyperiond.exe", "path": "C:\\Program Files\\Hyperion", "user": "", "visible": true, "fallback": true }'
    payload_off: '{ "command": "C:\\Distributiv\\nircmd\\nircmd.exe", "args": "nircmd killprocess hyperiond.exe", "path": "C:\\Distributiv\\nircmd\\", "user": "", "visible": true, "fallback": true }'
    state_on: 'ON'
    state_off: 'OFF'
    optimistic: false
    qos: 0
    retain: true
    icon: mdi:television-ambient-light

Creating a sensor that opens YouTube in the browser

How I automated Hyperion using IO Link

I will share an option on how to create a sensor of what we are watching on a YouTube computer. Why is this necessary? There is such an integration, called Hyperion, it allows you to capture an image and transfer colors to address LEDs. I have made Hyperion automatically turn on/off when launching games or when enabling fullscreen mode in the browser. But there is one thing, but if I turn on fullscreen mode in the browser, then Hyperion will turn on, and I don’t need it, since I need it to turn on if I watch YouTube in fullscreen mode. So, by creating such a sensor, we exclude Hyperion auto-switching when enabling fullscreen mode in another contribution, only when watching YouTube

If you look at json in qt, we see the following and we are interested in the string “MainWindowTitle”, which we will use in the sensor. The line “MainWindowTitle” displays information about which page we have opened in the browser and can pull out keywords, in our case it is YouTube

Data in MQTT Explorer
{
  "Id": "12852",
  "SessionId": "6",
  "ProcessName": "opera",
  "StartDateTime": "2021-12-09 18:29:45",
  "Uptime": "00:03:05:19",
  "MemoryUsed": "735",
  "ProcessorUsage": "1,34",
  "MainWindowTitle": "More Real 12K HDR 60FPS Dolby Vision - YouTube - Opera",
  "FullScreen": "False",
  "Status": "Running",
  "Windows": [
    "More Real 12K HDR 60FPS Dolby Vision - YouTube - Opera",
    "Chrome Legacy Window",
    "Chrome Legacy Window"
  ],
  "ClassNames": [
    "Chrome_WidgetWin_1",
    "Chrome_RenderWidgetHostHWND",
    "Chrome_RenderWidgetHostHWND"
  ]
}

Creating such a sensor

Screenshots

A tab is open in the browser IIOT Link - Windows Management using MQTT


image

A tab is open in the browser YouTube


image

Sensor Code

#Browser. We are tracking the MainWindowTitle lines, from where we will pull out the word YouTube
  - platform: mqtt
    name: "IOT Link. PC Home. Browsers. MainWindowTitle"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/browsers/sensor"
    value_template: "{{ value_json.MainWindowTitle }}"
    qos: 0

#Video player. Pulling out the status of the fullscreen mode
  - platform: mqtt
    name: "IOT Link. PC Home. Potplayer. FullScreen"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/potplayer/sensor"
    value_template: "{{ value_json.FullScreen }}"
    qos: 0

#Игры. Pulling out the status of the fullscreen mode
  - platform: mqtt
    name: "IOT Link. PC Home. Games. FullScreen"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/games/sensor"
    value_template: "{{ value_json.FullScreen }}"
    qos: 0

#Sensor. Pulls the YouTube word from the MainWindowTitle. Multiple title variants are used to catch the YouTube word
  - platform: template
    sensors:
      iotlink_pc_home_browser_opera_channel:
        friendly_name: "PC. Browsers. YouTube"
        icon_template: mdi:youtube
        value_template: >
            {% if "YouTube" in states("sensor.iot_link_pc_home_browsers_mainwindowtitle") %} YouTube
            {% else %} off
            {% endif %}

#Full-screen mode sensor for Potplayer
  - platform: template
    sensors:
      potplayer_fullscreen_mode:
        friendly_name: "PorPlayer. Full-screen mode"
        icon_template: mdi:theater
        value_template: >
            {% set potplayer = states("binary_sensor.home_potplayer") %}
            {% set potplayer_fullscreen = states("sensor.iot_link_pc_home_potplayer_fullscreen")%}
            {% if potplayer == 'on' and potplayer_fullscreen == 'True' %} on
            {% else %} off
            {% endif %}

#Fullscreen mode sensor for YouTube
  - platform: template
    sensors:
      youtube_fullscreen_mode:
        friendly_name: "YouTube. Full-screen mode"
        icon_template: mdi:youtube
        value_template: >
            {% set youtube = states("sensor.iotlink_pc_home_browser_opera_channel") %}
            {% set browsers_fullscreen = states("binary_sensor.home_browsers_fullscreen") %}
            {% if youtube == 'YouTube' and browsers_fullscreen == 'on' %} on
            {% else %} off
            {% endif %}


#Full-screen mode sensor for games
  - platform: template
    sensors:
      game_fullscreen_mode:
        friendly_name: "Game. Full-screen mode"
        icon_template: mdi:google-controller
        value_template: >
            {% set game = states("binary_sensor.home_games") %}
            {% set game_fullscreen = states("sensor.iot_link_pc_home_games_fullscreen") %}
            {% if game == 'on' and game_fullscreen == 'True' %} on
            {% else %} off
            {% endif %}



Текст на русском (Text in Russian)

Создаем сенсор, что в браузере открыт YouTube

Как я автоматизировал Hyperion с помощью IOT Link

Поделюсь вариантом как можно создать сенсор того, что мы смотрим на компьютере YouTube. Зачем это нужно? Есть такая интеграция, называется Hyperion, она позволяет захватывать изображение и передавать цвета на адресные светодиоды. Я сделал автоматическое включение\выключение Hyperion при запуске игр или при включении полноэкранного режима в браузере. Но есть одно но, если я включаю в браузере полноэкранные режим, то Hyperion включится, а мне это не нужно, так как мне нужно, чтобы он включался, если я смотрю YouTube в полноэкранном режиме. Так вот, создав такой сенсор, мы исключаем авто включение Hyperion при включении полноэкранного режима в другой вкладе, только при просмотре YouTube

Если посмотреть json в mqtt, то мы видим следующее и нас интересует строка “MainWindowTitle”, которую будем использовать в сенсоре. Строка “MainWindowTitle” выводит информацию, какую страницу мы открыли в браузере и можем выдергивать ключевые слова, в нашем случае это YouTube

Данные в MQTT Explorer
{
  "Id": "12852",
  "SessionId": "6",
  "ProcessName": "opera",
  "StartDateTime": "2021-12-09 18:29:45",
  "Uptime": "00:03:05:19",
  "MemoryUsed": "735",
  "ProcessorUsage": "1,34",
  "MainWindowTitle": "More Real 12K HDR 60FPS Dolby Vision - YouTube - Opera",
  "FullScreen": "False",
  "Status": "Running",
  "Windows": [
    "More Real 12K HDR 60FPS Dolby Vision - YouTube - Opera",
    "Chrome Legacy Window",
    "Chrome Legacy Window"
  ],
  "ClassNames": [
    "Chrome_WidgetWin_1",
    "Chrome_RenderWidgetHostHWND",
    "Chrome_RenderWidgetHostHWND"
  ]
}

Создаем такой сенсор

Скриншоты

В браузере открыта вкладка IIOT Link - Windows Management using MQTT


image

В браузере открыта вкладка YouTube


image

Код сенсора
sensor:
#Браузер. Отслеживаем строки MainWindowTitle, откуда будем выдергивать слово YouTube
  - platform: mqtt
    name: "IOT Link. PC Home. Browsers. MainWindowTitle"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/browsers/sensor"
    value_template: "{{ value_json.MainWindowTitle }}"
    qos: 0


#Видеоплеер. Выдергиваем статус полноэкранного режима
  - platform: mqtt
    name: "IOT Link. PC Home. Potplayer. FullScreen"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/potplayer/sensor"
    value_template: "{{ value_json.FullScreen }}"
    qos: 0

#Игры. Выдергиваем статус полноэкранного режима
  - platform: mqtt
    name: "IOT Link. PC Home. Games. FullScreen"
    state_topic: "iotlink/workgroup/home/process-monitor/processes/games/sensor"
    value_template: "{{ value_json.FullScreen }}"
    qos: 0

#Сенсор. Выдергивает из MainWindowTitle слово YouTube. Используется несколько вариантов title, чтобы поймать слово YouTube
  - platform: template
    sensors:
      iotlink_pc_home_browser_opera_channel:
        friendly_name: "ПК. Браузер Опера. YouTube"
        icon_template: mdi:youtube
        value_template: >
            {% if "YouTube" in states("sensor.iot_link_pc_home_browsers_mainwindowtitle") %} YouTube
            {% else %} off
            {% endif %}

#Сенсор полноэкранного режима для PorPlayer
  - platform: template
    sensors:
      potplayer_fullscreen_mode:
        friendly_name: "PorPlayer. Полноэкранный режим"
        icon_template: mdi:theater
        value_template: >
            {% set potplayer = states("binary_sensor.home_potplayer") %}
            {% set potplayer_fullscreen = states("sensor.iot_link_pc_home_potplayer_fullscreen")%}
            {% if potplayer == 'on' and potplayer_fullscreen == 'True' %} on
            {% else %} off
            {% endif %}

#Сенсор полноэкранного режима для YouTube
  - platform: template
    sensors:
      youtube_fullscreen_mode:
        friendly_name: "YouTube. Полноэкранный режим"
        icon_template: mdi:youtube
        value_template: >
            {% set youtube = states("sensor.iotlink_pc_home_browser_opera_channel") %}
            {% set browsers_fullscreen = states("binary_sensor.home_browsers_fullscreen") %}
            {% if youtube == 'YouTube' and browsers_fullscreen == 'on' %} on
            {% else %} off
            {% endif %}


#Сенсор полноэкранного режима для игр
  - platform: template
    sensors:
      game_fullscreen_mode:
        friendly_name: "Игра. Полноэкранный режим"
        icon_template: mdi:google-controller
        value_template: >
            {% set game = states("binary_sensor.home_games") %}
            {% set game_fullscreen = states("sensor.iot_link_pc_home_games_fullscreen") %}
            {% if game == 'on' and game_fullscreen == 'True' %} on
            {% else %} off
            {% endif %}
1 Like

Hi is it Possible to open an windows Shortcut with the Run Command?

I use an vbs Script to change the pc colors or copy some files. At the moment i use Assistant Computer Control where i can open Shortcuts , but this works over dropbox with an delay.

So i try to open a file called “green.lnk” but it dont work, it only works with .exe or .bat files.

Someone knows how i could fix that?

Thx in advance

Now i have also installed iotlink, it works great on Windows 11.on my PC i would also show my dashboard,monitor turn Off Skript work, now i will automated this with a Hue Motion Sensor, they should trigger display on when Motion, and after 10 Min turn Off and so on. How i can do that? Thanks for Help and Merry Christmas

Hi, I’m a bit stuck and I can’t find what’s not working.

  • My mqtt broker works and I’m using it for various automations
  • Software installed (in admin), all seems to work
  • MQTT explorer shows lots of messages from my PC
  • But Home Assistant fails to get anything working

In Home Assistant:
image

One example of how I am calling it from HA:

  - platform: mqtt
    name: "My Computer - Current User"
    state_topic: "iotlink/workgroup/w-s4su3841/windows-monitor/stats/system/current-user"
    unit_of_measurement: ''
    icon: mdi:account
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/w-s4su3841/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

Any suggestions?

Can’t see anything wrong here. But I do have a few questions.

  1. Why not just use MQTT Discovery?
  2. There is no need to have value_template on this example, because without a template the state is a string of whatever is published to that topic.
1 Like

Thanks. I went down the rabit hole of checking everything and I realized that my mosquito broker in integration in home assistant was… wrong. I used Nodered as a standard so I never thought about checking there. It works now. Thanks!
image

1 Like

Hello. I am still looking a way to open chrome in incognito. I have tried creating a shortcut and editing the shortcut properties, but does not work.

Hi!
Is it possible to unlock the computer from the lock state?
I got the lock command working but I would love to unlock it aswell.

Thanks