Howto: FHEM: Kindle Display: Refresh on state/value change

I’m using FHEM a lot these days, so i decided to buy an Amazon Kindle and make a status display with it.
The KindleDisplay-Article on helped me a lot doing these thing, the only downside was that it would only update every couple of minutes, which is a bit boring.

So there are two problems in my way to have a realtime Kindle-Display:
1. Update the Status-Image with FReplacer everytime something shown on the display changes.
2. Tell the Kindle to fetch a new picture.

The first problem is solved pretty easy, you just define a dummy-variable to safe the old values in there:

define kindledisplayvalues dummy

Then make an at to check every couple seconds (i do this every 5 seconds) if something has changed:

define kindlerefresh at +*00:00:05 {
 my $oldvals="kindledisplayvalues";
 my $attrvalue="";
 my $valuename="";
 my $attr="";
 my @attrs=split / /, AttrVal($display,"userattr","none");
 my @attrvalues="";
 my $updatedisplay="no";
 if ($attrs[0] eq "none") {
 foreach $attr (@attrs) {
  if (index($attr, "Reading") ne -1) {
   if (index($valuename, $display . ":LastUpdate") eq -1) {
    if (index($valuename, ":") ne -1) {
     @attrvalues=split /:/, $valuename;
    } else {
    if (ReadingsVal($oldvals,$valuename,"none") ne $attrvalue) {
     fhem("setreading " . $oldvals . " " . $valuename . " " . $attrvalue);
 if ($updatedisplay eq "yes") {
  Log 2, "Updating Kindle Display";
  fhem("set ". $display ." ReplaceNow");

Only downside: If you have “RepXXExpr” atrributes in your FReplacer defined, you should consider defining “RepXXReading” attributes (just use some numbers where there is no “RegXXRegex”) with the devicenames used in the expr, so that the Script checks those too.

First problem solved.

Second Problem:

This is a bit of fiddling around, but still doable.
First of all, you copy the ssh public key of your fhem-user to the Kindle.

sudo scp /opt/fhem/.ssh/ root@<ip_of_your_kindle>:/mnt/us/usbnet/etc/authorized_keys

After you did that, FHEM should be able to Login on the Kindle via SSH without putting in a password.

Now we tell the FReplacer to Login on the Kindle and Fetch a new Image when it is finished:

attr kindledisplay PostCommand convert /opt/fhem/www/images/KindleDisplay.svg -type GrayScale -depth 8 /opt/fhem/www/images/KindleDisplay.png 2>/dev/null;;ssh root@<ip_of_your_kindle> '/mnt/us/extensions/onlinescreensaver/bin/' 2>/dev/null &

A small hint: If you don’t want the display to flicker when it gets updated: Search for “eips” in the and remove the “-f” behind it, the Kindle does only incremental updates then.
I copied the to, removed the “-f” and call the “” now with the FReplacer. This means it makes an incremental displayrefresh on change and i let it still call the normal every hour, so i don’t get any ghosting on the display.