HA_Desktop_Companion

Here is another error message as I start up my computer:

I will look to that but recent version is running on my computer 2 days wihtout crash :slight_smile:

Do you have any link to documentation

What is last line in log when this happens ?

I implemented wew thinks already

Stable release is Out :slight_smile: Release First Really Stable Release · GamerClassN7/HA_Desktop_Companion · GitHub

I’ll see if I can find it tomorrow, if I have time for it.
Had a very intense day today at work.

Talk me about it :smiley:

It’s been a while since I’ve coded this stuff, but here are some guidelines. Note that I haven’t looked at your code and don’t know what your application’s architecture is. I’m just following the thread out of interest.

You probably want to start here: SystemEvents.PowerModeChanged Event (Microsoft.Win32) | Microsoft Docs.

Another but more complex setup, is to make your client application thin and handle most work in a service. It means you need to install two pieces of software, where the client app speaks with the service and the service speaks with HA. Making a service also gives you access to more things on the Windows platform (so it typically needs higher privileges to run). One advantage is that you can handle all the heavy lifting in the service where if you implement the start, stop and suspend methods correctly, all the power stuff will work properly. You typically implement this interface to build a proper Windows service: ManagerBase Class (Microsoft.Azure.Management.ResourceManager.Fluent.Core) - Azure for .NET Developers | Microsoft Docs.

Thanks i will try to read all the stuff you send, just for now I don’t wat to run as service as it require amin privileges, and most of users dont have them

Not necessarily admin (you need admin to install, but can run with lower privileges, I think), but I get your point. Simpler is initially better.

I’ll just leave you with this thought for the future: Running an app would require a user to be logged in and there could be things you’d want to monitor and expose as sensors that might not be tied to a specific user. A background service would be able to do that.

1 Like

@Hellis81 can you please provide feedback from testing the latest version ? for me it is running stably for mor than a week even with Sleep and hibernation cyrcels

I have forgotten.
I will install it today

The camera is stuck.

