HASS.Agent
HASS.Agent copied to clipboard
Bug: Powershell Sensor stay "unknown" after HA restart or reload of integration
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:
Sensor unknown:
Send & Activate Sensors:
Sensor working again:
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](IEnumerable
1 source, Func2 predicate)+MoveNext() at System.Linq.Enumerable.TakeWhileIterator[TSource](IEnumerable
1 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 -->
has someone looked into this allready?
any update on this?
For me it constantly says "Unknown".
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 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.
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 :)