How to get IP Address via Telegram

994 views
Skip to first unread message

Ajith Vasudevan

unread,
Jan 9, 2021, 1:19:03 AM1/9/21
to TasmotaUsers

Hello friends,

This is my very first post for help with a Tasmota feature. I've been a user of Tasmota for over 2 years now, and consider myself quite an expert in using it.

I recently discovered that Tasmota has Telegram support, and wish to leverage it for obtaining the DHCP--assigned IP address of my Tasmotized Wemos D1 Mini.

I am able to send messages to my Telegram Bot from Tasmota using "tmsend <message>".
I could use this command in a Tasmota Rule, but I am unable to figure out how to access the IPAddress in a Rule. I know that the INFO2 Tele- message on startup has the info I need. However, I cannot find any documentation as to how to trigger a rule when that Tele- message is sent.

I need this for a remote deployment, and I do not want to use MQTT for getting the IPAddress (STATUS 5), because, for my usecase, I have no need for MQTT for anything else.

It would be great if someone can help me with this.

Thanks in advance!

-Ajith

Philip Knowles

unread,
Jan 9, 2021, 1:35:46 AM1/9/21
to TasmotaUsers, Ajith Vasudevan
If you send a command with IPAddress1 and no parameters Tasmota will respond with the IP address. Don't know if that helps.
Please bear in mind that the whole point of Tasmota is to use MQTT.
Why not just set a static IP?

Regards

Phil K



From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Ajith Vasudevan <ajith.v...@gmail.com>
Sent: Saturday, January 9, 2021 6:19:03 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: How to get IP Address via Telegram
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/7096e064-38c5-4094-ac66-87fc2a8f7e2an%40googlegroups.com.

Ajith Vasudevan

unread,
Jan 9, 2021, 1:59:28 AM1/9/21
to TasmotaUsers
Thanks, Phil, for the quick reply.

As I mentioned, this is for a remote deployment and the only thing known about the network is the SSID and password. The subnet is also not known, for me to be able to set a static IP which would work.
The whole point of getting the IP address is for me to be able to tell it to the people at the remote site (over phone), so they can use it to access the web interface on their mobiles (to set the Timer, which, by the way, is the usecase )
As you can see, this is required only one-time after startup. Without the IP address (and MQTT), I cannot use the IPAddress1 command either.

I will setup MQTT in the worst case, but wanted to see if I can avoid it, because there's no use for it otherwise in my scenario.

I know that that Rules support "Tele-" events. But I am unable to figure out how to trigger a rule for the tele/SENSORS/INFO2 event at startup.
Also, is it possible to trigger Rules on "stat-" events? Because the command "IPAddress1" send out a "stat/<topic>/RESULT message. It is enough if I am able to access that in the Rule.


Regards,
Ajith

Philip Knowles

unread,
Jan 9, 2021, 2:29:34 AM1/9/21
to Ajith Vasudevan, TasmotaUsers

I’ll have a think but, in the worst case, you could use a public MQTT server, read the IP address and then disable MQTT. You could actually set that up in a rule so that it was totally automatic.

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

From: Ajith Vasudevan
Sent: 09 January 2021 06:59
To: TasmotaUsers
Subject: Re: How to get IP Address via Telegram

 

Thanks, Phil, for the quick reply.

 

As I mentioned, this is for a remote deployment and the only thing known about the network is the SSID and password. The subnet is also not known, for me to be able to set a static IP which would work.

The whole point of getting the IP address is for me to be able to tell it to the people at the remote site (over phone), so they can use it to access the web interface on their mobiles (to set the Timer, which, by the way, is the usecase )

As you can see, this is required only one-time after startup. Without the IP address (and MQTT), I cannot use the IPAddress1 command either.

 

I will setup MQTT in the worst case, but wanted to see if I can avoid it, because there's no use for it otherwise in my scenario.

 

I know that that Rules support "Tele-" events. But I am unable to figure out how to trigger a rule for the tele/SENSORS/INFO2 event at startup.

Also, is it possible to trigger Rules on "stat-" events? Because the command "IPAddress1" send out a "stat/<topic>/RESULT message. It is enough if I am able to access that in the Rule.

 

 

