Announcement

Collapse
No announcement yet.

any way to change Cal values on xap1wire setup page via code

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

    any way to change Cal values on xap1wire setup page via code

    i would like to programmatically change the Cal value on a switch device from HS. how can i do this?
    Mark

    HS3 Pro 4.2.19.5
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
    Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

    #2
    Earlier versions of xapmcs1Wire supported the xAP schema that allowed a centralized setup management, but I found that I did not want to pursue that direction and removed that capability. There is a user that had posted a HTTP request to xapmcs1wire that emulated the setup page, but that is a lot of effort since so many keys are involved.

    I will review what I commented out and see if I can reenable a subset of it to provide the capability that you are looking for.

    Comment


      #3
      Thanks for the consideration Michael.

      I am basically trying to use the switch device (associated with a temp device) as a thermostat, but i would like to be able to change the cal values at different times of the day.

      I realize i could just setup a bunch of events to check the value of the temp sensor at different times of the day, but i was looking for something a little more elegant.
      Mark

      HS3 Pro 4.2.19.5
      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
      Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

      Comment


        #4
        I reenabled the Config schema with the latest posting of xapmcs1Wire V2.7.0. Be very careful to make a backup of the xapmcs1wire.ini file before you start playing with this as you could really mess things up if you are not careful.

        The following are examples of how to query xapmcs1wire for a configuration setting, its response, and how you can change a setting. There is no validation checking for the new value. I think I may add validation to give another degree of protection, but it is not there now. You need to look at your xapmcs1wire.ini to get the group, keys and format of the values.

        Code:
        xap-header
        {
        v=13
        hop=1
        uid=FF.000E:00
        class=Config.Query
        source=mcs.mcsXap.MCS6
        target=mcs.OneWire.MCS6
        }
        Config.Group
        {
        Group=DEVICES_CAL
        Key=360000002C49CA28
        }
        
        
        
        xap-header
        {
        v=13
        hop=1
        uid=FF.0005:00
        class=Config.Notification
        source=mcs.OneWire.MCS6
        }
        Config.Group
        {
        File=mcsXap1Wire.ini
        Group=DEVICES_CAL
        Key=360000002C49CA28
        Value=0;31|33;0;0;0;0;0;0
        }
        
        
        
        xap-header
        {
        v=13
        hop=1
        uid=FF.000E:00
        class=Config.Set
        source=mcs.mcsXap.MCS6
        target=mcs.OneWire.MCS6
        }
        Config.Group
        {
        Group=DEVICES_CAL
        Key=FE0008000879C210
        Value=0;0;0;0;0;0;0;0
        }

        Comment


          #5
          Thanks Michael.

          I gave it a try (but no go) using the XAP send msg action within a event. the attached image are the values i entered.

          i captured the following msg from the hub activity window. it isn't formated the same as your sample.

          Any suggestions?

          PS the second image is a snap from the event action page. i think the target and class values are reversed in the display

          Code:
          xap-header
          {
          v=13
          hop=1
          uid=FF.000E:0000
          class=Config.Set
          source=mcs.Xap.SERVER
          target=mcs.onewire.server
          }
          DEVICES_CAL
          {
          260008013621c510=1;75|76;0;0;0;0;0;0
          }
          Attached Files
          Mark

          HS3 Pro 4.2.19.5
          Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
          Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
          Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

          Comment


            #6
            The fields of interest are the following from my example

            class=Config.Set
            target=mcs.OneWire.MCS6
            section=Config.Group
            key=Group ... value=DEVICES_CAL
            key=Key ... value=FE0008000879C210
            key=Value ... value=0;0;0;0;0;0;0;0

            Comment


              #7
              got it working, with one issue

              I can change the Cal value (with the 1st mg below), but the the Rev also seems to be getting set to 1 every time. The second msg below was attempt to set the Cal & Rev value with 1 msg, but the Rev did not change as expected.

              i see [DEVCIES_REVERSEPOLARITY] & [DEVICES_REVERSEPOLARITY] as a section heading in the ini. is this correct?

              Any thoughts

              PS. the format of the summary msg in the event action is a little out of order

              *1ST MESSAGE*
              Code:
              xap-header
              {
              v=13
              hop=1
              uid=FF.000E:0000
              class=Config.Set
              source=mcs.Xap.SERVER
              target=mcs.onewire.server
              }
              Config.Group
              {
              Group=DEVICES_CAL
              Key=260008013621c510
              Value=1;75|76;0;0;0;0;0;0
              }

              *2ND MESSAGE*
              Code:
              xap-header
              {
              v=13
              hop=1
              uid=FF.000E:0000
              class=Config.Set
              source=mcs.Xap.SERVER
              target=mcs.onewire.server
              }
              Config.Group
              {
              Group=DEVICES_CAL
              Key=260008013621c510
              Value=1;75|76;0;0;0;0;0;0
              Group=DEVICES_REVERSEPOLARITY
              Key=260008013621c510
              Value=0;0;0;0;0;0;0;0
              }
              Mark

              HS3 Pro 4.2.19.5
              Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
              Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
              Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

              Comment


                #8
                I saw the reverse polarity setting when I was using the debugger, but forgot to compile after I fixed it. It is now uploaded with the correction. It is a leftover from when the cal field was used for this purpose on discretes.

                xAP provides the facility to use one message to convey multiple actions within the same message class. This is one of the differences between xAP and xPL. I did not implement multiple-sections for the Config class in xapmcs1wire, nor did I provide the mcsXap UI to send these via events. Had it been implemented it would look like:

                Code:
                xap-header
                {
                v=13
                hop=1
                uid=FF.000E:0000
                class=Config.Set
                source=mcs.Xap.SERVER
                target=mcs.onewire.server
                }
                Config.Group.1
                {
                Group=DEVICES_CAL
                Key=260008013621c510
                Value=1;75|76;0;0;0;0;0;0
                }
                Config.Group.2
                {
                Group=DEVICES_REVERSEPOLARITY
                Key=260008013621c510
                Value=0;0;0;0;0;0;0;0
                }
                What is significant is that xAP is designed for minimal size hardware so the parsing for messages needs to be done going forward only without a need for memory space to retain recursive information. Within a message each section name needs to be unique. Within a section each key needs to be unique.

                The multiple-group messages can be sent using the scripting interface provided by mcsXap. If you have a need to do this I will have xapmcs1wire accept these. I do not expect to add this to the Action UI for mcsXap.

                Comment


                  #9
                  thanks for the fix on the reverse polarity issue.

                  i think i can just send single msgs at a time for now using the event action feature.

                  for future reference, can you point in the direction of the documentation if i do need to use the scripting feature of the xap.net plugin?
                  Mark

                  HS3 Pro 4.2.19.5
                  Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
                  Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
                  Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

                  Comment


                    #10
                    The only thing that you will likely need is the abilty to send an xAp message (SendXapMessage), but other capabilities also exist. I put the full list below. It was documented in the HomeseerOverThere document several years ago that likely now has become dated and no longer totally correct.

                    I also included immediately below the script I use to monitor a folder to see if a camera has uploaded something into a folder. When it has an xAP message is sent using the Message.Display schema. This schema is used for various notification displays. This shows you how to format the string with the chr(0) and chr(1) delimiters. chr(0) corresponds to a newline character while chr(1) corresponds to the equal sign. I use this convention so there would not be confusion within the software when something like an equal sign is part of the data being sent in the message.

                    Another "freebe" to point out is the SendTCP that allows you to send messages to devices that use HTTP protocol rather than xAP. I do not know if I maintained this one with the .NET.

                    Code:
                    Sub Main()
                    
                    	Set fso = CreateObject("Scripting.FileSystemObject")
                    	FileCount = fso.GetFolder("C:\AnthemCamera\Data").Files.Count
                    	FolderCount = fso.GetFolder("C:\AnthemCamera\Data").SubFolders.Count
                    
                    	if (FileCount + FolderCount) <> cint(hs.GetIniSetting("Camera","Count","0","AnthemCamera.ini")) Then
                    		hs.SaveIniSetting "Camera","Count",cstr(FileCount + FolderCount),"AnthemCamera.ini"
                    		sData = "Duration" & chr(1) & "5" & chr(0) & _
                    			"Line1" & chr(1) & "Anthem Camera Motion" & chr(0) & _
                    			"Line2" & chr(1) & "File Count=" & cstr(FileCount + FolderCount) & " as of " & cstr(now)
                    		hs.GetPlugins("mcsXap").SendXapMessage "","Message.Display","Display.Text",cstr(sData),"",""
                    	End If
                    
                    End Sub

                    Code:
                        '================ APPLICATION INTERFACE ==================
                    
                        Public Sub SendXapMessage(ByRef sTarget As String, ByRef sClass As String, ByRef sSection As String, ByRef sData As String, Optional ByRef sSubaddress As String = "", Optional ByRef sUIDIn As String = "")
                    
                        Public Sub RegisterXapCallback(ByRef sFile As String, ByRef sProcedure As String)
                    
                        Public Sub UnRegisterXapCallback(ByRef sFile As String, ByRef sProcedure As String)
                    
                        'Script Callback on receipt of xap message ... not invoked from anywhere
                        Public Sub onMessage()
                    
                        Public Function mcsXapAsp(ByRef RequestObject As Request, ByRef ResponseObject As Object) As String
                    
                        Public Sub SendTCP(ByRef sIP As String, ByRef iPort As Integer, ByRef sData As String)
                    
                        Public Function XapReceiveCollectionCount() As Long
                    
                        Public Function XapReceiveMessagesCount() As Long
                    
                        Public Function XapProcessedMesssagesCount() As Long
                    
                        Public Function XapSocket1State() As Long
                     
                       Public Function XapSocket2State() As Long

                    Comment

                    Working...
                    X