-
-
Notifications
You must be signed in to change notification settings - Fork 28
Modernization #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iantrich
wants to merge
17
commits into
master
Choose a base branch
from
modernization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Modernization #178
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1963d22
feat: complete Lit 3 migration cleanup, typing fixes, and shouldUpdat…
iantrich 7044fef
Add visual editor and devcontainer updates
iantrich 7865907
Fix duration handling; update tests, docs, license
iantrich cbc133f
Improve helpers loading, timers, and touch handling
iantrich aca2e06
Use showConfirmationDialog for confirmations
iantrich 39ea364
dev dashboard config for testing
iantrich dd2261b
Allow empty-map restrictions; fix touchend handling
iantrich 65e76c7
Refactor release workflow to use environment variable for versioning
iantrich 8a7f2b3
Update label for unlocked icon in ha-icon-picker to clarify default b…
iantrich 6583f01
Add unit tests for action-handler-directive functionality
iantrich 7d5ddc5
Update src/restriction-card.ts
iantrich cb8b96b
Update src/restriction-card.ts
iantrich 46f939d
Update localization guidelines and enhance example section formatting…
iantrich d535c7f
Merge branch 'modernization' of https://github.com/iantrich/restricti…
iantrich cd0ebbb
Remove outdated YAML resources section from README
iantrich 9790381
Refactor devcontainer setup: remove Dockerfile and update to use cust…
iantrich 8fcbe1f
Update devcontainer base image to use latest version
iantrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| # Home Assistant Custom Card - Dev Container Setup | ||
|
|
||
| This directory contains the development container configuration for building and testing the restriction-card custom card for Home Assistant. | ||
|
|
||
| ## Setup Instructions | ||
|
|
||
| 1. **Install VS Code Remote Containers** | ||
| - [VS Code Extension: Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) | ||
|
|
||
| 2. **Open in Dev Container** | ||
| - Open the project folder in VS Code | ||
| - Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac) | ||
| - Type "Remote-Containers: Reopen in Container" | ||
| - Wait for the container to build (first time takes ~2-3 minutes) | ||
|
|
||
| 3. **Build the Card** | ||
| ```bash | ||
| yarn build # Lint and build | ||
| yarn start # Start dev server with hot reload (port 5000) | ||
| yarn lint # Check code quality | ||
| yarn rollup # Production build | ||
| ``` | ||
|
|
||
| 4. **Access Services** | ||
| - **Dev Container**: Terminal in VS Code (automatic) | ||
| - **Home Assistant**: http://localhost:8123 (user: dev/pass: dev) | ||
| - **Rollup Dev Server**: http://localhost:5000 | ||
|
|
||
| 5. **Configure Home Assistant to Use Your Card** | ||
| - In Home Assistant, go to Settings > Dashboards | ||
| - Create a new Dashboard | ||
| - Add the card from the GUI | ||
|
|
||
| ## File Structure | ||
|
|
||
| ``` | ||
| .devcontainer/ | ||
| ├── devcontainer.json # VS Code dev container config | ||
| ├── .gitignore # Ignore HA data | ||
| └── README.md # This file | ||
| ``` | ||
|
|
||
| ## Base Image | ||
|
|
||
| This project uses the published image: | ||
|
|
||
| - `ghcr.io/custom-cards/custom-card-devcontainer:latest` | ||
|
|
||
| The image includes the `container` helper used by the devcontainer lifecycle commands. | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| ### Building the Card | ||
|
|
||
| ```bash | ||
| # One-time setup (automatic on container creation) | ||
| yarn install | ||
|
|
||
| # Development with hot reload | ||
| yarn start # Runs Rollup in watch mode on port 5000 | ||
|
|
||
| # Quality checks | ||
| yarn lint # ESLint check | ||
| yarn build # Full build pipeline (lint + rollup) | ||
|
|
||
| # Production build | ||
| yarn rollup # Create optimized dist files | ||
| ``` | ||
|
|
||
| ### File Locations | ||
|
|
||
| - **Source Code**: `src/` | ||
| - **Built Output**: `dist/` (inside container) | ||
| - **Configuration**: Root directory (`tsconfig.json`, `rollup.config.js`, etc.) | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Container Won't Start | ||
| ```bash | ||
| # Rebuild the container | ||
| ctrl+shift+p → "Remote: Rebuild Container" | ||
| ``` | ||
|
|
||
| ### Port Already in Use | ||
| ```bash | ||
| # Find what's using port 5000 or 8123 | ||
| lsof -i :5000 | ||
| lsof -i :8123 | ||
| ``` | ||
|
|
||
| ### Node Modules Issues | ||
| ```bash | ||
| # Clear and reinstall dependencies | ||
| rm -rf node_modules | ||
| yarn install | ||
| ``` | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [Home Assistant Custom Card Development](https://developers.home-assistant.io/docs/frontend/custom-ui/custom-card/) | ||
| - [VS Code Dev Containers Docs](https://code.visualstudio.com/docs/remote/containers) | ||
| - [Lit Documentation](https://lit.dev/) | ||
| - [Material Design Web Components](https://github.com/material-components/material-web) | ||
|
|
||
| ## Environment Details | ||
|
|
||
| - **Node.js**: 24 | ||
| - **TypeScript**: 5.9.3 | ||
| - **Build Tool**: Rollup 4.20 | ||
| - **Linter**: ESLint 9 + TypeScript Support | ||
| - **Code Formatter**: Prettier 3.8 | ||
| - **Web Framework**: Lit 3.3 | ||
| - **Home Assistant Image**: Latest (optional) | ||
|
|
||
| ## Notes | ||
|
|
||
| - All Yarn commands run inside the container automatically | ||
| - VS Code extensions are configured for TypeScript and YAML development |
4 changes: 2 additions & 2 deletions
4
.devcontainer/configuration.yaml → .devcontainer/config/configuration.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| default_config: | ||
| lovelace: | ||
| mode: yaml | ||
| homeassistant_alerts: | ||
| enabled: false | ||
| demo: | ||
| frontend: | ||
| themes: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,70 @@ | ||
| // See https://aka.ms/vscode-remote/devcontainer.json for format details. | ||
| // For format details, see https://aka.ms/devcontainer.json | ||
| // Uses custom-cards/custom-card-devcontainer image for Home Assistant + Dev environment | ||
| { | ||
| "name": "Restriction Card Development", | ||
| "image": "ludeeus/container:monster", | ||
| "context": "..", | ||
| "appPort": ["5000:5000", "9123:8123"], | ||
| "postCreateCommand": "npm install", | ||
| "runArgs": [ | ||
| "-v", | ||
| "${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh" // This is added so you can push from inside the container | ||
| "name": "Home Assistant Custom Card Dev", | ||
|
|
||
| // Use published devcontainer image | ||
| "image": "ghcr.io/custom-cards/custom-card-devcontainer:latest", | ||
| "remoteUser": "vscode", | ||
|
|
||
| // Set working directory | ||
| "workspaceFolder": "/workspaces/test", | ||
|
|
||
| // Mount project to workspace, dist to Lovelace plugins, and config directory for Home Assistant | ||
| "mounts": [ | ||
| "source=${localWorkspaceFolder},target=/workspaces/test,type=bind", | ||
| "source=${localWorkspaceFolder}/dist,target=/config/www/workspace,type=bind", | ||
| "source=${localWorkspaceFolder}/.devcontainer/config,target=/config,type=bind" | ||
| ], | ||
| "extensions": [ | ||
| "github.vscode-pull-request-github", | ||
| "eamodio.gitlens", | ||
| "dbaeumer.vscode-eslint", | ||
| "esbenp.prettier-vscode", | ||
| "bierner.lit-html", | ||
| "runem.lit-plugin", | ||
| "auchenberg.vscode-browser-preview", | ||
| "davidanson.vscode-markdownlint", | ||
| "redhat.vscode-yaml" | ||
| ], | ||
| "settings": { | ||
| "files.eol": "\n", | ||
| "editor.tabSize": 4, | ||
| "terminal.integrated.shell.linux": "/bin/bash", | ||
| "editor.formatOnPaste": false, | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnType": true, | ||
| "files.trimTrailingWhitespace": true | ||
|
|
||
| // Forward Home Assistant port | ||
| "forwardPorts": [8123], | ||
| "portsAttributes": { | ||
| "8123": { | ||
| "label": "Home Assistant", | ||
| "onAutoForward": "notify" | ||
| } | ||
| }, | ||
|
|
||
| // Container environment variables for Home Assistant setup | ||
| "containerEnv": { | ||
| "COREPACK_ENABLE_DOWNLOAD_PROMPT": "0", | ||
| "DEVCONTAINER": "1", | ||
| "HASS_USERNAME": "dev", | ||
| "HASS_PASSWORD": "dev", | ||
| "LOVELACE_REMOTE_FILES": "http://localhost:5000/restriction-card.js" | ||
| }, | ||
|
|
||
| // Setup Home Assistant and install dependencies | ||
| "postCreateCommand": "container setup && corepack enable && yarn install", | ||
| "postStartCommand": "container launch & yarn start & wait", | ||
|
|
||
| // VS Code extensions for development | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "github.vscode-github-actions", | ||
| "github.vscode-pull-request-github", | ||
| "bierner.lit-html", | ||
| "redhat.vscode-yaml", | ||
| "esbenp.prettier-vscode" | ||
| ], | ||
| "settings": { | ||
| "typescript.enablePromptUseWorkspaceTsdk": true, | ||
| "[typescript]": { | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode", | ||
| "editor.formatOnSave": true, | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll.eslint": "explicit" | ||
| } | ||
| }, | ||
| "typescript.tsdk": "node_modules/typescript/lib", | ||
| "typescript.tsserver.pluginPaths": [ | ||
| "node_modules/typescript/lib" | ||
| ], | ||
| "files.eol": "\n", | ||
| "task.allowAutomaticTasks": "on" | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.