Regards,

Ajith

 

On Saturday, January 9, 2021 at 12:05:46 PM UTC+5:30 knowles...@gmail.com wrote:

If you send a command with IPAddress1 and no parameters Tasmota will respond with the IP address. Don't know if that helps.

Please bear in mind that the whole point of Tasmota is to use MQTT.

Why not just set a static IP?

Regards

Phil K

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Ajith Vasudevan <ajith.v...@gmail.com>
Sent: Saturday, January 9, 2021 6:19:03 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: How to get IP Address via Telegram

 

 

Hello friends,

 

This is my very first post for help with a Tasmota feature. I've been a user of Tasmota for over 2 years now, and consider myself quite an expert in using it.

 

I recently discovered that Tasmota has Telegram support, and wish to leverage it for obtaining the DHCP--assigned IP address of my Tasmotized Wemos D1 Mini.

 

I am able to send messages to my Telegram Bot from Tasmota using "tmsend <message>".

I could use this command in a Tasmota Rule, but I am unable to figure out how to access the IPAddress in a Rule. I know that the INFO2 Tele- message on startup has the info I need. However, I cannot find any documentation as to how to trigger a rule when that Tele- message is sent.

 

I need this for a remote deployment, and I do not want to use MQTT for getting the IPAddress (STATUS 5), because, for my usecase, I have no need for MQTT for anything else.

 

It would be great if someone can help me with this.

 

Thanks in advance!

 

-Ajith

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/7096e064-38c5-4094-ac66-87fc2a8f7e2an%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Barry Parr

unread,
Jan 9, 2021, 2:41:42 AM1/9/21
to TasmotaUsers
have you considered mDNS ?
they could then access it via

need to build with 
#define USE_DISCOVERY
then setoption55 1
hostname will be advertised in the information screen


Ajith Vasudevan

unread,
Jan 9, 2021, 2:43:52 AM1/9/21
to Philip Knowles, TasmotaUsers
Thanks again, Phil. That is one solution I can do, for now.
I was hoping that I somehow missed seeing the documentation on a stat- event Rule, or, a "%ipaddress% Rule variable, and that I will be chided and informed about it here ...  :)

Regards,
Ajith

Ajith Vasudevan

unread,
Jan 9, 2021, 2:47:43 AM1/9/21
to Barry Parr, TasmotaUsers
Thanks Barry! This sounds promising. I'm no stranger to building Tasmota from code. But how will I access the information screen in the first place without the IP Addresss?

I suppose I can set the hostname as well while building Tasmota. Will it be #define HOSTNAME   <my-host-name>  ?

Will it add those random characters to the actual advertised hostname?






You received this message because you are subscribed to a topic in the Google Groups "TasmotaUsers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonoffusers/CzRBWeNG21g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/CAECyPQi0gOd35OMuByX-Z1GB-sgPh4-DdkgcD0RUz7VpOhRZTQ%40mail.gmail.com.

Barry Parr

unread,
Jan 9, 2021, 2:59:11 AM1/9/21
to TasmotaUsers
haven't actually tried to set the hostname so can't answer that .
the default is based on the MAC addr , so it won't change
I presume you will be setting up the device before installing it.
I'll have a tinker tomorrow with setting hostname.

Philip Knowles

unread,
Jan 9, 2021, 3:01:30 AM1/9/21
to Barry Parr, TasmotaUsers

Hostname can be set via console

 

Sent from Mail for Windows 10

 

Ajith Vasudevan

unread,
Jan 9, 2021, 3:23:44 AM1/9/21
to Barry Parr, TasmotaUsers
Yes, I will be setting the device up and sending it off to the other location where someone else will be installing it.

As Phil mentioned, I will first try setting up the hostname from the console while the device is with me.



Ajith Vasudevan

unread,
Jan 9, 2021, 3:24:08 AM1/9/21
to Philip Knowles, Barry Parr, TasmotaUsers
Will try that. Thank you.


Ajith Vasudevan

