Announcement

Collapse
No announcement yet.

Script for 2 Way Control over RS232

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

    #16
    got it working but zwave device doesnt turn on as i thought, i now need to look in to capi

    Comment


      #17
      Originally posted by Matt Powell View Post
      got it working but zwave device doesnt turn on as i thought, i now need to look in to capi
      If you haven't already, take a look at TenScriptAid. It provides examples of the CAPI code for any device you select.
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #18
        Thanks, i have downloaded and create this script but it works once, then doesnt work again. Any thoughts on what i am doing wrong.

        Sub main(ByVal data)

        Dim DeviceRef As Integer
        Dim dimvalue As Integer

        DeviceRef = Mid(data, 5, 3)
        dimvalue = Mid(data, 8, 3)

        Dim cc As HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(DeviceRef, True, "(value)%", False, False)
        cc.ControlValue = dimvalue
        Dim cr As HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)

        End Sub

        THIS IS MY ERROR IN LOG


        Aug-24 19:13:18 Error 3 Running script capi.vb :Exception has been thrown by the target of an invocation.->Does entry point main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Obj ect obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at A.c17b105f989efe61e5979e67bec1ef734.cffd66cb0782c50126727e3f a75582d7a()

        Comment


          #19
          Try adding an explicit conversion of the data to integer values.

          DeviceRef = CInt(Mid(data, 5, 3))
          dimvalue = CInt(Mid(data, 8, 3))

          Some WriteLog statements may help to identify what is happening, as well.
          hs.WriteLog "data", data
          hs.WriteLog "data53", DeviceRef
          hs.WriteLog "data83", dimvalue

          Also, try changing Sub main to Sub Main with a capital M, and capitalize Main in the calling statement e = hs.OpenComPortTerm(2, "19200,N,8,1", 1, "rx.vb", "Main", chr(13))
          I recall another case where that caused the call to fail.
          Last edited by Uncle Michael; August 24, 2017, 01:57 PM. Reason: capitalization quirk
          Mike____________________________________________________________ __________________
          HS3 Pro Edition 3.0.0.548, NUC i3

          HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

          Comment


            #20
            Is there a way to clear the data will it be held if i dont use it?

            After the first message i then always get an error so its not working out the mids correctly.

            Aug-24 20:01:41 capi.vb Error, Exception parsing Parm: Conversion from string "E06" to type 'Integer' is not valid.

            I can change the message that hs3 is being sents but i will still need to split it down somehow for the device ref and value

            Comment


              #21
              Aug-24 20:14:36 capi.vb Error, Exception parsing Parm: Conversion from string "E06" to type 'Integer' is not valid.
              Aug-24 20:14:36 data LITE067030


              so the mid isnt working correctly ? but it does the first time if fire a command in

              Comment


                #22
                Originally posted by Matt Powell View Post
                Is there a way to clear the data will it be held if i dont use it?
                After the first message i then always get an error so its not working out the mids correctly.

                I can change the message that hs3 is being sents but i will still need to split it down somehow for the device ref and value
                It should dump the entire contents of the buffer to the script when the terminator is reached. I sometimes see a problem the first time my parsing script is called after a restart of HS, but then it works without issue after that.

                Can you use a different terminator? I use a '$' as my terminator,
                hs.OpenComPortTerm(21, "9600,N,8,1", 1, "Data_GetSG_ASCII.vb", "Main", "$")
                and that has been effective. Any character that will not show up as part of a normal control string ought to work.

                PS. Do you know there is no line feed after the Chr(13)? If there is, Chr(10) may be the first character in the buffer for each successive message.
                Mike____________________________________________________________ __________________
                HS3 Pro Edition 3.0.0.548, NUC i3

                HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                Comment


                  #23
                  thank you very much!!!! change the term to a $ which works and it makes sense the after the first message the line feed must of taken position 1 moving them all along!

                  Comment


                    #24
                    Excellent. Glad it's working.
                    Mike____________________________________________________________ __________________
                    HS3 Pro Edition 3.0.0.548, NUC i3

                    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                    Comment


                      #25
                      Mrhappy & UncleMichael I would just like to say a big thank you to both of you for your help!

                      I now have HS3 sending status if any device changes state on the fly and also receiving on - off - dim commands.

                      Comment


                        #26
                        Generic needs seen/receive on port

                        Hi,
                        I have been reading this thread in hope of solving my needs.

                        The problem looks extremely generic:
                        - Open (and keep open) port:
                        - send strings coming from somewhere
                        - receive and trap strings for destination elsewhere

                        I need exactly above, would you mind posting the final solution as it would help me a lot.

                        Thx,

                        Bob

                        Comment


                          #27
                          Originally posted by Bobone View Post
                          Hi,
                          I have been reading this thread in hope of solving my needs.

                          The problem looks extremely generic:
                          - Open (and keep open) port:
                          - send strings coming from somewhere
                          - receive and trap strings for destination elsewhere

                          I need exactly above, would you mind posting the final solution as it would help me a lot.

                          Thx,

                          Bob

                          Hi Bob,

                          I will put something together to send over as bits need putting in startup script aswell as 3 others.

                          Do you need what comes out on the RS232 leg to be generic or specific if its a light or pir etc ? I use the device ref to change the RS232 command.

                          Comment

                          Working...
                          X