Announcement

Collapse
No announcement yet.

Clickable Tasmota IP-Address

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

    Clickable Tasmota IP-Address

    I am using the mcsMQTT plugin with great pleasure for a number of years now (Many thanks Michael). Many relative cheap power plugs are in my house, all flashed with tasmota. One thing that is sometimes needed, is to connect to the web interface of a tasmota device. In the beginning I used the /INFO2:IPAddress field in a homeseer device. This gave two challenges: 1) You always have to type the ipaddress in a new browser window to connect and 2) the /INFO2:IPAddress is not up to date. This is only send during the boot of a tasmota device and can later change if you use DHCP.

    I solved 1 in the following way (by making the devicestring in homeseer clickable. It will open the webUI of tasmota in a new browser window):

    Click image for larger version

Name:	TasmotaDeviceWIthClickableIP.png
Views:	86
Size:	38.4 KB
ID:	1421945
    To make the devicestring clickable do this in mcsMQTT: create a device with the ipaddress:
    Click image for larger version

Name:	mqttdevice.png
Views:	84
Size:	10.4 KB
ID:	1421946
    And make the following regular expression (RegEx):
    for copy/past: (.+)
    for copy/past: <a href="http://$1"target="_blank">$1</a>

    Click image for larger version

Name:	mqttRegEx.png
Views:	87
Size:	94.5 KB
ID:	1421947

    2) To fix the updating of the ipaddress you need to use this topic (status 5 in tasmota) and have it updated regularly:
    btw: first execute the STATUS 5 command in the console of your tasmota device so it sends the STATUS 5 message to mcsMQTT

    Click image for larger version

Name:	Status5Topic.png
Views:	80
Size:	11.5 KB
ID:	1421950

    Unfortunately the status 5 is not send automatically by tasmota. I created the following 2 rules to do that:
    # create rule
    rule1 on rules#timer=1 do status 5 endon on rules#timer=1 do ruletimer 600 endon
    # enable rule
    rule1 ON
    #Send status 5 on boot
    rule2 on System#Boot do ruletimer1 1 endon
    rule2 ON

    You can send this to your device using the publication list function of mcsMQTT (or type it in the console of your tasmota device)
    Click image for larger version

