Announcement

Collapse
No announcement yet.

Expression Calculation broken in HS4 5.9.3.2 (coming from HS4 5.6.3.0)?

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

    Expression Calculation broken in HS4 5.9.3.2 (coming from HS4 5.6.3.0)?

    Hi Michael,

    Today I noticed the is an update available for this great mcsMQTT plugin so I updated (to HS4 5.9.3.2). After that I noticed all Expression calculations are not working anymore, I have a lot of (simple calculations like $$PAYLOAD: / 3600000 and it turned out it doesn't matter what you put in; it's not taken into account anymore. I reverted back to HS4 5.6.3.0 and all is fine again.


    #2
    I just downloaded and tried an expression without issue. I suspect the issue relates to regional settings. What does the payload look like that is failing?

    Comment


      #3
      It's just a big integer, example:1207072800 . Divided by 3600000 the result should be 33,5298

      Comment


        #4
        I did a test with 2000000001 payload and same expression you posted. This is what was contained in the debug log. Can you post what is in your debug log for something similar? Debug is enabled from the top of the General tab. Created file is \data\mcsMQTT\mcsMQTT Debug.txt

        11/24/2020 12:38:24 PM 284989 | Update Accepted 9004 to 2000000001 StatusType=2 Payload=2000000001 RegExValue=2000000001
        11/24/2020 12:38:24 PM 284995 | Updating Device from 277.777778055556 PayloadNumeric=True
        11/24/2020 12:38:24 PM 284997 | ApplyExpression 2000000001 / 3600000 Result=555.555555833333

        Comment


          #5
          Michael McSharry

          I have the same problem, since I installed HS4 5.9.3.2
          The device you had me modified about 10 days ago because decimal values were transfer as zero (probably because of regional settings) in the "humidity" feature value once again are showing 0 eventough I made no change to the mcsmqtt device expression page

          see https://forums.homeseer.com/forum/hs...86#post1433786

          here is the debug
          2020-11-28 10:45:50 312843564 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 80| 80| 2205
          2020-11-28 10:45:50 312843565 | Update Accepted 2210 to 12,34 StatusType=2 Payload=12.34 RegExValue=12,34
          2020-11-28 10:45:50 312843569 | Updating Device from 0 PayloadNumeric=True
          2020-11-28 10:45:50 312843569 | ApplyExression 12,34/100 Unexpected comma : at position 3 0 Unexpected comma : at position 3
          2020-11-28 10:45:50 312843572 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 0| 0| 2210
          2020-11-28 10:45:50 312843572 | Update Accepted 2366 to 15 StatusType=2 Payload=15 RegExValue=15
          2020-11-28 10:45:50 312843577 | Updating Device from 15 PayloadNumeric=True
          2020-11-28 10:45:50 312843579 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 15| 15| 2366
          2020-11-28 10:45:50 312843580 | Update Accepted 2199 to 989.1 StatusType=2 Payload=989.1 RegExValue=989.1
          2020-11-28 10:45:50 312843583 | Updating Device from 0 PayloadNumeric=False
          2020-11-28 10:45:50 312843585 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 0| 0| 2199
          2020-11-28 10:45:50 312843586 | Update Accepted 2197 to 21.77 StatusType=3 Payload=21.77 RegExValue=21.77
          2020-11-28 10:45:50 312843587 | Updating Device from 22 PayloadNumeric=False
          2020-11-28 10:45:50 312843588 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 22| 22| 2197
          2020-11-28 10:45:50 312843588 | Update Accepted 2206 to 2965 StatusType=2 Payload=2965 RegExValue=2965
          2020-11-28 10:45:50 312843590 | Updating Device from 2965 PayloadNumeric=True
          2020-11-28 10:45:50 312843590 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 2965| 2965| 2206
          2020-11-28 10:45:50 312843591 | ManageNewMessage zigbee2mqtt/Detecteur humidite SDB
          2020-11-28 10:45:50 312843591 | ActoOnMessageForTrigger Topic zigbee2mqtt/Detecteur humidite SDB,Payload={"battery":80,"humidity":12.34,"linkquality":15, "pressure":989.1,"temperature":21.77,"voltage":2965}

          Comment


            #6
            2020-11-28 10:45:50 312843565 | Update Accepted 2210 to 12,34 StatusType=2 Payload=12.34 RegExValue=12,34
            2020-11-28 10:45:50 312843569 | Updating Device from 0 PayloadNumeric=True
            2020-11-28 10:45:50 312843569 | ApplyExression 12,34/100 Unexpected comma : at position 3 0 Unexpected comma : at position 3
            Expressions are parsed using USA convention of period for the decimal separator. When RegEx is used to convert period to comma then the payload can no longer be used in expressions. In an earlier discussion the problem was going in the other direction and to deal with that a replacement variable $$VALUE_EUROPE: was added so that the plugin knows to expect a comma rather than a period for numbers.

            I can add $$PAYLOAD_EUROPE: to accomplish the same objective, but I do not think it should be needed. I believe the desired result will be obtained if you remove the RegEx. If you still have a problem then I can go back to the original method I used for dealing with regional settings where I explicitly do the conversions rather than letting .NET handle it.

            Comment


              #7
              I tried removing the ReGex and kept the $$PAYLOAD:/100 but the result of the expression never makes it to the device value

              here is the payload:
              {"battery":80,"humidity":11.22,"linkquality":15,"pressure":9 89.1,"temperature":21.77,"voltage":2965}

              here is the debug:

              2020-11-28 17:43:30 706328 | Update Accepted 2210 to 11.22 StatusType=2 Payload=11.22 RegExValue=11.22
              2020-11-28 17:43:30 706329 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 80| 80| 2205
              2020-11-28 17:43:30 706330 | Updating Device from 1122 PayloadNumeric=False
              2020-11-28 17:43:30 706330 | ApplyExpression 11.22/100 Result=0,1122
              2020-11-28 17:43:30 706331 | HSEvent VALUE_SET| 2048| zigbee2mqtt/Detecteur humidite SDB| 1122| 1122| 2210

              here is the device:
              Click image for larger version

Name:	mcsmqtt.PNG
Views:	150
Size:	25.8 KB
ID:	1436822

              Comment


                #8
                Let us try going back to the previous method to deal with regional settings. Unzip the attached into the \bin\mcsMQTT folder when mcsMQTT is not running. No RegEx and the Expression.

                What I expected to see in your previous test is the HS device received a value of 0 with the fractional part not showing. I think you would have obtained your desired result if the expression was divide by 1 rather than divide by 100. I also expect the desired result if you had only the RegEx to change the period to a comma without the additional expression to divide by 100.

                Attached Files

                Comment


                  #9
                  Hi Michael

                  With this new dll,
                  1- if i keep the the same setup as previous test, the value field is not even changed and here is the debug line with a "convert string to double" error
                  2020-11-28 20:50:57 1422343 | SetDevcieValueString2 RegEx on 9.66, Pattern=, Replace=, Match=0, sValue=9.66 La conversion de la chaîne "9.66" en type 'Double' n'est pas valide. 0 La conversion de la chaîne "9.66" en type 'Double' n'est pas valide.

                  2- if i go with the regex witout any expression I have the desired result (22.33 is changed to 22,33 in the value field of the device)

                  Comment


                    #10
                    I believe #2 is the intended interface and conversion method. Are you set now or is there something else that is causing issue?

                    I will need to look at #1 and trap the error so it is not raised to the log.

                    Comment


                      #11
                      Michael McSharry I am set, thank you for this fix.

                      Comment

                      Working...
                      X