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

Hello!

I’m sending Frigate notifications to my computer and I’ve found a curious issue.

Using the API directly, I get no image:


I must manually add the address for it to work:

But when I try the native HA API without the address it works:

I’m not sure if this is worthy of opening an issue, so let me know!

So nothing comes up in the HASS logs other then when it sends a notification to my other system.

2022-11-28 12:36:23.829 DEBUG (MainThread) [custom_components.hass_agent.notify] Preparing notification
2022-11-28 12:36:23.829 DEBUG (MainThread) [custom_components.hass_agent.notify] Sending notification

I also checked the application logs and it seems to indicate everything is all good. Then it throws an error I dont fully understand but it seems to point to a port issue. I have tried adding manual firewall rules, even disabling the firewall all without any change. This is on a pretty fresh copy of Windows 11 Pro, I am not hosting any services on this machine.

2022-11-28 12:35:53.973 -07:00 [INF] [MAIN] HASS.Agent version: 2022.14.0
2022-11-28 12:35:53.975 -07:00 [INF] [MAIN] Extended logging enabled
2022-11-28 12:35:53.977 -07:00 [INF] [SETTINGS] Config storage path: C:\Users\Jeffrey\AppData\Roaming\LAB02 Research\HASS.Agent\config
2022-11-28 12:35:54.040 -07:00 [INF] [SETTINGS] Configuration loaded
2022-11-28 12:35:54.042 -07:00 [INF] [LOCALIZATION] Selected UI culture: [en] English
2022-11-28 12:35:54.166 -07:00 [INF] [SETTINGS_QUICKACTIONS] Config not found, no entities loaded
2022-11-28 12:35:54.182 -07:00 [INF] [SETTINGS_COMMANDS] Loaded 2 entities
2022-11-28 12:35:54.367 -07:00 [INF] [SETTINGS_SENSORS] Loaded 4 entities
2022-11-28 12:35:54.369 -07:00 [INF] [MQTT] Identifying as device: (redacted)
2022-11-28 12:35:54.369 -07:00 [INF] [SERVICE] Local install path: C:\Program Files (x86)\LAB02 Research\HASS.Agent Satellite Service\
2022-11-28 12:35:54.370 -07:00 [INF] [LOCALAPI] Disabled
2022-11-28 12:35:54.372 -07:00 [INF] [MQTT] Connecting ..
2022-11-28 12:35:54.395 -07:00 [INF] [MQTT] Connected
2022-11-28 12:35:54.409 -07:00 [INF] [HASS_API] Home Assistant version: 2022.11.4
2022-11-28 12:35:54.436 -07:00 [INF] [MEDIA] Ready
2022-11-28 12:35:54.438 -07:00 [INF] [NOTIFIER] Ready
2022-11-28 12:35:54.448 -07:00 [INF] [MEDIA] Now playing: (redacted)
2022-11-28 12:35:54.463 -07:00 [INF] [MEDIA] New state: Paused
2022-11-28 12:35:54.552 -07:00 [INF] [HASS_API] System connected with http://192.168.70.205:8123
2022-11-28 12:35:56.384 -07:00 [INF] [MQTT] Initial registration completed
2022-11-28 12:38:09.458 -07:00 [FTL] [PROGRAM] FirstChanceException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
 ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
   at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer)

Thought I should also note, that if I add it manually using the the local API, notifications work just fine. But of course there is no media fucntion and sending TTS annoucements to my system is the main reason i use it.

Just wanted to say thank you. Use this on Windows 11 and it works great. Doesn’t use any noticeable resources. I had started my own self baked solution using Electron but it was a resource hog, then I found your project and my life is easy.

3 Likes

In your first screenshot, I suspect Home Assistant just sends the url as-is, you can verify that if the following entry exists in your logs:

[STORAGE] Unable to download image: only HTTP uri's are allowed, got: {uri}

With the third screenshot, HA parses it to a valid url which HASS.Agent can then use.

1 Like

Note: you don’t have to do anything with the firewall if you’re using mqtt.

Are you comfortable with using regedit? If so, could you please shutdown HASS.Agent, then open regedit and open the following key:

HKEY_CURRENT_USER\Software\LAB02Research\HASSAgent

There should be a value called DeviceSerialNumber. Change the data a bit, doesn’t matter what, for instance just the first letter/number.

Then restart Home Assistant, and afterwards restart HASS.Agent. See if that triggers autodiscovery.

Thanks @503Dev! Nice to hear :smiley:

1 Like

