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

The WMI Query sensor will be your friend for anything not already listed, You will be absolutely astounded by how much info you can pull out of a machine.

Querying WMI - Win32 apps | Microsoft Learn

Wow, that is very powerful.

I don’t know anything about WMI, but a quick look leads me to think it’s challenging.

I just installed Libre Hardware Monitoring and was able to call the WMI:

SELECT value FROM Sensor WHERE Name LIKE “%CPU Core%” AND SensorType = “Temperature”

But I got that from the examples, and have no idea how to get any other data.

And (I think), using WMI requires running another application on the host, right?

Thank you!

WMI is a core service builtin to Windows. It’s been on every version since. Windows XP (I believe…, about 90% sure)

Yes it’s incredibly powerful. It’s the same interface all modern system management tools reach into to query your machine in a corporate network.

Theres plenty of tools around to query tie structure like Libre you should be able to build a query like you did and pop it directly into the WMI query spot and make a sensor.

1 Like

Hi guys. i wanted to find out if there was a way to reactivate the monitor as well as turning it off. i can’t seem to find it as a command. So I thought to make a custom one, using powershell I found the command to turn the monitor on or off, and it works, but when I turn the monitor on, after 1 second it turns off, I don’t understand why. any suggestions for how to do this, via hass.agent

Is there a sensor that shows, if the PC has a running remote desktop connection?

I used Hass Agent to enable the monitorwake, monitorsleep and monitorpowerstate sensors, then made a template switch to toggle between the two. Hope this code helps you:

switch:
# PC Monitor Switch
  - platform: template
    switches:
      PCNAME_monitor_power:
        unique_id: PCNAME_monitor_power
        friendly_name: "PCNAME Monitors"
        value_template: "{{ is_state('sensor.PCNAME_monitorpowerstate', 'PowerOn') }}"
        icon_template: >-
          {% if is_state('sensor.PCNAME_monitorpowerstate', 'PowerOn') %}
            mdi:monitor-shimmer
          {% elif is_state('sensor.PCNAME_monitorpowerstate', 'PowerOff') %}
            mdi:monitor
          {% else %}
            mdi:monitor-off
          {% endif %}
        turn_on:
          service: button.press
          target:
            entity_id: button.PCNAME_monitorwake
        turn_off:
          service: button.press
          target:
            entity_id: button.PCNAME_monitorsleep

Hey @all,

I just wanted to install the HASS.agent client on an old trekstore tablet I had laying around without any use. Since I wanted to dynamically turn the monitor on and off for showing a HA dashboard this project would be perfect for this application. However upon trying to install HASS.agent on the machine I got the error fairly quickly that 32bit OS is not supported. Is this still a limitation today or is there any workaround possible?

Thanks and greetings

Thank you for this program. I use it with my Dell notebbook, since it doesn’t like to start with my Thunderbolt dock connected I turn on the dock (using a smaert power plug) once the OS started and turn it off after 3 minutes after powering off the PC. The only think I’d like to improve is the boot sequence.
HASS.agent starts automatically on boot but after other programs like Adobe cloud desktop, Google Drive etc. Is it possible to set HASS.agent to start right after the OS boot is complete?

That’s windows doing that as part of boot optimization. (the OS holds services and autostart items until after boot is complete and the user is logged on to give you a faster boot experience)

So to change that you’ll have to selectively turn parts of that off. (I wouldn’t recommend it.)

What part is giving you the issue that can’t wait 15 more seconds?

Thank you for the answer :grinning:
The problem it’s not to wait 15 or 30 seconds more I just wondering if I can optimize the boot sequence since I noticed that some startup programs that aren’t part of the os start before HASS.Agent.
Obviously I can disable other programs to boot but they’re enabled because I need them (but not so early on the boot).
A possible solution I was thinking is to disable the start at boot from the other programs and set them to start at every boot but with a delay through windows scheduler but I don’t know if it’s reliable.

You can’t tell Windows to start services early, but you can tell it to start services as delayed. So, instead of trying to HASS.agent to start early, I guess you could just tell Windows to start Adobe cloud desktop and Google Drive afterwards.

In Services window, you can set those services’ startup type to “Automatic (delayed start)”.

1 Like

Ever since I updated to core_2023.11.2 my HASS agent cannot connect to the HA API. In config I try to do the test and it says I cannot connect. Nothing has changed in my settings except the core update, I haven’t changed URIs or Tokens since…Is this a bug or some kind of new conflict?

Mine will connect, but only for a minute or two and then just dissappears from windows tray.

I figured it was just my messed up windows install, but more people are having issues maybe not

I know it’s been a while, but if anyone needs a solution to this that doesn’t involve sending to a file, you can run the bat with @echo off and it’ll give the correct output for the sensor. Script I use:

@echo off
C:\<change_THIS_to_your_path>\ControlMyMonitor.exe /GetValue "\\.\DISPLAY1\Monitor0" 60
echo %errorlevel%
1 Like

What is the best way to check if the PC is powered in an automation?

I’m testing if the sessionstate sensor is unavailable, but I wonder if there’s a cleaner way?

action:
  - if:
      - condition: state
        state: unavailable
        entity_id: sensor.silent_desktop_sessionstate
    then:
      - service: switch.turn_on
        target:
          entity_id: switch.monitor_smsl_on_off

Not really. If its off all the sensors should be unavailable. Because off.

1 Like

Guys… two questions: if i have 4 PC’s in my network, all of them have HASS.Agent installed: do i have to set unique API port for each installation? Default is 5115, so do i leave all as is or must it be 5115,5116,5117… ?
The reason i’m asking is (if it’s conneced to this problem at all) because on two PC’s media player works, but on other two it’s not even present in HA - hass.agent integration has zero entities for these two PC’s. MQTT sensors and custom commands work on all 4, however. I tried to remove hass on these two PC’s, reinstalled, removed PC’s in HA integration and re-added them… but nothing works - media player doesn’t show up.

I wouldn’t dare to remove two working PC’s and remove/reinstall integration completely from HA, because i’m afraid that if i do that I’ll loose these working PC’s, too…

Is there anything left i can do?

No something else is wrong. You should not need to change ports unless something else on the pc is already using the default port.

Aha… so if understand you correctly this port is on PC, not on HA side? Then i agree, it’s ok to have them set to 5115 on all devices. Ok, that part is clear then. Many thanks!

Basically, haven’t had coffee yet and would need to review my config for the full answer.

That said when I installed my copy I don’t remember any of the media stuff showing up by default and I had to set it up by hand. I remember thinking hey this is cool I only have to setup the commands and sensors I need. And it’s not bogged down (yes you can call WMI too much too fast) by what someone else thinks I need… You sure it’s not working and just needs a bit of extra config?