Announcement

Collapse
No announcement yet.

Easy question; Change case of topic template?

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

    Easy question; Change case of topic template?

    I am using a default topic template for publishing that relies on names, locations, etc ($$room:,etc).

    However, rather than deal with case issues, is there a way to force them to all be lowercase? I feel like I've seen this in the manual and upon searching for it I didn't see it. Thanks!

    #2
    There is the Lower expression method that I think can be applied to the pub topic, but there is no general setting that applies at the time of association creation. I always change my pub topics as they generally are commands to control some other widget.

    <<Lower($$FLOOR./$$ROOM.)>> or perhaps <<Lower("$$FLOOR./$$ROOM.")>> are examples with the colon replaced by period so not interpreted as an emoji.

    Comment


      #3
      Originally posted by Michael McSharry View Post
      There is the Lower expression method that I think can be applied to the pub topic, but there is no general setting that applies at the time of association creation. I always change my pub topics as they generally are commands to control some other widget.

      <<Lower($$FLOOR./$$ROOM.)>> or perhaps <<Lower("$$FLOOR./$$ROOM.")>> are examples with the colon replaced by period so not interpreted as an emoji.
      I understand, as I mentioned, I was working on an mqtt panel, so if the case is consistent and matches my homeseer layout then it's an easy default.
      I've tried the suggestions with both "s and without and it only seems to add the string itself.

      Also, I realize this is a bigger ask however, is there a way to make mcsMqtt abide by the hs4 setting that puts Location first, then Location 2? It clearly isn't super common (as there are still several hs4 bugs regarding it) but my original hs3 system was built around 2 coming after 1. (If I could quickly invert these on all devices, I would too deal with the bugs.)

      Click image for larger version  Name:	Screenshot_20210223-224154.png Views:	0 Size:	384.4 KB ID:	1458487

      Comment


        #4
        I did an evaluation with the following test case where I controlled device 4468 from HS.

        Click image for larger version

Name:	Capture.PNG
Views:	63
Size:	20.7 KB
ID:	1458644

        In the debug I see the debug for the expression and for the topic that was published
        2/24/2021 1:19:23 PM 722198 | ApplyExpression lower("Broadlink/192.168.0.241/ir/set") Result=broadlink/192.168.0.241/ir/set
        2/24/2021 1:19:23 PM 722199 | Publish broadlink/192.168.0.241/ir/set=Toshiba-Right
        I should be able to setup a default topic template so newly created devices would have the format that you desire. Would this be what you need?

        Comment


          #5
          Originally posted by Michael McSharry View Post
          I did an evaluation with the following test case where I controlled device 4468 from HS.

          Click image for larger version

Name:	Capture.PNG
Views:	63
Size:	20.7 KB
ID:	1458644

          In the debug I see the debug for the expression and for the topic that was published


          I should be able to setup a default topic template so newly created devices would have the format that you desire. Would this be what you need?
          Yes, that's what I was trying to do.

          Comment


            #6
            What did you get when you used the lower function as I showed in the above? I got the expected result of a lower case topic being published.

            Comment


              #7
              Originally posted by Michael McSharry View Post
              What did you get when you used the lower function as I showed in the above? I got the expected result of a lower case topic being published.
              The screenshot I posted is exactly what I received. I went to create a new device, and it put the whole "<<Lower ... string in the field.

              Edit: Whoops, I didn't realize the image was cropped so poorly;
              Click image for larger version

Name:	hs4_mcsmqtt_try3.png
Views:	51
Size:	15.7 KB
ID:	1458941

              Comment


                #8
                I tried it with both the HS3 and HS4 plugin. I also tried it with "lower" and "Lower" to confirm case does not matter. I set the default topic template on the General tab to be the lower case of room, floor and name. This way each new association on non-plugin devices will have the desired pub topic format

                Click image for larger version

Name:	Capture1.PNG
Views:	42
Size:	8.3 KB
ID:	1459167

                I created n new HS virtual device Th default name was Control with upper case C

                Click image for larger version

Name:	Capture2.PNG
Views:	40
Size:	13.1 KB
ID:	1459168

                I clicked the Enumerate Non-Plugin Devices from the bottom of General tab so that mcsMQTT will know about the newly created HS device.

                Click image for larger version

Name:	Capture3.PNG
Views:	51
Size:	6.1 KB
ID:	1459169

                I clicked the "a" column checkbox for ref 3056. The association was made and the default pub topic template is the default that was setup above.

                Click image for larger version

Name:	Capture.PNG
Views:	64
Size:	19.6 KB
ID:	1459166

                I clicked the Off button on HS Devices page for device 3056. HS generated an event callback to mcsMQTT indicating that device 3056 changed from 100 to 0. mcsMQTT used the expression to populate the topic fields with a resultant topic of "unknown/unknown/control". mcsMQTT published the message on this topic. These steps were recorded in the mcsMQTT Debug.txt file shown below.
                Code:
                2/26/2021 9:34:44 AM 213917 | HSEvent VALUE_CHANGE| 1024| | 0| 100| 3056
                2/26/2021 9:34:44 AM 213919 | ApplyExpression Lower("Unknown/Unknown/Control") Result=unknown/unknown/control
                2/26/2021 9:34:44 AM 213920 | Publish unknown/unknown/[B]control[/B]=0

                Comment


                  #9
                  Originally posted by Michael McSharry View Post
                  I tried it with both the HS3 and HS4 plugin. I also tried it with "lower" and "Lower" to confirm case does not matter. I set the default topic template on the General tab to be the lower case of room, floor and name. This way each new association on non-plugin devices will have the desired pub topic format

                  Click image for larger version

Name:	Capture1.PNG
Views:	42
Size:	8.3 KB
ID:	1459167

                  I created n new HS virtual device Th default name was Control with upper case C

                  Click image for larger version

Name:	Capture2.PNG
Views:	40
Size:	13.1 KB
ID:	1459168

                  I clicked the Enumerate Non-Plugin Devices from the bottom of General tab so that mcsMQTT will know about the newly created HS device.

                  Click image for larger version

Name:	Capture3.PNG
Views:	51
Size:	6.1 KB
ID:	1459169

                  I clicked the "a" column checkbox for ref 3056. The association was made and the default pub topic template is the default that was setup above.

                  Click image for larger version

Name:	Capture.PNG
Views:	64
Size:	19.6 KB
ID:	1459166

                  I clicked the Off button on HS Devices page for device 3056. HS generated an event callback to mcsMQTT indicating that device 3056 changed from 100 to 0. mcsMQTT used the expression to populate the topic fields with a resultant topic of "unknown/unknown/control". mcsMQTT published the message on this topic. These steps were recorded in the mcsMQTT Debug.txt file shown below.
                  Code:
                  2/26/2021 9:34:44 AM 213917 | HSEvent VALUE_CHANGE| 1024| | 0| 100| 3056
                  2/26/2021 9:34:44 AM 213919 | ApplyExpression Lower("Unknown/Unknown/Control") Result=unknown/unknown/control
                  2/26/2021 9:34:44 AM 213920 | Publish unknown/unknown/[B]control[/B]=0
                  Apologies. I think it's clear based on my post and yours following up, that I misunderstood where the substitution was taking place.
                  Once again, clearly my mistake. Thank you for taking the time to document that.
                  I will confirm the output of my publishes.

                  Comment

                  Working...
                  X