hass-agent / HASS.Agent

Unofficial development project for the HASS.Agent platform.
https://hass-agent.io
MIT License
406 stars 12 forks source link

Bug: Audio sensor not updating #179

Open dfrazao opened 1 month ago

dfrazao commented 1 month ago

Describe the bug I'm having an issue with the audio sensor, the value is not being updated and in the sensor configuration the last known value is infinite. I've added the logs below, with screenshots of the sensor configuration window and the specific sensor configuration.

Expected behavior The audio sensor being updated

Screenshots image image

Misc info:

Please check what's applicable (multiple answers possible):

Logs

HASS.Agent Logs:

2024-10-09 12:23:35.973 +01:00 [INF] [MAIN] HASS.Agent version: 2.1.0
2024-10-09 12:23:35.978 +01:00 [INF] [MAIN] Extended logging enabled
2024-10-09 12:23:35.981 +01:00 [INF] [SETTINGS] Config storage path: C:\Users\frazas\AppData\Local\HASS.Agent\Client\config
2024-10-09 12:23:36.102 +01:00 [INF] [SETTINGS] Configuration loaded
2024-10-09 12:23:36.106 +01:00 [INF] [LOCALIZATION] Selected UI culture: [en] English
2024-10-09 12:23:36.488 +01:00 [DBG] [RADIOMGR] Initialization started
2024-10-09 12:23:36.547 +01:00 [INF] [RADIOMGR] Radio management permission granted
2024-10-09 12:23:36.548 +01:00 [DBG] [RADIOMGR] Enumerating proximity/NFC devices
2024-10-09 12:23:36.563 +01:00 [INF] [RADIOMGR] Ready
2024-10-09 12:23:38.611 +01:00 [INF] [INTERNALSENSORS] Ready
2024-10-09 12:23:39.186 +01:00 [INF] [VIRTDESKT] Virtual Desktop Manager initialized
2024-10-09 12:23:39.187 +01:00 [DBG] [AUDIOMGR] initializing
2024-10-09 12:23:39.838 +01:00 [INF] [AUDIOMGR] initialized
2024-10-09 12:23:39.853 +01:00 [INF] [SETTINGS_QUICKACTIONS] Config not found, no entities loaded
2024-10-09 12:23:39.880 +01:00 [INF] [SETTINGS_COMMANDS] Loaded 7 entities
2024-10-09 12:23:39.963 +01:00 [FTL] [PROGRAM] FirstChanceException: Process with an Id of 12716 is not running.
System.ArgumentException: Process with an Id of 12716 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at System.Diagnostics.Process.GetProcessById(Int32 processId)
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetSessionDisplayName(InternalAudioSession session) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 124
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 144
2024-10-09 12:23:39.979 +01:00 [ERR] [AUDIOMGR] failed to retrieve devices: error retrieving session information for Speakers (NVIDIA High Definition Audio)
HASS.Agent.Shared.Managers.Audio.Exceptions.AudioSessionException: error retrieving session information for Speakers (NVIDIA High Definition Audio)
 ---> System.ArgumentException: Process with an Id of 12716 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at System.Diagnostics.Process.GetProcessById(Int32 processId)
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetSessionDisplayName(InternalAudioSession session) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 124
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 144
   --- End of inner exception stack trace ---
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 166
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(MMDevice mmDevice) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 133
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDevices() in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 230
2024-10-09 12:23:39.999 +01:00 [INF] [SETTINGS_SENSORS] Loaded 3 entities
2024-10-09 12:23:40.391 +01:00 [INF] [LOCALAPI] Disabled
2024-10-09 12:23:40.392 +01:00 [INF] [MQTT] Identifying as device: DES
2024-10-09 12:23:40.400 +01:00 [INF] [MQTT] Connecting ..
2024-10-09 12:23:40.408 +01:00 [INF] [SERVICE] Local install path: C:\Program Files\HASS.Agent Satellite Service\Service\
2024-10-09 12:23:40.505 +01:00 [INF] [MEDIA] Ready
2024-10-09 12:23:40.509 +01:00 [INF] [NOTIFIER] Ready
2024-10-09 12:23:40.521 +01:00 [INF] [MEDIA] Now playing: Drake - Too Good
2024-10-09 12:23:40.545 +01:00 [WRN] [MQTT] Not connected, message dropped (won't report again for 5 minutes)
2024-10-09 12:23:40.546 +01:00 [INF] [MEDIA] New state: Playing
2024-10-09 12:23:40.572 +01:00 [ERR] [AUDIOMGR] failed to retrieve devices: error retrieving session information for Speakers (NVIDIA High Definition Audio)
HASS.Agent.Shared.Managers.Audio.Exceptions.AudioSessionException: error retrieving session information for Speakers (NVIDIA High Definition Audio)
 ---> System.ArgumentException: Process with an Id of 12716 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at System.Diagnostics.Process.GetProcessById(Int32 processId)
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetSessionDisplayName(InternalAudioSession session) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 124
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 144
   --- End of inner exception stack trace ---
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 166
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(MMDevice mmDevice) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 133
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDevices() in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 230
2024-10-09 12:23:40.938 +01:00 [INF] [MQTT] Connected
2024-10-09 12:23:41.134 +01:00 [INF] [HASS_API] Home Assistant version: 2024.10.1
2024-10-09 12:23:41.980 +01:00 [ERR] [AUDIOMGR] failed to retrieve devices: error retrieving session information for Speakers (NVIDIA High Definition Audio)
HASS.Agent.Shared.Managers.Audio.Exceptions.AudioSessionException: error retrieving session information for Speakers (NVIDIA High Definition Audio)
 ---> System.ArgumentException: Process with an Id of 12716 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at System.Diagnostics.Process.GetProcessById(Int32 processId)
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetSessionDisplayName(InternalAudioSession session) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 124
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 144
   --- End of inner exception stack trace ---
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 166
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(MMDevice mmDevice) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 133
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDevices() in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 230
2024-10-09 12:23:42.430 +01:00 [INF] [MQTT] Initial registration completed
2024-10-09 12:23:42.638 +01:00 [ERR] [AUDIOMGR] failed to retrieve devices: error retrieving session information for Speakers (NVIDIA High Definition Audio)
HASS.Agent.Shared.Managers.Audio.Exceptions.AudioSessionException: error retrieving session information for Speakers (NVIDIA High Definition Audio)
 ---> System.ArgumentException: Process with an Id of 12716 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at System.Diagnostics.Process.GetProcessById(Int32 processId)
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetSessionDisplayName(InternalAudioSession session) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 124
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 144
   --- End of inner exception stack trace ---
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 166
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(MMDevice mmDevice) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 133
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDevices() in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 230
2024-10-09 12:23:43.185 +01:00 [INF] [HASS_API] System connected with https://ha.frazas.duckdns.org
2024-10-09 12:23:44.679 +01:00 [ERR] [AUDIOMGR] failed to retrieve devices: error retrieving session information for Speakers (NVIDIA High Definition Audio)
HASS.Agent.Shared.Managers.Audio.Exceptions.AudioSessionException: error retrieving session information for Speakers (NVIDIA High Definition Audio)
 ---> System.ArgumentException: Process with an Id of 12716 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at System.Diagnostics.Process.GetProcessById(Int32 processId)
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetSessionDisplayName(InternalAudioSession session) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 128
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 144
   --- End of inner exception stack trace ---
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(String deviceName, InternalAudioSessionManager internalAudioSessionManager) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 166
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDeviceSessions(MMDevice mmDevice) in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 133
   at HASS.Agent.Shared.Managers.Audio.AudioManager.GetDevices() in D:\a\HASS.Agent\HASS.Agent\src\HASS.Agent\HASS.Agent.Shared\Managers\Audio\AudioManager.cs:line 230

Satellite Service logs:

2024-10-09 11:02:49.198 +01:00 [INF] [MAIN] Version: 2.1.0.0
2024-10-09 11:02:49.218 +01:00 [INF] [MAIN] Service started, initializing ..
2024-10-09 11:02:49.525 +01:00 [INF] [MAIN] Running as a service, initializing lifetime manager
2024-10-09 11:02:49.566 +01:00 [INF] [LIFETIMEMANAGER] Initialized
2024-10-09 11:02:49.730 +01:00 [INF] [WORKER] Startup completed, commencing execution ..
2024-10-09 11:02:50.074 +01:00 [INF] [SETTINGS] Config storage path: C:\Program Files\HASS.Agent Satellite Service\Service\config
2024-10-09 11:02:50.081 +01:00 [INF] [SETTINGS] No config found, storing default settings
2024-10-09 11:02:50.158 +01:00 [INF] [SETTINGS] No MQTT config found, storing default settings
2024-10-09 11:02:50.169 +01:00 [INF] Application started. Hosting environment: Production; Content root path: C:\Program Files\HASS.Agent Satellite Service\Service\
2024-10-09 11:02:50.226 +01:00 [INF] [MQTT] Identifying as device: DES-satellite
2024-10-09 11:02:50.249 +01:00 [INF] [SETTINGS] Configuration stored
2024-10-09 11:02:50.257 +01:00 [INF] [MQTT] Connecting ..
2024-10-09 11:02:50.272 +01:00 [INF] [RPCMANAGER] Listening
2024-10-09 11:03:50.670 +01:00 [WRN] [MQTT] Disconnected: UnspecifiedError
2024-10-09 11:03:50.686 +01:00 [FTL] [MQTT] Error while connecting: Connecting with MQTT server failed (NotAuthorized).
MQTTnet.Adapter.MqttConnectingFailedException: Connecting with MQTT server failed (NotAuthorized).
   at MQTTnet.Client.MqttClient.Authenticate(IMqttChannelAdapter channelAdapter, MqttClientOptions options, CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ConnectInternal(IMqttChannelAdapter channelAdapter, CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ConnectAsync(MqttClientOptions options, CancellationToken cancellationToken)
   at MQTTnet.Client.MqttClient.ConnectAsync(MqttClientOptions options, CancellationToken cancellationToken)
   at MQTTnet.Extensions.ManagedClient.ManagedMqttClient.ReconnectIfRequiredAsync(CancellationToken cancellationToken)
2024-10-09 11:22:40.550 +01:00 [INF] [SETTINGS] Configuration stored
2024-10-09 11:22:40.550 +01:00 [INF] [SETTINGS] Received MQTT settings stored
2024-10-09 11:22:40.551 +01:00 [INF] [MQTT] Reloading configuration ..
2024-10-09 11:23:27.682 +01:00 [INF] [MQTT] Initializing ..
2024-10-09 11:23:27.682 +01:00 [INF] [MQTT] Identifying as device: DES-satellite
2024-10-09 11:23:27.682 +01:00 [INF] [SETTINGS] Configuration stored
2024-10-09 11:23:27.683 +01:00 [INF] [MQTT] Connecting ..
2024-10-09 11:23:27.696 +01:00 [INF] [MQTT] Connected
2024-10-09 11:23:28.601 +01:00 [INF] [MQTT] Initial registration completed
2024-10-09 11:23:29.710 +01:00 [INF] [MQTT] Initial registration completed
2024-10-09 11:27:28.025 +01:00 [INF] [SETTINGS] Received MQTT settings are identical, nothing to do
2024-10-09 11:53:17.127 +01:00 [INF] [SETTINGS] Received MQTT settings are identical, nothing to do
2024-10-09 11:54:48.165 +01:00 [INF] [SETTINGS] Received MQTT settings are identical, nothing to do
2024-10-09 12:12:19.717 +01:00 [INF] [SETTINGS] Received MQTT settings are identical, nothing to do
amadeo-alex commented 1 month ago

Hello,

In the current version of HASS.Agent the audio sensor is of "multi" value - multiple separate sensors are created when you add "Audio" sensor. The infinite symbol is expected, could you please check if the sensors are present in Home Assistant / MQTT?

One thing that I've noticed though that there are multiple entries of failed session retrieval for "NVIDIA High Definition Audio" - I might add a logic that will stop printing those out after X iterations.

alxstojanovic commented 1 month ago

Hi, I believe that the user is referring to the Peak Volume function which just stopped working after upgrading to 2.1.0. I have a lot of automations and dashboards which update or do things based on whether Peak Volume has been 0 for some time or above 0 for a while, but as of last night all that has simply frozen. Screenshot 2024-10-28 at 09 30 37 Screenshot 2024-10-28 at 09 30 57

I tried also going through the Satellite Service route, but even the satellite sensor is not updating at all. Additionally, I've reinstalled hass agent once, rebooted both HAOS Server and the machine running HASS Agent but everything is still pretty frozen. The other computers which have not been upgraded yet to agent 2.1.0 are not experiencing this issue.

alxstojanovic commented 4 weeks ago

Hi, with some additional mucking about with the thing, I found that the entire audio sensor stops working after I reinstall the agent.

AJolly commented 3 weeks ago

Unsure if this is related, but mine is giving very wrong values for the default input device volume.