Integrating a Webpage with a URL that changes

For a Webpage on a local Webserver I want to have a URL that can be set as a variable.
I would like to feed the current URL via a MQTT-server to the Home Assistant Server.
MQTT is operating fine for other things already but I need to have it made aware of the latest
URL, avoiding the need to update it by hand. The URL is variable because the Webserver is connected with DHCP and every day the Router gets a restart and all other devices fight for the IP-Addresses again, so the assigned IP-Address varies. I do not want/cannot use a Static IP Address for the Webserver in this case.
My question: How can I load a value into a variable that is then used inside the Dashboard definition so the link to the URL of the Webserver is always correct after sending the newest valid URL for this Server.

Currently I have this Dashboard definition (taken from Raw-Configuration Editor).
So the line ‘url:’ should be something with a variable in it. I have been reading about variables but I cannot figure out how variables can be used in the GUI. Also I do not know how to get this variable updated via MQTT. Alternatively a HTTP-GET to the Home Assistant would also be an option to set this variable, but I rather like MQTT for this, since then this is even more flexible for external Web-servers, since sender and receiver are then decoupled, avoiding the need for portforwarding-configuration and what not.

  - title: Water Web Monitor
    path: watermonitor
    type: panel
    badges: []
      - type: iframe
        aspect_ratio: 150%
        title: Water Monitor Server

Any insights on this are warmly welcomed ! :slight_smile:

What about reserving the IP in the router then?

Hey Hellis81
Thanks for looking into this !

Well the reason is to use a Dynamic IP since I do not want to involve the router in the configuration. It makes it more independent from that. One could indeed connect a MAC-Address to a certain DHCP-address to be reserved.
I want to install it at a friends place and they have a very simple router, so I would like to prevent I get stuck on some third party device.

The server will be knowing its assigned DHCP IP-address. So I am looking for a mechanism to get it into a variable inside HA. I am just a few weeks busy with HA and have not found how one uses variables (do they exist? I would expect so…), and how to use them for the purpose described.

The best solution for this would be if the device supports a network name (i.e. http://watermonitor.local/homepage), is this an option?

I have never seen a router that does not support IP reservation.

Yesss, maybe. I have to say I have a lot problems with these bonjour/mDNS names. Sometimes it works, sometimes not. I tend to end up with IP-Addresses. I have two HA Servers running so then I already got stuck with the standard: homeassistant.local:8123/lovelace. So not the biggest fan of mDNS
I appreciate your answer though!

Have you ever had a friend that lost his accesscode to his router. I do …! And believe me I have seen a lot of very simple routers Internet Providers which do not have that.
So I am really looking for the described approach. I do not want to be dependent on anything that I cannot control
I am looking for an answer to my question to be honest, not for a new router or … or … Just assume that me asking the question already implies I have ran through all kinds of options before I ask somebody else. There is some knowledge I do not have with HA and I need some pointers to that.
It feels a bit awkward when one says: "I want to have an Ice-Cream. Which flavour would you recommend?"
Answer: "Why do you want an Ice-Cream? They are not healthy, don't you know that!". It is just not very helpful to the person asking the question.
Thanks for your efforts anyway!

So you’re one of them?
The I-asked-the-question-therefore-I-know-best,-even-though-I-asked-a-question-that-could-imply-that-I-don’t-know-best-but-that-is-not-true.

If you can’t tolerate that people ask you why you insist on reinventing the wheel then don’t ask questions.

I am not sure who them is. But if I want an Icecream, because I feel it is the best option, then I am entitled to have a preference for that. I do not need to be convinced to get vegan.
Router-configuration is a tricky one when one does not know if the possibilities exist as on my used router. So I want to exclude that beforehand out of the equation. In my question I specifically stated that I what solution I would like to implement. Most probably you can assume that the writer of the questions has its reasons. Now it is like : I want to have a variable for that. Then one says: “Why you want a variable, router-configuration is soooo much more cool. Variables are soo 2020”.
It gets me tired to be honest.

The most probable reason is usually because the asker has no clue.
And please just leave your ice cream out of this.

The answers you have gotten so far is the most valid and the best answers.
You has not made it enough clear in your question that you knew about IP reservation or network name that is why you got the obvious counter questions.

If your friends have so much problems with their routers and passwords then I just advice you to not help with something this advanced because it will bite you.

Well I have to give you some slack on this. But … I really want to know how to get variables work in the GUI since I do see the added value of that. I have not found any documentation on this, but the documentation is extensive and is more a reference manual than a cookbook with recipes for some approaches. So one has to stitch all kinds of information of the various pages of the reference manual and cook some solution oneself, try fail, retry fail, sigh, take coffee, retry, you know how it is. I really want to solve this programmatically since all the configuration of sensors I already do via MQTT Discovery and this would be just one setting more to send the the HA server. It saves anyone from have to edit YAML files, which I find simply elegant, since changes can be implemented in an automated fashion, without the need of physical presence at the installation location. Edit one time and then forget about them. So I already worked with some variables and I am looking how to put the as a URL in this case so another the correct address is used AND I am looking for a way to fill that variable via MQTT in an automated fashion from outside HA. In the course of getting an answer I hope to get my knowledge at a higher level how variables are used in the Lovelace-GUI and HA in General. Allowing me to do a lot more even with that gained knowledge and insights. Thats all. I tend to be stubborn until I get to the end of the road in the forest to know what is there. There might be a bus, but I do not take it, since the journey itself is very interesting and leads to better wisdom. :wink: