Kindle Display

Aus FHEMWiki
Version vom 19. März 2017, 20:48 Uhr von Markusbloch (Diskussion | Beiträge) (Ersetzung von Forum-Links mit Vorlage Link2Forum)
Zur Navigation springen Zur Suche springen

This article shows how to configure a Amazon Kindle eBook-Reader as a information display for fhem. Use this manual at your own risk. Jailbreaking a Kindle is quite easy but there is no guarantee for breaking the system.
I will show how to configure it with the FileReplacer.pm from Stefan. The "old" method with the special function in MyUtils is not part of this article.

All of the information shown below is collected from the fhem-forum fhem-Forum. Many thanks to everybody who participated on the development of this information to get it done.Special thanks to "alex" and "stefan" from the board. Further information is from the mobileread board.

Hardware requirements

Kindle Touch / Paperwhite / Paperwhite 2

You can use Kindle Touch / Paperwhite / Paperwhite 2 without any limitations.

Kindle 4

For setting this up on the Kindle 4 (with the 5-way button) you need some more configuration work but it's also working. Addidional tasks for this version are shown down below.

Prerequisites

fhem and server configuration

Server configuration

Not sure if still needed, but just for in case it is, install imagemagick on your linux system.

apt-get install imagemagick

That's it :)

fhem configuration

First you need a svg-template. You can find one in the first posting on the fhem-Forum thread. In the template just replace the data with some placeholder you like. Later this placeholder is found via a regular expression and replaced by your data.
For example, you can set XYZ at the place where the first temperature should be shown and ABC for the first humidity value.
If you want to edit the template you can use the free software [www.inkscape.org/de/ Inkscape]. For more information about generating SVGs for fhem please refer to this article Icons. Most important information is to save the SVG as a "normal SVG" and not as an inkscape SVG.
For the Kindle Paperwhite the resolution of the SVG must be 758 x 1024 for the Kindle 4 version use 600x800. This is mandatory. Wrong scaled images won't be displayed on the Kindle.
Copy the Kindle_Template.svg to /opt/fhem/www/images/.

Download and install the latest version of the FReplacer.pm module from fhem Forums, save it to /opt/fhem/FHEM and load the module. You can also restart fhem instead.

All we're doing now is using the FReplacer module to read the SVG template, replace a search pattern with our data and saving it.

define kindledisplay FReplacer /opt/fhem/www/images/template1.svg /opt/fhem/www/images/status1.svg 60
attr kindledisplay PostCommand convert /opt/fhem/www/images/status.svg -type GrayScale -depth 8 /opt/fhem/www/images/status.png 2>/dev/null &
attr kindledisplay ReplacementEncode UTF-8
attr kindledisplay room Display

PostCommand defines that the external command will be issued after the replacement to convert the resulting SVG to a PNG in 8 bit GreyScale mode. UTF8-Encode might be needed to support special characters.
Now just create your mappings:

attr kindledisplay Rep01Regex XYZ
attr kindledisplay Rep01Reading Sensor1:Temp1
attr kindledisplay Rep01Format %.1f
attr kindledisplay Rep02Regex ABC
attr kindledisplay Rep02Reading Sensor1:Hum1
attr kindledisplay Rep01Format %.1f

And so on... :) The FReplacer module will replace the pattern XYZ with the ReadingsVal from Sensor1.
Now check if the PNG is created http://your-fhem-ip:8083/fhem/www/images/KindleDisplay.png. If so, be happy, the first part is done!
If you want to use more complex Perl expressions to compute the replacement string, you can use the RepExpr attribute instead of RepReading and do someting like this:

attr kindledisplay Rep11Expr (ReadingsVal("XY", "Reading", "off") eq "on" ? "An" : "Aus")

If you want to add a "last modified" timestamp to the dispaly, create a placeholder for it in your SVG template (like "last modified lmtime123") and then define a Regex / Reading attribute pair to replace it with the Reading "LastUpdate" from your FReplacer device:

