Announcement

Collapse
No announcement yet.

Cloud based server PHP script to access Homeseer ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I changed the newtonsoft.Json version to 8.03. I got the same error as before when connecting with PHP. I then ran a couple of vb.net scripts in Homeseer that have always worked fine and they wouldn't run and complained about not being able to find the version 8.0.0.0 file --- makes no sense. So I switched it back to 12 and all is well -- the world didn't collapse afterall.

    I did refer back to the plugin doc you had provided. that is where I found the command that did work. While there were a bunch of other commands, none seemed to do what I needed.

    I will try out the stuff you just posted.

    Thank you !!

    Comment


      #17
      So where/when do you see the Newtonsoft error? Is it in the curl_error (might change the echo curl_error($ch) to "Error: ".curl_error($ch) to make it clear) after the getstatus call?
      On your request=controldevicebylabel call, does it throw an error?
      Try the "request=getstatus&ref=xxxx" and see what it returns?

      Just to be clear, your comments about scripts is another issue, right? Not related to the PHP calls (eg no scripts where harmed in this process)?
      For scripts, I believe it pulls the Newtonsoft dll from the /Bin/scripting directory. Don't think you need the import if it's in the ScriptingReference?
      Easy enough to check, just comment it out and see if it barfs..

      Comment


        #18
        I did change the error verbiage as you describe. But the error does not occur in the curl section:

        Request Example url: https://connected22.homeseer.com/JSON?user=[user]&pass=[pass]&request=getstatus

        Request Example: Error generating page: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


        The controldevicebylabel call does throw an error, but the device turns on and off as it should:
        { "Response":"Error, controlling device" }


        Set Control Device 2 url: https://connected22.homeseer.com/JSON?user=[user]&pass=[pass]&request=getstatus& ref=14

        Set Control Device response 2: Error generating page: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


        Yes. Comments about scripts is another issue. The reason it is involved is that when I changed the Newtonsoft.Json dll to version 8.0.3, some HS3 scripts failed. They would not run with the 8.0.3 version of Newtonsoft. So I changed the version back to the 12.0.1.22727 version and the scripts now run.


        I wonder whether the 8.0.0.0 related error is with regards to one of the child functions of the NewtonsoftJson file rather than to the file in general. Maybe the .NetFramework version works with a particular version of a child function within the Newtonsoft.Json file. Like maybe there can be a mismatch between the version of Newtonsoft and NetFramework. I will change the Newtonsoft version to 13 and see what happens.

        Something else that occurred to me about your previous question... You can avoid importing files if you instead name them in each vb.net statement that requires a particular import.

        If you can think of any more possibilities, or if I missed a question, let me know.

        Thank you!

        Comment


          #19
          Just to be sure,
          The error is the response to the Request and you echo that response?
          That is, you enter the URL on your browser and the error shows up on the webpage??

          Other odd thing is, where is the Vers 8.0.0 coming from? Do you have Visual Studio loaded on your HS box?

          Z

          Comment


            #20
            This is interesting...

            I changed the NewtonsoftJson vesion to 13.0.1.25517. I then ran the PHP get status script consisting of several commands ... pretty much the larger script you had posted. It returned lots of data with no errors. Even the "controldevicebylabel " command worked and returned a bunch of data -- while it used to control the device, it didn't return data.

            However, I ran a vb.script and it errored out as follows:

            Running script C:\Program Files (x86)\HomeSeer HS3\scripts\ETCalc3.vb :Exception has been thrown by the target of an invocation.Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

            So there is a mismatch somewhere. I wish I was smarter so that I could figure out what is mismatched. Maybe somehow between .NetFramework and NewtonsoftJson ?

            I switched back to 12.0. I wonder if there is some sort of software switch to make parts of a version look like another.

            Comment


              #21
              Also check:
              In root. HS4.exe.config
              Look for Newtonsoft
              Do you have \Bin\homeseer\Newtonsoft as Vers 12.0.0. ?

              What version of HS4 are you running?

              Comment


                #22
                Originally posted by vasrc View Post
                Just to be sure,
                The error is the response to the Request and you echo that response?
                That is, you enter the URL on your browser and the error shows up on the webpage??

                Other odd thing is, where is the Vers 8.0.0 coming from? Do you have Visual Studio loaded on your HS box?

                Z
                Yes. When I enter the request in the webpage, the error is displayed in the browser.

                Yes. Visual Studio is loaded on the HS box. But I find no Newtonsoft.Json.dll file available. For example, I do have a single NuGet folder that has all of the versions in it. But they are buried several layers down. (??) And it seems that the vb.net scripts I write are happy with the 12.0 version. And when I try to run them with 13 or with 8, they crash.

                I'm hoping you didn't miss my post above. Maybe you and I were posting at the same time.

                Comment


                  #23
                  Here is my HS3.exe.config file contents:

                  PHP Code:

                  <?xml version="1.0"?>
                  <configuration>
                  <startup>
                  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
                  </startup>
                  <runtime>
                  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                  <probing privatePath="bin/homeseer;bin"/>
                  </assemblyBinding>
                  </runtime>
                  </configuration>

                  I am running HS3 version 3.0.0.548

                  You asked...
                  Do you have \Bin\homeseer\Newtonsoft as Vers 12.0.0. ?
                  No. I have version 8.0.3.19514

                  oh boy... Maybe I will change that one. Are you ready?

                  Comment


                    #24
                    I changed the \Bin\homeseer\Newtonsoft file to Vers 12. I rebooted the PC. The PHP scripts still error out with reference to 8.0.0.0. My vb.net scripts still work.

                    Do you know what the "Newtonsoft.Json.xml" file does that is in that same folder? It has the same date as the version 8 .dll file. (3/14/2016)

                    You've mentioned HS4 a couple of times. I am assume you know I'm using HS3. I actually purchased HS4, but haven't got the nerve to upgrade to it yet.

                    Comment


                      #25
                      HS3.. Humm.. Maybe having HS4 installed nearby is causing HS3 to misbehave

                      Don't have the old HS3 code available easily. I'm going to guess, Vers 8.0.3 is correct for HS3.. You would think a newer version would be fine... Perhaps not..

                      You should probably drop support an email and see what they suggest to sync up the Newtonsoft vers in HS3 (they're still supporting HS3??)

                      Also wonder, since Newtonsoft isn't in the hs3.exe.config, if installing Newtonsoft with Nuget might not have messed something up..
                      When you google the error you got (as well as the HS board), there's a LOT of discussion, so it's not an unusual problem..

                      Comment


                        #26
                        I paid for HS4... I've neither downloaded nor installed it yet. I figure if I'm having this much trouble with HS3... I really don't know what will be involved to upgrade to HS4. I do have a lot of scripts. I really don't know whether they'll have to be modified............... but, maybe that would be a good time to make sure all these file versions are correct. Maybe a third of my scripts are compiled into .exe files.

                        Great idea to drop Support an email and work toward fixing HS3 even if I do have to fix some scripts to get things back to normal.

                        Thank so much for all your time and guidance with this !!

                        Comment


                          #27
                          not sure i’d classify it as guidance…

                          i survived the move over to hs4 although it was a little rocky at times. still haven’t converted all of the old hs3 devices to the new format yet (the conversion tool isn’t 100%) but overall for as small a shop as HS is, it went well.

                          Like it or not, upgrades happen 😄

                          Comment


                            #28
                            I agree. That is why I purchased HS4 -- so as not to get left further behind than I already am. I have X10 stuff and a Concord Alarm panel. So the upgrade may take some time.

                            I did put Newtonsoft 13 in the bin/scripts folder without changing anything else. The PHP calls still failed. But also the script I ran crashed with this:

                            Running script C:\Program Files (x86)\HomeSeer HS3\scripts\ETCalc3.vb :Exception has been thrown by the target of an invocation.Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

                            So... having the file in the folder certainly wasn't ignored. I just don't get it !!

                            I will try it again tomorrow. I didn't reboot the PC like I have been doing. So maybe that would make a difference. I did restart HS3.

                            Thanks again for your efforts !!

                            Comment


                              #29
                              Solved the Newtonsoft.JSON problem by adding a section to the HS3.exe.config file as shown below. This is necessary in HS3, but not necessary in HS4. It just says to use Newtonsoft.Json version 12 when a version up to 10 is requested.


                              PHP Code:
                              <?xml version="1.0"?>
                              <configuration>
                                <startup>
                                   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
                                </startup>

                               <runtime>
                                 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                                   <probing privatePath="bin/homeseer;bin"/>
                                 </assemblyBinding>
                                     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                                        <dependentAssembly>
                                          <assemblyIdentity name="Newtonsoft.Json"
                                              publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
                                           <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="12.0.0.0"/>
                                        </dependentAssembly>
                                     </assemblyBinding>
                                </runtime>
                              </configuration>

                              Comment

                              Working...
                              X