Skip to content

Commit

Permalink
Merge pull request #96 from jsuchal/jsuchal/add-browser-launch-timeout
Browse files Browse the repository at this point in the history
Add support for browser launch timeout
  • Loading branch information
sibbl authored Nov 27, 2023
2 parents 6a374c7 + 8e07610 commit 56ef990
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ You can then access the image by doing a simple GET request to e.g. `http://loca

Home Assistant related stuff:

| 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 |
| `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 |
| `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`. |
| `DITHER` | `false` | no | yes | Apply a dither to the images. |
| 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 |
| `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`. |
| `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. |

**\* 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.
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
pages: getPagesConfig(),
port: process.env.PORT || 5000,
renderingTimeout: process.env.RENDERING_TIMEOUT || 10000,
browserLaunchTimeout: process.env.BROWSER_LAUNCH_TIMEOUT || 30000,
language: process.env.LANGUAGE || "en",
debug: process.env.DEBUG === "true",
ignoreCertificateErrors:
Expand Down
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ options:
RENDERING_DELAY: '0'
RENDERING_SCREEN_HEIGHT: '800'
RENDERING_SCREEN_WIDTH: '600'
BROWSER_LAUNCH_TIMEOUT: '30000'
ROTATION: '0'
SCALING: '1'
GRAYSCALE_DEPTH: '8'
Expand All @@ -46,6 +47,7 @@ schema:
RENDERING_DELAY: "int"
RENDERING_SCREEN_HEIGHT: "int"
RENDERING_SCREEN_WIDTH: "int"
BROWSER_LAUNCH_TIMEOUT: "int"
ROTATION: "int"
SCALING: "int"
GRAYSCALE_DEPTH: "int"
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const batteryStore = {};
`--lang=${config.language}`,
config.ignoreCertificateErrors && "--ignore-certificate-errors"
].filter((x) => x),
timeout: config.browserLaunchTimeout,
headless: config.debug !== true
});

Expand Down

0 comments on commit 56ef990

Please sign in to comment.