# @davidhekim/homebridge-website-change-check

> Homebridge plugin for checking if a value on a website has changed.

Latest version **1.0.12** (published 2023-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @davidhekim/homebridge-website-change-check
pnpm add @davidhekim/homebridge-website-change-check
yarn add @davidhekim/homebridge-website-change-check
bun add @davidhekim/homebridge-website-change-check
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2023-03-05 |
| First published | 2023-03-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 217.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | David Hekim |
| Maintainers | davidhekim |
| Keywords | homebridge-plugin, website-change-check, change-updates |

## Links

- npm: https://www.npmjs.com/package/@davidhekim/homebridge-website-change-check
- Repository: https://github.com/davidhekim/homebridge-website-change-check
- Homepage: https://github.com/davidhekim/homebridge-website-change-check#readme
- Issues: https://github.com/davidhekim/homebridge-website-change-check/issues
- Funding: https://paypal.me/davidhekim
- npm.io page: https://npm.io/package/@davidhekim/homebridge-website-change-check

## Dependencies (2)

- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [playwright-core](https://npm.io/package/playwright-core.md) ^1.9.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2023-03-05
- 1.0.11 — 2023-03-04
- 1.0.10 — 2023-03-04

## README

<span align="center">

# @davidhekim/homebridge-website-change-check

[![@davidhekim/homebridge-website-change-check](https://badgen.net/npm/v/@davidhekim/homebridge-website-change-check?icon=npm)](https://www.npmjs.com/package/@davidhekim/homebridge-website-change-check)
[![mit-license](https://badgen.net/npm/license/@davidhekim/homebridge-website-change-check)](https://github.com/davidhekim/homebridge-website-change-check/blob/master/LICENSE)

</span>

`@davidhekim/homebridge-website-change-check` is a plugin for homebridge which allows you to check if a value on a website has changed. The special part of this plugin is that values are checked using a headless browser. Therefor values can even be fetched on websites with asynchronous data calls.

## Installation

If you are new to homebridge, please first read the homebridge [documentation](https://www.npmjs.com/package/homebridge).
If you are running on a Raspberry, you will find a tutorial in the [homebridge wiki](https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Raspbian).

Install homebridge:
```sh
sudo npm install -g homebridge
```

Install @davidhekim/homebridge-website-change-check:
```sh
sudo npm install -g @davidhekim/homebridge-website-change-check
```

In the Homebridge terminal, run:
```sh
sudo apt install chromium-browser chromium-codecs-ffmpeg
```

This is necessary when running on an ARM processor, like on a Raspberry Pi. This will install a headless Chromium browser which is used for change detection. 

## Configuration

Add the `WebsiteChangeCheck` platform in `config.json` in your home directory inside `.homebridge`.

Example configuration:

```js
{
  "platforms": [
    {
        "platform": "WebsiteChangeCheck",
        "changeChecks": [
            {
                "name": "BBC check",
                "url": "http://bbc.com/",
                "selector": ".module--header .module__title span",
                "checkInterval": 300000,
                "ignoreValues": []
            }
        ]
    }
  ]
}
```

Every device stated in the config will be automatically added as an accessory to Homekit. 

### Platform Configuration fields

Property | Required? | Remarks
--- | :-: | ---
`platform` | :heavy_check_mark: | Should always be **"WebsiteChangeCheck"**.
`changeChecks` | :heavy_check_mark: | A list of your website checks.

### changeChecks configuration fields
Property | Required? | Remarks
--- | :-: | ---
`name` | :heavy_check_mark: |Custom name for your check
`url` | :heavy_check_mark: | URL of the website/page you want to check
`selector` | :heavy_check_mark: | Selector of the value you want to compare. 
`checkInterval` | | Interval of the checks
`stepsBeforeCheck` | | List of steps that should be executed before checking for the selector. Could be useful if, for example, a value is only visible after filling in a form. See [configuration](#stepsbeforecheck-configuration-fields)
`ignoreValues` | | List of change values that do not cause a motion trigger
### stepsBeforeCheck configuration options
Type | Remarks 
--- | ---
`{ action: 'setSelectValue', selector: string, value: string \| number \| '*' }` | Used for selecting a value in a `select` element. The value can be either a string, a number, or a `*`. The `*` value makes sure the first possible truthy value will be set. 
`{ action: 'setInputValue', selector: string, value: string \| number }` | Used for setting a value in an `input` element.
`{ action: 'click', selector: string }` | Used for clicking an element
`{ action: 'waitForMilliseconds', value: number }` | Used for waiting a certain amount of milliseconds before the next action takes place

#### stepsBeforeCheck example usage in config
```js
{
  "platforms": [
    {
        "platform": "WebsiteChangeCheck",
        "changeChecks": [
            {
                "name": "BBC check",
                "url": "http://bbc.com/",
                "selector": ".module--header .module__title span",
                "checkInterval": 300000,
                "stepsBeforeCheck": [
                    {
                        "action": "waitForMilliseconds",
                        "value": 500
                    },
                    {
                        "action": "setSelectValue", 
                        "selector": "#mySelectId", 
                        "value": "*"
                    }
                ]
            }
        ]
    }
  ]
}
```
In this example the script will wait 500 milliseconds, then set the first possible truthy value in the #mySelectId `select` element, after which it checks the value in `.module--header .module__title span`.

## Local debugging
See the [LOCAL_DEBUG.md](LOCAL_DEBUG.md) manual for an explanation on how to test your scenario on your local machine. This also includes screenshot so you can visually see what every step of your script does.

## Contributors
If you'd like to contribute to this repository, feel free to! 
 
Only know that if you're testing the scripts locally, you have to install Chromium yourself. This is because `puppeteer` with Chromium included didn't work on my RaspberryPi Homebridge, therefor like stated above, it requires a manual installation. For that reason you need to download it locally as well. You can find the right version for you over [here](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html). Just make sure that the correct path is included in a `.env` file. For an example of the `.env` file, see `.env.example`.

---
_Source: https://npm.io/package/@davidhekim/homebridge-website-change-check · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
