Programmer's entertainment: the Kindle lock screen displays the component information in homeassistant and obtains the Kindle power in homeassistant

Mintimate 2022-05-04 16:03:18 阅读数:840

The head picture can be less ??? Obviously not.

Blog :

Mintimate’s Blog, Just to share with you

Now everything pays attention to interconnection , I introduced it a while ago Smart bubble panel Kindle Prison break and raspberry pie installation Home Assistant. This time, , Let's teach you how to organically combine the two , Realization :

  • Kindle Replace the lock screen with Home Assistant The monitoring panel , And refresh regularly (KPW4 And above , You may have to press the power key or wake up the smart cover , It's fine too Kindle Always turn on the power before , because Kindle The economizer will be disconnected Wi-Fi).
  • Home Assistant You can see Kindle The remaining power of (KPW4 And above , ditto ).

Article premise

The premise is simple , As mentioned above , We need to :

Be careful ️:KPW4 And above Kindle, Because the screen will be automatically disconnected after locking Wi-Fi, And because of firmware , The user cannot press the power button again until the power button is turned on ; So automatically and regularly declare data , stay KPW4 in the future , The user needs to manually light up the screen to make a declaration ( Mainly , I don't know Kindle Of Wake Up What is the instruction ……), perhaps ~ You can take Kindle Keep the power on for power on ~~ This will not trigger sleep break Wi-Fi The mechanism of .

Realization effect

The effect is very simple , for instance : our Home Assistant The monitoring panel :

Control panel

After us , Take a screenshot of the page and sharpen it , You can get such a black-and-white picture :

Processed pictures

Last , Push it to Kindle On , Apply as lock screen wallpaper :

Lock screen wallpaper

Be careful : This is the lock screen wallpaper , No Kindle Built in browser .

coordination Home Assistant The built-in Webhook hook ( Be similar to Git Of hook), Can achieve Kindle Power tracking :

Kindle Power tracking

When charging Kindle Will not start sleep off the network , It can be used to track power consumption :

Kindle Power tracking

wuhu , Charging is still very fast ⁄(⁄ ⁄ ⁄ω⁄ ⁄ ⁄)⁄

The preparation of the instruments

The tools to prepare are simple , Remove the basic Kindle Prison break and Home Assistant Out of demand , We also need plug-ins :

  • Kindle plug-in unit Kual: For managing plug-ins
  • Kindle plug-in unit MR Package Installer: For installing plug-ins
  • Kindle plug-in unit ScreenSavers Hack: Used to change Kindle wallpaper
  • Kindle plug-in unit Online Screensaver: For loading and downloading Web Kindle Picture as ScreenSavers Hack Of wallpaper .

The above tools , Download address :

Other tools are :

  • Docker Containers hass-lovelace-kindle-screensaver: For deploying a nodejs service , Regularly HA The control panel is grayed out Kindle picture ( Used as wallpaper ).

above Docker Address of the container :

HA Set up

For the convenience of follow-up operation , Let's finish first Home Assistant Internal operation :

  • Create auxiliary entity class : We need to create auxiliary entity classes , For later Webhook Receiving parameters (Kindle Power and Kindle Charging state )
  • Create long-term Token: We create a long-term Token( Ten years ), be used for Docker The container is airtight 、 Remote login .

Create long-term Token

We enter Home Assistant Graphical interface , You can create a Token token :


The token should be like this :

Get the token

We need to pay attention to ️: The token content will only be displayed once , It is recommended to save it in Notepad or after forgetting , Delete the old and recreate .

Auxiliary class entity

after , We need to create auxiliary class entities , It's simple , stay configuration.yaml Add a configuration file to the , I'm here for the convenience of management , Adopt multi file mode :

Multi file mode

Create a... Respectively input_boolean and input_number type , It is convenient to receive parameters later :


name: Kindle Battery Charging
icon: mdi:book-check-outline


icon: mdi:currency-usd
name: Kindle Battery Level
min: 1
max: 100
step: 0.1
Created entities

after , restart Home Assistant that will do , These auxiliary entities are used below .

establish webhook

after , In order to use the auxiliary entity class we created above , And provide a webhook Address , Let's add an automation template : One click Add automation template

after , Use templates to create automated :

Create automated

This is the time , You can select the auxiliary entity above :

Create auxiliary script

We need to pay attention to , Here I create this script (webhook) It's called KindleAuto, This can be customized , However, the changes will be synchronized later .

Lock screen wallpaper rendering

The above said , We need to install ScreenSavers Hack plug-in unit , I believe everyone knows the installation method , If not …… You can read the tutorial accompanying the book .

After installation , We need to pay attention , We'd better put only one picture :

Just one picture

Be careful ️: The content of this picture will be later OnlineScreensaver Cover

This chapter , This paper mainly introduces Docker Container configuration .

Docker Containers

Originally , I want to write one myself Kindle Wallpaper generated , But I found that the boss had written :

My raspberry pie has Docker Environmental Science , So I pulled it directly on the raspberry pie Docker Containers :

docker pull sibbl/hass-lovelace-kindle-screensaver
Pull the mirror image

Container start parameters

According to the stable introduction :

We're starting Docker Environment variables need to be set in the process , The environment variable parameters I recommend :

  • HA_BASE_URL=''
  • HA_SCREENSHOT_URL='/lovelace/info?kiosk'
  • HA_ACCESS_TOKEN='eyJ0eXAi*O6JdOXtQe5co'
  • LANGUAGE="en"
  • TZ=Asia/Shanghai

among ,HA_BASE_URL by Home Assistant Address ;RENDERING_TIMEOUT by Docker obtain Home Assistant Data timeout period , Set up here 30s;LANGUAGE Set the language for English ( Do not set to Chinese ~ No Chinese font );TZ Is the time zone ;HA_BATTERY_WEBHOOK by Webhook name , Set above ;RENDERING_SCREEN_WIDTH Set picture width ;RENDERING_SCREEN_HEIGHT Set the image height ;HA_ACCESS_TOKEN Above, Home Assistant Set up Token.

HA_SCREENSHOT_URL Is that we need to be in Kindle The lock screen shows

panel , such as :


Then add ?kiosk Of get request , It's actually Home Assistant Front end plug-ins :, You can hide the sidebar with this plug-in :

Hide sidebar

therefore , Finally, I created Docker Containers :

docker run -d -e HA_BASE_URL='' -e RENDERING_TIMEOUT=30000 -e LANGUAGE="en" -e LANG="zh_CN.UTF-8" -e TZ=Asia/Shanghai -e RENDERING_DELAY=5000 -e HA_BATTERY_WEBHOOK=KindleAuto -e RENDERING_SCREEN_WIDTH=1150 -e RENDERING_SCREEN_HEIGHT=1450 -e HA_SCREENSHOT_URL='/lovelace/info?kiosk' -e HA_ACCESS_TOKEN='eyJ******5co' -p:5000:5000 sibbl/hass-lovelace-kindle-screensaver
establish Docker
Created Docker state

If there's nothing wrong , You can access it through the browser :


Next , We can go back to Kindle On , Continue the subsequent configuration .

If you guys don't understand Docker Containers , There will be a chance to publish an article in the future , Give you a detailed explanation Docker(**-**)

OnlineScreensaver plug-in unit

As I said before , Need to install Online Screensaver Expand , The final result should be like this :

Installed plug-ins

This plug-in has not been updated for a long time , In the new Kindle On the system version , Need to repair permissions .

Patch permissions

Fixing permissions is simple , stay Online Screensaver Inside :

Online Screensaver Inside

We need to change,、、 and In file :


Is the full absolute path :

source /mnt/us/extensions/onlinescreensaver/bin/
source /mnt/us/extensions/onlinescreensaver/bin/

And put Internal :

wait_for ()

Method , Change the whole to :

wait_for () {
ENDWAIT=$(( $(currentTime) + $1 ))
REMAININGWAITTIME=$(( $ENDWAIT - $(currentTime) ))
logger "Starting to wait for timeout to expire: $1"
# wait for timeout to expire
while [ $REMAININGWAITTIME -gt 0 ]; do
EVENT=$(lipc-wait-event -s $1 com.lab126.powerd readyToSuspend,wakeupFromSuspend,resuming)
REMAININGWAITTIME=$(( $ENDWAIT - $(currentTime) ))
logger "Received event: $EVENT"
case "$EVENT" in
logger "Finishing the wait"
logger "Ignored event: $EVENT"
logger "Wait finished"

after , It can be used normally .

Configure the service

after , open, We configure it according to the prompts , Such as my :

My configuration

We need to pay attention to :

  • IMAGE_URI: We configured above Docker Address of the container (5000 port )
  • LOGFILE: Log file output

Running successfully

Last , restart Kindle:

restart Kindle

All configurations can be applied . You can see the effect without accident :

Lock screen wallpaper

Of course , You can also be in KUAL Manual update in :

Update manually

Of course , If there are questions , You can view the log :

Kindle journal

As I said earlier ,KPW4 After sleep ( Without power on ) It will automatically turn off Wi-Fi.

That is to say , We need to take Kindle Wake up the ( Press the power button ), After etc. Kindle Connected to the Wi-Fi after , The wallpaper will be updated .

Actually Kindle The essence is Linux, Yes, you can write scripts manually and open them regularly Wi-Fi And we Docker On the container Web Communicating , But I can't write this , I'll leave it to you ~~