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

Thanks for the quick response! I should be quicker to try out these things now that I have a good use case for setting up HASS.Agent. The existing implementations of IoTLink are working fine so “if it ain’t broke don’t fix it”.

Is it possible to setup the HASS.Agent to work as a Windows Service or something else that would allow it to function in a global sense? IoTLink currently allows me to sleep the PC regardless of who is logged in but right now HASS.Agent only sleeps if I’m logged in, not my son, presumably because I original set it up under my user account. I saw mentioned during setup or in the doc somewhere about user specific registry settings IIRC so I assume that’s why.

You’re really in sync with my development cycle @bverkron :yum: I’ve been working on a ‘satellite service’ which allows you to run specified sensors/commands in the background, regardless of being logged on. Been quite some work as I want it done properly, but the beta should be released within a week or two.

1 Like

Nice! Good plan.

In the meantime what’s the best way to migrate installation to my sons user account? It’s his PC so if it can only function under one account for now I want it to be under his. I tried launching the agent under his account and I get a permissions error. If I run the installer under his account it gives me options to modify / repair / uninstall. I guess backup the config and re-install under his account?

Edit: this is an interesting usecase, multiple users on the same machine with parallel running instances. It shouldn’t be too hard to have HASS.Agent support this out-of-the-box. I’ll put it on my todo list. For now, you can follow the below instructions :slight_smile:


The current installer runs under administrative privileges, so even if it’s installed in a user folder, it’ll still get registered system wide. The reason for the privileges is that it has to reserve a port to receive notifications.

Tthe easiest way to install HASS.Agent in any user account (multiple accounts isn’t a problem) is to download the .zip instead of the installer. Extract it to any folder in which it has write access (so no program files). The onboarding will help you enable start-on-login.

If you just want the user that used the installer to receive notifications, you don’t have to do anything. Just make sure to disable notifications in the other accounts.

If you want a user other that the one that used the installer to receive notifications, run the following in an elevated command prompt:

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

If you want all users to be able to receive notifications, that’s no problem either. Decide on a port number for each user. Then run this command for every port number (change 5115):

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

Then run the following command for each port in an elevated command prompt (change 2x 5115):

netsh advfirewall firewall add rule name="HASS.Agent Notifier 5115" dir=in action=allow protocol=TCP localport=5115

You can only auto-update the account that uses the installer. The others need to be done manually with the zip release.

This all is very cumbersome, I know. It’ll get better in future versions. If there’s anything more I can do to help, let me know!

1 Like

Problem with setup: I already have one PC working as expected, however on the second I end without any possibility to create sensors or actions.
Installation happend with no problems/errors. I can send notification to the PC. The PC is not in MQTT (the other one is there as a device).

When the agent is started I get this picture

When I try and create a sensor I get this picture

I have tried to uninstall and install again. I have tried with different client names, I have tried to reconfigure the MQTT part, I have tried in MQTT with both IP address and homeassistant.local
I have tested the API and token, it report “connection OK” and show the correct versionnumber for HA.

Here is my current MQTT configuration

Im open for any good idea.

Hi @khvej8, that’s a known DPI scaling bug. You probably have Windows scaling on 110% (or higher) on that machine. The bug’s fixed in the next version, but until that’s released a simple workaround is to temporarily set your Windows scaling on 100% while configuring the commands and sensors.

Hope this helps!

1 Like

Worked perfectly, thanks

1 Like

I would like to have HA turn on my printer via a power socket when a print dialog window opens on my PC.

I sort of got this working with the HASS workstation service but I can’t get the service to run reliably so need another way.

Will your HASS.Agent do this ??

Hi @gaz99. So you want a sensor that detects the print dialog, and in HA, you have that sensor hooked to a powersocket switch that turns on your printer, right? That’s possible, you can use a ‘NamedWindowSensor’ (set the update value low).

However, a better way would be for me to make a sensor that sends the amount of files in your printer queue. Then you can easily make an automation that turns on your printer, as soon as the queue is higher than one. I’ll put it on the todo list. For now, you can use the NamedWindowSensor.

Let me know how it goes!

1 Like

That was easy, working as I want, when I print a document, the print window pops up, the smart plug turns the printer on.

The pop up goes away when the print job has been sent to the printer so I set the printer to turn off after few minutes.

I’ll have a play with the print queue version when you get that done.

BTW, when installing I got a warning that the language ‘English (Australia) - US’ is unknown. I don’t have any quick actions yet so not sure what this should do.

Thanks.

1 Like

Great! Really clever idea as well to save standby power, nicely done :slight_smile:

BTW, when installing I got a warning that the language ‘English (Australia) - US’ is unknown.

Yep known bug, will also be fixed in the upcoming release.

Thanks for your work on this!

I was previously using sleevezipper’s HASS Workstation and had a few bugs impacting me, and your client not only solves those but it also gives me the notifications part, which I was looking for.

Is it possible to use the notification service with tailscale so as to have the same ip always being valid in the configuration?

On my setup, my laptop will switch between 2 IPs depending on if it is docked (wired ethernet) and undocked (wifi).

I tried using the tailscale IP but then I am unable to send notifications to HASS Agent - I assume it must be an issue with the port.

