From 30d4f3c4919ee9cbec1763eca44cfbfe06778253 Mon Sep 17 00:00:00 2001 From: t0bst4r <82281152+t0bst4r@users.noreply.github.com> Date: Sun, 2 Jun 2024 11:14:19 +0200 Subject: [PATCH] fix: removed npm provenance and added readme --- .github/workflows/release.yml | 2 - .projenrc.js | 1 + README.md | 58 ++++++++++++++++++++- package.json | 3 -- src/home-assistant/home-assistant-client.ts | 1 + 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9b02119..af33607 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,6 @@ jobs: needs: release runs-on: ubuntu-latest permissions: - id-token: write contents: read if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha steps: @@ -102,6 +101,5 @@ jobs: env: NPM_DIST_TAG: latest NPM_REGISTRY: registry.npmjs.org - NPM_CONFIG_PROVENANCE: "true" NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: npx -p publib@latest publib-npm diff --git a/.projenrc.js b/.projenrc.js index c8381a8..764c2c2 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -24,6 +24,7 @@ const project = new typescript.TypeScriptProject({ ], releaseToNpm: true, + npmProvenance: false, tsconfig: { compilerOptions: { diff --git a/README.md b/README.md index 61f63db..42015ac 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,63 @@ --- -The Matterbridge Home Assistant package provides bindings to connect [HomeAssistant](https://www.npmjs.com/package/home-assistant-js-websocket) to [Matterbridge](https://github.com/Luligu/matterbridge/). +This **Matterbridge Home Assistant** package provides bindings to connect [HomeAssistant](https://www.npmjs.com/package/home-assistant-js-websocket) to [Matterbridge](https://github.com/Luligu/matterbridge/). -Currently supported entities: +## Installation +- Follow [those instructions](https://github.com/Luligu/matterbridge/?tab=readme-ov-file#installation) to setup `matterbridge`. +- Run `matterbridge -add matterbridge-home-assistant` +- Make the plugin is configured properly using environment variables. +- Start matterbridge using `matterbridge -bridge` + +## Configuration +This package can be configured using environment variables. + +- `HOME_ASSISTANT_URL` - the home assistant url (e.g. `http://192.168.178.23:8123`) +- `HOME_ASSISTANT_ACCSESS_TOKEN` - a long living access token created in Home Assistant +- `HOME_ASSISTANT_CLIENT_CONFIG` - a json string containing the client config (see below) + +### Client Config +The client config has to be a json string and can have the following properties: +```typescript +interface HomeAssistantClientConfig { + /** + * The domains to include. + * If set, ALL entities must match one of those domains - even those configured in `includePatterns` + * @example [ "light", "media_player" ] + */ + includeDomains?: Array; + /** + * Glob-Patterns to include entities. + * If set, ALL entities must match at least one pattern - even those configured in `includeDomains` + * @example [ "light.*", "media_player.*_tv_*" ] + */ + includePatterns?: Array; + /** + * The domains to exclude. + * If set, entities must not match any of those domains. + * Exclusions are always winning against inclusions. + * @example [ "media_player" ] + */ + excludeDomains?: Array; + /** + * Glob-Patterns to exclude entities. + * If set, entities must not match at any of those patterns. + * Exclusions are always winning against inclusions. + * @example [ "media_player.*echo*" ] + */ + excludePatterns?: Array; +} +``` + +### Example Configuration +``` +HOME_ASSISTANT_URL=http://192.168.178.23:8123 +HOME_ASSISTANT_ACCSESS_TOKEN=ey....yQ +HOME_ASSISTANT_CLIENT_CONFIG={ "includeDomains": ["light", "media_player"], "excludePatterns": ["media_player.*echo*"] } +``` + +## Supported Entities - Light entities (`light.`) including on-off, brightness and hue & saturation control - Switch entities (`switch.`) including on-off control - Media Players (`media_player.`) are mapped to Switches and currently only support on-off control + diff --git a/package.json b/package.json index 0b44cd1..3de34ae 100644 --- a/package.json +++ b/package.json @@ -56,9 +56,6 @@ }, "main": "lib/index.js", "license": "Apache-2.0", - "publishConfig": { - "access": "public" - }, "version": "0.0.0", "jest": { "coverageProvider": "v8", diff --git a/src/home-assistant/home-assistant-client.ts b/src/home-assistant/home-assistant-client.ts index 5e8cb18..bc49f3f 100644 --- a/src/home-assistant/home-assistant-client.ts +++ b/src/home-assistant/home-assistant-client.ts @@ -18,6 +18,7 @@ export interface HomeAssistantClientConfig { export class HomeAssistantClient { public static async create(url: string, accessToken: string, config?: HomeAssistantClientConfig): Promise { + url = url.replace(/\/$/, ''); const auth = createLongLivedTokenAuth(url, accessToken); const connection = await createConnection({ auth }); return new HomeAssistantClient(connection, config ?? {});