unread,
Jan 9, 2021, 4:32:57 AM1/9/21
to TasmotaUsers
I compiled Tasmota with #define USE_DISCOVERY and  #define HOSTNAME  <my-hostname>.
After startup, I checked in the information page that the hostname was set to just <my-hostname>  with none of the MAC address appended.
Then ran setOption55 1. Re-checked the information page and found that it added ".local" to <my-hostname>.

Then I tried http://<my-hostname>.local  in the browser and it didn't work at first. After a few refreshes, I got the Tasmota UI displayed.

Re-booted the Wemos and tried to access with the .local URL again. It didn't work straightaway this time as well. It took a few tries until it displayed the UI.

I will probably use this for now.

Thanks Barry and Phil for the suggestions.

Philip Knowles

unread,
Jan 9, 2021, 4:50:51 AM1/9/21
to TasmotaUsers, Ajith Vasudevan
It's one of the annoyances of Tasmota that you can't set an IP address in the AP mode. I know it wouldn't help you in this case Ajith but everytime I set up a device I have to log in to my router to get the IP address. I then have to go into the device to set a static IP - I have a range of IP addresses for each room so that it's easier to find them later.
The ability to store the IP address in a variable (or, better still, automatically create a 'system' variable) might help.
Regards

Phil K

Sent: Saturday, January 9, 2021 9:32:57 AM
To: TasmotaUsers <sonof...@googlegroups.com>

Ajith Vasudevan

unread,
Jan 9, 2021, 5:15:19 AM1/9/21
to TasmotaUsers
True that. I have a similar setup at home, with a Wemos running Tasmota in every room (including the bathrooms!)
I used to do the same with setting IP Addresses. Now I don't bother with Static IPs and I simply "reserve" the DHCP IP address in my router (its just click of a button in the router's DHCP clients page ), so it always assigns the same IP address to that device (based on its MAC ID), even in DHCP mode.

That said, to find the IP address the first time, I no longer log into my router. I either run the "screen" Linux command ( screen /dev/ttyUSB0 115200   )  or fire up Arduino IDE''s Serial Monitor window while the Wemos is still connected to my PC via USB. Resetting the Wemos, either of them will show the debug messages (same thing you see in the Tasmota Web UI), and I take the IP Address from there.

On Saturday, January 9, 2021 at 3:20:51 PM UTC+5:30 knowles...@gmail.com wrote:
It's one of the annoyances of Tasmota that you can't set an IP address in the AP mode. I know it wouldn't help you in this case Ajith but everytime I set up a device I have to log in to my router to get the IP address. I then have to go into the device to set a static IP - I have a range of IP addresses for each room so that it's easier to find them later.
The ability to store the IP address in a variable (or, better still, automatically create a 'system' variable) might help.
Regards

Phil K

Ajith Vasudevan

unread,
Jan 9, 2021, 6:06:10 AM1/9/21
to TasmotaUsers
I had posted the same query on Github as well.  And there's an elegant solution!   https://github.com/arendst/Tasmota/discussions/10467

Barry Parr

unread,
Jan 9, 2021, 9:21:06 PM1/9/21
to TasmotaUsers
I had not bothered to change Hostname Before.
Can change it also in the wifi Page.
Have just realised a big advantage in doing so.
when ya save config , the hostname is in the file name.
I.E.  Config_RF433_9.2.0.1.dmp
this makes my backup folder much easier to use !

Ajith Vasudevan

unread,
Jan 9, 2021, 9:39:33 PM1/9/21
to Barry Parr, TasmotaUsers
Yes, I was always doing that, however, I had never enabled nDNS/DISCOVERY, so I never got the other benefit of not having to add /etc/host entries to access the UI in the browser by name!

--
You received this message because you are subscribed to a topic in the Google Groups "TasmotaUsers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonoffusers/CzRBWeNG21g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonoffusers...@googlegroups.com.

Barry Parr

unread,
Jan 10, 2021, 1:15:34 AM1/10/21
to TasmotaUsers
BTW , have found a few issues with mDNS implementation.
it could explain why it is sluggish to respond sometimes.
will do a PR when I have cleaned up the fix & it also adds mDNS for ESP32.

Ajith Vasudevan

unread,
Jan 10, 2021, 1:30:22 AM1/10/21
to Barry Parr, TasmotaUsers
That's great! Will watch out for the fix!

