Announcement

Collapse
No announcement yet.

Problem with expression after updating to 4.0.3.0

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

  • Problem with expression after updating to 4.0.3.0

    Thanks for a great plugin!
    After updating to version 4.0.3.0 I have a problem with devices where the payload is transformed with an expression. The device is then populated with a the number 0 even tough it should be a positive number. This has been working fine before the update, so I suspect that the update is the cause or perhaps in a combination with the expression I use. On example is "$$PAYLOAD: / 10 * 1.25". However the problem seem to be the case with different expressions. If I remove the expression the device is updated with the original payload. One example in the pictures below. I have tried to adjust the expressions I use with no success. Also, the debug file contains no warning, it just says that the device is update

    Click image for larger version

Name:	Skjermbilde 2019-07-17 kl. 12.22.31.png
Views:	71
Size:	791.0 KB
ID:	1316163
    Click image for larger version

Name:	Skjermbilde 2019-07-17 kl. 14.50.59.png
Views:	66
Size:	78.9 KB
ID:	1316164


    Click image for larger version

Name:	Skjermbilde 2019-07-17 kl. 14.52.50.png
Views:	64
Size:	15.6 KB
ID:	1316165

  • #2
    I tried the expression with some test data and all seems to be working fine here. I do not know what version was working for you, but in the change log I do not see anything that I think would affect it. When Express mode was introduced is the last time that I see this area was touched.

    I notice that your expression has 1.25 rather than 1,25. I suspect the period is what the eval function is expecting, but then you all pass the payload that has a comma for the decimal point after going through the regex.

    Could the comma vs. period be a source of problem? I can add more debug if necessary, but first evaluate if it related to comma/period.

    Comment


    • #3
      Thanks for the answer. According to my lif the previous version installed was 4.0.0.0. Changing the expression (comma/period) did not solve the problem. Actually I was not able to get any expression to work in my setup, the just result in the device getting populated by a 0. I have solved my problem with a function in node red before sending data to HS. Happy to help with more debug if this is of any interest.

      Comment


      • #4
        I added debug around the RegEx and the Expression. My test shows the following in the debug for a payload of 10.0 that had the period removed with regex and the expression of $$PAYLOAD:/10*1.25 for a result of 12.5 that was stored in the HS device.

        7/19/2019 11:03:29 AM 339948 | Update Accepted 1380 to 100 StatusType=2 Payload= 10.0 RegExValue=100
        7/19/2019 11:03:29 AM 339979 | Updating Device from 25.5 PayloadNumeric=True
        7/19/2019 11:03:34 AM 344344 | ApplyExpression 100/10*1.25 Result=12.5

        The plugin with this additional debug is at http://mcsSprinklers.com/HSPI_MCSMQTT_4100.zip. Do a representative test and post the debug file or something similar to what I posted here.

        Comment


        • #5
          I have done a test with the testversion. I added the expression $$PAYLOAD:/10*1.25 to device 1157. The problem persists, the device 1157 is populated with a 0. This is the result from the log:

          19.07.2019 22:35:06 1 | mcsMQTT Version 4.1.0.0 running at C:\Program Files (x86)\HomeSeer HS3, HS is at C:\Program Files (x86)\HomeSeer HS3
          19.07.2019 22:35:06 19 | mcsMQTT InitHW ComputerName= XXXXPC, IOEnabled=False
          19.07.2019 22:35:06 147 | mcsMQTT Debug InitHW Database Ready
          19.07.2019 22:35:06 157 | PopulateReceiveDict AMSal1, PluginDevice=1, Ref=1121
          19.07.2019 22:35:06 172 | PopulateReceiveDict AMSal2, PluginDevice=1, Ref=1122
          19.07.2019 22:35:06 176 | PopulateReceiveDict AMSal3, PluginDevice=1, Ref=1123
          19.07.2019 22:35:06 179 | PopulateReceiveDict AMSvolt1, PluginDevice=1, Ref=1119
          19.07.2019 22:35:06 183 | PopulateReceiveDict AMSvolt3, PluginDevice=1, Ref=1120
          19.07.2019 22:35:06 186 | PopulateReceiveDict AMSwatt, PluginDevice=1, Ref=1118
          19.07.2019 22:35:06 190 | PopulateReceiveDict TotalConsumption, PluginDevice=2, Ref=1281
          19.07.2019 22:35:06 193 | PopulateReceiveDict 01:00, PluginDevice=1, Ref=1157
          ........

          19.07.2019 22:35:41 34951 | Update Accepted 1157 to "1:00" StatusType=2 Payload= "1:00" RegExValue="1:00"
          19.07.2019 22:35:41 34955 | Updating Device from 0 PayloadNumeric=False
          19.07.2019 22:35:41 34957 | ApplyExpression 0/10*1.25 Result=0
          19.07.2019 22:35:41 34958 | ActoOnMessageForTrigger Topic 01:00,Payload="1:00"
          19.07.2019 22:35:41 35056 | Update Accepted 1157 to 45,613749999999996 StatusType=2 Payload= 45.613749999999996 RegExValue=45,613749999999996
          19.07.2019 22:35:41 35057 | Updating Device from 0 PayloadNumeric=True
          19.07.2019 22:35:41 35061 | ApplyExression 45,61375/10*1.25 Unexpected comma : at position 3 0 Unexpected comma : at position 3
          19.07.2019 22:35:41 35063 | ActoOnMessageForTrigger Topic 01:00,Payload=45.613749999999996
          19.07.2019 22:35:41 35138 | Update Accepted 1156 to "2:00" StatusType=2 Payload= "2:00" RegExValue="2:00"
          19.07.2019 22:35:41 35140 | Updating Device from 44,65 PayloadNumeric=False
          19.07.2019 22:35:41 35141 | ActoOnMessageForTrigger Topic 02:00,Payload="2:00"
          19.07.2019 22:35:41 35152 | HSEvent VALUE_CHANGE| 1024| 02| 0| 44,65| 1156
          19.07.2019 22:35:41 35217 | Update Accepted 1156 to 44,65 StatusType=2 Payload= 44.65 RegExValue=44,65
          19.07.2019 22:35:41 35218 | Updating Device from 0 PayloadNumeric=True
          19.07.2019 22:35:41 35219 | ActoOnMessageForTrigger Topic 02:00,Payload=44.65
          19.07.2019 22:35:41 35230 | HSEvent VALUE_CHANGE| 1024| 02| 44,65| 0| 1156


          I am not an expert so not sure what to make of this. What I can say is that due to my limited knowledge of Node Red each topic receive a payload with text, and then a numeric payload. But this worked fine before the update. Also notice the spelling error on line 35061- a lacking "p" in ApplyExression.


          Comment


          • #6
            The comma at postion 3 is due the regular expression that was setup to change the period to a comma. If you remove the regular expression then you should have a good result. If you do not use a numeric expression then you likely need the regular expression due to your regional settings of expecting a comma for numbers.

            Comment

            Working...
            X