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?
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.
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, 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?
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 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?
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?