genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
392 stars 155 forks source link

Zwave db rework #260

Closed Bounz closed 8 years ago

genemars commented 8 years ago

Hi BounZ, there's a javascript error when the device is not found in Pepper1 DB:

       $.get('/' + HG.WebApp.Data.ServiceKey + '/HomeAutomation.ZWave/1/Db.GetDevice/' + manufacturerspec.Value.toLowerCase() + '/' + version, function (data) {
            $.mobile.loading('hide');
   ----->   var responseData = JSON.parse(data.ResponseValue);**
            devinfo = responseData[0];
            if (typeof devinfo === 'undefined') {
//...

_SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data_

the data in the response from the $.get call is

"{"ClassName":"System.IO.FileNotFoundException","Message":"Could not find file \"/usr/local/bin/homegenie/additionalZwaveDevices.xml\".","InnerException":null,"HelpURL":null,"StackTraceString":"  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0 \n  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0 \n  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)\n  at System.IO.FileInfo.Open (FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0 \n  at System.IO.FileInfo.Open (FileMode mode, FileAccess access) [0x00000] in <filename unknown>:0 \n  at System.IO.FileInfo.OpenText () [0x00000] in <filename unknown>:0 \n  at (wrapper remoting-invoke-with-check) System.IO.FileInfo:OpenText ()\n  at MIG.Interfaces.HomeAutomation.Pepper1Db.GetDeviceInfoInDb (System.String filename, System.String manufacturerId, System.String version) [0x00000] in <filename unknown>:0 \n  at MIG.Interfaces.HomeAutomation.Pepper1Db.GetDeviceInfo (System.String manufacturerId, System.String version) [0x00000] in <filename unknown>:0 \n  at MIG.Interfaces.HomeAutomation.ZWave.InterfaceControl (MIG.MigInterfaceCommand request) [0x00000] in <filename unknown>:0 \n  at MIG.MigService.Gateway_PreProcessRequest (System.Object sender, MIG.ProcessRequestEventArgs args) [0x00000] in <filename unknown>:0 ","RemoteStackTraceString":null,"RemoteStackIndex":0,"HResult":-2146232799,"Source":"mscorlib","ExceptionMethod":null,"Data":null,"FileNotFound_FileName":"/usr/local/bin/homegenie/additionalZwaveDevices.xml","FileNotFound_FusionLog":null}"

also if there's data files to store, please keep them in the same ZWaveLib.dll folder as it happens with zwavenodex.xml file, otherwise it will be not included in the backup files.

Bounz commented 8 years ago

Hi, Gene. The error is because I forgot to include that file (additionalZwaveDevices.xml) into csproj. This is the database of ZWave devices which are not present at pepper1, but were in HG's json files. So, this database is distributed with HG and should not be backed up. Also, I included this file in the HG project, not in Mig.HomeAutomation, because it simplifies distribution of Mig.HomeAutomation.dll library.

genemars commented 8 years ago

it's ok to include the file in HG project, but read my other comment here:

https://github.com/genielabs/mig-service-dotnet/pull/9#issuecomment-202351219