--
You received this message because you are subscribed to a topic in the Google Groups "TasmotaUsers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonoffusers/CzRBWeNG21g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonoffusers...@googlegroups.com.

Barry Parr

unread,
Jan 10, 2021, 12:54:23 PM1/10/21
to TasmotaUsers
fix was merged into development a few hrs ago

Ajith Vasudevan

unread,
Jan 10, 2021, 1:01:51 PM1/10/21
to Barry Parr, TasmotaUsers
Thanks for the update. Will try it tomorrow and report.

headley , m.d.

unread,
May 16, 2021, 6:50:41 PM5/16/21
to TasmotaUsers
Hi Ajith,

I easily understand your need to have the ipaddress on hand to remotely help a user.

You likely found a different way to accomplish it by now, but this trigger would allow you to store the ipaddress on MCU's startup and manipulate it accordingly...

ON Info2#IPAddress do 
Mem1 %value% 
- or - 
websend [w.x.y.z] /store_ipaddr.ext?ipaddr=%value% or %Mem1% etc

Ajith Vasudevan

unread,
May 16, 2021, 11:15:13 PM5/16/21
to TasmotaUsers
Hi headley,

Thanks for the reply. Yes, I have a solution now, similar to what you mentioned, from a discussion here: https://github.com/arendst/Tasmota/discussions/10467

The following is what I use currently:

on IPAddress1 do tmsend %value% endon
on System#Boot do Backlog IPAddress endon


Thanks and regards,
Ajith

Automater

unread,
Jul 5, 2021, 6:27:17 AM7/5/21
to TasmotaUsers
I followed the example but get the IP address in the form 0.0.0.0 (192.168.1.3)
How can I just get 192.168.1.3?

Ajith Vasudevan

unread,
Jul 5, 2021, 6:45:54 AM7/5/21
to TasmotaUsers
Although I've not used it myself, I am sure Tasmota's "Scripting" could be used to achieve what you want.

Ajith Vasudevan

unread,
Jul 5, 2021, 7:07:26 AM7/5/21
to TasmotaUsers

Under the heading "Special Variables", there's this:

lip = local ip as string

This would likely be just the bare IP address, which you can use.



On Monday, July 5, 2021 at 4:15:54 PM UTC+5:30 Ajith Vasudevan wrote:
Although I've not used it myself, I am sure Tasmota's "Scripting" could be used to achieve what you want.


On Monday, July 5, 2021 at 3:57:17 PM UTC+5:30 Automater wrote:
I followed the example but get the IP address in the form 0.0.0.0 (192.168.1.3)
How can I just get 192.168.1.3?

Automater

unread,
Jul 5, 2021, 10:28:16 AM7/5/21
to TasmotaUsers
Thanks for the recommendation but just for this single issue I don't want to recompile my tasmotas. Isn't there a solution within the command/rule set?

Ajith Vasudevan

unread,
Jul 5, 2021, 10:35:00 AM7/5/21
to TasmotaUsers

>> Isn't there a solution within the command/rule set?
I tried to see if there is a solution a while back, for myself. Couldn't find one. Sorry.

If you are fetching this value into your Telegram Bot, then a work-around could be to pre-process the value received  (using some regex or string manipulation to get rid of the unwanted text) in your Telegram receiving code before actually using the IP Address value.

Philip Knowles

unread,
Jul 5, 2021, 11:18:59 AM7/5/21
to Ajith Vasudevan, TasmotaUsers

The answer is no.

IPAddress1 will return the IP Address with 0.0.0.0 in front to signify that it is a DHCP address.

Status 5 will give you JSON (which you could parse) with the IP Address in it but there isn’t a way to get the output of Status 5 as a trigger for a rule  (status5#ipaddress).

Your best bet is to use regex to extract the contents of the brackets \(([^()]+)\)*

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

From: Ajith Vasudevan
Sent: 05 July 2021 15:35
To: TasmotaUsers
Subject: Re: How to get IP Address via Telegram

 

 

>> Isn't there a solution within the command/rule set?

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/2dc4053b-af56-409f-8618-c77a8ca1a14en%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages