bk1285 / rpi_wordclock

Software to create a Raspberry Pi based wordclock
GNU General Public License v3.0
214 stars 107 forks source link

Web Interface: Simple Example for an APP #238

Closed PeterBrenden closed 1 year ago

PeterBrenden commented 1 year ago

Hello to everybody, first of all MANY THANKS to Bernd! Great project. Sofar I have extended it with weeksday, an alarm clock and a new language "allemanic". Everything is working fine, even the API, which I was able to extend, too. My problem: I have no idea how to excess the API from an APP (to control the wordclock with a smart phone). Is the anybody out there (sorry stolen from Pink Floyd), how maybe could show me some lines of code (like the *.html) , e.g. one button sending directly a "POST" or a "GET"? Thanks a lot in advance and have a nice evening Best regards Peter

FrankX0 commented 1 year ago

Well, it already has a build-in "APP": the webinterface. Just go to the IP address of your clock on your smart phone. On an iPhone you can even then put it on your Home Screen: then it actually feels like a normal APP.

PeterBrenden commented 1 year ago

Hi Frank, thanks for the feedback. You are right, this part is working fine. Browser => http://192.168.2.139/api#/API => 1 2 So e.g. 4. steps are required to change the brigthness.

  1. "POST, 2."Try out", 3. Enter new value, 4. "Execute"

Means, I'm searching for the code, which I can adapt: change brigthness with one buttoen (taking the "Execute" button, move it to another site, change style and so on)

