LAB02-Research / HASS.Agent

Windows-based client for Home Assistant. Provides notifications, quick actions, commands, sensors and more.
https://hassagent.lab02-research.org
MIT License
1.56k stars 68 forks source link

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

Open Zarox666 opened 12 months ago

Zarox666 commented 12 months ago

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):

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 commented 11 months ago

has someone looked into this allready?

Zarox666 commented 9 months ago

any update on this?

EpicLPer commented 7 months ago

For me it constantly says "Unknown".

Zarox666 commented 7 months ago

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.

EpicLPer commented 7 months ago

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 commented 7 months ago

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 :)