Announcement

Collapse
No announcement yet.

Status of Device Created by Big6 HTTP call

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

    Status of Device Created by Big6 HTTP call

    Hi all, this is probably a basic question but I've tried different solution and can't figure out what controls this aspect. This is on HS4

    I've created a Big6 HTTP profile to call to a doorlock API that requests a "status". I'm using that status with a virtual device I created with a string command to figure out if the lock is locked or unlocked. This is generally all working fine.

    The issue is that the Big6 HTTP call auto-creates a device and, in the device view, the status of that device is showing the full API response to that call. There's a lot of code-looking info and extra info that I don't want to see, but I can't figure out how to change what appears in that field. I've tried to use expressions, but I'm not sure where that expression goes to parse out just part of the response to show the status. Ideally I'd like to use the autogenerated device to do that lock/unlock reporting, but the status response is so long it's not usable.

    Thanks for any help!

    Best,
    Jason

    #2
    Expressions are well documented in the online documentation. Regardless I’ll gladly help if needed. Please provide the whole string and tell me what part to parse.

    Comment


      #3
      Hi,

      Thank you for your help! I have gone through the expression documentation and all that makes sense. Using the sandbox I wrote an expression that extracted the message I wanted from the API response (which I cut & paste into the input field). The expression is something like ${ JSON(input,"status") }. The output is "AugLockState_Locked".

      What I don't understand is where to input the expression to make the status of the device only show that output above.

      My profile is an HTTP Put command with a ${input} at the end. It carries a header with a lot of authentication data. I have nothing in the Big6 Expression (root or feature) section.

      The event adds the payload to ask for status (/remoteoperate/[specific item ID]/status)
      - I THINK this is the element that creates the "device" since the device status is showing the API response to this event (i.e. the full message I inputted into the sandbox), however I am not sure about that

      The device status shows as {"status":"kAugLockState_Locked","info":{"action":"status"," startTime":"2022-08-17T18:39:15.979Z","context":XXXXXXXX super long string of info}

      I would like it to just show the kAugLockState_Locked - I would ACTUALLY like it to just show Locked, but I hopefully can figure that out with a more thoughtful expression.

      Hopefully this is clear and thank you again for your support.


      Comment


        #4
        Congrats on the significant progress. The expression goes in "Device value expression" box. Please remove the ${ } wrap and place it there.
        Big6 uses profile name as device name by default, but if you want some fancy custom device name you can put it in the "Device name expression". Doesn't need to be an expression. Could be a static value such as "My lock", however you can also extract the name from the incoming string by an expression. This allows one single HTTP profile to serve several devices.

        Comment


          #5
          P.S. Yes, you can get just "Locked" parsed from your incoming JSON instead of the longer "kAugLockState_Locked". Use Split expression along the underline charcter and pick the second portion. You apply split on top of JSON like that

          Code:
          ${Split(JSON(input,"status"),"_")[1]}

          Comment


            #6
            Thank you for that help. Unfortunately, I'm still running into issues. When I run the event, the log is showing this response:

            [HTTP] [Big6 Plugin] [#PFL:door.front] [HttpConnection] [Raw message in]: {"status":"kAugLockState_Unlocked","info":{"action":"status" ,"startTime":"2022-08-17T20:19:08.494Z","context":{"transactionID":"tOyvbmLxrh","s tartDate":"2022-08-17T20:19:08.490Z","retryCount":1},"lockType":"lock_version_5 ","serialNumber":"XXXXXXX","rssi":-1,"wlanRSSI":-35,"wlanSNR":-1,"duration":3086,"lockID":"XXXXXXXX","bridgeID":"XXXXXXXXX" ,"serial":"XXXXXXX"},"doorState":"kAugDoorState_Init","retry Count":1,"totalTime":3105,"resultsFromOperationCache":false}

            If I use everything after "Raw message in]" in the sandbox, ${ JSON(input,"status") } outputs kAugLockState_Unlocked

            If I put JSON(input,"status") in the Device Value Expression box in the door.front profile, the log has a Big6 error:

            [HTTP] [Big6 Plugin] [#PFL:door.front] An error happened on incomming message. ErrorMessage Index was outside the bounds of the array. on at HSPI_Big6.HSPI.HandleIncommingMessage (HSPI_Big6.Features.Big6Connection con, HSPI_Big6.Features.Big6Message msg, HSPI_Big6.Features.Big6Profile profile, HSPI_Big6.Features.Big6Type type) [0x00275] in :0

            Not sure what is going wrong. If I cut/paste the entire log msg response above (with the [HTTP] [Big6 Plugin].... section) into the sandbox, the expression doesn't work, but I'm not sure that's the issue.

            Thanks again for your support, hopefully close now!


            Comment


              #7
              Everything you do is correct except for the last paragraph. You can't feed random text from the log into the sandbox.

              Please doublecheck for typos. Also curly quote characters " are frequent problem. Make sure that you use straight quotes " only. Retype all quotes. If nothing helps than please provide a screenshot of your profile here for me to analyze and try to reproduce the problem.

              Comment


                #8
                I rebuilt the Profile but still got the same error. Even if I change the Device Value Expression to a simple expression like Substring(input, 8, 4), I get the exact same error. For some reason Big6 doesn't seem able to analyze the response from the API. See below for details

                Click image for larger version

Name:	Screenshot 2022-08-18 000221.png
Views:	223
Size:	148.0 KB
ID:	1562178

                Click image for larger version

Name:	Screenshot 2022-08-18 000540.png
Views:	213
Size:	162.5 KB
ID:	1562179


                Comment


                  #9
                  Thanks. I'll look into it and let you know soon.

                  Comment


                    #10
                    Big6 tested O.K.

                    I can't replicate your case here exactly at my test bench for obvious reasons. As far as the problem is with the parsing reportedly I decided to check the parsing alone using TCP connection. I created "listening" TCP profile and I used third party TCP client to send out this JSON to Big6 listening profile.

                    Code:
                    {"status":"kAugLockState_Unlocked","info":{"action":"status" ,"startTime":"2022-08-17T20:19:08.494Z","context":{"transactionID":"tOyvbmLxrh","s tartDate":"2022-08-17T20:19:08.490Z","retryCount":1},"lockType":"lock_version_5 ","serialNumber":"XXXXXXX","rssi":-1,"wlanRSSI":-35,"wlanSNR":-1,"duration":3086,"lockID":"XXXXXXXX","bridgeID":"XXXXXXXXX" ,"serial":"XXXXXXX"},"doorState":"kAugDoorState_Init","retry Count":1,"totalTime":3105,"resultsFromOperationCache":false}
                    Sure enough everything works and Big6 created the HS4 device with status : kAugLockState_Unlocked
                    I used expression JSON(input, "status")

                    With this said I would recommend following actions for you.

                    Disable, uninstall and reinstall the latest beta version of Big6 v. 3.60.0.0

                    Comment


                      #11
                      Firstly, thank you for continuing to help here, I really appreciate the time and effort.

                      Your results are disappointing, but not that surprising I guess since I get the right response in the sandbox too, so I don't think it's the actual Raw Message In. I reloaded with the Beta version and still get the same error.

                      Could it be in the response header? Using a rest API client I ran the same PUT status request and this is the response header. If you add that to the TCP payload, does that create the same Big6 error I get?

                      date:Thu, 18 Aug 2022 06:31:42
                      GMTcontent-type:application/json
                      connection:keep-alive
                      content-security-policy:default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests
                      x-dns-prefetch-controlff
                      expect-ct:max-age=0
                      x-frame-options:SAMEORIGIN
                      strict-transport-security:max-age=15552000; includeSubDomains
                      x-download-options:noopen
                      x-content-type-options:nosniff
                      x-permitted-cross-domain-policies:none
                      referrer-policy:no-referrer
                      x-xss-protection:0
                      api-version:0.0.1
                      x-august-access-token:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXhbGxJZCRRRRRRRRRRRRRRRRv cmQiOZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZZZZZZZZ9uZSI6WyJwaG9uZTorMTQxNTg5NDkwNDkiXSwiZXhwaXJlc0 F0IjoiMjAyMi0xMi0xNlQwNjozMTo0MC45OTBaIiwidGVtcG9YYYYYYYYYYY YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
                      x-response-time:1258
                      cf-cache-statusYNAMIC
                      set-cookie:__cf_bm=3.qN5jmulc6._3YT2LA_kUU61rwcLmidD5e.IQ7VqBE-1660804302-0-AVORqeuTSSf3XFwiIcx99NEIpMNuELv9XZFYaqUroJiY+wfjQuiZEVcut9Zn z9q/rsdkVWNX6GQiC3UGNMCE2KE=; path=/; expires=Thu, 18-Aug-22 07:01:42 GMT; domain=.august.com; HttpOnly; Secure; SameSite=None
                      server:cloudflare
                      cf-ray:73c89ba0abcb9645-SJC
                      content-length:507

                      Comment


                        #12
                        Did you restart HS4 as well ? Please do if you didn’t.
                        I don’t think that the header is supposed to be part of the payload. Otherwise we will see this problem all over.
                        I will pass this to our developers for review and advise.

                        Comment


                          #13
                          Hi, I hadn't restarted before, but I just did and same had the same issue after I stopped, removed, restarted, added the Beta, restarted again.

                          I tried to run an expression on a different GET HTTP call and I have the same error message (see screen shots).

                          I am running HS4 on a Linux VM - could that be an issue? The thing is though, without any expression the HTTP profile works fine, it just populates the device status with the full response. It's only when I add something to the Device Value Expression that this error appears.



                          Click image for larger version

Name:	Screenshot 2022-08-18 203323.png
Views:	207
Size:	115.3 KB
ID:	1562349

                          Comment


                            #14
                            Our developers looked at it and told me that if you use value expression than you must use name expression as well for both root and feature devices. Please give it a try and let us know.

                            Comment


                              #15
                              Ok, that worked! Thanks so much for that insight!

                              One more question, although this is maybe more best practice. I'm trying to add a "feature" to the created device that can actually Lock and Unlock the connected device but I keep running into a circular reference. The feature is pulling a status (via the &&Device value expression) from the Big6 command (just set to some specific string for now) and I create an "Edit Controls" set for that feature (Lock / Unlock with values 0/1). I have it so pressing the lock button calls the same big6 profile but with "lock" instead of "status". I did this by executing an event whenever that feature is set to "lock"

                              When I press lock though, it sends the lock signal as expected, but the whole device updates also and the lock-button command fires again in an infinite loop.

                              Is there a way to add a command button that operates inside the Big6 created device that then controls that same device? Or do I create a different virtual device to act as the command?

                              Thanks so much for the help!

                              Comment

                              Working...
                              X