Does this descripton make sense to you, or is my writing still bad, not understandable (don't worry, just let me know :) Many thanks Peter

FrankX0 commented 1 year ago

Hi Peter. Just to be clear: you are aware that this APP implementation already exists? In your case http://192.168.2.139 Regards, Frank.

PeterBrenden commented 1 year ago

Hi Frank, sorry for beeing a pain... I'm not that sure, maybe if have an old version? With http://192.168.2.139 I'll get: image and then (pressing "API..." image Best regards Peter

FrankX0 commented 1 year ago

Hi Peter. This is a known issue: #218 Best would be to start using the latest (Python3) branch. Please let me know if this is possible for you.

PeterBrenden commented 1 year ago

Hi Frank, I updated python to 3.11, but still having the same problem. I tryed your "new" webinterface (https://github.com/FrankX0/rpi_wordclock/commit/0edce92307fefca6f44287f07e958324d2fa055c)? Ending up with the error "module web could not be imported" and installing endet up with some more errors... I'm so sorry... Best regards Peter

FrankX0 commented 1 year ago

Did you update Python or did you install the latest wordclock branch? If not done so, you should follow the Software setup.

PeterBrenden commented 1 year ago

I think I give up. after "sudo pip3 install -r requirements.txt", I'll get Could not find a version that satisfies the requirement astral==2.2 (from -r requirements.txt (line 2)) (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.6.1, 0.6.2, 0.7, 0.7.1, 0.7.2, 0.7.3, 0.7.4, 0.7.5, 0.8, 0.8.1, 0.8.2, 0.9, 1.0, 1.1, 1.2, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4, 1.5, 1.6, 1.6.1, 1.7, 1.7.1, 1.8, 1.9, 1.9.1, 1.9.2, 1.10, 1.10.1) No matching distribution found for astral==2.2 (from -r requirements.txt (line 2)) And similar to allmost every next install Best regards Peter

FrankX0 commented 1 year ago

Hi Peter. Don't give up. We'll get this sorted out. From the reports I conclude you are running an outdated Python3 installation. Can you execute python3 --version? Are you running the latest Pi OS version (bullseye)?

PeterBrenden commented 1 year ago

Hi Frank, thanks for your patience, I realy apprechiate that!

After struggeling with lots of error message, I thought nearly the same as you: Starting from scratch?!

I'm using "2019-04-08-raspbian-stretch-lite"... So, you think, too: creating a new OS: 2022-09-22-raspios-bullseye-armhf-lite.img.xz This sounds like a long way. But you convinced me: I'll try

Again thanks a lot Peter

-----Original-Nachricht----- Betreff: Re: [bk1285/rpi_wordclock] Web Interface: Simple Example for an APP (Issue #238) Datum: 2023-01-09T09:03:01+0100 Von: "Frank Exoo" @.> An: "bk1285/rpi_wordclock" @.>

Hi Peter. Don't give up. We'll get this sorted out. From the reports I conclude you are running an outdated Python3 installation. Can you execute python3 --version? Are you running the latest Pi OS version (bullseye)? — Reply to this email directly, view it on GitHub https://github.com/bk1285/rpi_wordclock/issues/238#issuecomment-1375231077 , or unsubscribe https://github.com/notifications/unsubscribe-auth/A5EDHZTJQYBXPIY6ZBBWLC3WRPA3BANCNFSM6AAAAAATUCC5FU . You are receiving this because you authored the thread.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/bk1285/rpi_wordclock/issues/238#issuecomment-1375231077", "url": "https://github.com/bk1285/rpi_wordclock/issues/238#issuecomment-1375231077", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ] 

FrankX0 commented 1 year ago

I agree this is probably the right time to start fresh and moving to bullseye. I have my clock running on bullseye, so I expect you will encounter less problems (fingers crossed).

Good luck, Frank.

phenze commented 1 year ago

Yes you have to use bullseye (or Buster as a minimum). It is not working on stretch. Maybe we should mention this in the docs @bk1285

And it is not a long way ;). It is much easier as you might think.

PeterBrenden commented 1 year ago

Sorry, It's me again, but I think with fairly good news So far bullseye is done. ssh is working, everything according to https://rpi-wordclock.readthedocs.io/en/main/doc_software_setup.html

Is this right source ? git clone https://github.com/bk1285/rpi_wordclock.git Because running the wordclock gives an import error: ImportError: cannot import name 'parse_rule' from 'werkzeug.routing' (/usr/local/lib/python3.9/dist-packages/werkzeug/routing/init.py) I tryed both installing werkzeug 2.1.2 and the betterone werkzeug 2.2.2 Best regards from blackforest Peter

PeterBrenden commented 1 year ago

maybe her the complete message: pi@raspberrypi:~/rpi_wordclock $ sudo python3 wordclock.py Traceback (most recent call last): File "/home/pi/rpi_wordclock/wordclock.py", line 17, in import wordclock_interfaces.web_interface as wciweb File "/home/pi/rpi_wordclock/wordclock_interfaces/web_interface.py", line 4, in from flask_restx import Api, Resource, fields File "/usr/local/lib/python3.9/dist-packages/flask_restx/init.py", line 5, in from .api import Api # noqa File "/usr/local/lib/python3.9/dist-packages/flask_restx/api.py", line 50, in from .swagger import Swagger File "/usr/local/lib/python3.9/dist-packages/flask_restx/swagger.py", line 18, in from werkzeug.routing import parse_rule ImportError: cannot import name 'parse_rule' from 'werkzeug.routing' (/usr/local/lib/python3.9/dist-packages/werkzeug/routing/init.py)

FrankX0 commented 1 year ago

Hi Peter, almost there..... Can you try:

sudo pip3 install flask==2.0.2
sudo pip3 install werkzeug==2.0.2
PeterBrenden commented 1 year ago

Hi Frank, how did you know?! Now it is Christmas again. the workclock is running!!!!!!

Now I can start implemention my source. Thank you so much. Have a nice evening. All the best Peter

FrankX0 commented 1 year ago

Hi Peter, That is good to hear! I guess the APP now also works as intended. If you are extending the functionality you might want to share through a pull request, if you think it could be useful to others. Kind regards, Frank.

PeterBrenden commented 1 year ago

Hi Frank, yes the APP is running fine! For now I'm still struggeling with some little challenges, getting my version running on the new plattform (e.g. python2=>3, changes and improvement within your latest wordclock-version). I'm sure whether my code is that good, some one else would enjoy :) We will see later. Again many thanks Peter

PeterBrenden commented 1 year ago

Hi Frank, sorry, it's me again. I implented my function, one by one. With last one (sound) the APP worked "for a while", but the browes can't reach it anymore (ssh is still working). Does this error message makes sence to you?

Many thanks from the blackforest Peter

PeterBrenden commented 1 year ago

Just in addintion, in case it helps: I did sudo apt-get install sox sudo apt-get install libsox-fmt-mp3

PeterBrenden commented 1 year ago

I think I can stop for now and we could close this issue. I think I have to search for another soundplayer. I'll let you know, when it is hepofully done.

(reasons: with bullsey sox +APP does not work; sox+soundplayer works "sometimes".)

First think for me to do is to learn threading, since I have never done this.

Again many thanks and enjoy programming Peter