Thanks,

Hi @cromelex, glad to hear it :smiley:

That shouldn’t be a problem, I actually use tailscale myself as well. I presume you have tailscale configured in Home Assistant? What you can try first as a test, is to see if you can reach this page:

http://{tailscale_ip}:5115

Where you change {tailscale_ip} into the ip of the machine on which you want to show notifications. If you see ‘HASS.Agent Active’, the connection works. Ideally test this from another tailscale connected machine.

Oh and to be sure; sending notifications via a normal ip works right?

Very weird - I can access the page showing HASS.Agent Active from my other tailscale connected machines, but cannot send the notifications from HASS via the tailscale ip.

I have tailscale configured and can access the HASS machine (RPI4) outside my home network, so I would assume tailscale is working properly. I can also ping the the ip of the machine I want to notify from the command-line on my HASS instalation.

The notifications are working flawlessly with the normal IP.

Would I need any special configuration in tailscale that I might be missing?
Ultimately this isn’t a big deal for me, my laptop is docked 90% of time, but it would be a good to have.

On a separate note, regarding the WMI query for CPU Temp, I am getting an error from the Scope field - going from the example, do I need to set any specific path rather than the one form the example on the release notes? For this I am completely clueless. I do have OpenHardwareMonitor installed, but if I save the below in HASS.Agent as a sensor I get an error.

  • Example cpu temperature query for the latter:
    • Scope: .\ROOT\OpenHardwareMonitor
    • Query: SELECT value FROM Sensor WHERE Name LIKE “%CPU Core%” AND SensorType = “Temperature”

Thank you in advance,

I reproduced your configuration and you’re right, it won’t send notifications over Tailscale (I use Tailscale for MQTT which does work). There’s already a ticket created for this, but @frenck hasn’t responded since it was created almost three months ago :frowning:

It also doesn’t work for zerotier, so I’m affraid the addons don’t share the network with other addons. A solution could be to install tailscale on the rpi’s os itself instead of as an addon.

Regarding WMI, there was an error in the example, one of the backslashes got removed.
Try this one:

Scope: \\.\ROOT\OpenHardwareMonitor
Query: SELECT value FROM Sensor WHERE Name LIKE "%CPU Core%" AND SensorType = "Temperature"

Please note the two backslashes that start the scope.

By the way, if you can’t get your router to give the same ip regardless of wireless/wired, you could also make a notification group containing two notifier endpoints; one for each ip.

The latest hass.agent notifier version doesn’t give an error anymore when it can’t reach a client, so your logs won’t get polluted. Just send the notification and see which one gets it :smiley:

Brilliant, thanks for the feedback.

For tailscale, seems that it is a limitation - I am ok with this. I might just try your suggestion of setting up 2 notifier endpoints - I already do this with my tv and the log doesn’t get polluted with error due to client being unreacheable, as you mentioned.
I already use notification groups and was able to group HASS.Agent with my Android mobile clients and the TV without any issue. So it is all working as it should.

For WMI, I managed to get it working with your updated example.
I see it’s giving me 3 decimals and no Cº indicator - will you be updating this at some point? (i see post HASS.Agent: a new Windows based client to receive notifications, perform quick actions and much more! - #73 by SamKr mentioning the possibility of updating this).

For a Ryzen 5600X (AMD Zen3) I had to replace “%CPU Core%” with “%CPU Package%” (as that’s where the temperature gets populated in OpenHardwareMonitor - just sharing this here for future reference in case someone needs to do something similar.

Thanks again - I will make sure I include you in the next round of coffees I buy :grinning:

1 Like

Yep I’ll add the possibility to provide the sensor’s datatype in an upcoming version :slight_smile:

Thanks for sharing the WMI info, I’m collecting examples to update the wiki with as soon as the upcoming satellite service update is done.

Thanks again - I will make sure I include you in the next round of coffees I buy :grinning:

Thank you! You’re very welcome :smiley:

1 Like

When I set up a wmi query with Scope: .\ROOT\OpenHardwareMonitor and
Query: SELECT value FROM Sensor WHERE Name LIKE “%CPU Core%” AND SensorType = “Temperature” I get an error when activating it:

2022-04-07 15:09:42.415 +02:00 [FTL] [SENSORSMANAGER] Error while storing: Der Parameter ist ungültig. 
System.Management.ManagementException: Der Parameter ist ungültig. 
   at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
   at System.Management.ManagementPath.CreateWbemPath(String path)
   at System.Management.ManagementPath..ctor(String path)
   at System.Management.ManagementScope..ctor(String path)
   at HASSAgent.Shared.Models.HomeAssistant.Sensors.WmiQuerySensor..ctor(String query, String scope, Nullable`1 updateInterval, String name, String id)
   at HASSAgent.Settings.StoredSensors.ConvertConfiguredToAbstractSingleValue(ConfiguredSensor sensor)
   at HASSAgent.Sensors.SensorsManager.StoreAsync(List`1 sensors, List`1 toBeDeletedSensors)

What’s going wrong?

Hi @nightfever,

Can you please make sure your scope looks like this (note the double backslash at the beginning):

\\.\ROOT\OpenHardwareMonitor
1 Like