HASS.Agent: Windows client to receive notifications, use commands, sensors, quick actions and more!

First:
Tnx for this great addon!

Second:
Can anyone help me with this?
I’m using a command in the HASS Agent to execute ControlMyMonitor.exe. This tool echo’s a value (eg. “3”, this is the input device number of my monitor). I can write this value to a txt file with > text.txt, but can I store/upload this value in a HASS sensor somehow?

Did you also click the ‘execute port reservation’ button?

Not currently no :frowning: I tried a few angles, but it always just comes back to the local Spotify instance. That’d require integrating with the Spotify API I guess to see if it’s actually playing on the current machine.

You can try with a ‘PowershellSensor’, as the command just enter the exe. Use the test command or script button to see if you actually get that value back.

I’m sorry, but I don’t fully understand how to use it.

I’ve added the following command:

The command that I execute is:

"C:\Users\verdo\OneDrive\Downloads\controlmymonitor\ControlMyMonitor.exe" /GetValue "\\.\DISPLAY4\Monitor0" 60

This value can be seen by entering
echo %errorlevel%

It returns a value of 1, 3, 4 or 15. It this value that I want to “import” in a Home Assistant sensor somehow…

Ok, the solution might be dirty, but it works :sweat_smile:

I use the PowerShellCommand to execute a .bat file:

"C:\Users\xxxxxx\OneDrive\Downloads\controlmymonitor\ControlMyMonitor.exe" /GetValue "\\.\DISPLAY4\Monitor0" 60
echo %errorlevel% > \\192.168.x.x\config\test.txt

This exports the result to a text file on my HASS OS server.
This file gets read by a simple command_line sensor:

  - platform: command_line
    name: inputrechts
    command: "tail -n 1 /config/test.txt"
    value_template: >
          {% if value|float == 1 %}
          "VGA"
          {% elif value|float == 3 %}
          "DVI - Laptop"
          {% elif value|float == 4 %}
          "HDMI - PS5"
          {% elif value|float == 15 %}
          "DisplayPort"
          {% else %}
          value
          {% endif %}

Like I’ve said, it’s ugly, but it works!

1 Like

Yes, I did. It works fine with admin account, but throws an error with standard user account.

Since you have a copy of the file on you HASS server, you can use the built-in File integration sensor to read it.

– John

1 Like

Is there a known problem with umlauts yet?

On the picture I have an example, where I read the clipboard with a Powershell command. With the letters äöü and ß and possibly others there are problems with the output.

Please run these commands in an elevated command prompt:

netsh http delete urlacl http://+:5115/
netsh http add urlacl url=http://+:5115/ user=Everyone

Not yet, that’s not good! Can you please give me that text, so I can use it to test?

Welch übermütiges Entzücken: zum hübschen Blümchen sich zu bücken.
Üh! Kühles Übel drückt die Füße! Hinüber ist die müß’ge Süße,
verfrüht die schwülen Frühlingsgrüße, für Übermut ich rüd’ nun büße.
?$%/"()!#*

Sure, thank you!

1 Like

No worries, thanks for the update. Agree not worth considering if I’m the only person with this use case. I’ll survive. :slight_smile: Thanks again for all the great work.

1 Like

Thanks. This fixed the issue.

1 Like

I’m having an issue running a Powershell script via the Commands. Working seeee way down at bottom.

Here is the PS script to Minimize All Windows.

$shell = New-Object -ComObject "Shell.Application"
$shell.minimizeall()

When I run the PS script on the PC it works:
image

Here is how I have the command in HASS.Agent Commands:

I’ve tried with and without the quotes for the script location. Any ideas?

EDIT

Have also done the above mentioned

Ran PowerShell as Administrator and ran Set-ExecutionPolicy RemoteSigned

image

EDIT #2

A bit more digging and learning and I have self-signed the ps1 script but still can’t get HASS.agent to trigger it

EDIT #3

So playing around more I found a temp-workaround by creating a shortcut to the ps1 script and used the Custom Command. That works for now but would like to still figure out why the PowerShell doesn’t work directly.

EDIT #4
Tried the screenshot PS script and it works. Does my script because it uses shell somehow not make it work?

A bit more testing and my PS scripts kind of work. Some of the windows closed while some stayed open. So I guess the PS is working. Need to find a better script to Minimize and Maximize all windows. Or maybe it’s just Windows being Windoze.

Thanks again for a great tool.

1 Like

Is there a way to reconfigure the order of items in the Quick Action window?

Well you can do it the ‘hacky’ way, by opening the quickactions config file (%appdata%\LAB02 Research\HASS.Agent\config\quickactions.json) and reordering them there.

But it’s a good adition, I’ve added it to the list (hassagent-149)

Hi, the release notes for the latest beta say “snappy, no more lagging behind” for media player. However I am still seeing a 3 to 4 second delay in state change (the state itself and the attributes) upon playing, pausing and change of song.

Just wondering if I am missing something or misconfigured?
Is Agent polling or gets/sends immediate feedback from a media player?
Also, how do I access the new cover art?

For context I am using foobar2000 as the media player on a dedicated NUC hooked up to speakers, and using Agent to send commands to fb2k and retrieve the state and media info. I presume fb2k supports Windows’ media API since I am getting the status and media title info in HA?

Hi @echo_Mark, that only applies to the new integration, did you set that one up? It’ll create new entities, so you’ll have to modify your automations (if you have them), unless you delete your old integration + old entities and rename the new ones to match the old names.

Let me know how it goes, it’s great that you’re testing the beta!

Just moved over from the HASS Workstation Service, per their recommendation, and wow, what an upgrade. Great work!

For some reason, however, my PC would not remain in sleep nor hibernation after moving over. When put to sleep it would wake again inside of 60 seconds. I seem to have finally resolved it by disabling the media_player component. Am I the only one? Is there any way to have the media_player and allow the computer to sleep?

2 Likes