npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@davidhekim/homebridge-website-change-check

v1.0.12

Published

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

Downloads

9

Readme

@davidhekim/homebridge-website-change-check

@davidhekim/homebridge-website-change-check mit-license

@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. If you are running on a Raspberry, you will find a tutorial in the homebridge wiki.

Install homebridge:

sudo npm install -g homebridge

Install @davidhekim/homebridge-website-change-check:

sudo npm install -g @davidhekim/homebridge-website-change-check

In the Homebridge terminal, run:

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:

{
  "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 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

{
  "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 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. Just make sure that the correct path is included in a .env file. For an example of the .env file, see .env.example.