@inradius/solid-wc-hass-mixin 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/package.json +6 -1
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @inradius/solid-wc-hass-mixin
|
|
2
|
+
 
|
|
3
|
+
|
|
4
|
+
A lightweight mixin for [component-register](https://www.npmjs.com/package/component-register) that streamlines the creation of Home Assistant Custom Cards using Solid.js.
|
|
5
|
+
|
|
6
|
+
This mixin automatically handles the boilerplate required by Home Assistant, including `setConfig`, card registration in the global window object, and the `getCardSize` method.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
- **Automatic Registration:** Automatically pushes your card configuration to the Home Assistant `customCards` registry.
|
|
10
|
+
- **Config Handling:** Implements `setConfig` and merges your `defaultConfig` with user-provided settings.
|
|
11
|
+
- **TypeScript Ready:** Full type safety for Home Assistant card configurations.
|
|
12
|
+
- **Clean Integration:** Designed to work seamlessly with `compose` and `register`.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @inradius/solid-wc-hass-mixin component-register
|
|
16
|
+
# or
|
|
17
|
+
pnpm add @inradius/solid-wc-hass-mixin component-register
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
Use `withHomeAssistant` within your `compose` pipeline. It should wrap your final component ***before*** registration.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { register, compose, withSolid } from 'component-register';
|
|
25
|
+
import withHomeAssistant from '@inradius/solid-wc-hass-mixin';
|
|
26
|
+
import { MyApp } from './MyApp';
|
|
27
|
+
|
|
28
|
+
compose(
|
|
29
|
+
withHomeAssistant({
|
|
30
|
+
defaultConfig: {
|
|
31
|
+
name: 'My Card',
|
|
32
|
+
layout: 'vertical',
|
|
33
|
+
},
|
|
34
|
+
customCard: {
|
|
35
|
+
type: 'my-custom-card',
|
|
36
|
+
name: 'My Custom Card',
|
|
37
|
+
description: 'A beautiful Solid.js card for Home Assistant.',
|
|
38
|
+
preview: true
|
|
39
|
+
},
|
|
40
|
+
cardSize: 3
|
|
41
|
+
}),
|
|
42
|
+
register('my-custom-card'),
|
|
43
|
+
withSolid
|
|
44
|
+
)(MyApp);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Options
|
|
48
|
+
The `withHomeAssistant` function accepts an options object:
|
|
49
|
+
|
|
50
|
+
| Property | Type | Default | Description |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| customCard | CustomCardEntry | Required | The metadata used by the Home Assistant UI picker. |
|
|
53
|
+
| defaultConfig | Record<string, unknown> | {} | Default values for your card's YAML configuration. |
|
|
54
|
+
| cardSize | number | 3 | The height of the card in the Home Assistant grid. |
|
|
55
|
+
|
|
56
|
+
## How it works
|
|
57
|
+
1. `setConfig(config)`: Home Assistant calls this when the UI editor changes. This mixin ensures a valid config is provided and attaches it to `this.config`.
|
|
58
|
+
2. `getCardSize()`: Returns the specified grid height for the Home Assistant dashboard.
|
|
59
|
+
3. Global Registry: Adds your card to `window.customCards` so it appears in the "Add Card" dialog in the Lovelace UI.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
MIT © Travis
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inradius/solid-wc-hass-mixin",
|
|
3
3
|
"author": "Travis Stroud <travis.unfasten577@travisstroud.me>",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"description": "A Solid.js Home Assistant web component mixin.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/inradius/solid-wc-utils-monorepo.git",
|
|
9
|
+
"directory": "packages/solid-wc-hass-mixin"
|
|
10
|
+
},
|
|
6
11
|
"type": "module",
|
|
7
12
|
"main": "./dist/index.cjs",
|
|
8
13
|
"module": "./dist/index.js",
|