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

Hi all,

I’ve installed this on 3 computers in the house, but on one of them, the media player entity in Ha has not been created, and the device is not detected by the agent. The MQTT device and sensor entities have been created, its only the media player that is not detected/created. Anyone else had this? I’ve obviously removed and reinstalled the app on the computer. The computer that isn’t working is windows 10 pro, and the working ones are win 11 and win 10 pro.

Update: I’ve installed the agent on a 4th computer in the house, another Win 10 Pro, and the media player has not been set up in HA, and the Agent integration is not detecting the new device. The MQTT device and sensors have been set up in HA as expected, and the media player option has been enabled on the computer.

Update 2: I added another Win 11 computer, which also did not appear as a media player. I removed the integration from HA and HACS, then restarted HA, and readded the integration. when I restarted HA, all the computers were discovered and added as media players.

Thanks for the great work, this is super helpful around the house.

Hi. I just installed HASS.Agent and I have a couple of questions, please.

I am trying to grab some information about VMs on my PC running Microsoft Hyper-V. To start, I’d just like to see the results of a get-vm command in Home Assistant. I am trying to set up a powershell sensor in HASS.Agent for this.

  1. This command requires elevation. Only administrators can run it. But even if my user is administrator, I get an error. I’m sure others have solved this problem before: how to run the powershell sensor command as admin?

  2. When I set up the sensor with a powershell command, my PC goes crazy with a blue window popping up and disappearing every second! How do I make this run without any sort of window? It should be a background command…

Thanks in advance for any help!

Alternatively, this whould also be possible with WMI.

This works in Powershell as admin:

Get-WmiObject -Class Msvm_ComputerSystem -Namespace "root\virtualization\v2" 

I see a list of my Hyper-V VMs.

But this does not work as a WMI sensor in HASS.Agent:

image

In the past I was looking to run a powershell command and I don’t think they will be run using elevated admin permissions, even if the account used has them. I think it might also actually say that in the box where you configure the command to be run (if I remember correctly).

Thanks. The powershell sensor is a bit useless with these limitations, but I understand, sometimes these things are just not possible.

The WMI route looks more promising.

After fixing a detail with my WMI, I am now able to get a result from this:

select ElementName from Msvm_ComputerSystem

I get a single string with the name of my first VM.

How can I get the other elements in the collection? I have 3 VMs, and the WMI command, if I run it from command-line, shows all of them…

Can WMI queries return multiple values to the sensor?

@SamKr I’m starting to think this is not a bug, just a feature that has not been developed yet. So allow me to make a feature request - one that I hope will relatively easy to implement but that might have an excellent return in terms of value delivered.

Basically, allow any WMI query to return complex data, just iterate through it recursively and return a JSON response. Home assistant is good enough to evaluate JSON responses, so it’s easy to make use of that data on HA side.

There’s so much stuff that can be obtained from WMI that this would make HASS.Agent really powerful. I think I could build my whole Hyper-V monitoring system just from that.

Thanks in advance!

1 Like

For anyone who is having the same issue, expose the webcamprocess sensor to see what is hogging the webcam. In my case, it was an old instance of Microsoft Teams. Once I opened that and closed it again, it released the camera. :slight_smile:

I use this mainly to watch for my PC session state, and when HA is running, it properly reacts to session lock and unlock. However, if I reboot HA during an unlocked session, the session in HA is reported as ‘Unknown’. This status is new.

A) I notice HASS.Agent still properly reports the session as ‘Unlocked’.

B) I have the below script set as a Dashboard action. It properly changes the session to ‘Unlocked’. However, the session gets changed back to ‘Unknown’ a minute later w/o any interaction. I don’t understand.

service: python_script.set_state
data_template:
  entity_id: sensor.pc1_sessionstate
  state: Unlocked

Has anyone else come across this issue.
When enabling notifications in the HASS agent UI, the following error pops up in the logs:

