winstonma / RPi-MagicMirror-Waveshare

Script that show MagicMirror content on Waveshare E-Ink device
GNU Affero General Public License v3.0
5 stars 1 forks source link

Change to wrong directory in setup #1

Closed Coernel82 closed 1 year ago

Coernel82 commented 1 year ago
# Clone/copy the project files to your system
git clone https://github.com/winstonma/RPi-MagicMirror-Waveshare.git
# Move to the project folder

cd rpi-magicmirror-eink
##########
shouldn't it be cd RPi-MagicMirror-Waveshare
otherwise the pip install won't work!
##########

# Install python dependencies (inside the `rpi-magicmirror-eink` folder)
sudo pip install -r requirements.txt
# Start the script with PM2 and run it in the background
pm2 start index.js --name "eink-update"
pm2 save
Coernel82 commented 1 year ago

There are more things unclear to me: for pm2 start index.js --name "eink-update" there must be https://github.com/BenRoe/rpi-magicmirror-eink installed, right? So I have your RPi-MagicMirror-Waveshare folder and also the rpi-magicmirror-eink folder on my system.

Does your folder need to be inside the original folder? Like:

cd ~/rpi-magicmirror-eink
git clone https://github.com/winstonma/RPi-MagicMirror-Waveshare.git

I would be so happy if you could clarify the installation process!

winstonma commented 1 year ago
  1. I will update the README.md
  2. There is no need to install https://github.com/BenRoe/rpi-magicmirror-eink
winstonma commented 1 year ago

@Coernel82 I updated README.md

Please let me know if this works for you

Coernel82 commented 1 year ago

Thank you for the quick response however it does not work. Here is my setup:

pm2 list showing:

id name namespace version mode pid uptime status cpu mem user watching
0 MagicMirror default 2.21.0 fork N/A 0 0 stopped 0% 0b coernel disabled
5 eink-update default N/A fork 4241 0s 0 online 0% 3.5mb coernel disabled
1 node default N/A fork 1007 18m 0 online 0% 17.9mb coernel disabled
2 serveronly default 2.21.0 fork 1013 18m 0 online 0% 60.2mb coernel disabled

Magicmirror is working networkwide on http://magicmirror:8080

Coernel82 commented 1 year ago

Small update: changing the address to http://magicmirror:8080/ in the config doesn't change anything. Localhost should be working anyways.

Coernel82 commented 1 year ago

Finally (nearly) successfull

I came across the idea to directly start your file: python3 main.py - just using python main.py resulted in the error that selenium could not be imported. I added some print('xyz') to the code (that is all I can do in python - to see where the script stops. I can see that it successfully runs the while-loop which displays the screenshot - except that the screenshot won't show on the display. After that I forced python3 as interpreter for pm: pm2 start main.py --name "eink-update" --interpreter python3 - no success either. Using VS Code debuggin mode (which I have never used before) I cam acorrs the error:

Exception has occurred: NoSectionError
No section: 'Display'

During handling of the above exception, another exception occurred:

  File "/home/coernel/RPi-MagicMirror-Waveshare/main.py", line 23, in <module>
    refreshRate = config.getint('Display', 'refesh_rate')

Of course there is the section Display in config.cfg ... so I hardcoded:

model = 'epd7in5_V2'
refreshRate = 180

And holy shhhh..... HALLELUJAH! I got a black / white flashing display for a second. Next error: No section 'MagicMirror in the config file. Hardcoding again. Restarting.

Again: flashin black white..... wait ... wait... screen turns black. Console output: <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=800x480 at 0x73D73268> And then: I got my magic mirror (nearly) working. Now it is just a matter of scaling, everything simply is far to small. Again: pm2 start main.py --name "eink-update" --interpreter python3 And here it also works.

Hope this helps in improving your script!

Coernel82 commented 1 year ago

One important question: Waveshare says that the power has to be switched off after the screen update otherwise the screen gets damaged. Is this done?

winstonma commented 1 year ago

One important question: Waveshare says that the power has to be switched off after the screen update otherwise the screen gets damaged. Is this done?

I am using waveshare-epaper module in Python and I didn't know if it is switched off (I believe it would). In addition I modified the main.py and added the partial refresh capability, so far my eink panel keeps working after one year.

This is my modified main.py, you can try to replace your main.py and update the refesh_rate. But the partial refresh is not very good.

winstonma commented 1 year ago

Good to hear that it works for you.

Also for the font setting, I created custom.css (in MagicMirror/css folder) and hope the setting works for you.

winstonma commented 1 year ago

But it is weird that config.cfg doesn't work for you because it works on my side. Would you mind checking the Python version on your RPi? This is my output:

pi@raspberrypi:~/RPi-MagicMirror-Waveshare $ python --version
Python 3.9.2
pi@raspberrypi:~/RPi-MagicMirror-Waveshare $ pip --version
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)
Coernel82 commented 1 year ago

