Announcement

Collapse
No announcement yet.

Screen Update: Virtual Device vs. .ini File

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

    Screen Update: Virtual Device vs. .ini File

    This may be out there, but I'm hoping someone may have come across this before.

    I didn't like my TStat's scheduling interface, so I decided to create my own. I did it 2 ways, one by creating a bunch of virtual devices for all the different setpoints, and the way I wanted to do it - by saving the setpoints in an .ini file.

    Both screens look pretty much like this:

    Click image for larger version

Name:	TStat ini Screen.PNG
Views:	173
Size:	166.1 KB
ID:	1360394

    Both use similar scripts to change the setpoints when one of the arrow buttons is clicked.

    The version using the virtual devices updates the numbers on the screen instantly. The problem is with the .ini file - it can take up to 15 seconds to update the number on the screen after the arrow button is clicked.

    Here is the script I'm using, can anyone see anything I'm doing wrong to slow the HSTouch screen response?

    Code:
    'HS3 Script 2020-01-05  JG
    Sub Main(ByVal parm As Object)
    
    
        ' Get Setpoint to change and change direction
        Dim OldValue = 0, NewValue = 0, SetPointToChange, ChangeAction, RowLock, Row, Temp, Day
    
        SetPointToChange = parm(0).ToString ' Get Setpoint to change from HSTouch
        ChangeAction = parm(1).ToString ' Get increment direction from HSTouch
        RowLock = parm(2).ToString ' Get whether to change all row's setpoints from HSTouch
        Row = Mid(SetPointToChange, 16, 4) ' Get which row has been selected in HSTouch: Wake/Away/Home/Sleep
        Temp = Mid(SetPointToChange, 4, 4) ' Get whether Cool or Heat Setpoint has been selected in HSTouch
        Day = Mid(SetPointToChange, 1, 3) ' Get what day has been selected in HSTouch
    
        OldValue = hs.GetINISetting("Thermostat", SetPointToChange, "", "EyeNetTStat.ini")
    
        If ChangeAction = "UP" Then ' Calculate the new setpoint
            NewValue = OldValue + 1
        Else
            NewValue = OldValue - 1
        End If
    
        If RowLock = "Locked" And (Day = "Sat" or Day = "Sun") Then ' Override lock if day selected was Sat or Sun
            RowLock = "Unlocked"
        End If
    
        If RowLock = "Locked" ' Change M-F on the selected row all at the same time
            If Temp = "HEAT" Then
                If Row = "WAKE"
                    hs.SaveINISetting("Thermostat", "MonHeatSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueHeatSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedHeatSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuHeatSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriHeatSetpointWAKE", NewValue, "EyeNetTStat.ini")
                End If
                If Row = "AWAY" Then
                    hs.SaveINISetting("Thermostat", "MonHeatSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueHeatSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedHeatSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuHeatSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriHeatSetpointAWAY", NewValue, "EyeNetTStat.ini")
                End If 
                If Row = "HOME" Then
                    hs.SaveINISetting("Thermostat", "MonHeatSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueHeatSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedHeatSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuHeatSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriHeatSetpointHOME", NewValue, "EyeNetTStat.ini")
                End If 
                If Row = "SLEE" Then
                    hs.SaveINISetting("Thermostat", "MonHeatSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueHeatSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedHeatSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuHeatSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriHeatSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                End If 
            Else
                If Row = "WAKE" Then
                    hs.SaveINISetting("Thermostat", "MonCoolSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueCoolSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedCoolSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuCoolSetpointWAKE", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriCoolSetpointWAKE", NewValue, "EyeNetTStat.ini")
                End If
                If Row = "AWAY" Then
                    hs.SaveINISetting("Thermostat", "MonCoolSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueCoolSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedCoolSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuCoolSetpointAWAY", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriCoolSetpointAWAY", NewValue, "EyeNetTStat.ini")
                End If 
                If Row = "HOME" Then
                    hs.SaveINISetting("Thermostat", "MonCoolSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueCoolSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedCoolSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuCoolSetpointHOME", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriCoolSetpointHOME", NewValue, "EyeNetTStat.ini")
                End If 
                If Row = "SLEE" Then
                    hs.SaveINISetting("Thermostat", "MonCoolSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "TueCoolSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "WedCoolSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "ThuCoolSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                    hs.SaveINISetting("Thermostat", "FriCoolSetpointSLEEP", NewValue, "EyeNetTStat.ini")
                End If 
            End If
            hs.writelog("Climate",CStr(SetPointToChange & " changed to: " & NewValue & " Action: " & ChangeAction & ", Rows are: " & RowLock & " Row: " & Row))
        Else ' Change only the day selected
            hs.SaveINISetting("Thermostat", SetPointToChange, NewValue, "EyeNetTStat.ini")
            hs.writelog("Climate",CStr(SetPointToChange & " changed to: " & NewValue & " Action: " & ChangeAction & ", Rows are: " & RowLock))
        End If
    
    End Sub
    Again, I know this is a bit out there, but any advice would be greatly appreciated! I really want to get rid of all those virtual devices!!!
    Attached Files

    #2
    It's just how HST implemented the get/save ini functions. It's takes seconds to read/write them. Got the same results with a plugin I'm writing. Found an alternate 3rd party library that read/writes the under 1/4 of a second.

    Comment


      #3
      Have you considered concatenating a row as a string and parsing as you need it? This would reduce the action to one open/close on the file instead of 5. You could also read the file in as a string (My.Computer.FileSystem.ReadAllText("C:\test.txt")) and parse it yourself. Another option is to write a perl / python script to do the parsing.

      Comment


        #4
        Originally posted by AllHailJ View Post
        Have you considered concatenating a row as a string and parsing as you need it? This would reduce the action to one open/close on the file instead of 5. You could also read the file in as a string (My.Computer.FileSystem.ReadAllText("C:\test.txt")) and parse it yourself. Another option is to write a perl / python script to do the parsing.
        Thanks for that, I'll look at reading the whole file & parsing. If you look at the last part of the script, where it just changes one line, that still takes 10-15 seconds.

        Originally posted by dtsouers View Post
        It's just how HST implemented the get/save ini functions. It's takes seconds to read/write them. Got the same results with a plugin I'm writing. Found an alternate 3rd party library that read/writes the under 1/4 of a second.
        Thanks, I like .25 seconds! May I ask what 3rd party product that is?

        Comment


          #5
          You could manage the file without using the .ini functions. The .ini file structure is simple and you then have complete control over the file.

          Comment

          Working...
          X