2023-05-22 11:37:19.101 +01:00 [FTL] [NOTIFIER] Error while initializing: Failed initializing notifications
System.InvalidOperationException: Failed initializing notifications
 ---> System.IO.IOException: Cannot create a stable subkey under a volatile parent key.
   at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   at Microsoft.Win32.RegistryKey.CreateSubKeyInternalCore(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
   at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
   at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey)
   at Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.Initialize()
   at Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.CreateToastNotifier()
   at HASS.Agent.Managers.NotificationManager.Initialize()
1 Like

Can anyone please help with sensor value rounding?

With these:

# Disks Free
# Barad-dur
        sys_disk:
            friendly_name: 'System Disk'
            value_template: "{{ state_attr('sensor.barad_dur_storage_c', 'AvailableSpaceMB') | float(0) }}"
            unit_of_measurement: GB
        data_disk:
            friendly_name: 'Data Disk'
            value_template: "{{ state_attr('sensor.barad_dur_storage_d', 'AvailableSpaceMB') | float(0) }}"
            unit_of_measurement: GB
# York-II            
        nas_disk:
            friendly_name: 'Battletech'
            value_template: "{{ state_attr('sensor.york_ii_storage_c', 'AvailableSpaceMB') | float(0) }}"
            unit_of_measurement: GB
        hass_disk:
            friendly_name: 'Media'
            value_template: "{{ state_attr('sensor.york_ii_storage_e', 'AvailableSpaceMB') | float(0) }}"
            unit_of_measurement: GB

Screenshot_1

I get values in MB with 3 digits after point, but i want GB and TB (for a Media drive). | round(0) did not work. I mean, this digits should look like 311.1 GB for System, etc.
Also, please help with power status (want it yellow if system powered, so far unable to get that)

Btw, great app. Way better than IOTLink.

I think you should’ve created a new topic for this, as it has nothing to do with Hass.Agent itself.

I am curious if I don’t see CPU temperatures, power consumption, and fan speed sensors builtin into HASS.Agent (see screenshot below), I would have to also install LibreHardwareMonitor and access this data via its WMI classes?
image

I am facing a problem.

When the media_player.computer is idle, the volume level is displayed incorrectly. It always displays as 0%. But after starting the media, the volume is displayed correctly. After turning off the media becomes 0% again.

At the same time, audio_default_device_volume sensor always shows the correct value.

Is there any way to fix this?

Thanks @flyinglow . Was going crazy figuring out why the last_active sensor sometimes work as expected and sometimes not. For me it was the ps4 controller.

1 Like

Hello everybody! I would really like to thank the author about this wonderful piece of software, that makes me integrate perfectly my pc into my HA setup :slight_smile: I am so happy for that!

I have a little question about the MQTT setup.

In the picture you can see the resulting MQTT from HASS.Agent: it publishes a lot of stuff under the topic “sensor”; “mexdell” il the name I gave to my pc, but what I notice is that duplicated topics are published, as “battery/battery_charge_status” and “battery_charge_status”.

I realized that the latter is the discovery topic (maybe) for HA, but since I am very very focused on the tidiness of my setup, I would like to know if is it possible to personalize how topic are structured!

Can anybody help me? :slight_smile:

Is anyone here using the hass.agent media player to play tts? If so, I need help.
My volume on my computer is set to 90%, that is where I like it. Of course, I don’t want the tts notifications blaring at me at 90%!! but the media_player volume is directly tied to the computer volume so when I set the media_player to a reasonable 20% for notifications, the computer volume gets set there too. I have made some work arounds by setting volume, delay 5 sec, play notifications, delay 5 sec, reset volume.

Would be so much better to have separate volumes for the hass.agent media_player…

Any ideas?

1 Like

In case anyone comes roaming through here in the future, function keys (e.g. F1, F2) don’t work above F12 for quick action hotkeys, even though they register when setting them up. All the regular ones work fine though!

1 Like

Today, when I logged into my Home Assistant instance, I saw a repair suggestion:

I have not fully integrated HASS.Agent yet in my instance (and this error is for some of my other entities) but wanted to check if any changes are needed for the integration.

1 Like

Hi @wwwescape, it’s being worked on and will get fixed before then :slight_smile: Thanks!

6 Likes

Thanks for the confirmation. :+1: