Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from base repo #2

Open
wants to merge 103 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
9d8c6cc
Add support to render multiple lovelace tabs within the same instance
sibbl Apr 24, 2021
c337122
Add option to ignore certificate errors #9
sibbl Apr 24, 2021
ba812b9
Update README.md
sibbl Apr 24, 2021
28df568
Use possibly swapped size/height for custom css added to body #11
sibbl Jun 30, 2021
454df2e
Support for letting HA keep track of Kindle battery level
bictorv Aug 10, 2021
7c07c4f
Add support for charging state
bictorv Sep 30, 2021
630be79
Untabify
bictorv Sep 30, 2021
da983d8
Bump Alpine docker version to use Node.js 16 LTS
sibbl Nov 9, 2021
f2fe8f8
Update dependencies
sibbl Nov 9, 2021
ff0b23c
Wait for "home-assistant" selector, add Last-Modified header, some cl…
sibbl Nov 9, 2021
41c6b93
Update CI to use package.json version as git + docker tags
sibbl Nov 9, 2021
b243798
Bump to version 1.0.1
sibbl Nov 9, 2021
81b5d2f
Merge pull request #16 from sibbl/fixes
sibbl Nov 9, 2021
e5cfd7b
Specify Alpine version 3.11 to get armv7 compatibility
sibbl Nov 9, 2021
24eb068
Merge pull request #17 from sibbl/fixes
sibbl Nov 9, 2021
fda528d
only copy needed files to container
lanrat Nov 10, 2021
b45c198
add support for changing the color mode
lanrat Nov 10, 2021
dbf1513
render image on startup before cron
lanrat Nov 10, 2021
9f3c682
update dockerignore
lanrat Nov 10, 2021
0694906
Merge pull request #18 from lanrat/color_config
sibbl Nov 22, 2021
1125cdf
Merge pull request #20 from lanrat/pre-render
sibbl Nov 22, 2021
f2831ba
Merge pull request #19 from lanrat/dockerfile-tweaks
sibbl Nov 22, 2021
96c4131
Bump to version 1.0.2
sibbl Nov 22, 2021
12a1668
Merge branch 'main' into battery-level
bictorv Nov 30, 2021
b1bb6bc
dither config
lanrat Dec 1, 2021
de16187
set quality to 100 by default
lanrat Dec 1, 2021
26da1bd
mend
lanrat Dec 1, 2021
ee7ab16
Merge pull request #22 from lanrat/quality
sibbl Dec 13, 2021
0d493a0
Merge pull request #23 from lanrat/dither-config
sibbl Dec 13, 2021
e7e7162
Bump version to 1.0.3
sibbl Dec 13, 2021
2ec5f4a
Merge branch 'rendering-improvements' of https://github.com/sibbl/has…
sibbl Dec 13, 2021
42cd1e9
Merge pull request #24 from sibbl/rendering-improvements
sibbl Dec 13, 2021
46484e6
Cleanup
bictorv Dec 17, 2021
dcc8865
Merge pull request #13 from bictorv/battery-level
sibbl Dec 17, 2021
771c7d0
Add multiple device support for battery webhook and unify naming, rea…
sibbl Dec 17, 2021
e3593e2
Bump to v1.0.4
sibbl Dec 17, 2021
202a2d6
Fix variable naming
sibbl Dec 17, 2021
b2b1171
Update documentation
sibbl Dec 17, 2021
748e791
Merge pull request #25 from sibbl/battery-sensor
sibbl Dec 17, 2021
254454a
Add battery sensor blueprint
sibbl Dec 17, 2021
d963ddf
Rename yml to yaml to avoid HA blueprint import having ".yml.yaml" fi…
sibbl Dec 17, 2021
c41bebf
Merge pull request #27 from sibbl/battery-sensor
sibbl Dec 17, 2021
63b7a93
Add "1" and "0" to expected battery isCharging values
sibbl May 8, 2022
882d7c7
Add option to control image black and white levels.
jaenis May 14, 2022
a728b3b
Merge pull request #37 from jaenis/main
sibbl May 14, 2022
f9797d7
Add battery status diff for kindle 4 extension #35
sibbl Jun 18, 2022
145a702
Improve README
sibbl Jun 18, 2022
0b60bd6
Link to new kiosk HACS addon in readme
sibbl Jul 12, 2022
b6ca2bd
Make docker compose instructions more precise
sibbl Jul 18, 2022
56f121a
Fix typo
sibbl Jul 18, 2022
b819f75
Consider ignoreCertificateErrors when sending battery status to HA
LorenzoRogai Jul 30, 2022
c64c856
Merge pull request #43 from LorenzoRogai/main
sibbl Jul 31, 2022
e1d6bb0
Bump alpine to 3.17 to include newer chromium #7
sibbl Jan 16, 2023
ea916cf
Include emoji font #48
sibbl Jan 16, 2023
8ec79ab
Merge pull request #49 from sibbl/bump-alpine-include-emoji
sibbl Jan 16, 2023
7b3a36c
Adding HA Addon files
J3n50m4t Apr 26, 2023
bb3e3cd
cleanup
J3n50m4t Apr 27, 2023
6f20b3a
Add instructions how to install the addon
J3n50m4t Apr 27, 2023
c8e4cc4
Merge pull request #61 from J3n50m4t/main
sibbl May 29, 2023
4d9de93
Add local_only input to blueprint
davide125 Jun 5, 2023
f31d74c
Merge pull request #65 from davide125/blueprint
sibbl Jun 7, 2023
16b368c
Update config.yaml
rjlee Jun 25, 2023
23f14a9
Added HA_BATTERY_WEBHOOK env variable setting
rjlee Jun 26, 2023
a50fddc
Bumping release version
rjlee Jun 26, 2023
3664145
Merge pull request #69 from rjlee/rjlee-patch-1
sibbl Jun 27, 2023
8050ed3
Wait until first render is done before starting up cron job.
jaenis Oct 13, 2023
784bf3e
Merge pull request #87 from jaenis/main
sibbl Oct 13, 2023
797cfb8
Add option to remove Gamma correction from image.
jaenis Oct 13, 2023
6a374c7
Merge pull request #88 from jaenis/main
sibbl Oct 13, 2023
8e07610
Add support for browser launch timeout
jsuchal Nov 25, 2023
56ef990
Merge pull request #96 from jsuchal/jsuchal/add-browser-launch-timeout
sibbl Nov 27, 2023
dd33180
Add option to enable browser dark mode
deenter Dec 2, 2023
2e88cfb
Add option to enable browser dark mode
deenter Dec 2, 2023
bc03fd8
Add option to enable browser dark mode
deenter Dec 2, 2023
6364bf1
Add option to enable browser dark mode, Hass.io dropdown entry
deenter Dec 2, 2023
22e648d
Merge pull request #97 from deenter/dark_mode
sibbl Dec 2, 2023
40c379f
Fix bug in config.yaml for proper scaling
paulchevalier Jan 5, 2024
3946956
Merge pull request #102 from paulchevalier/main
sibbl Jan 5, 2024
f5255cc
Bump to version 1.0.6
sibbl Jan 21, 2024
36ec4a8
Bump package.json to 1.0.6
sibbl Jan 21, 2024
a921ac8
Add armv7 support for Hassio addon (#106)
sibbl Feb 6, 2024
27cdea6
Allow additional env vars for Hass Add-On + add missing config params…
sibbl Feb 22, 2024
0d073a2
Remove DITHER option from HA Add-On again
sibbl Feb 23, 2024
5380aad
Use architecture and versions during CI build of hass addon
sibbl Mar 4, 2024
24b1a8c
Allow switching output image format
nbarrientos Mar 15, 2024
b8ab75c
Bump version, update changelog
sibbl Mar 15, 2024
e616150
Merge pull request #116 from nbarrientos/ib_jpeg
sibbl Mar 15, 2024
73d2dc7
REMOVE_GAMMA and DITHER options were strings and always true
cosote Apr 9, 2024
117ebb7
Change CI trigger to use versions
sibbl Apr 14, 2024
93b9fd6
Merge pull request #118 from cosote/cosote_fix_boolean_config
sibbl Apr 14, 2024
3cd7e08
Bump version to 1.0.10
sibbl Apr 14, 2024
5112964
Skip tagging commit via CI
sibbl Apr 14, 2024
31487f7
Fix Viewport resizing upon page.screenshot
beeh5 May 22, 2024
49b1acd
Merge pull request #125 from beeh5/fix-viewport-resize
sibbl May 22, 2024
885d0f9
Extend changelog, bump version to 1.0.11
sibbl May 22, 2024
c9d90e8
Swap CSS scale for zoom
avhm Aug 6, 2024
4d2224a
Merge pull request #127 from avhm/main
sibbl Aug 7, 2024
a0111ca
Bump version to 1.0.12
sibbl Aug 7, 2024
af6e154
Add image controls including saturation and contrast
harry48225 Dec 23, 2024
836cd87
Add new variables to home assistant config
harry48225 Dec 23, 2024
d7ba1fa
Only apply quality setting to screenshot if jpeg
harry48225 Dec 23, 2024
af1e72f
Merge pull request #135 from harry48225/contrast-and-saturation-adjust
sibbl Dec 27, 2024
1822d90
Bump verison to 1.0.13
sibbl Dec 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
node_modules/
.github/
.git/
.vscode/
assets/
config.*.js
docker-compose.*.yml
output/
docker-compose.yml
output/
LICENSE
*.md
*.yml
*.yaml
56 changes: 44 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,66 @@ name: ci

on:
push:
branches: main
tags: [ 'v*.*.*' ]

jobs:
multi:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
- name: Extract package version
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
- name: Build and push to Docker
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: |
sibbl/hass-lovelace-kindle-screensaver:${{ env.PACKAGE_VERSION }},
sibbl/hass-lovelace-kindle-screensaver:latest
- name: Build and push HA_Addon AMD64 to Docker
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.HA_ADDON
build-args: BUILD_FROM=homeassistant/amd64-base:latest
platforms: linux/amd64
push: true
tags: |
sibbl/hass-lovelace-kindle-screensaver-ha-addon-amd64:${{ env.PACKAGE_VERSION }},
sibbl/hass-lovelace-kindle-screensaver-ha-addon-amd64:latest
- name: Build and push HA_Addon aarch64 to Docker
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.HA_ADDON
build-args: BUILD_FROM=homeassistant/aarch64-base:latest
platforms: linux/arm64/v8
push: true
tags: |
sibbl/hass-lovelace-kindle-screensaver-ha-addon-aarch64:${{ env.PACKAGE_VERSION }},
sibbl/hass-lovelace-kindle-screensaver-ha-addon-aarch64:latest

- name: Build and push HA_Addon ARMv7 to Docker
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.HA_ADDON
build-args: BUILD_FROM=homeassistant/armv7-base:latest
platforms: linux/arm/v7
push: true
tags: |
sibbl/hass-lovelace-kindle-screensaver-ha-addon-armv7:${{ env.PACKAGE_VERSION }},
sibbl/hass-lovelace-kindle-screensaver-ha-addon-armv7:latest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules/
config.*.js
docker-compose.*.yml
cover.png
output/
.devcontainer/
.DS_Store
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Changelog

## 1.0.13

### Added

* Allow configuring contrast, saturation, black level and white level. JPEG quality is set to 100% (thanks to [@harry48225](https://github.com/harry48225))

## 1.0.12

### Fixed

* Fix scaling bug by using zoom css property instead of transforms (thanks to [@avhm](https://github.com/avhm))

## 1.0.11

### Fixed

* Avoid viewport resize causing another rerender when taking screenshot (thanks to [@beeh5](https://github.com/beeh5))

## 1.0.10

### Fixed

* Fix REMOVE_GAMMA and DITHER always being enabled for Home Assistant Add-On

## 1.0.9

### Added

* Add jpeg support via new `IMAGE_TYPE` config env variable (thanks to [@nbarrientos](https://github.com/nbarrientos))

## 1.0.8

### Fixed

* Remove DITHER option from Home Assistant Add-On again until the gm/im incompatibility will be fixed

## 1.0.7

### Added

* Finally there's a changelog
* Allow custom environment variables to Home Assistant Add-On

### Fixed

* Add missing config variables to Home Assistant Add-On
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM node:12-alpine
FROM node:16-alpine3.17

WORKDIR /app

RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype \
font-noto-emoji \
freetype-dev \
harfbuzz \
ca-certificates \
Expand All @@ -17,10 +18,11 @@ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
USE_IMAGE_MAGICK=true

COPY package*.json ./
COPY local.conf /etc/fonts/local.conf

RUN npm ci

COPY . .
COPY *.js ./

EXPOSE 5000

Expand Down
33 changes: 33 additions & 0 deletions Dockerfile.HA_ADDON
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG BUILD_FROM
FROM ${BUILD_FROM}

WORKDIR /app
RUN apk add --no-cache \
chromium \
nss \
freetype \
font-noto-emoji \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
imagemagick \
nodejs \
npm

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
USE_IMAGE_MAGICK=true

COPY package*.json ./
COPY local.conf /etc/fonts/local.conf
COPY *.js ./

RUN npm ci


# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh

CMD [ "/run.sh" ]
115 changes: 94 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,109 @@ If you're looking for a way to render your own HTML, see my other project [hass-

## Features

This tool regularly takes a screenshot of a specific page of your home assistant setup. It converts it into the PNG grayscale format which Kindles can display.
This tool regularly takes a screenshot of a specific page of your home assistant setup. It converts it into the PNG/JPEG grayscale format which Kindles can display.

Using my [own Kindle 4 setup guide](https://github.com/sibbl/hass-lovelace-kindle-4) or the [online screensaver extension](https://www.mobileread.com/forums/showthread.php?t=236104) for any jailbroken Kindle, this image can be regularly polled from your device so you can use it as a weather station, a display for next public transport departures etc.

## Usage

You may simple set up the [sibbl/hass-lovelace-kindle-screensaver](https://hub.docker.com/r/sibbl/hass-lovelace-kindle-screensaver) docker container. The container exposes a single port (5000 by default). You can access the image by doing a simple GET request to e.g. `http://localhost:5000/` to receive the most recent image.
You may simple set up the [sibbl/hass-lovelace-kindle-screensaver](https://hub.docker.com/r/sibbl/hass-lovelace-kindle-screensaver) docker container. The container exposes a single port (5000 by default).

Home Assistant related stuff:

- `HA_BASE_URL=https://your-hass-instance.com:8123`
- `HA_SCREENSHOT_URL=/lovelace/screensaver?kiosk` (I recommend the [kiosk mode](https://github.com/maykar/kiosk-mode) project)
- `HA_ACCESS_TOKEN=eyJ0...` (you need to create this token in Home Assistant first)
- `LANGUAGE=en` (language to use in Home Assistant frontend)
- `CRON_JOB=* * * * *` (how often to take screenshots, by default every minute)
Another way is to use Hassio Addons where you have to add this repository or click [here](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fsibbl%2Fhass-lovelace-kindle-screensaver). Then Reload and you should see options to the Lovelace Kindle Screensaver Addon

Kindle related stuff:
I recommend simply using the `docker-compose.yml` file inside this repository, configure everything in there and run `docker-compose up -d` within the file's directory. This will pull the docker image, create the container with all environment variables from the file and run it in detached mode (using `-d`, so it continues running even when you exit your shell/bash/ssh connection).
Additionally, you can then later use `docker-compose pull && docker-compose up -d` to update the image in case you want to update it.

- `RENDERING_TIMEOUT=10000` (timeout of render process, necessary if your HASS instance might be down, in milliseconds)
- `RENDERING_DELAY=0` (how long to wait between navigating to the page and taking the screenshot, in milliseconds)
- `RENDERING_SCREEN_HEIGHT=800` (height of your kindle screen resolution, see below)
- `RENDERING_SCREEN_WIDTH=600` (width of your kindle screen resolution, see below)
- `ROTATION=0` (rotation of image in degrees, i.e. use 90 or 270 to render in landscape)
- `SCALING=1` (scaling factor, i.e. 1.5 to zoom in or 0.75 to zoom out)
- `GRAYSCALE_DEPTH=8` (grayscale bit depth your kindle supports)
You can then access the image by doing a simple GET request to e.g. `http://localhost:5000/` to receive the most recent image (might take up to 60s after the first run).

Advanced stuff:
Home Assistant related stuff:

- `OUTPUT_PATH=./output.png` (destination of rendered image)
| Env Var | Sample value | Required | Array?\* | Description |
|---------------------------|---------------------------------------| -------- | -------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `HA_BASE_URL` | `https://your-hass-instance.com:8123` | yes | no | Base URL of your home assistant instance |
| `HA_SCREENSHOT_URL` | `/lovelace/screensaver?kiosk` | yes | yes | Relative URL to take screenshot of (btw, the `?kiosk` parameter hides the nav bar using the [kiosk mode](https://github.com/NemesisRE/kiosk-mode) project) |
| `HA_ACCESS_TOKEN` | `eyJ0...` | yes | no | Long-lived access token from Home Assistant, see [official docs](https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token) |
| `HA_BATTERY_WEBHOOK` | `set_kindle_battery_level` | no | yes | Webhook definied in HA which receives `batteryLevel` (number between 0-100) and `isCharging` (boolean) as JSON |
| `LANGUAGE` | `en` | no | no | Language to set in browser and home assistant |
| `PREFERS_COLOR_SCHEME` | `light` | no | no | Enable browser dark mode, use `light` or `dark`. |
| `CRON_JOB` | `* * * * *` | no | no | How often to take screenshot |
| `RENDERING_TIMEOUT` | `10000` | no | no | Timeout of render process, helpful if your HASS instance might be down |
| `RENDERING_DELAY` | `0` | no | yes | how long to wait between navigating to the page and taking the screenshot, in milliseconds |
| `RENDERING_SCREEN_HEIGHT` | `800` | no | yes | Height of your kindle screen resolution |
| `RENDERING_SCREEN_WIDTH` | `600` | no | yes | Width of your kindle screen resolution |
| `BROWSER_LAUNCH_TIMEOUT` | `30000` | no | no | Timeout for browser launch, helpful if your HASS instance is slow |
| `ROTATION` | `0` | no | yes | Rotation of image in degrees, e.g. use 90 or 270 to render in landscape |
| `SCALING` | `1` | no | yes | Scaling factor, e.g. `1.5` to zoom in or `0.75` to zoom out |
| `GRAYSCALE_DEPTH` | `8` | no | yes | Grayscale bit depth your kindle supports |
| `COLOR_MODE` | `GrayScale` | no | yes | ColorMode to use, ex: `GrayScale`, or `TrueColor`. |
| `IMAGE_FORMAT` | `png` | no | no | Format for the generated images. Acceptable values are `png` or `jpeg`. |
| `DITHER` | `false` | no | yes | Apply a dither to the images. |
| `REMOVE_GAMMA` | `true` | no | no | Remove gamma correction from image. Computer images are normally gamma corrected since monitors expect gamma corrected data, however some E-Ink displays expect images not to have gamma correction. |
| SATURATION | 2 | no | no | Saturation level multiplier, e.g. 2 doubles the saturation |
| CONTRAST | 2 | no | no | Contrast level multiplier, e.g. 2 doubles the contrast |
| BLACK_LEVEL | 30% | no | no | Black point as percentage of MaxRGB, i.e. crushes blacks below specified level |
| WHITE_LEVEL | 90% | no | no | White point as percentage of MaxRGB, i.e. crushes whites above specified level |

**\* Array** means that you can set `HA_SCREENSHOT_URL_2`, `HA_SCREENSHOT_URL_3`, ... `HA_SCREENSHOT_URL_n` to render multiple pages within the same instance.
If you use `HA_SCREENSHOT_URL_2`, you can also set `ROTATION_2=180`. If there is no `ROTATION_n` set, then `ROTATION` will be used as a fallback.
You can access these additional images by making GET Requests `http://localhost:5000/2`, `http://localhost:5000/3` etc.

To make us of the array feature in the Home Assistant Add-On, you may use `ADDITIONAL_ENV_VARS`. It expects a format like this to set any additional environment variable:

```yaml
- name: "HA_SCREENSHOT_URL_2"
value: "/lovelace/second-page"
- name: "ROTATION_2"
value: "180"
- name: "HA_SCREENSHOT_URL_3"
value: "/lovelace/third-page"
```

To avoid problems, please ensure that the name only contains upper case letters, numbers and underscores. The value field must be a string, so it's better to always put your value (especially numbers) into a `"string"` .

### How to set up the webhook

The webhook setting is to let HA keep track of the battery level of the Kindle, so it can warn you about charging it. You need to do the following:

1. See below for a patch needed to make the Kindle Online Screensaver plugin send the battery level to this application.
1. Create two new helper entities in Home Assistant:
1. a new `input_number` entity, e.g. `input_number.kindle_battery_level`
1. a new `input_boolean` entity, e.g. `input_boolean.kindle_battery_charging`
1. Add an automation to set the values of these entities using a webhook: [![import blueprint](https://my.home-assistant.io/badges/blueprint_import.svg)](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgithub.com%2Fsibbl%2Fhass-lovelace-kindle-screensaver%2Fblob%2Fmain%2Fbattery_sensor_blueprint.yaml)
1. Define this application's environment variable `HA_BATTERY_WEBHOOK` to the name of the webhook defined in the previous step. For multiple devices, `HA_BATTERY_WEBHOOK_2`, ... `HA_BATTERY_WEBHOOK_n` is supported as well.

#### Patch for [Kindle Online Screensaver extension](https://www.mobileread.com/forums/showthread.php?t=236104)

Modify the following lines in the Kindle Online Screensaver extension's `bin/update.sh` (absolute path on device should be `/mnt/us/extensions/onlinescreensaver/bin/update.sh`):

```diff
...
if [ 1 -eq $CONNECTED ]; then
- if wget -q $IMAGE_URI -O $TMPFILE; then
+ batteryLevel=`/usr/bin/powerd_test -s | awk -F: '/Battery Level/ {print substr($2, 0, length($2)-1) - 0}'`
+ isCharging=`/usr/bin/powerd_test -s | awk -F: '/Charging/ {print substr($2,2,length($2))}'`
+ if wget -q "$IMAGE_URI?batteryLevel=$batteryLevel&isCharging=$isCharging" -O $TMPFILE; then
mv $TMPFILE $SCREENSAVERFILE
logger "Screen saver image updated"
...
```

#### Patch for [HASS Lovelace Kindle 4 extension](https://github.com/sibbl/hass-lovelace-kindle-4/)

Modify the following lines in the HASS Lovelace Kindle 4 extension's [`script.sh`](https://github.com/sibbl/hass-lovelace-kindle-4/blob/main/extensions/homeassistant/script.sh#L133) (absolute path on device should be `/mnt/us/extensions/homeassistant/script.sh`):

```diff
...
- DOWNLOADRESULT=$(wget -q "$IMAGE_URI" -O $TMPFILE)
+ DOWNLOADRESULT=$(wget -q "$IMAGE_URI?batteryLevel=$CHECKBATTERY&isCharging=$IS_CHARGING" -O $TMPFILE)
...
```

### Advanced configuration

Some advanced variables for local usage which shouldn't be necessary when using Docker:

- `OUTPUT_PATH=./output` (destination of rendered image, without extension. `OUTPUT_2`, `OUTPUT_3`, ... is also supported)
- `PORT=5000` (port of server, which returns the last image)
- `USE_IMAGE_MAGICK=false` (use ImageMagick instead of GraphicsMagick)

You may also simply use the `docker-compose.yml` file inside this repository, configure everything in there and run `docker-compose up`.
- `UNSAFE_IGNORE_CERTIFICATE_ERRORS=true` (ignore certificate errors of e.g. self-signed certificates at your own risk)
Loading