# Balenadash: how to change URL dynamically

**URL:** <https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371>\
**Category:** Project help\
**Tags:** balenadash\
**Created:** [February 20, 2019, 4:50pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371 "2019-02-20T16:50:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mozz100](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mozz100](https://forums.balena.io/u/mozz100)\
**Post date:** [February 20, 2019, 4:50pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/1 "2019-02-20T16:50:47Z")

</div>

I’ve got a balenadash up and running. I can point it to a URL with the WPE\_URL environment variable.

How might I go about changing the web page on screen, _without_ logging into balena-cloud, changing a device variable, waiting for the containers to restart…

I would like to be able to ping a webhook on the device and have the displayed webpage change. Happy to open source my work but not sure how I would go about getting started… or is this something that’s easy to do without further development?

---

<div class="post-metadata">

**Author:** ![dansku](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dansku/32/1183_2.png) [@dansku](https://forums.balena.io/u/dansku)\
**Post date:** [February 21, 2019, 8:16am UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/2 "2019-02-21T08:16:12Z")

</div>

Hey @mozz100

I think a good approach to this is, instead of changing the `WPE_URL` variable, you can point your device to a website hosted on the same device, and have that page redirect to other pages.

Here is an example project [https://github.com/balena-io-playground/balena-dash-google-photos](https://github.com/balena-io-playground/balena-dash-google-photos), if you see the file [https://github.com/balena-io-playground/balena-dash-google-photos/blob/master/wpe/public\_html/index.html](https://github.com/balena-io-playground/balena-dash-google-photos/blob/master/wpe/public_html/index.html) it waits for one page to come alive and then redirect. It’s not the exact same as you asked, but its the general idea.

On a second idea, you can update the environment variable using the API here [https://www.balena.io/docs/reference/api/resources/device\_environment\_variable/#update-device-env-var](https://www.balena.io/docs/reference/api/resources/device_environment_variable/#update-device-env-var)

Let me know if this helps,  
Cheers

---

<div class="post-metadata">

**Author:** ![mozz100](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mozz100](https://forums.balena.io/u/mozz100)\
**Post date:** [February 21, 2019, 1:17pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/3 "2019-02-21T13:17:46Z")

</div>

Thanks @dansku - response much appreciated. I’m still seeking more help, please: I’m not sure either approach solves the problem for me. Maybe I’m not understanding correctly. Here goes…

Your first suggestion - I could just implement a server that issues a 301 redirect, right? But once I have redirected the on-screen browser to e.g. [www.bbc.co.uk/news](http://www.bbc.co.uk/news), I lose control and can’t switch away from it, until everything is restarted by a reboot or something. If I’m understanding things correctly, the process inside the `wpe` container doesn’t restart itself on a schedule, or check the `WPE_URL` periodically. Or does it?

Your second suggestion about changing the variable using the API. I can do that - nice API and docs! - but this exhibits the exact problem I’m trying to solve. After I hit the API I get “OK”, but there’s no on-screen indication until tens of seconds later, when the containers begin to cycle, and after that it’s about 2 minutes wait while the containers restart. The new page displays as expected.

So what I have discovered is if I manually go to the balena UI and use the web-based terminal to execute e.g. `WPELauncher https://www.bbc.co.uk/` inside the `wpe` container, a new browser fills the screen and renders quickly. After I hit Ctrl+C, I’m back to where I was - the original page shows back.

Can I get my device or containers to listen for some network-originated instruction and do the same thing? I’d like colleagues to be able to send a URL to the screen and see it load in front of their eyes. That would be so awesome - and I would certainly share the code.

Can I e.g. run a python of javascript process alongside the two containers already running, and send some sort of signal to the `wpe` process, or run commands inside it? Or can I write a script that runs inside the `wpe` container and listens on a port (js or python preferable, but open to suggestions)?

Or is there another way I could listen on a port and control the screen on the wall without the two-minute delay?

All help much appreciated.

(EDIT - clarification)

---

<div class="post-metadata">

**Author:** ![mozz100](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mozz100](https://forums.balena.io/u/mozz100)\
**Post date:** [February 21, 2019, 2:15pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/4 "2019-02-21T14:15:34Z")

</div>

Maybe an http server compiled for ARM and running inside the wpe container? Might be my first golang project

---

<div class="post-metadata">

**Author:** ![wwalker](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/wwalker/32/1225_2.png) [@wwalker](https://forums.balena.io/u/wwalker)\
**Post date:** [February 23, 2019, 4:47pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/5 "2019-02-23T16:47:53Z")

</div>

@mozz100 check out my alternative balenaDash project here, which includes support for multiple URLs. Let me know if you need help! [https://github.com/willswire/balena-dashboards](https://github.com/willswire/balena-dashboards)

---

<div class="post-metadata">

**Author:** ![mozz100](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mozz100](https://forums.balena.io/u/mozz100)\
**Post date:** [March 4, 2019, 8:49pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/6 "2019-03-04T20:49:38Z")

</div>

So, I wrote my first ever lines of golang. It works nicely. Plenty of features that could be added but new URLs flash up on screen pretty much instantly with this, and it reverts to existing behaviour when it’s not doing anything

> **[mozz100/tohora](https://github.com/mozz100/tohora)**
>
> A web UI for balenaDash. Contribute to mozz100/tohora development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![chrisys](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/chrisys/32/1731_2.png) [@chrisys](https://forums.balena.io/u/chrisys)\
**Post date:** [March 4, 2019, 11:36pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/9 "2019-03-04T23:36:36Z")

</div>

@mozz100 this is very cool. We would love to roll your work into the balenaDash project and add this as a feature; have you considered submitting a PR to add that functionality?

---

<div class="post-metadata">

**Author:** ![mozz100](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mozz100](https://forums.balena.io/u/mozz100)\
**Post date:** [March 5, 2019, 3:18pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/11 "2019-03-05T15:18:10Z")

</div>

Thanks @chrisys - I’ll submit a PR soon. Gimme a couple of days to write a blog post (spare time limited at the mo!) about my (excellent) experiences with balena first? 🙂

---

<div class="post-metadata">

**Author:** ![chrisys](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/chrisys/32/1731_2.png) [@chrisys](https://forums.balena.io/u/chrisys)\
**Post date:** [March 5, 2019, 4:02pm UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/13 "2019-03-05T16:02:50Z")

</div>

Sounds awesome and maybe a perfect candidate for our [blog4swag](https://forums.balena.io/t/the-return-of-balenablog4swag-share-your-balena-project-writeup-for-swag/726) program - just let me know when you’ve posted it 😉

---

<div class="post-metadata">

**Author:** ![mozz100](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mozz100](https://forums.balena.io/u/mozz100)\
**Post date:** [March 9, 2019, 8:10am UTC](https://forums.balena.io/t/balenadash-how-to-change-url-dynamically/5371/15 "2019-03-09T08:10:07Z")

</div>

Alrighty - I created “tohora” and have blogged about my experiences making it on balena here: [https://www.rmorrison.net/mnemozzyne/2019/03/07/tohora-instant-control-balenadash/](https://www.rmorrison.net/mnemozzyne/2019/03/07/tohora-instant-control-balenadash/)

and submitted a pull request here - [https://github.com/balena-io-projects/balena-dash/pull/10](https://github.com/balena-io-projects/balena-dash/pull/10)

Hope it’s useful to others!