[20220906T101341]-MAIN/SYNCER/TICK/4
[20220906T101342]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220906T101342]-API/ADD/SKIP/SAME/[battery_state]'Fully Charged'=='Fully Charged'
[20220906T101342]-API/ADD/DATA[free_ram]='470448'
[20220906T101342]-API/ADD/DATA[currently_active_window]='Möte | Microsoft Teams'
[20220906T101342]-API/ADD/SKIP/SAME/[battery_level]'100'=='100'
[20220906T101342]-API/ADD/SKIP/SAME/[uptime]'143'=='143'
[20220906T101342]-API/ADD/SKIP/SAME/[camera_in_use]'False'=='False'
[20220906T101342]-API/ADD/SKIP/SAME/[microphone_in_use]'False'=='False'
[20220906T101342]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220906T101343]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220906T101343]-API/ADD/SKIP/SAME/[is_charging]'True'=='True'
[20220906T101343]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220906T101343]-API/ADD/DATA[cpu_usage]='79'
[20220906T101343]-SENSOR/READ/True[20220906T101343]- (12x)
[20220906T101343]-API/SEND/BODY
[20220906T101343]-{"data":[{"unique_id":"free_ram","type":"sensor","state":470448,"icon":"mdi:clock"},{"unique_id":"currently_active_window","type":"sensor","state":"Möte | Microsoft Teams","icon":"mdi:application"},{"unique_id":"cpu_usage","type":"sensor","state":"79","icon":"mdi:cpu-64-bit"}],"type":"update_sensor_states"}
[20220906T101344]-API/RESPONSE/CODE/OK[200]
[20220906T101344]-API/RESPONSE/BODY
[20220906T101344]-"{\"free_ram\": {\"success\": true}, \"currently_active_window\": {\"success\": true}, \"cpu_usage\": {\"success\": true}}"
[20220906T101354]-MAIN/SYNCER/TICK/5
[20220906T101354]-API/ADD/DATA[free_ram]='558648'
[20220906T101354]-API/ADD/SKIP/SAME/[battery_state]'Fully Charged'=='Fully Charged'
[20220906T101354]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220906T101354]-API/ADD/DATA[currently_active_window]='Möte | Microsoft Teams'
[20220906T101354]-API/ADD/SKIP/SAME/[uptime]'143'=='143'
[20220906T101354]-API/ADD/DATA[camera_in_use]='True'
[20220906T101354]-API/ADD/SKIP/SAME/[microphone_in_use]'False'=='False'
[20220906T101354]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220906T101354]-API/ADD/SKIP/SAME/[battery_level]'100'=='100'
[20220906T101354]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220906T101354]-API/ADD/SKIP/SAME/[is_charging]'True'=='True'
[20220906T101354]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220906T101355]-API/ADD/DATA[cpu_usage]='44'
[20220906T101355]-SENSOR/READ/True[20220906T101355]- (12x)
[20220906T101355]-API/SEND/BODY
[20220906T101355]-{"data":[{"unique_id":"free_ram","type":"sensor","state":558648,"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":"cpu_usage","type":"sensor","state":"44","icon":"mdi:cpu-64-bit"}],"type":"update_sensor_states"}
[20220906T101355]-API/RESPONSE/CODE/OK[200]
[20220906T101355]-API/RESPONSE/BODY
[20220906T101355]-"{\"free_ram\": {\"success\": true}, \"currently_active_window\": {\"success\": true}, \"camera_in_use\": {\"success\": true}, \"cpu_usage\": {\"success\": true}}"
[20220906T101405]-MAIN/SYNCER/TICK/6
[20220906T101406]-API/ADD/SKIP/SAME/[battery_level]'100'=='100'
[20220906T101406]-API/ADD/DATA[currently_active_window]='Möte | Microsoft Teams'
[20220906T101406]-API/ADD/SKIP/SAME/[uptime]'143'=='143'
[20220906T101406]-API/ADD/DATA[camera_in_use]='True'
[20220906T101406]-API/ADD/SKIP/SAME/[microphone_in_use]'False'=='False'
[20220906T101406]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220906T101406]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220906T101406]-API/ADD/SKIP/SAME/[battery_state]'Fully Charged'=='Fully Charged'
[20220906T101406]-API/ADD/DATA[free_ram]='517228'
[20220906T101406]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220906T101406]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220906T101406]-API/ADD/SKIP/SAME/[is_charging]'True'=='True'
[20220906T101407]-API/ADD/DATA[cpu_usage]='52'
[20220906T101407]-SENSOR/READ/True[20220906T101407]- (12x)
[20220906T101407]-API/SEND/BODY
[20220906T101407]-{"data":[{"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":"free_ram","type":"sensor","state":517228,"icon":"mdi:clock"},{"unique_id":"cpu_usage","type":"sensor","state":"52","icon":"mdi:cpu-64-bit"}],"type":"update_sensor_states"}
[20220906T101407]-API/RESPONSE/CODE/OK[200]
[20220906T101407]-API/RESPONSE/BODY
[20220906T101407]-"{\"currently_active_window\": {\"success\": true}, \"camera_in_use\": {\"success\": true}, \"free_ram\": {\"success\": true}, \"cpu_usage\": {\"success\": true}}"
[20220906T101417]-MAIN/SYNCER/TICK/7
[20220906T101417]-API/ADD/SKIP/SAME/[battery_state]'Fully Charged'=='Fully Charged'
[20220906T101417]-API/ADD/SKIP/SAME/[currently_active_window]'Settings – Home Assistant och 13 sidor till - Arbete – Microsoft? Edge'=='Settings – Home Assistant och 13 sidor till - Arbete – Microsoft? Edge'
[20220906T101417]-API/ADD/SKIP/SAME/[uptime]'143'=='143'
[20220906T101417]-API/ADD/SKIP/SAME/[camera_in_use]'False'=='False'
[20220906T101417]-API/ADD/SKIP/SAME/[microphone_in_use]'False'=='False'
[20220906T101417]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220906T101417]-API/ADD/SKIP/SAME/[battery_level]'100'=='100'
[20220906T101417]-API/ADD/DATA[free_ram]='568640'
[20220906T101417]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220906T101417]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220906T101418]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220906T101418]-API/ADD/SKIP/SAME/[is_charging]'True'=='True'
[20220906T101419]-API/ADD/DATA[cpu_usage]='27'
[20220906T101419]-SENSOR/READ/True[20220906T101419]- (12x)
[20220906T101419]-API/SEND/BODY
[20220906T101419]-{"data":[{"unique_id":"free_ram","type":"sensor","state":568640,"icon":"mdi:clock"},{"unique_id":"cpu_usage","type":"sensor","state":"27","icon":"mdi:cpu-64-bit"}],"type":"update_sensor_states"}
[20220906T101419]-API/RESPONSE/CODE/OK[200]
[20220906T101419]-API/RESPONSE/BODY
[20220906T101419]-"{\"free_ram\": {\"success\": true}, \"cpu_usage\": {\"success\": true}}"
[20220906T101429]-MAIN/SYNCER/TICK/8
[20220906T101429]-API/ADD/DATA[free_ram]='617932'
[20220906T101429]-API/ADD/SKIP/SAME/[currently_active_window]'Settings – Home Assistant och 13 sidor till - Arbete – Microsoft? Edge'=='Settings – Home Assistant och 13 sidor till - Arbete – Microsoft? Edge'
[20220906T101429]-API/ADD/SKIP/SAME/[uptime]'143'=='143'
[20220906T101429]-API/ADD/SKIP/SAME/[camera_in_use]'False'=='False'
[20220906T101429]-API/ADD/SKIP/SAME/[microphone_in_use]'False'=='False'
[20220906T101429]-API/ADD/SKIP/SAME/[location_in_use]'False'=='False'
[20220906T101429]-API/ADD/SKIP/SAME/[wifi_state]''==''
[20220906T101429]-API/ADD/SKIP/SAME/[battery_state]'Fully Charged'=='Fully Charged'
[20220906T101429]-API/ADD/SKIP/SAME/[wifi_ssid]''==''
[20220906T101429]-API/ADD/SKIP/SAME/[cpu_temp]''==''
[20220906T101430]-API/ADD/SKIP/SAME/[battery_level]'100'=='100'
[20220906T101430]-API/ADD/SKIP/SAME/[is_charging]'True'=='True'
[20220906T101430]-API/ADD/DATA[cpu_usage]='50'
[20220906T101430]-SENSOR/READ/True[20220906T101430]- (12x)

yes, it is because i implemented code you suggested will try to investigate further :smiley:

The source code still has the shorthand if and the extra if below

dont know where are you looking but sourscode of version you try has your fix in place

Here:

That is weird can you try this one ?

if you see same thinks here ?

Really strange…

I see now I was looking in the wrong place.
I have a meeting now so I will have to test it later.