@@ -193,7 +193,7 @@ Python source code are compiled and cached on load. You need to restart Home Ass
193193sensor:
194194- platform: python_script
195195 name: My IP address
196- scan_interval: '00:05:00' # optional
196+ scan_interval: '00:05:00' # optional, default: 30s
197197 source: |
198198 import requests
199199 r = requests.get('https://api.ipify.org?format=json')
@@ -209,4 +209,18 @@ sensor:
209209 logger.debug("Update DB size")
210210 filename = self.hass.config.path('home-assistant_v2.db')
211211 self.state = round(os.stat(filename).st_size / 1_000_000, 1)
212- ` ` `
212+
213+ - platform: python_script
214+ name: Instance external url #more info https://developers.home-assistant.io/docs/instance_url/
215+ scan_interval: '01:00:00' # optional
216+ source: |
217+ from homeassistant.helpers import network
218+ try:
219+ self.state = network.get_url(
220+ self.hass,
221+ allow_internal=False,
222+ )
223+ except network.NoURLAvailableError:
224+ raise MyInvalidValueError("Failed to find suitable URL for my integration")
225+
226+ ` ` `