HASS.Agent icon indicating copy to clipboard operation
HASS.Agent copied to clipboard

Bug: Powershell Sensor stay "unknown" after HA restart or reload of integration

Open Zarox666 opened this issue 1 year ago • 6 comments

Describe the bug When restarting HA, or reloading the MQTT Integratrion any Powershell Sensor remains in an "unknown" state afterwards. When loging on to the Windows System and clicking on Send & Activate Sensors it imediately starts working again. This applies to sensors from the Service as well as from the Agent. Non-Powershell Sensors such as CPU Load do reconnect automaticaly.

Not sure if it is related, but also removed Sensors do not disappear (or become deletable) in HA even so there are no Sensors in HASS Agent or Satelite Service anymore.

To Reproduce Reload integration: image

Sensor unknown: image

Send & Activate Sensors: image

Sensor working again: image

Expected behavior Powershell Sensors should resume working like any other Sensor after reload of the MQTT integration or HA restart.

Screenshots see above

Misc info (please complete the following information):

  • Windows Server 2022 21H2
  • HASS.Agent version: 2022.14.0
  • Satelite Service Version: 2022.20.0.0

Logs HASS Satelite Service log for today: <-- Start of Logfile --> 2023-10-05 08:27:10.035 +02:00 [INF] [SENSORSMANAGER] Processing 2 received sensor(s), deleting 0 sensor(s) .. 2023-10-05 08:27:10.333 +02:00 [FTL] [SENSORSMANAGER] Error while publishing: Collection was modified; enumeration operation may not execute. System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.Generic.List1.Enumerator.MoveNextRare() at System.Linq.Enumerable.TakeWhileIterator[TSource](IEnumerable1 source, Func2 predicate)+MoveNext() at System.Linq.Enumerable.TakeWhileIterator[TSource](IEnumerable1 source, Func`2 predicate)+MoveNext() at HASS.Agent.Satellite.Service.Sensors.SensorsManager.Process() 2023-10-05 08:27:10.360 +02:00 [INF] [SENSORS] Modified single-value sensor: MinerInstances 2023-10-05 08:27:10.362 +02:00 [INF] [SENSORS] Modified single-value sensor: CPULoad 2023-10-05 08:27:10.362 +02:00 [INF] [SETTINGS_SENSORS] Stored 2 entities

<-- Reload of MQTT -->

2023-10-05 08:29:23.817 +02:00 [INF] [MQTT] Connected 2023-10-05 08:33:15.633 +02:00 [INF] [SENSORSMANAGER] Processing 2 received sensor(s), deleting 0 sensor(s) .. 2023-10-05 08:33:15.950 +02:00 [INF] [SENSORS] Modified single-value sensor: MinerInstances 2023-10-05 08:33:15.951 +02:00 [INF] [SENSORS] Modified single-value sensor: CPULoad 2023-10-05 08:33:15.952 +02:00 [INF] [SETTINGS_SENSORS] Stored 2 entities

<-- End of Logfile -->

Zarox666 avatar Oct 05 '23 06:10 Zarox666

has someone looked into this allready?

Zarox666 avatar Oct 30 '23 07:10 Zarox666

any update on this?

Zarox666 avatar Dec 21 '23 09:12 Zarox666

For me it constantly says "Unknown".

EpicLPer avatar Feb 29 '24 14:02 EpicLPer

I gave up waiting for this to be fixed, and instead use HAs RestAPI from Powershell directly: https://developers.home-assistant.io/docs/api/rest/

What I havent yet figured out, is how I can wait with Powershell for an Event triggered by HA. Once I have that, I can finaly uninstall the HASS Agent.

Zarox666 avatar Feb 29 '24 15:02 Zarox666

I gave up waiting for this to be fixed, and instead use HAs RestAPI from Powershell directly: https://developers.home-assistant.io/docs/api/rest/

What I havent yet figured out, is how I can wait with Powershell for an Event triggered by HA. Once I have that, I can finaly uninstall the HASS Agent.

I mean, for your specific case the first thing coming to mind is: You simply start the PowerShell script via a command from Hass.Agent, this way you don't have to wait for anything inside your script.

EpicLPer avatar Feb 29 '24 16:02 EpicLPer

And on another note: There is a newer fork of HASS.Agent that is trying to make it a better project, maybe worth a look for you: https://github.com/hass-agent/HASS.Agent Same bug there so far but I reported it just a few minutes ago, hopefully they'll take a look at it :)

EpicLPer avatar Feb 29 '24 16:02 EpicLPer