I think you are right that there are issues with different versions:

coernel@magicmirror:~/RPi-MagicMirror-Waveshare $ python --version && pip --version
Python 2.7.18
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

I investigated further, partially getting different results from yesterday as I did not always reboot yesterday an also getting different results today:

Test scenario

  1. Using VS Code. No files opened.
  2. command like python or pm2
  3. see what is happening and checking on windows computer if MagicMirror² is working
  4. in case of using pm2 deactivating and deleting eink-update and pm2 save
  5. sudo reboot

direct execution such as: starting main.py with python = leaving blank, python2 and python pm2 execution such as: pm2 start ~/RPi-MagicMirror-Waveshare/main.py --name "eink-update"

version pm2 direct execution
leaving blank photocopy edges and pm2 eink-update "errored" traceback (most recent call last): File "/home/coernel/RPi-MagicMirror-Waveshare/main.py", line 3, in <module> from selenium import webdriver ImportError: No module named selenium
python2 "photocopy" - see above "selenium" - see above
python3 instead of black now a white screen crash

I did get it to work as well. It seems the errors are highly random and not reproducable so far.

Details on: photocopy edges The edges of the screen look like those black blurred shadows from a photocopy. Status of eink-update in ``pm2 list`` is ''errored'' ``pm2 restart ~/RPi-MagicMirror-Waveshare/main.py --name "eink-update"`` erroring again after some seconds deleting eink-update, saving, rebooting.
Details on: crash Please note: Line numbers are different to yours as I inserted some ``print('xyz')`` I have 8 print commands. So should be 8 less (or a bit more if I also inserted blank lines. Crash is reproducable after reboot. ``` Traceback (most recent call last): File "/home/coernel/RPi-MagicMirror-Waveshare/main.py", line 50, in driver.get(start_url) File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webdriver.py", line 449, in get self.execute(Command.GET, {"url": url}) File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash from unknown error: cannot determine loading status from tab crashed (Session info: headless chrome=104.0.5112.105) Stacktrace: #0 0x000000964764 #1 0x00000076cb90 #2 0x00000075c2e8 #3 0x00000075bd64 #4 0x00000075b308 #5 0x00000075a1e4 #6 0x00000075a6ec #7 0x000000765a48 #8 0x0000007665d4 #9 0x0000007741bc #10 0x000000777d70 #11 0x00000075a9bc #12 0x000000773ddc #13 0x0000007d1704 #14 0x0000007bef74 #15 0x000000795f48 #16 0x000000796fb0 #17 0x0000009a94b8 #18 0x0000009abb58 #19 0x0000009ab5e0 #20 0x0000009ac1b0 #21 0x000000994210 #22 0x0000009ac478 #23 0x0000009893d4 #24 0x0000009c6000 #25 0x0000009c6170 #26 0x0000009e0994 #27 0x000076eb3310 #28 0x000000000000 ```

other things I found out

After some research I found out that there are some fundamental differences in Phython 2 and Python 3. https://python-forum.io/thread-10832.html:

Try code like the following. Please note that you are using Python 2. For Python 3 'ConfigParser.' becomes lower case 'configparser.' (configparser dot) and import ConfigParser becomes import configparser

Thank you for the custom.css!

Coernel82 commented 1 year ago

I have broken my system now completely. I will start with a clean install and report back to you later.

Coernel82 commented 1 year ago

Found the solution

After a complete reinstall I found the solution:

Your script has the requirement that MagicMirror² is installed the default way and not using an installer script. Your script started working instantly. I make a pull request now.

winstonma commented 1 year ago

In normal case the python version and the pip version should in sync with each other.

coernel@magicmirror:~/RPi-MagicMirror-Waveshare $ python --version && pip --version
Python 2.7.18
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

But your pip version and python version is different and that's why the pip installed modules (Python v3.9) can't be accessed by Python v2.7.

Also thanks for updating the README.md as I was too lazy just put the working script onto this repo.