Name:	makeRules.png
Views:	83
Size:	64.7 KB
ID:	1421949

    Hoop this is useful for anyone. Or let me know if you have a better way.
    Regards,
    Bart

    (btw: I don't use the %prefix% on my tasmota devices, so your topics my look different)

    Attached Files

    #2
    Thanks for no1, nice tweak.
    for no2, I use automatically triggered mqtt events to all units, this way I dont have to add rules manually when adding devices ( status 0 or 5 )

    Click image for larger version

Name:	Screenshot_20200926-095810_Samsung Internet.jpg
Views:	85
Size:	87.0 KB
ID:	1421984

    Comment


      #3
      Great tips, thanks!
      stefxx

      Comment


        #4
        bartg why aren't you using the %prefix% on the tasmotas? What are the benefits (and drawbacks, if any)?

        123qweasd I tried to duplicate your events, but I don't believe they do anything on my system. I am quite new to MQTT, so it might be a dumb question, but is there anything else I should do to make this work? I verified that the group topic on my devices are indeed "tasmotas".

        Thanks!!
        stefxx

        Comment


          #5
          123qweasd I always have a love hate relationship with "where to put which functionality". Within homeseer it is very easy to create functionality. But with the growing size on my homeseer over the last 12 years (any many scripts and plugins) I often don't know anymore why some events are there. Must be my age🙄


          why aren't you using the %prefix% on the tasmotas? What are the benefits (and drawbacks, if any)?
          If I would do over again, I would not change the default. I even think of changing them all back to the default (unfortunately you cannot control the mcsMQTT plugin with a script) . My challenge was my ESPNow to MQTT gateway which I have written. The gateway in the first versions used the mac address of an ESP with ":" in the MQTT topic (example 30:AE:A4:CF:38:6C/luchtdruk). That gave unwanted behavior with the mcsMQTT plugin (fills the T1, T2, -- T6). Only way the fix it at that moment was to make sure the first word in the mqtt topic was the device name.

          If anybody is interested, I use ESP32 devices with battery which last for 2 years. These are using the ESPNow protocol (but I can switch on WiFi for software updates). In homeseer they are MQTT devices.
          The device mac-address is the devicename (in the MQTT topic):
          Click image for larger version  Name:	espnow.PNG Views:	0 Size:	140.3 KB ID:	1422019
          For example motion sensor:
          Click image for larger version  Name:	esonowMotionSensor.PNG Views:	0 Size:	290.1 KB ID:	1422020

          Comment


            #6
            I tried to duplicate your events, but I don't believe they do anything on my system. I am quite new to MQTT, so it might be a dumb question, but is there anything else I should do to make this work? I verified that the group topic on my devices are indeed "tasmotas".
            Try keywords in capitals. STATUS

            Comment


              #7
              Also, to double check, open any Tasmota device console and check if it responds.

              I like polling status 0 as it returns all available data but if you prefer you can just poll status 5 to get the IP address.

              Comment


                #8
                I must all commend this idea of converting the payload into a hyperlink. Thank you for sharing.

                In my case I assign static addresses using my router DHCP assignment table so I do not have an issue of the IP address changing. This also makes it very easy for me to detect new devices that use DHCP as their IP will be assigned in the x.x.x.2xx range. I am at x.x.x.141 now so have room for another 58 devices before I need to change my DHCP range upward.

                I also do not use the %prefix% in my topics. It is a matter of organization from me. I want my topics to look like a file folder structure starting from the root. When the Tasmota default of %prefix% is prepended then this organization is lost. It it kind of like Windows Downloads folder where Windows always prefixes its sort by periods of time (This week, Last Week, This Month, Last Month, This Year, Long Time). If I am looking for file xyz, then I first need to know what block of time that xyz was downloaded so it because more difficult to locate this file in the Downloads folder listing.

                Note that when %prefix% is not used in Tasmota that the HS publish topics are no longer cmnd/x/y, but are x/cmnd/y. Most other firmwares have the topic convention of x/y/command or x/y/set

                Breaking down rules into component parts and using two rules makes it easier to understand. Adding them to a publist provides good documentation and an easy way to clone. Just FYI, I believe the following does the same thing. Note that it is ruletime1 600 rather than ruletimer 600 for proper syntax. It could be that both forms will work just as power1 and power have the same meaning.
                Code:
                rule1 on System#Boot do ruletimer1 1 endon on rules#timer=1 do backlog status 5; ruletimer1 600 endon
                rule1 1

                Comment


                  #9
                  Thanks. I tried capitals, no change. When I look at the console of the Tasmota device, I see nothing happening.
                  stefxx

                  Comment


                    #10
                    Here is my event:

                    Click image for larger version

Name:	Untitled.png
Views:	74
Size:	116.8 KB
ID:	1422034

                    As you see I am using HS4 but that shouldn't make a difference I assume.
                    stefxx

                    Comment


                      #11
                      unfortunately you cannot control the mcsMQTT plugin with a script
                      Can you give an example of what you would like to be able to do via script?

                      The gateway in the first versions used the mac address of an ESP with ":" in the MQTT topic (example 30:AE:A4:CF:38:6C/luchtdruk). That gave unwanted behavior with the mcsMQTT plugin (fills the T1, T2, -- T6). Only way the fix it at that moment was to make sure the first word in the mqtt topic was the device name.
                      I understand potential issues with topic that has colon and mcsMQTT convention of using colon as a JSON level separator. Can you explain why something that starts with luchtdruk/30:AE:A4:CF:38:6C provides a better result than starting with 30:AE:A4:CF:38:6C/luchtdruk?

                      I understand the efficiency gains with ESPNow, but what do you have implemented using it? Somebody in the past has suggested it for the BLE location tracking projected I implemented as a means of the ESP32 to intercommunicate to share beacon information.

                      Comment


                        #12
                        "cmnd" must be lowercaps for sure.
                        ​​​​​​

                        Comment


                          #13
                          Thanks Michael McSharry . As I only have 3 devices into my production environment, I can still change quite easily (I plan to add many more soon). I like the idea of dropping the prefix, as I believe it is clearer and more orderly indeed. But before I do that, I like to understand any negative consequences. From your post I don't see any, however bartg wants to go back to default... I like to understand why?
                          stefxx

                          Comment


                            #14
                            Originally posted by 123qweasd View Post
                            "cmnd" must be lowercaps for sure.​​​​
                            Thanks. Tried that as well, same result
                            stefxx

                            Comment


                              #15
                              From your post I don't see any, however bartg wants to go back to default... I like to understand why?
                              He will need to answer that question. In my case I always flash Tasmota from source so my default does not have the prefix. If you flash from from the Tasmota site binary then the default will have it and you need to manually configure it each time a new device is flashed. Reflashing Tasmota on the same device will not change the topic nomenclature so it only needs to be done the first time.

                              Comment

                              Working...
                              X