AmpliPi icon indicating copy to clipboard operation
AmpliPi copied to clipboard

Move automatic source selection from the frontend to the backend

Open SteveMicroNova opened this issue 8 months ago • 5 comments

Sources were once specifically chosen in webapp1 but have been hidden in webapp2, but with our re-upping of both home assistant and the wallpanels we've found that the logic to find and automatically select a source is handled completely in the frontend javascript and thus is inaccessible from the two orbiting usecases

Move that logic from the frontend to the backend, and make sure it's plugged in everywhere that it's needed:

  • [ ] AmpliPi
  • [ ] pyamplipi
  • [ ] hacs_amplipi

SteveMicroNova avatar Apr 25 '25 15:04 SteveMicroNova

I've labeled this as "Good First Issue" because it is ideally fairly easy: Look at two functions (one written in javascript, the other in python) and translate that into python in such a way that nothing is lost, but as far as "Good First Issue"s go it's actually insane to say it's a nice and easy trip to simply touch 3 repos and make sure they're all in alignment

Here's further documentation of the issue and where to look to find what you need:

  • AmpliPi:
    • Everywhere that the variable nextAvailableSource is used in amplipi/web/pages/Home.jsx
    • Place the api side function in amplipi/app.py, call the endpoint something like GET /api/sources/available/
  • hacs_amplipi:
    • the function called find_source inside of AmpliPiMediaPlayer (not sharing the file directory as that's pending to be changed and I'm uncertain where it'll be shortly). Note that this is the best version of this function IMO, and you should retain the fact that it either returns a source or None if no sources are available.
  • pyamplipi:
    • You'll likely need to call your new api endpoint from pyamplipi somewhere but I'm uncertain that's necessary; I don't really know the plumbing on that side yet

SteveMicroNova avatar Apr 25 '25 16:04 SteveMicroNova

Hi, i'm gabriel, can i help you with your open-source? I dont know use github yet, but i know front-end and C. I dont know what are you doing but I will definitely find out and would be grateful if you would give me a chance to be helpful. Im a begginer in programming, i only 16 years old. Thank you.

bieltris avatar Apr 25 '25 21:04 bieltris

I dont know what are you doing but I will definitely find out

I'd suggest finding out what you're getting into first, this isn't an easy repo to simply enter as a beginner due to the amount of prep your dev environment would need

To do any testing you'd need to be running Linux; if you're on Windows like me you can get away with using WSL. On top of that, you'd also need to install NodeJs and React for any frontend work

I'd also suggest interrogating why you'd want to work on an open source project that you know nothing about. If it's to learn and get experience, good! If it's just to build up a resume without any particular mind for meaningful personal growth, you'll find that recruiters are getting wise to that practice and it might just set you back.

You are welcome to help out, as an entry exam I'd suggest finding out how to copy this repo to your local machine, getting your dev env set up, and also running the front and back ends on your local machine by using the scripts at scripts/run_debug_webserver for the backend (run this first) and in another terminal run scripts/run_debug_frontend. To get those to work you might have to do a few things I didn't mention, mostly installing a few requirements.txts to get the proper python and npm packages; I'd consider that part of the test as you'll have to largely use google to research how to make things work. Please avoid using AI for this.

SteveMicroNova avatar Apr 28 '25 15:04 SteveMicroNova

Coming back to this, I'd like to apologize for my tone; when I make messages like these I often read them in the tone I meant them while writing and then come back a day or so later and realize I've actually been fairly rude or terse.

My intended tone here was one of a mentor saying "This would be hard, you've got to be ready to be up for the task and also here's my advice about how to operate in the world to achieve your goals" and less of a "berating a newcomer for the sin of being inexperienced". You're very welcome to assist, though this particular issue might not be for you. Despite this issue being labeled "Good First Issue", this is a fairly complicated task; most things under that label were marked with a summer intern in mind, not so much the "This is literally my first github issue" crowd. Here's a picking of issues you'd be able to take a better bite out of:

  • https://github.com/micro-nova/AmpliPi/issues/950
  • https://github.com/micro-nova/AmpliPi/issues/1024
  • https://github.com/micro-nova/AmpliPi/issues/1042
  • https://github.com/micro-nova/AmpliPi/issues/931

If you need any more direction for any of those, reach out in the relevant issue thread and I can give you a step by step guide of what to do and how to test that it works.

SteveMicroNova avatar Apr 29 '25 17:04 SteveMicroNova

Hi Steve

First of all, I'm sorry I didn't reply to your previous message. I have very little free time during my day, and I just ended up not having a chance to answer. But I want you to know that I understand your concerns about beginners joining the project, and I also understand your mentor mindset. I really appreciate your honesty. Also, regarding what you said earlier — my goal in joining an open-source project isn't just to fill up my résumé. I truly want to grow as a developer and gain real knowledge and experience. Yesterday, after reading your message, I started setting up my machine to run the repository. I also spent some time learning about the project itself, and if I understood correctly, it's a sound amplifier. Thank you as well for offering your help with the other issues. I really appreciate it — but first, I’d like to try solving the errors on my own. Thanks again for your guidance and for giving me this opportunity.

Gabriel

bieltris avatar Apr 29 '25 21:04 bieltris