Announcement

Collapse
No announcement yet.

Controlling outputs via script

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

    Controlling outputs via script

    There seems to be an issue controlling outputs via scripts. Jon told me to use hs.setdevicestatus deviceid,2 to turn on. Yet it never does in the latest release. I believe it was working in a prior release though.

    Any ideas?

    #2
    Ultrajones,

    Any idea on this?

    Comment


      #3
      Not yet. I have been painting all day. I'll try to look at it as soon as possible.
      Plug-ins: UltraMon, UltraM1G, UltraCID, Ultra1Wire, UltraLog, UltraWeatherBug, UltraPioneerAVR, UltraGCIR

      Comment


        #4
        Sorry this reply took so long.

        The HomeSeer device status for outputs are:

        0 = Off
        1 = On

        Setting the device value to 2 won't work.

        You can also use the scripting interface:

        PHP Code:
        Function ControlOutput(ByVal strOutput As String
                                        
        ByVal strAction As String
                                        
        ByVal strOnTime As String) As String 
        strOutput is any supported output from 001 to 208.
        strAction is "On", "Off", "Toggle".
        strOnTime is a the ontime in seconds from from 0 to 65535.

        Example code to turn ouput 16 off:
        PHP Code:
        Sub Main(parm as object)

          
        Dim strResults as String ""

          
        strResults hs.plugin("UltraM1G").ControlOutput("016""Off""0")

          If 
        strResults.Length 0 then
            Call hs
        .WriteLog("Error"strResults)
          
        End If

        End Sub 
        As stated before, if you attempt to turn an output on that is already on, the plug-in will write a warning message stating the command wasn't sent successfully to the Elk M1. I think I'll end up excluding output actions from the re-try logic. Thoughts?

        Regards,
        Ultrajones
        Plug-ins: UltraMon, UltraM1G, UltraCID, Ultra1Wire, UltraLog, UltraWeatherBug, UltraPioneerAVR, UltraGCIR

        Comment


          #5
          Ultra,

          I am putting the following in my script and it wont turn the output on.

          hs.SetDeviceStatus "*35", 1

          Comment


            #6
            It is a value not a status. Try SetDeviceValue.

            Jon


            Originally posted by chrkov View Post
            Ultra,

            I am putting the following in my script and it wont turn the output on.

            hs.SetDeviceStatus "*35", 1
            Jon Ort
            JonOrt@The--Orts.com
            (Remove the dashes in the address, spam is getting out of hand)

            Comment


              #7
              I changed is to

              hs.SetDeviceValue "*35", 1

              Now it does update the HS device to on, but the actual Elk output does not turn on.

              Comment


                #8
                Can you turn on the debug logging and post the results when you run the script?

                Jon


                Originally posted by chrkov View Post
                I changed is to

                hs.SetDeviceValue "*35", 1

                Now it does update the HS device to on, but the actual Elk output does not turn on.
                Jon Ort
                JonOrt@The--Orts.com
                (Remove the dashes in the address, spam is getting out of hand)

                Comment


                  #9
                  Here is the script I am running

                  <PHP>
                  Sub Main
                  hs.SetDeviceValue "*30", 1
                  End Sub
                  </PHP>


                  Here is the log.


                  3/11/2007 10:25:03 PM Info Running script in background: controltest.txt
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessReceived() function with a string '0CST014099004F'
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessCommand() subroutine.
                  3/11/2007 10:25:03 PM UltraM1G Debug Command ST response received by Elk M1.
                  3/11/2007 10:25:03 PM UltraM1G Debug Processing response [ST]
                  3/11/2007 10:25:03 PM UltraM1G Debug Temperature Probe unit 014 is 39
                  3/11/2007 10:25:03 PM UltraM1G Debug Waited 140 milliseconds for the command response.
                  3/11/2007 10:25:03 PM UltraM1G Debug Sending command: 'st015' to Elk M1, attempt # 1
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered SendToM1G() function.
                  3/11/2007 10:25:03 PM UltraM1G Debug Sending st015 to M1G via Ethernet.
                  3/11/2007 10:25:03 PM UltraM1G Debug Waiting for the M1 to respond with 'ST' for up to 1.5 seconds...
                  3/11/2007 10:25:03 PM Elk-M1 Probe Probe Temp [16=39
                  3/11/2007 10:25:03 PM Elk-M1 Probe Probe Temp [17=82
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessReceived() function with a string '0CST0151420059'
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessCommand() subroutine.
                  3/11/2007 10:25:03 PM UltraM1G Debug Command ST response received by Elk M1.
                  3/11/2007 10:25:03 PM UltraM1G Debug Processing response [ST]
                  3/11/2007 10:25:03 PM UltraM1G Debug Temperature Probe unit 015 is 82
                  3/11/2007 10:25:03 PM UltraM1G Debug Waited 156 milliseconds for the command response.
                  3/11/2007 10:25:03 PM UltraM1G Debug Sending command: 'tr01' to Elk M1, attempt # 1
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered SendToM1G() function.
                  3/11/2007 10:25:03 PM UltraM1G Debug Sending tr01 to M1G via Ethernet.
                  3/11/2007 10:25:03 PM UltraM1G Debug Waiting for the M1 to respond with 'TR' for up to 1.5 seconds...
                  3/11/2007 10:25:03 PM Elk-M1 ThermTemp Thermostat Temp ] 3=71
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessReceived() function with a string '13TR0100071658000000A'
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessCommand() subroutine.
                  3/11/2007 10:25:03 PM UltraM1G Debug Command TR response received by Elk M1.
                  3/11/2007 10:25:03 PM UltraM1G Debug Processing response [TR]
                  3/11/2007 10:25:03 PM UltraM1G Debug Waited 125 milliseconds for the command response.
                  3/11/2007 10:25:03 PM UltraM1G Debug Sending command: 'tr02' to Elk M1, attempt # 1
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered SendToM1G() function.
                  3/11/2007 10:25:03 PM UltraM1G Debug Sending tr02 to M1G via Ethernet.
                  3/11/2007 10:25:03 PM UltraM1G Debug Waiting for the M1 to respond with 'TR' for up to 1.5 seconds...
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessReceived() function with a string '13TR02000726580000008'
                  3/11/2007 10:25:03 PM UltraM1G Debug Entered ProcessCommand() subroutine.
                  3/11/2007 10:25:03 PM UltraM1G Debug Command TR response received by Elk M1.
                  3/11/2007 10:25:03 PM UltraM1G Debug Processing response [TR]
                  3/11/2007 10:25:03 PM UltraM1G Debug Waited 156 milliseconds for the command response.
                  3/11/2007 10:25:03 PM Elk-M1 ThermTemp Thermostat Temp ] 10=72
                  3/11/2007 10:25:05 PM UltraM1G Debug Entered ProcessReceived() function with a string '0AZC026900C1'
                  3/11/2007 10:25:05 PM UltraM1G Debug Entered ProcessCommand() subroutine.
                  3/11/2007 10:25:06 PM UltraM1G Debug Processing response [ZC]
                  3/11/2007 10:25:06 PM UltraM1G Debug Zone is 026; status is Violated [Open] (Violated

                  Comment


                    #10
                    Not sure what is going on, but I am able to duplicate this. Seems that attempting to control the ouput using hs.SetDeviceValue isn't calling SetIO. I'll need to research this a bit more.

                    The other methods seem to be working though.

                    Regards,
                    Ultrajones
                    Plug-ins: UltraMon, UltraM1G, UltraCID, Ultra1Wire, UltraLog, UltraWeatherBug, UltraPioneerAVR, UltraGCIR

                    Comment


                      #11
                      Originally posted by Ultrajones View Post
                      As stated before, if you attempt to turn an output on that is already on, the plug-in will write a warning message stating the command wasn't sent successfully to the Elk M1. I think I'll end up excluding output actions from the re-try logic. Thoughts?

                      Regards,
                      Ultrajones

                      Would it be possible to query the current state of the output and then If it matches just deregard the command, otherwise transmit the command as usual? Is this possible? My concern is that the outputs might get out of sync somehow.

                      Chris
                      Last edited by chrkov; March 13, 2007, 07:41 PM.

                      Comment


                        #12
                        Originally posted by Ultrajones View Post
                        Not sure what is going on, but I am able to duplicate this. Seems that attempting to control the ouput using hs.SetDeviceValue isn't calling SetIO. I'll need to research this a bit more.

                        The other methods seem to be working though.

                        Regards,
                        Ultrajones
                        I am going to wait for the hs.SetDeviceValue to be fixed and working correctly. Using that would make updating my script so much easier then the other way.

                        Comment


                          #13
                          UltraJones,

                          Any update on this?

                          Comment


                            #14
                            Originally posted by chrkov View Post
                            UltraJones,

                            Any update on this?

                            Not yet. Still working on it.
                            Plug-ins: UltraMon, UltraM1G, UltraCID, Ultra1Wire, UltraLog, UltraWeatherBug, UltraPioneerAVR, UltraGCIR

                            Comment


                              #15
                              I updated the Elk M1 plug-in to suppress the warning messages for outputs. It appears the Elk *does not* send an Output Change Update if the output status doesn't change. This can happen if you turn an output on that is already on.

                              If you want to control an output via script, then use the following function:

                              PHP Code:
                              Sub Main(parm as object

                                
                              Dim strResults as String "" 

                                
                              strResults hs.plugin("UltraM1G").ControlOutput("016""Off""0"

                                If 
                              strResults.Length 0 then 
                                  Call hs
                              .WriteLog("Error"strResults
                                
                              End If 

                              End Sub 
                              If you don't care about the results, you can also use:

                              PHP Code:
                              hs.plugin("UltraM1G").ControlOutput("016""Off""0"
                              I ended up sending Rich an email asking of it is possible to create a device that can be controlled via the web page and through a script using hs.SetDeviceValue. I can't figure it out. I can get one or the other working, but not both.

                              Using the UltraM1G plug-in ControlOutput function allows a bit more control than just simply setting the device value.

                              Regards,
                              Ultrajones
                              Plug-ins: UltraMon, UltraM1G, UltraCID, Ultra1Wire, UltraLog, UltraWeatherBug, UltraPioneerAVR, UltraGCIR

                              Comment

                              Working...
                              X