Try to run it again on new laptop it is still running
is in log file correct URL of your HA ? this seems like web socket address created from Api adresss did not started with HTTPS or http
Got more of the message this time:
[20220825T210411]-System.ArgumentException: Only Uris starting with 'ws://' or 'wss://' are supported. (Parameter 'uri')
at System.Net.WebSockets.ClientWebSocket.ConnectAsync(Uri uri, CancellationToken cancellationToken)
at HA_Desktop_Companion.Libraries.HAApi_Websocket.registerWebSocket()
at HA_Desktop_Companion.Libraries.HAApi_Websocket..ctor(String baseUrl, String apiToken, Logging logInstance, String webHookId, String remoteUiUrl, String cloudhookUrl)
at HA_Desktop_Companion.MainWindow.registrationAsync_Click(Object sender, RoutedEventArgs e)
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at Sys
I tired copy the URL from the log and paste it in browser and I got to my HA. So it seems to be correct.
In log I see this: [20220825T210344]-MAIN-URL:https://Random_stuff.ui.nabu.casa/
Could you please send me uncensored url in PM so I can visually inspect it ?
Thaank you so much for sharing and for sharing URL I manage to resolve WS error it was problem of nabucasa i implemented workaround. Please test following version:
We have ten releases already Thank you all for support and testing
The camera and mic is still stuck.
I turned on a Teams meeting then left it and got this:
[20220826T103421]-MAIN-Syncer Tick n:36
[20220826T103421]-API/ADD/DATA[free_ram]'442928'
[20220826T103421]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220826T103421]-API/ADD/SKIP/SAME/[battery_level]'100'=='100'
[20220826T103421]-API/ADD/SKIP/SAME/[battery_state]'Fully Charged'=='Fully Charged'
[20220826T103421]-API/ADD/DATA[currently_active_window]'Möte | Microsoft Teams'
[20220826T103421]-API/ADD/SKIP/SAME/[uptime]'43'=='43'
[20220826T103421]-API/ADD/DATA[camera_in_use]'True'
[20220826T103421]-API/ADD/DATA[microphone_in_use]'True'
[20220826T103421]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220826T103421]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220826T103421]-API/ADD/SKIP/SAME/[is_charging]'True'=='True'
[20220826T103422]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220826T103423]-API/ADD/DATA[cpu_usage]'44'
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-SENSOR/READ/True
[20220826T103423]-API -> {"data":[{"unique_id":"free_ram","type":"sensor","state":442928,"icon":"mdi:clock"},{"unique_id":"currently_active_window","type":"sensor","state":"Möte | Microsoft Teams","icon":"mdi:application"},{"unique_id":"camera_in_use","type":"binary_sensor","state":true,"icon":"mdi:camera"},{"unique_id":"microphone_in_use","type":"binary_sensor","state":true,"icon":"mdi:microphone"},{"unique_id":"cpu_usage","type":"sensor","state":"44","icon":"mdi:cpu-64-bit"}],"type":"update_sensor_states"}
[20220826T103423]-API CODE <- OK
[20220826T103423]-API <- "{\"free_ram\": {\"success\": true}, \"currently_active_window\": {\"success\": true}, \"camera_in_use\": {\"success\": true}, \"microphone_in_use\": {\"success\": true}, \"cpu_usage\": {\"success\": true}}"
[20220826T103433]-MAIN-Syncer Tick n:37
[20220826T103433]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220826T103433]-API/ADD/SKIP/SAME/[battery_state]'Fully Charged'=='Fully Charged'
[20220826T103433]-API/ADD/SKIP/SAME/[battery_level]'100'=='100'
[20220826T103433]-API/ADD/DATA[free_ram]'679708'
[20220826T103433]-API/ADD/DATA[currently_active_window]'Rebecca | Microsoft Teams'
[20220826T103433]-API/ADD/SKIP/SAME/[uptime]'43'=='43'
[20220826T103433]-API/ADD/SKIP/SAME/[camera_in_use]'False'=='False'
[20220826T103433]-API/ADD/SKIP/SAME/[microphone_in_use]'False'=='False'
[20220826T103433]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220826T103433]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220826T103433]-API/ADD/SKIP/SAME/[is_charging]'True'=='True'
[20220826T103433]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220826T103434]-API/ADD/DATA[cpu_usage]'14'
[20220826T103434]-SENSOR/READ/True
[20220826
So camera and mic is true, then false.
But the entity stays on:
10:26 is probably when I started up the app.
10:27 it noted that it was off.
10:28 I started the meeting
according to log.txt I left the meeting 10:34 (and I actually tried a few times in between)
But it is stable.
It crashed on me the first boot, but then I removed the trailing/
and it works.
Not sure if the /
was the issue or not but it works now
When I look at the registry I see this when the camera is not in use by Teams:
And this when it is in use:
The one called Microsoft.WindowsCamera_8wekyb3d8bbwe
is just for the Microsoft camera app as I can see.
yes each app has separed folder
if register is 0 it mean it is used if something else it is not
var endTime = subKey.GetValue("LastUsedTimeStop") is long ? (long)subKey.GetValue("LastUsedTimeStop") : -1;
if (endTime <= 0)
{
//MessageBox.Show(subKey.GetValue("LastUsedTimeStop").ToString());
return true;
}
it should work isn’t different app using the camera or mic ? are you sure ?
also are notifications finally working for you ?
Hmm…
I don’t know what is qualified as long
.
But if endtime is set to the value in registry a UNIX time, or -1 when it’s zero in registry.
That means when it is above 0 the camera is on.
if (endTime >= 0)
then true
Or am I wrong?
if it is above 0 mean that it is used right now, long is value which can be bigger than maximum value of int type.
What about notifications are they working ?
Sorry yes notifications work…
Surely that is if less than or equal to 0?
Never mind I see my mistake now.
Why not just if larger than 0?
</s> <s>if ((long)subKey.GetValue("LastUsedTimeStop") > 0)</s> <s>{</s> <s> return true;</s> <s>}</s> <s>
Wait…
When it is not used I see a UNIX timestamp.
When it is in use the value is 0
if ((long)subKey.GetValue("LastUsedTimeStop") == 0){
return true;
} else {
return false;
}
And I’m sure no other software uses the camera. I can see it in the registry and the LED on the camera is off.
I will try to implement your sugestion
I see your code queryConsentStore.
I’m not a C# coder but I don’t understand the reason for two if’s
var endTime = subKey.GetValue("LastUsedTimeStop") is long ? (long)subKey.GetValue("LastUsedTimeStop") : -1;
Is a shorthand if-else.
Then you have another if to see what the result of the previous if was.
As I said I don’t know C# but in all other languages I have written in I would have skipped the variable and just done an if on the actual value == 0 { return true; }
I see now that the else that I added does not fit the code.
But I compared what the code does to my registry and it should work the way you have it currently on GitHub as I see it.
Hinally have som clue what is happening when it crash ‘[36948] HA_Desktop_Companion.exe’ has exited with code 4294967295 (0xffffffff). but unable to google anything
I noticed the app crashes/does not boot up after the laptop has gone to sleep.
Here we see the computer went to lock screen then sleep.
[20220826T203510]-MAIN-Syncer Tick n:501
[20220826T203510]-API/ADD/SKIP/SAME/[battery_state]'On AC'=='On AC'
[20220826T203510]-API/ADD/DATA[battery_level]'27'
[20220826T203510]-API/ADD/DATA[free_ram]'1130828'
[20220826T203510]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220826T203510]-API/ADD/DATA[currently_active_window]'Standardlåsskärm för Windows'
[20220826T203510]-API/ADD/DATA[uptime]'53'
[20220826T203510]-API/ADD/SKIP/SAME/[camera_in_use]'False'=='False'
[20220826T203510]-API/ADD/SKIP/SAME/[microphone_in_use]'False'=='False'
[20220826T203510]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220826T203510]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220826T203510]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220826T203510]-API/ADD/SKIP/SAME/[is_charging]'False'=='False'
[20220826T203512]-API/ADD/DATA[cpu_usage]'20'
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-SENSOR/READ/True
[20220826T203512]-API -> {"data":[{"unique_id":"battery_level","type":"sensor","state":"27","icon":"mdi:battery"},{"unique_id":"free_ram","type":"sensor","state":1130828,"icon":"mdi:clock"},{"unique_id":"currently_active_window","type":"sensor","state":"Standardlåsskärm för Windows","icon":"mdi:application"},{"unique_id":"uptime","type":"sensor","state":"53","icon":"mdi[20220829T083940]-MAIN ->LOADED Start
[20220829T083940]-MAIN ->Setting Loaded
[20220829T083940]-MAIN ->UI Set
[20220829T083941]-MAIN-configuration.yaml LOADED
[20220829T083941]-MAIN-Sync Timer Registered
[20220829T083941]-MAIN-Previous Run detected trying to autostart
[20220829T083944]-System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.Security.SslStream.<FillHandshakeBufferAsync>g__InternalFillHandshakeBufferAsync|189_0[TIOAdapter](TIOAdapter adap, ValueTask`1 task, Int32 minSize)
at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter)
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellation(CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.SocketsHttpHandler.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClientHandler.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpMessageInvoker.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.Send(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.Send(HttpRequestMessage request)
at HA_Desktop_Companion.Libraries.HAApi_v2.validateHaUrl()
at HA_Desktop_Companion.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Wi[20220829T083953]-MAIN ->LOADED Start
I tried to start the app again now a few minutes ago since i noticed it was not on.
I will inspect issue tomorrow already have stable wersion o
Witch did not crashed for several hours.
From error you send it seems like app was not able to communicate with nabucassa securely
It seems it crashes when I have left the computer for a long time, so probably the computer goes in to sleep then when it wakes up it crashes.
Could it be because the app tries to connect to HA before there is a wifi/internet connection on the computer?
Another thing I have noticed is that the log file is getting rather large.
Perhaps some cleaning is needed of the log file?
Remove values that is > x days old if that is possible?
There are various handlers that must be implemented for sleep and hibernation modes. Typically one needs to close all connections when the signal is received so that the service/app can be suspended (and data serialised, etc.) and re-establish it when the service/app resumes.