Announcement

Collapse
No announcement yet.

Grab console output and set virtual device values

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

    #16
    Originally posted by jon00 View Post
    Add the following to the ini file:

    DeviceMode=2

    This will allow you to set the status graphics from the value (0 or 100) but keep the device text (Locked/unlocked)

    Alternatively use:

    DeviceMode=3

    This will allow you to set the status graphics and also set the status text from the value (0 or 100).
    Thanks, that worked. But now I have a different problem. I have changed the names of the locks to Front/Side Door to better fit my Homeseer naming convention. But that broke the script. The HS log says

    Code:
     [TABLE="class: log_table_row, cellspacing: 0"]
    [TR]
    [TD="class: LogDateShort LogDateTime0, align: left"][COLOR=#FF0000]Dec-18 11:41:39 [/COLOR][/TD]
     			[TD="class: LogPri0, align: left"] [/TD]
     			[TD="class: LogType0, colspan: 3, align: left"][COLOR=#FF0000]Jon00_DataScrape [/COLOR][/TD]
     			[TD="class: LogEntry0, colspan: 8, align: left"][COLOR=#FF0000]Error - Cannot access path: [/COLOR][/TD]
     		[/TR]
    [/TABLE]
    [TABLE="class: log_table_row, cellspacing: 0"]
    [TR]
    [TD="class: LogDateShort LogDateTime1, align: left"][COLOR=#000000]Dec-18 11:41:39 [/COLOR][/TD]
     			[TD="class: LogPri1, align: left"] [/TD]
     			[TD="class: LogType1, colspan: 3, align: left"][COLOR=#000000]Event [/COLOR][/TD]
     			[TD="class: LogEntry1, colspan: 8, align: left"][COLOR=#000000]Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/Jon00DataScraper.vben("Main","1") [/COLOR][/TD]
     		[/TR]
    [/TABLE]
    [TABLE="class: log_table_row, cellspacing: 0"]
    [TR]
    [TD="class: LogDateShort LogDateTime0, align: left"][COLOR=#000000]Dec-18 11:41:39 [/COLOR][/TD]
     			[TD="class: LogPri0, align: left"] [/TD]
     			[TD="class: LogType0, colspan: 3, align: left"][COLOR=#000000]Event [/COLOR][/TD]
     			[TD="class: LogEntry0, colspan: 8, align: left"][COLOR=#000000]Event Trigger "Security UpdateDoorLockStatus" [/COLOR][/TD]
     		[/TR]
    [/TABLE]
    [TABLE="class: log_table_row, cellspacing: 0"]
    [TR]
    [TD="class: LogDateShort LogDateTime1, align: left"][COLOR=#000000]Dec-18 11:41:39 [/COLOR][/TD]
     			[TD="class: LogPri1, align: left"] [/TD]
     			[TD="class: LogType1, colspan: 3, align: left"][COLOR=#000000]Event [/COLOR][/TD]
     			[TD="class: LogEntry1, colspan: 8, align: left"][COLOR=#000000]Event Security UpdateDoorLockStatus triggered by the event page 'Run' button[/COLOR][/TD]
     		[/TR]
    [/TABLE]
    .ini file

    Code:
    [Grab1]
    Path="C:\ProgramData\vsure\lockstatus.txt"
    TextFile=0
    Encoding=
    Username=
    Password=
    Options=
    UserAgent=
    Devicemode=3
    StripHTML=0
    Pattern1=(?s)Front Door.*?currentLockState": "(.*?)",
    Pattern2=(?s)Side Door.*?currentLockState": "(.*?)",
    DeviceName1=Front Door Status
    DeviceName2=Side Door Status
    DeviceText1=[0]
    DeviceText2=[100]
    DeviceValue1=[0] [replace "UNLOCKED","0"][replace "LOCKED","100"]
    DeviceValue2=[100] [replace "UNLOCKED","0"][replace "LOCKED","100"]
    and the input file

    Code:
    [
        {
            "deviceLabel": "XXX",
            "area": "Front Door",
            "method": "THUMB",
            "lockedState": "UNLOCKED",
            "currentLockState": "UNLOCKED",
            "pendingLockState": "NONE",
            "eventTime": "2018-12-18T07:33:58.000Z",
            "secureModeActive": false,
            "motorJam": false,
            "paired": true
        },
        {
            "deviceLabel": "XXX",
            "area": "Side Door",
            "userString": "YYY",
            "method": "TAG",
            "lockedState": "UNLOCKED",
            "currentLockState": "UNLOCKED",
            "pendingLockState": "NONE",
            "eventTime": "2018-12-18T07:26:11.000Z",
            "secureModeActive": false,
            "motorJam": false,
            "paired": true
        }
    ]
    i.e the same as before except for the changed lock names.The "Cannot access path" is throwing me off - the paths are correct and all files present. It doesn't matter which path I use anyway.

    Is it the spaces in "Front Door" and "Side Door"?

    Comment


      #17
      The config has nothing to do with the path of the file. If the filename has not changed, I cannot see why you are getting this error.
      Jon

      Comment


        #18
        Originally posted by jon00 View Post
        The config has nothing to do with the path of the file. If the filename has not changed, I cannot see why you are getting this error.
        I must have broken something during my tinkering. I restored the system to a time before I installed the script (thank God for virtual machines), started over, and it works again.

        Comment


          #19
          Apologies for all the questions, but now that I have the basics working I would like to scrape some more values. I think I understand how to do a simple two-state variable, but what about a time stamp or other string?

          Code:
          [
              {
                  "deviceLabel": "XXX",
                  "area": "FrontDoor",
                  "userString": "[COLOR=#FF0000]John Doe[/COLOR]",
                  "method": "[COLOR=#FF0000]REMOTE[/COLOR]",
                  "lockedState": "UNLOCKED",
                  "currentLockState": "UNLOCKED",
                  "pendingLockState": "NONE",
                  "eventTime": "[COLOR=#FF0000]2018-12-19T10:11:18.000Z[/COLOR]",
                  "secureModeActive": false,
                  "motorJam": false,
                  "paired": true
              },
              {
                  "deviceLabel": "YYY",
                  "area": "SideDoor",
                  "userString": "[COLOR=#FF0000]Jane Doe[/COLOR]",
                  "method": "[COLOR=#FF0000]TAG[/COLOR]",
                  "lockedState": "UNLOCKED",
                  "currentLockState": "UNLOCKED",
                  "pendingLockState": "NONE",
                  "eventTime": "[COLOR=#FF0000]2018-12-19T07:16:22.000Z[/COLOR]",
                  "secureModeActive": false,
                  "motorJam": false,
                  "paired": true
              }
          ]
          Code:
          [Grab1]
          Path=C:\ProgramData\vsure\lockstatus.txt
          TextFile=0
          Encoding=
          Username=
          Password=
          Options=
          UserAgent=
          Devicemode=3
          StripHTML=0
          Pattern1=(?s)FrontDoor.*?currentLockState": "(.*?)",
          Pattern2=(?s)SideDoor.*?currentLockState": "(.*?)",
          DeviceName1=FrontDoor Status
          DeviceName2=SideDoor Status
          DeviceText1=[0]
          DeviceText2=[100]
          DeviceValue1=[0] [replace "UNLOCKED","0"][replace "LOCKED","100"]
          DeviceValue2=[100] [replace "UNLOCKED","0"][replace "LOCKED","100"]
          I would have to scrape these and then somehow get the values into the Homeseer UI. Status variable values won't work for things like dates.

          Comment


            #20
            Add the following to the ini file:

            Code:
            Pattern3=(?s)FrontDoor.*?userString": "(.*?)",
            Pattern4=(?s)SideDoor.*?userString": "(.*?)",
            Pattern5=(?s)FrontDoor.*?method": "(.*?)",
            Pattern6=(?s)SideDoor.*?method": "(.*?)",
            Pattern7=(?s)FrontDoor.*?eventTime": "(.*?)",
            Pattern8=(?s)SideDoor.*?eventTime": "(.*?)",
            DeviceName3=FrontDoor User
            DeviceName4=SideDoor User
            DeviceName5=FrontDoor Method
            DeviceName6=SideDoor Method
            DeviceName7=FrontDoor Time
            DeviceName8=SideDoor Time
            DeviceText3=[200]
            DeviceText4=[300]
            DeviceText5=[400]
            DeviceText6=[500]
            DeviceText7=[600]
            DeviceText8=[700]
            This should provide the status. You can add values using my Locked/unlocked example.
            Jon

            Comment


              #21
              Thanks, I did this but how would I use it on a string like a date? The grab is 100% correct but I have problems with the timestamps.


              Code:
              [Grab1Data]
              0=UNLOCKED
              500=Home Helpers
              600=2018-12-19T10:11:18.000Z
              700=2018-12-19T07:16:22.000Z
              100=UNLOCKED
              200=REMOTE
              300=TAG
              400=Per-Olof Litby
              Code:
              Pattern7=(?s)FrontDoor.*?eventTime": "(.*?)",
              DeviceName7=FrontDoor Timestamp
              DeviceText7=[600]
              In your pollen example you are using

              Code:
              DeviceText1=[100] [200]<br>[0]
              
              to get
              
              Wednesday March 11, 2015
              9.30
              but I just get "Unknown".

              Comment


                #22
                The pollen example is grabbing the time/date in that format as that was how it was displayed on the web page. The script has no direct functions to convert the UNIX time stamp to a date format in words. All you can do is make it more readable by removing some characters i.e.

                DeviceText7=[600][replace "T"," "] [replace ".000Z"," "]

                This should format the output as 2018-12-19 10:11:18 instead of 2018-12-19T10:11:18.000Z
                Jon

                Comment


                  #23
                  Originally posted by jon00 View Post
                  The pollen example is grabbing the time/date in that format as that was how it was displayed on the web page. The script has no direct functions to convert the UNIX time stamp to a date format in words. All you can do is make it more readable by removing some characters i.e.

                  DeviceText7=[600][replace "T"," "] [replace ".000Z"," "]

                  This should format the output as 2018-12-19 10:11:18 instead of 2018-12-19T10:11:18.000Z
                  Understood, and I'm happy with just the date string, but the problem is that I get nothing at all.

                  Code:
                  DeviceText7=[600][replace "T"," "] [replace ".000Z"," "]
                  just results in "Unknown":

                  Click image for larger version

Name:	Capture.PNG
Views:	77
Size:	165.1 KB
ID:	1267857

                  Comment


                    #24
                    SOLVED. I had DeviceMode set to 3 when it should be 2.

                    Now all I have to figure out is how to change the time to CET instead of Zulu.

                    Comment

                    Working...
                    X