Thank you for helping to diagnose. I changed the serial, restarted HASS then the app with no change. I thought it may be due to having setup the notfications using local API, so I removed that and again changed the serial and rebooted HASS then the app. Still nothing. The logs show the same error as before. If I enable the local API all works perfectly except there is no media player discovered.

Does the autodiscovery rely on MDNS or somthing? I do have a unique setup with IOT Vlans however all my firewall rules are correct and everything involved should have access to each other. The only thing I can think of is I have MDNS disabled due to an issue with unifi mdns and multiple vlans.

edit: i did try enabling mdns to see if it would help but it did not, but maybe i needed to reset the serial after that?

I’m not sure when this started happening but my Powershell sensors are behaving very strangely. I have most sensors set at 300 seconds however I can see that they are triggering too frequently. In Windows task manager the ps1 scripts being executed constantly within a few seconds of each other which causes my CPU to go about 90%. I can see the values being updating via MQTT at the same rate.

Hi, have you managed to work this out? I have my lan and hassio network as separate vlans too. I installed (upgraded) hass agent on on of computers and it does not show in autodiscovery. It shows in mqtt.
I have another PC in my LAN and it showed in autodiscovery when i upgraded my hass.agent on it few weeks ago. Don’t know, what’s the difference.

Older PC has hass.agent version 2022.14.0, newer has 2022.20.0.0

No I still havent. I think it is somthing to do with the new client. Because my old PC continues to work perfectly even with the new client software installed now. Might see if I can try installing with an old client software and upgrading it.

Hm… where did you get version 2022.20.0.0? Latest is 2022.14.0… at least my PC’s hass.agent says so…?

I’m pretty sure, it was 2022.20.0.0 yesterday in mqtt, but today, it says 2022.14.0 (it’s retained message)

hass.agent/devices/PAVLINKA-TABLET {"serial_number":"7d411ec2-b701-46e2-b583-ed49764dacd7","device":{"identifiers":"hass.agent-PAVLINKA-TABLET","manufacturer":"LAB02 Research","model":"Microsoft Windows NT 10.0.19045.0","name":"PAVLINKA-TABLET","sw_version":"2022.14.0"},"apis":{"notifications":true,"media_player":true}}

edit: found it, it comes from satellite

"device":{"identifiers":"hass.agent-PAVLINKA_TABLET-satellite","manufacturer":"LAB02 Research","model":"Microsoft Windows NT 10.0.19045.0","name":"PAVLINKA_TABLET-satellite","sw_version":"2022.20.0.0"},

Hm… i guess that author will have to explain… if i click “check for updates” v14 is latest.

No it only uses mqtt. Just to make sure: sensors and commands are working fine on that machine?

This is difficult to debug, as I can’t reproduce it and there are no apparent logs. Could you maybe try closing hass.agent on both devices, then removing the hass.agent integration in HA, then reboot HA, and then start hass.agent again on the device that’s now failing? Perhaps even restart HA again after this.

Interesting, I’ll look into it, thanks for reporting

HASS.Agent and the Satellite Service use different versioning. HASS.Agent is currently at 2022.14.0, and the service at 2022.20.0 - but this is legacy, I’ll bind the service’s versioning to the agent, since it never gets updated without a agent update as well.

Ya so to give a more complete picture. I had computer01 setup when your app first came out, and it worked flawlessly. I have slowly upgraded it to the new versions and it continues to work just fine.

I setup a new computer and installed the new version of the app and mqtt worked imediatly without issues, but the notifiation and media player never auto detected. So I manually setup the API and notifications work perfectly now, but media player still does not work. So the issue is with the auto detection. What ever magic is supposed to be happening is not and unfortunatly there is not way to manaully setup the media player as far as I can tell.

I will try those steps later today and report back if it helped. I did try older version of the agent software, but I dont think I have tried removing the intergration fully yet. So I will try that.

All fixed. Thank you very much SamKr

So I deleted the ingtergrations, then removed the add on from HACS. Restarted, reinstalled via HACS, Restarted again. Poof everything showed up via autodiscovery.

I actually got two entrys for my new machine because I still had the api on, but i deleted the extra entry, turned it off in the agent and restarted HASS and all is working perfectly again.

Thanks again.

1 Like

Hey Elkropac, I managed to get mine working. Basically I deleted the intergrations from home assistant, then removed the Hass Agent from HACS. Restarted HASS, then reinstalled the HASS Agent and restarted HASS again. Then everything autodetected and worked again. Hope this will work for you as well.