No announcement yet.

Topics with arrays, and decimal dot

  • Filter
  • Time
  • Show
Clear All
new posts

    Topics with arrays, and decimal dot

    Hi, looking for some advice. I have the following topics (from a Shelly 2.5 device):

    Click image for larger version

Name:	Screenshot 2020-09-27 172715.png
Views:	74
Size:	52.0 KB
ID:	1422274

    First, these topics contain an array for both switches of the dual device. What is the best way to handle this? In HS4 I would makes sense to have 2 features for each of those topics.

    Secondly, and probably based on my regional Windows settings, the decimal dot is ignored. So I always have to divide the result by 10, 100 or more depending on the number of decimals. It there any way this could be managed more intelligently by the plugin?


    For the array the control/status type will be CSV. A feature will be created for each array element. Search for CSV in the manual.
    For the period use edit tab, inbound subscription, expression row REPLACE($$PAYLOAD:,".",",") or use the regular expression replace \. with ,


      I searched for array in the docs, not for CSV. Now it makes perfect sense.

      For decimals, I can't get REPLACE($$PAYLOAD:,".",",") to work. But the regex (replace \. with ,) works fine, I will use that from now on. Much better than dividing by 10 or 100. Still think it would be better if the plugin would handle this internally.

      Thanks for your ongoing support! I appreciate the plugin more every single day. It seems to have a solution for almost every situation


        Glad it is working. I tried REPLACE function and worked for me when replacing one number for another. I will leave it alone.

        I suspect I could do the substitutions automatically if the user has selected a control/status UI that expects numbers. I put this in Please confirm it works with your regional settings.


          Great! However, it doesn't work for me.

          Not sure how you implemented this, but instead of replacing dots with comma's, it might be easier to just do
          System.Convert.ToDecimal(MQTT-value, New System.Globalization.CultureInfo("en-US"))
          which should always work, any region, as long as it is a valid number. I use this in my plugins when reading JSON values (which also have decimal dots).


            I put your suggestion in the attached.
            Attached Files