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

Well there’s %appdata%\LAB02 Research\HASS.Agent but you already got that. There’s also a reg key: HKEY_CURRENT_USER\Software\LAB02Research\HASSAgent.

Let me know if that fixes it

I tried the process again including nuking the reg key but that still hasn’t fixed it. I enabled the local API and added it manually which works too. But I want the media player part so I removed it all and tried again but still doesn’t auto-detect. Very strange. The local app when I reinstalled still had “autostart” enabled during the setup process so it has remembered that setting somewhere but it seems unlikely to be that. I also tried a new device name and generating a new ID for MQTT but none of that helped either. It’s really strange how the other PCs have worked (albeit after a few reboots) but this one just wont. All 4 PCs (3 working and 1 not) are on the same OS version, and are AM4 Ryzen systems. They’re all connected to the same network switch with the same network settings (from DHCP). I tried with the firewall disabled on the problem PC too. I’ll try to figure how to turn on full debug level logging for it and see if I can get anything from that. Any tips on what I need to enable in the logger would be most welcome :slight_smile:

Really weird. It’d be great if you could enable extended logging. You can do so by adding/modifying this to your configuration.yaml:

logger:
  default: warning
  logs:
    custom_components.hass_agent: debug

I use the Log Viewer addon to easily view logging output.

Is there any way to open a .exe file or a program using hass agent?

Yes you can use a Custom command and point it to the file

So in the custom box I can put C:\users…[.exe] and it would open the directed file?

Yep, make sure to put it between quotes if it contains spaces

Ok, thanks

Excellent integration!! Came over from IOTLink, replicated most if not all functions I needed, very happy with it.

Just a minor question, is there a command line HASS.Agent.exe option to restart the local app?
I know there is ‘update’ but it does not close a running instant.
I’m looking for a way to close an existing/running instant and restart.

TIA

Thank you @JTPublic :smiley:

Yep you can simply use restart to do that

Sorry, but how do you issue a restart?
My problem is that intermittently, hass.agent disappears after my PC wakes up. ie it is no longer running. The system tray icon is gone.
I created a Task Scheduler job to start hass.agent when it wakes up but then I sometimes get two instances of hass.agent running that also causes problems.
How to best solve this?
thanks

@sammyke007 I tried running “HASS.Agent.exe restart”, but it just timeout waiting for previous instance to close after 20 seconds. That’s from elevated Command Prompt.
If I exited the app first, yes, ‘restart’ works.

No big deal, I can kill the app first then restart.

On rare occasions, the app became nonresponsive, like all sensors become unavailable.
And from IOTLINK experiences :slight_smile: , want to have a way to restart the app.

Thanks anyway.

Hey @fantangelo, you can indeed run HASS.Agent restart (elevated) and it should restart. But that’s really weird behaviour.

If you have a scheduled task, and you have HASS.Agent’s own ‘start-on-login’ enabled, you could end up with two instances (and get errors). So best to stick to one. It’s fine to just use the scheduled task, but disable HASS.Agent’s method through its config panel.

You could set the scheduled task to start on login with a delay of a minute or so, just to check if that works.

If the systray icon disappears, check the task manager to make sure it’s not still runnning in the background. Let me know how it all goes!

You can just use a bat to kill the old instance, and then run hass.agent. Note: if you do so from an elevated prompt, HASS.Agent will start elevated - not a problem, but just something to keep in mind.

The non responsiveness is weird though. Is there anything showing in the logs? You could also temporarily enable extended logging in the config page, and see if that comes up with anything.

Thanks, I will try “HASS.Agent.exe restart”

Hello. Thanks for making this add-on. I appreciate it.
I have a simple requirement.
If I’m not active on my desktop for 15 mins, I want to switch off the lights in my room.

When I try to use the Desktop Last Active attribute, HA says that HASS.agent passes it a date and it’s expecting a number. In Lovelace, it shows 17 hours ago, that’s what I want to use in there a automation, but that value is not available. How do I fix it?

Thank you for the suggestions.
Just one of the laptops has this rare behavior, I suspect more the network connect and/or the user than HASS.Agent itself :white_check_mark:
I’ll check the log when that happens again.

Sort of related, I used the powershell sensor as a time-based automation to restart HASS.Agent app at intervals (1800s).

I have defined other similar PS sensors for local automation and work well.

Looks to me ‘local sensor’ are initialized regardless of the UpdateInterval at app start/restart.
In this case, the restart PS sensor command was executed and becomes a restart loop.

Is there a way to disable the initialization of a sensor for such automation?

Firstly, brilliant work on this - moved from HASS Workstation Service and this replicates all the functionality and loads more! Delighted with this.

Two thoughts - an ask and a bug!

Bug - I’ve installed on three PCs and it works fine, apart from I occasionally get the Hass.agent notification popping up in windows saying MQTT: Disconnected - this flicks on and off constantly for about 2 mins and then seems to resolve itself. Is there anything off here or is there a way to turn off this annoying notification?!?

Feature - secondly - as I’m installing on three PCs and likely will do on 4-5 more, is there any way to standardise the sensors and commands from the Home Assistant side? It just saves having to recreate 7-8 times every change I make or feature that is added that I wish to use? Just a thought

Great work though, loving this!

You can use one of the examples in the docs, for instance:

template:
  - binary_sensor:
      - name: "User Active"
        state: "{{ as_timestamp(now(),0) - as_timestamp(states('sensor.desktop_lastactive'),0) < 60 }}"

The 60 represent seconds, so change it to 900 for 15 minutes. You can use this binary_sensor to trigger an automation, switching off your lights.

I think you’re using the Powershell command as a sensor. The sensor variant is meant to periodically run a PS script that returns a value, which is then send as a sensor value to HA. So that’ll be initialized on start and then runs periodically, by design.

If you want it to execute when you want to, create a Powershell command. But of course you couldn’t trigger it from HA if you aren’t connected, so I guess you should just create a scheduled task.