attr kindledisplay Rep14Regex lmtime123
attr kindledisplay Rep14Reading kindledisplay:LastUpdate:never

Templates

You can find my templates here: fhem Forum. Feel free to use and modify.

Modifying the Kindle

To prevent from error messages like "your Kindle is no longer registered as a test Kindle..." please make sure your Kindle is connected to a valid Amazon Account.
We need to download some software to install it on the Kindle.
Please download it from Mobileread Forums


Always use the newest version and look for one who fits to your Kindle (e.G. K4).

Jailbreaking the Kindle

Don't worry. This sounds more hard and dangerous than it is in fact. It's just a few steps to have full access to your Kindle.

Kindle Touch/Paperwhite

  • Download the kindle-jailbreak-0.12.N.zip file, and unpack it. In there, you'll find some .bin files, and a src directory.Leave the directory alone, and upload the correct Update_*_install.bin file for your kindle & FW version to the root directory of your Kindle.


  • Now, eject & unplug your Kindle, and go to [HOME] -> [MENU] > Settings -> [MENU] > Update Your Kindle. It should be quick.
    (And, on FW 2.x only, it should FAIL (With a U006 error, in the bottom left corner of the screen). It's completely normal, intended, and harmless).


And that's it, your Kindle is now ready to install custom hacks!
(Quoted from http://www.mobileread.com/forums/showthread.php?t=88004)

Kindle 4 / Universal method

  • Download and unzip the jailbreak.
  • Plug in the Kindle and copy the data.tar.gz & ENABLE_DIAGS files plus the diagnostic_logs folder to the Kindle's USB drive's root
  • Safely remove the USB cable and restart the Kindle (Menu -> Settings -> Menu -> Restart)
  • Once the device restarts into diagnostics mode, select "D) Exit, Reboot or Disable Diags" (using the 5-way keypad)
  • Select "R) Reboot System" and "Q) To continue" (following on-screen instructions, when it tells you to use 'FW Left' to select an option, it means left on the 5-way keypad)
  • Wait about 20 seconds: you should see the Jailbreak screen for a while, and the device should then restart normally
  • After the Kindle restarts, you should see a new book titled "You are Jailbroken", if you see this, the jailbreak has been successful.

Installing additional software

MKK

The Mobileread Kindlet Kit (MKK) is used to execute custom Kindlets (programs) on the Kindle.
Download the software from here: MKK
Unzip the folder and copy the .bin file to the root directory of your kindle. Please note that you need to install the Kindle matching version (e.g. K4 = Kindle 4 with 5-way-button).
On the Kindle goto Menu -> Settings -> Menu -> Update your Kindle.
After the update it is installed.

KUAL

The Kindle Unified Application Launcher (KUAL) running applications on the Kindle.
Download it from here: KUAL
Unzip the folder and copy the matching .azw2 file to the documents directory of your kindle.

(K2, DX, K3, K4)
Put KUAL-KDK-1.0.azw2 in documents folder.
Run it by clicking new kindlet (book) document in your list.

(Touch, PaperWhite)
Put KUAL-KDK-2.0.azw2 in documents folder.
Run it by clicking icon.

Backdoorlock

This is used to prevent from getting automated updates which could remove the JailBreak.
Download from here: Backdoorlock
Unzip the folder and copy the .bin file to the root directory of your kindle. Please note that you need to install the Kindle matching version (e.g. K4 = Kindle 4 with 5-way-button). On the Kindle goto Menu -> Settings -> Menu -> Update your Kindle. After the update it is installed.

ScreenSavers Hack

The ScreenSavers Hack let you show custom screen savers on the kindle.
Download the file: ScreenSaver Hack
Install the corresponding .bin file as the others before and use the "update your kindle" function to install it.
After the installation you will find a directory called "linkss" in the Kindle root. Here open the screensavers dir and delete all images.

Online ScreeSaver

This application copies the fhem-PNG from your fhem-server to the ScreenSavers hack. Just download the application from here, extract the file and copy the folder into the extensions directory.
Now you have to edit the config.sh file up to your need.
NOTE Use a linux/unix compatible editor (like notepad++) only!
You need to enter the image URL, the update interval and the schedule for the updates. That's all.

Online Screen Saver - Kindle 4 Special Tasks

To get it running on a Kindle 4 you need to change some lines in the OnlineScreenSaver files.
You can find a .diff file for the changes here: fhem forum
No idea what to do with this file? It just shows you in which lines changes were made and what was changed. I recommend to edit all the files shown in the diff-file locally and then copy the whole package to the kindle first.

Kindle 4 additional tasks

A Kindle 4 differs in a few ways from the later models. It doesn't use upstart but old start up scripts so the online screensaver scripts will not start automatically after a reboot of your kindle. You can either manually start the patched /mnt/base-us/extensions/onlinescreensaver/bin/enable.sh which starts /mnt/base-us/extensions/onlinescreensaver/bin/scheduler.sh as a background process or you can create your own startup script in /etc/init.d or you can create a cron job to periodically update the screen.

Another difference is the power management. The original online screensave was created for a kindle paperwhite which has a real time clock with alarm functions that can be controlled through the sysfs. Utils.sh in the online screensavers bin directory puts the next wake up time in /sys/class/rtc/rtc$RTC/wakealarm to achieve this. So the Paperwhite can sleep most of the time and only wake up to retrieve the latest PNG, display it and go back to sleep. On a Kindle 4 this does not work so the Kindle can not go to sleep and wake up but is has to keep running. Therefore it needs a lot more power than a paperwhite. While the paperwhite might run for two weeks or longer before it needs a recharge (depending on your update frequency) the Kindle 4 will need a recharge after 2 days or a power connection / docking station.

As your Kindle 4 needs some more attention to get it done, please find the steps here:

USB Network Hack

This hack is used to get SSH/Telnet Access to your Kindle. We need this on Kindle 4 to change some settings on the system.
Download and install the kindle-usbnetwork file from here: USBNETWORK
I'm sure you know what to do in the meantime ;-)
After that, activate the USBNetwork via KUAL and connect the Kindle via USB.

Connecting to the Kindle

Before you can connect you need to install the RNDIS driver. Here you can find a very good "HowTo" to do this. Note that the IP-Addresses you need to configure are different then addresses used in the example. Your RNDIS Interface needs to have 192.168.15.201 configured, the Kindle uses 192.168.15.244 on this interface.
Don't wonder you cannot ping the Kindle!
Now you can use a ssh-client like putty to connect to the Kindle. Telnet is also an option but only when WiFI mode is disabled. So better forget about it. Success? Great job!

Changing the "sleep settings" to keep the Kindle awake

After you connected to the Kindle you will be asked for a password. Login with root and blank password. Should work.
Now we need to make the filesystem writeable:

mntroot rw

Changing the root password:

passwd

Changing the timeouts:

cd /etc/kdb.src/yoshi/system/daemon/powerd/

Edit the t1_timeout (time before the secreensaver gets displayed) with the editor "vi" and change the last line to 200.
Same for the t2_timeout but here we enter 200000 in the last line to keep the Kindle awake for at least 2 days.
These values are setting the "sleep" counters on the Kindle. Unfortunately this will lower the battery faster then normal so I recommend to have the display in a docking station.

Cron setting (optional)

In my case that all didn't really work for me so i decided to run the onlinescreensaver update script via cron:

vi /etc/crontab/root

Add the following line at the bottom. */5 means every 5 minutes.

*/5 * * * * /mnt/us/extensions/onlinescreensaver/bin/update.sh
/etc/init.d/cron restart

Setting back filesystem in read-only mode

mntroot ro

That's it for me. Not working? Ask and look here for help: FHEM Forum

Examples and Pictures

KindleDisplay.jpg Kindle Display Example on Kindle 4