private RpmSmartPlugState getWemoState()
 {
     try
     {
         var ApiAddress = $"http://{IpAddress}";
         var v          = new WemoNet.Wemo();
         var insight    = v.GetInsightParams(ApiAddress).GetAwaiter().GetResult();
         return(insight != null ? (RpmSmartPlugState)insight.State : RpmSmartPlugState.unknown);
     }
     catch (Exception ex)
     {
         throw new RpmSmartPlugCommunicationException($"Could not get state from plug. Message: {ex.Message}", RpmSmartPlugs.WeMoInsightSwitch, IpAddress, ex);
     }
 }
 private double getWemoCurrentPowerConsumption()
 {
     try
     {
         var ApiAddress = $"http://{IpAddress}";
         var v          = new WemoNet.Wemo();
         var insight    = v.GetInsightParams(ApiAddress).GetAwaiter().GetResult();
         return(insight != null ? insight.CurrentPowerConsumption : 0);
     }
     catch (Exception ex)
     {
         throw new RpmSmartPlugCommunicationException($"Could not get current power consumption from plug. Message: {ex.Message}", RpmSmartPlugs.WeMoInsightSwitch, IpAddress, ex);
     }
 }
 private string getWemoFriendlyName()
 {
     try
     {
         var ApiAddress = $"http://{IpAddress}";
         var v          = new WemoNet.Wemo();
         var result     = v.GetWemoResponseObjectAsync <Communications.Responses.GetFriendlyNameResponse>(Communications.Utilities.Soap.WemoGetCommands.GetFriendlyName, ApiAddress).GetAwaiter().GetResult();
         return(result?.FriendlyName);
     }
     catch (Exception ex)
     {
         throw new RpmSmartPlugCommunicationException($"Could not get name from plug. Message: {ex.Message}", RpmSmartPlugs.WeMoInsightSwitch, IpAddress, ex);
     }
 }
        private bool setWemoState(RpmSmartPlugState plugState)
        {
            try
            {
                var ApiAddress = $"http://{IpAddress}";
                var v          = new WemoNet.Wemo();
                switch (plugState)
                {
                case RpmSmartPlugState.off:
                    return(v.TurnOffWemoPlugAsync(ApiAddress).GetAwaiter().GetResult());

                case RpmSmartPlugState.on:
                    return(v.TurnOnWemoPlugAsync(ApiAddress).GetAwaiter().GetResult());

                case RpmSmartPlugState.unknown:
                default:
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new RpmSmartPlugCommunicationException($"Could not set the state of plug. Message: {ex.Message}", RpmSmartPlugs.WeMoInsightSwitch, IpAddress, ex);
            }
        }