From 78aa26599e880d56dc0791db067b8c970a61ea24 Mon Sep 17 00:00:00 2001 From: sleevezipper Date: Sun, 3 Jan 2021 16:01:26 +0100 Subject: [PATCH] WIP add webcam sensor --- .../DesignTimeBuild/.dtbcache.v2 | Bin 162527 -> 162527 bytes .vs/hass-workstation-service/v16/.suo | Bin 279552 -> 278016 bytes .../PublishProfiles/Standalone.pubxml | 18 ++ .../PublishProfiles/Standalone.pubxml.user | 6 + UserInterface/UserInterface.csproj.user | 2 +- UserInterface/Views/AddSensorDialog.axaml.cs | 8 +- .../InterProcessApi.cs | 3 + .../ServiceContractModels.cs | 3 +- .../Data/ConfigurationService.cs | 3 + .../Domain/Sensors/WebcamActiveSensor.cs | 182 ++++++++++++++++++ .../PublishProfiles/AzureHosted.pubxml | 2 +- .../PublishProfiles/FolderProfile.pubxml | 18 ++ .../PublishProfiles/FolderProfile.pubxml.user | 6 + .../hass-workstation-service.csproj.user | 2 +- 14 files changed, 248 insertions(+), 5 deletions(-) create mode 100644 UserInterface/Properties/PublishProfiles/Standalone.pubxml create mode 100644 UserInterface/Properties/PublishProfiles/Standalone.pubxml.user create mode 100644 hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs create mode 100644 hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml create mode 100644 hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml.user diff --git a/.vs/hass-workstation-service/DesignTimeBuild/.dtbcache.v2 b/.vs/hass-workstation-service/DesignTimeBuild/.dtbcache.v2 index 105da9a9eaa1964731c876bfabe82cc003f15fea..025b0a6486fe73dec1cc2a194215272899b2235d 100644 GIT binary patch delta 17545 zcmai*b$nFE*N1cO1b5fsP6=@V3WK{tDJ?BT7DyWsAV5oPfhtxcz~b%{r=?Ea-4#lO zQYy@LOBH#)=ggjz;rGY8pU>HOGI{pg-Mcr-&Y8oBb7fAPE8`E2UE&YY8Sy!pS($-A zc4As;LQ+a*W@}y#O44a2XEn7JhPi*MP zc17dPmMoQBkQ2x$m{e53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CzsZ+h6W-jMZ{IQLg-h~Ncr2v^c)q77t)QQ516ie z{4#B3bxlO~A8E-07X1s2mRE!i{kNE^L&GULne;NyAKA^XvQGKqX1b01Xw1Ogwz%`x zS>RcZ@0(PD18EX&o9S1irI$IUg;Q6O#jANg(X@s7h(TNEOcAn~mWYHZI=-%wQd!?d zjjX1M>Ki(!k%)8Gz|0@4qEVtFjOy#QF(|^^>s8cC)=y+cDjKVx;dYTQnSCwVlbK4^ zPi95}ce@~QF$G?Ono@l54fJk6-(<^&foHBxXWr<08pW_xG(m2?LUrU9i+=2B3U9~% zUg2K`;fZMch6XYCbS|o^X#g9eScWIrKvC7q0)=rhORSsDi1KuZ?LQN4ikt9ee2eZE znoyP`+HTXU;>vaUv3$OZ#ybe*b=oQ}d`tgZ1uonAaT0ZxtMA>(!A+5L#WsjMOw9_J zFCJgE(0=G+NZ>yVl7x=3=j5qj>{|z4{AOSa&W+iSz_*>GtrhHf`Nj}7jX-K~jfv|2 zDUaeK3c6^2afz^@;<;${xG>(PuA*5B@BJ;&Omi%c(;8#2a;dGnYL-!s@t&dy+)2+5SmL#&&~eF%dW z`2Xh`2v~!4HR-HXtUbVLxw;@u)Xrn6FYi~wSk*4{A--d#jht zF_bM5=>ypWU;ON53zrVz{|%B5>)HueyBtBB=`5Z;&PSeI%AO%&KsZ}0-V9^8V(wU` z7bn8mpT*u{Rw&O~#cCbvPBE#jlF_;rMr%sgQhDhWwwlWOBbbT(0wcH}4n?zsdn@#7 z7wl7Ka2M^}>>+XL3+5pkzhwF3=T_~F!d|N;%-86TmrYK42yDc@T3nN>7V30%@UGrv z)Vm{J^W17~%npv z_V?xOc`C7_ucYR+2jH>eB!Bs9o#aVGbts!8+I^&ezu$E6SZS0zDo%QjiHiPGoE#S? a + + + + Release + Any CPU + bin\Userinterface-standalone + FileSystem + netcoreapp3.1 + win-x64 + true + False + False + False + + \ No newline at end of file diff --git a/UserInterface/Properties/PublishProfiles/Standalone.pubxml.user b/UserInterface/Properties/PublishProfiles/Standalone.pubxml.user new file mode 100644 index 0000000..312c6e3 --- /dev/null +++ b/UserInterface/Properties/PublishProfiles/Standalone.pubxml.user @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/UserInterface/UserInterface.csproj.user b/UserInterface/UserInterface.csproj.user index 3d9bdf3..bbf9920 100644 --- a/UserInterface/UserInterface.csproj.user +++ b/UserInterface/UserInterface.csproj.user @@ -1,6 +1,6 @@  - <_LastSelectedProfileId>C:\Users\Maurits\Documents\Repo\hass-desktop-service\UserInterface\Properties\PublishProfiles\FolderProfile.pubxml + <_LastSelectedProfileId>C:\Users\Maurits\Documents\Repo\hass-desktop-service\UserInterface\Properties\PublishProfiles\Standalone.pubxml \ No newline at end of file diff --git a/UserInterface/Views/AddSensorDialog.axaml.cs b/UserInterface/Views/AddSensorDialog.axaml.cs index 3e31aef..2f307cd 100644 --- a/UserInterface/Views/AddSensorDialog.axaml.cs +++ b/UserInterface/Views/AddSensorDialog.axaml.cs @@ -90,7 +90,7 @@ namespace UserInterface.Views break; case AvailableSensors.MemoryUsageSensor: item.Description = "This sensor calculates the percentage of used memory."; - item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#usedmemorysensor"; + item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#usedmemory"; item.ShowQueryInput = false; item.UpdateInterval = 10; break; @@ -100,6 +100,12 @@ namespace UserInterface.Views item.ShowQueryInput = false; item.UpdateInterval = 5; break; + case AvailableSensors.WebcamActiveSensor: + item.Description = "This sensor shows if the webcam is currently in use."; + item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#webcamactive"; + item.ShowQueryInput = false; + item.UpdateInterval = 10; + break; default: item.Description = null; item.MoreInfoLink = null; diff --git a/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs b/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs index 64f77c7..c45b564 100644 --- a/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs +++ b/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs @@ -106,6 +106,9 @@ namespace hass_workstation_service.Communication.InterProcesCommunication case AvailableSensors.ActiveWindowSensor: sensorToCreate = new ActiveWindowSensor(this._publisher, (int)model.UpdateInterval, model.Name); break; + case AvailableSensors.WebcamActiveSensor: + sensorToCreate = new WebcamActiveSensor(this._publisher, (int)model.UpdateInterval, model.Name); + break; default: Log.Logger.Error("Unknown sensortype"); break; diff --git a/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs b/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs index d6e73f2..3e110ea 100644 --- a/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs +++ b/hass-workstation-service/Communication/InterProcesCommunication/ServiceContractModels.cs @@ -36,6 +36,7 @@ namespace hass_workstation_service.Communication.InterProcesCommunication.Models CPULoadSensor, WMIQuerySensor, MemoryUsageSensor, - ActiveWindowSensor + ActiveWindowSensor, + WebcamActiveSensor } } diff --git a/hass-workstation-service/Data/ConfigurationService.cs b/hass-workstation-service/Data/ConfigurationService.cs index b352d6a..742b27e 100644 --- a/hass-workstation-service/Data/ConfigurationService.cs +++ b/hass-workstation-service/Data/ConfigurationService.cs @@ -88,6 +88,9 @@ namespace hass_workstation_service.Data case "ActiveWindowSensor": sensor = new ActiveWindowSensor(publisher, configuredSensor.UpdateInterval, configuredSensor.Name, configuredSensor.Id); break; + case "WebcamActiveSensor": + sensor = new WebcamActiveSensor(publisher, configuredSensor.UpdateInterval, configuredSensor.Name, configuredSensor.Id); + break; default: Log.Logger.Error("unsupported sensor type in config"); break; diff --git a/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs b/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs new file mode 100644 index 0000000..6ff513a --- /dev/null +++ b/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs @@ -0,0 +1,182 @@ +using hass_workstation_service.Communication; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Management; +using System.Runtime.ExceptionServices; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; + +namespace hass_workstation_service.Domain.Sensors +{ + public class WebcamActiveSensor : AbstractSensor + { + public WebcamActiveSensor(MqttPublisher publisher, int? updateInterval = null, string name = "WebcamActive", Guid id = default) : base(publisher, name, updateInterval ?? 10, id) + { + } + public override string GetState() + { + try + { + List procs = WhoIsLocking("\\Device\\00000041"); + if (procs.Count > 0) + { + return "True"; + } + return "False"; + } + catch (Exception) + { + return "Error"; + } + } + public override AutoDiscoveryConfigModel GetAutoDiscoveryConfig() + { + return this._autoDiscoveryConfigModel ?? SetAutoDiscoveryConfigModel(new AutoDiscoveryConfigModel() + { + Name = this.Name, + Unique_id = this.Id.ToString(), + Device = this.Publisher.DeviceConfigModel, + State_topic = $"homeassistant/sensor/{this.Name}/state", + Icon = "mdi:webcam", + }); + } + + [StructLayout(LayoutKind.Sequential)] + struct RM_UNIQUE_PROCESS + { + public int dwProcessId; + public System.Runtime.InteropServices.ComTypes.FILETIME ProcessStartTime; + } + + const int RmRebootReasonNone = 0; + const int CCH_RM_MAX_APP_NAME = 255; + const int CCH_RM_MAX_SVC_NAME = 63; + + enum RM_APP_TYPE + { + RmUnknownApp = 0, + RmMainWindow = 1, + RmOtherWindow = 2, + RmService = 3, + RmExplorer = 4, + RmConsole = 5, + RmCritical = 1000 + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + struct RM_PROCESS_INFO + { + public RM_UNIQUE_PROCESS Process; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_APP_NAME + 1)] + public string strAppName; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_SVC_NAME + 1)] + public string strServiceShortName; + + public RM_APP_TYPE ApplicationType; + public uint AppStatus; + public uint TSSessionId; + [MarshalAs(UnmanagedType.Bool)] + public bool bRestartable; + } + + [DllImport("rstrtmgr.dll", CharSet = CharSet.Unicode)] + static extern int RmRegisterResources(uint pSessionHandle, + UInt32 nFiles, + string[] rgsFilenames, + UInt32 nApplications, + [In] RM_UNIQUE_PROCESS[] rgApplications, + UInt32 nServices, + string[] rgsServiceNames); + + [DllImport("rstrtmgr.dll", CharSet = CharSet.Auto)] + static extern int RmStartSession(out uint pSessionHandle, int dwSessionFlags, string strSessionKey); + + [DllImport("rstrtmgr.dll")] + static extern int RmEndSession(uint pSessionHandle); + + [DllImport("rstrtmgr.dll")] + static extern int RmGetList(uint dwSessionHandle, + out uint pnProcInfoNeeded, + ref uint pnProcInfo, + [In, Out] RM_PROCESS_INFO[] rgAffectedApps, + ref uint lpdwRebootReasons); + + /// + /// Find out what process(es) have a lock on the specified file. + /// + /// Path of the file. + /// Processes locking the file + /// See also: + /// http://msdn.microsoft.com/en-us/library/windows/desktop/aa373661(v=vs.85).aspx + /// http://wyupdate.googlecode.com/svn-history/r401/trunk/frmFilesInUse.cs (no copyright in code at time of viewing) + /// + /// + static public List WhoIsLocking(string path) + { + uint handle; + string key = Guid.NewGuid().ToString(); + List processes = new List(); + + int res = RmStartSession(out handle, 0, key); + if (res != 0) throw new Exception("Could not begin restart session. Unable to determine file locker."); + + try + { + const int ERROR_MORE_DATA = 234; + uint pnProcInfoNeeded = 0, + pnProcInfo = 0, + lpdwRebootReasons = RmRebootReasonNone; + + string[] resources = new string[] { path }; // Just checking on one resource. + + res = RmRegisterResources(handle, (uint)resources.Length, resources, 0, null, 0, null); + + if (res != 0) throw new Exception("Could not register resource."); + + //Note: there's a race condition here -- the first call to RmGetList() returns + // the total number of process. However, when we call RmGetList() again to get + // the actual processes this number may have increased. + res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, null, ref lpdwRebootReasons); + + if (res == ERROR_MORE_DATA) + { + // Create an array to store the process results + RM_PROCESS_INFO[] processInfo = new RM_PROCESS_INFO[pnProcInfoNeeded]; + pnProcInfo = pnProcInfoNeeded; + + // Get the list + res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, processInfo, ref lpdwRebootReasons); + if (res == 0) + { + processes = new List((int)pnProcInfo); + + // Enumerate all of the results and add them to the + // list to be returned + for (int i = 0; i < pnProcInfo; i++) + { + try + { + processes.Add(Process.GetProcessById(processInfo[i].Process.dwProcessId)); + } + // catch the error -- in case the process is no longer running + catch (ArgumentException) { } + } + } + else throw new Exception("Could not list processes locking resource."); + } + else if (res != 0) throw new Exception("Could not list processes locking resource. Failed to get size of result."); + } + finally + { + RmEndSession(handle); + } + + return processes; + } + + } +} diff --git a/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml b/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml index 35da0ec..8ad4e03 100644 --- a/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml +++ b/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - 25 + 26 1.0.0.* True Release diff --git a/hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml b/hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..786c0bc --- /dev/null +++ b/hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,18 @@ + + + + + Release + Any CPU + bin\Manual\ + FileSystem + netcoreapp3.1 + true + win-x64 + False + False + False + + \ No newline at end of file diff --git a/hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml.user b/hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml.user new file mode 100644 index 0000000..312c6e3 --- /dev/null +++ b/hass-workstation-service/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/hass-workstation-service/hass-workstation-service.csproj.user b/hass-workstation-service/hass-workstation-service.csproj.user index 958055e..3061c40 100644 --- a/hass-workstation-service/hass-workstation-service.csproj.user +++ b/hass-workstation-service/hass-workstation-service.csproj.user @@ -1,7 +1,7 @@  - <_LastSelectedProfileId>C:\Users\Maurits\Documents\Repo\hass-desktop-service\hass-workstation-service\Properties\PublishProfiles\AzureHosted.pubxml + <_LastSelectedProfileId>C:\Users\Maurits\Documents\Repo\hass-desktop-service\hass-workstation-service\Properties\PublishProfiles\FolderProfile.pubxml true \ No newline at end of file