mirror of
https://github.com/alexhopeoconnor/bom-local-card.git
synced 2026-10-03 22:22:00 +10:00
refactor: complete rename to bom-local-card and update documentation for dev/prod modes
This commit is contained in:
@@ -25,6 +25,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
chmod +x run.sh
|
chmod +x run.sh
|
||||||
./run.sh build npm
|
./run.sh build npm
|
||||||
|
cp dist/bom-local-card.js .
|
||||||
|
|
||||||
- name: HACS validation
|
- name: HACS validation
|
||||||
uses: "hacs/action@main"
|
uses: "hacs/action@main"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
# BOM Local Radar Card
|
# BOM Local Card
|
||||||
|
|
||||||
A Home Assistant custom card that displays Australian Bureau of Meteorology (BOM) rain radar data using the local [BOM Local Service](https://github.com/alexhopeoconnor/bom-local-service).
|
A Home Assistant custom card that displays Australian Bureau of Meteorology (BOM) rain radar data using the local [BOM Local Service](https://github.com/alexhopeoconnor/bom-local-service).
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ For more detailed service setup and configuration options, see the [BOM Local Se
|
|||||||
|
|
||||||
1. Open HACS in Home Assistant
|
1. Open HACS in Home Assistant
|
||||||
2. Go to **Frontend** → **Explore & Download Repositories**
|
2. Go to **Frontend** → **Explore & Download Repositories**
|
||||||
3. Search for **BOM Local Radar Card**
|
3. Search for **BOM Local Card**
|
||||||
4. Click **Download**
|
4. Click **Download**
|
||||||
5. Restart Home Assistant
|
5. Restart Home Assistant
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ For more detailed service setup and configuration options, see the [BOM Local Se
|
|||||||
|
|
||||||
1. Edit your Lovelace dashboard
|
1. Edit your Lovelace dashboard
|
||||||
2. Click **Add Card**
|
2. Click **Add Card**
|
||||||
3. Search for **BOM Local Radar Card** or select **Custom: BOM Local Radar Card**
|
3. Search for **BOM Local Card** or select **Custom: BOM Local Card**
|
||||||
4. Configure the card (see [Configuration](#configuration) section below)
|
4. Configure the card (see [Configuration](#configuration) section below)
|
||||||
5. Set the **Service URL** to match your service installation (e.g., `http://localhost:8082` or `http://192.168.1.50:8082`)
|
5. Set the **Service URL** to match your service installation (e.g., `http://localhost:8082` or `http://192.168.1.50:8082`)
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ For more detailed service setup and configuration options, see the [BOM Local Se
|
|||||||
### Using the Visual Editor (Recommended)
|
### Using the Visual Editor (Recommended)
|
||||||
|
|
||||||
1. Add a card to your Lovelace dashboard
|
1. Add a card to your Lovelace dashboard
|
||||||
2. Search for **BOM Local Radar Card** or select **Custom: BOM Local Radar Card**
|
2. Search for **BOM Local Card** or select **Custom: BOM Local Card**
|
||||||
3. Configure using the visual editor:
|
3. Configure using the visual editor:
|
||||||
|
|
||||||
**Service Configuration**:
|
**Service Configuration**:
|
||||||
@@ -189,7 +189,7 @@ For more detailed service setup and configuration options, see the [BOM Local Se
|
|||||||
### Using YAML
|
### Using YAML
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
service_url: http://localhost:8082
|
service_url: http://localhost:8082
|
||||||
suburb: Pomona
|
suburb: Pomona
|
||||||
state: QLD
|
state: QLD
|
||||||
@@ -204,7 +204,7 @@ refresh_interval: 30
|
|||||||
For custom time ranges:
|
For custom time ranges:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
service_url: http://localhost:8082
|
service_url: http://localhost:8082
|
||||||
suburb: Brisbane
|
suburb: Brisbane
|
||||||
state: QLD
|
state: QLD
|
||||||
@@ -293,7 +293,7 @@ custom_end_time: "2024-01-15T14:00:00Z"
|
|||||||
Display the latest radar frames for a location:
|
Display the latest radar frames for a location:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Brisbane
|
suburb: Brisbane
|
||||||
state: QLD
|
state: QLD
|
||||||
service_url: http://192.168.1.100:8082
|
service_url: http://192.168.1.100:8082
|
||||||
@@ -304,7 +304,7 @@ service_url: http://192.168.1.100:8082
|
|||||||
Show just the radar image with no controls or metadata:
|
Show just the radar image with no controls or metadata:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Brisbane
|
suburb: Brisbane
|
||||||
state: QLD
|
state: QLD
|
||||||
show_metadata: false
|
show_metadata: false
|
||||||
@@ -316,7 +316,7 @@ show_controls: false
|
|||||||
Overlay both controls and metadata on the radar image to save space:
|
Overlay both controls and metadata on the radar image to save space:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Brisbane
|
suburb: Brisbane
|
||||||
state: QLD
|
state: QLD
|
||||||
show_controls:
|
show_controls:
|
||||||
@@ -337,7 +337,7 @@ metadata_overlay_opacity: 0.85
|
|||||||
Zoom in on the radar image (may pixelate at higher zoom levels):
|
Zoom in on the radar image (may pixelate at higher zoom levels):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Brisbane
|
suburb: Brisbane
|
||||||
state: QLD
|
state: QLD
|
||||||
image_zoom: 1.5
|
image_zoom: 1.5
|
||||||
@@ -349,7 +349,7 @@ image_fit: contain
|
|||||||
Show only specific metadata items:
|
Show only specific metadata items:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Brisbane
|
suburb: Brisbane
|
||||||
state: QLD
|
state: QLD
|
||||||
show_metadata:
|
show_metadata:
|
||||||
@@ -368,7 +368,7 @@ show_metadata:
|
|||||||
Show only specific controls and position them above the image:
|
Show only specific controls and position them above the image:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Brisbane
|
suburb: Brisbane
|
||||||
state: QLD
|
state: QLD
|
||||||
show_controls:
|
show_controls:
|
||||||
@@ -385,7 +385,7 @@ show_controls:
|
|||||||
View radar history from the past 3 hours:
|
View radar history from the past 3 hours:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Melbourne
|
suburb: Melbourne
|
||||||
state: VIC
|
state: VIC
|
||||||
service_url: http://192.168.1.100:8082
|
service_url: http://192.168.1.100:8082
|
||||||
@@ -399,7 +399,7 @@ frame_interval: 1.5
|
|||||||
View radar data for a specific time period:
|
View radar data for a specific time period:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Sydney
|
suburb: Sydney
|
||||||
state: NSW
|
state: NSW
|
||||||
service_url: http://192.168.1.100:8082
|
service_url: http://192.168.1.100:8082
|
||||||
@@ -413,7 +413,7 @@ custom_end_time: "2024-01-15T14:00:00Z"
|
|||||||
Display radar with manual controls only:
|
Display radar with manual controls only:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Adelaide
|
suburb: Adelaide
|
||||||
state: SA
|
state: SA
|
||||||
service_url: http://192.168.1.100:8082
|
service_url: http://192.168.1.100:8082
|
||||||
@@ -426,7 +426,7 @@ frame_interval: 3.0
|
|||||||
If your BOM Local Service is running on a different machine:
|
If your BOM Local Service is running on a different machine:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:bom-local-radar-card
|
type: custom:bom-local-card
|
||||||
suburb: Perth
|
suburb: Perth
|
||||||
state: WA
|
state: WA
|
||||||
service_url: http://192.168.1.50:8082
|
service_url: http://192.168.1.50:8082
|
||||||
@@ -502,11 +502,11 @@ The repository includes several helper scripts for development:
|
|||||||
The main script that handles building, testing, and cleaning:
|
The main script that handles building, testing, and cleaning:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./run.sh [COMMAND] [BUILD_METHOD]
|
./run.sh [COMMAND] [BUILD_METHOD] [TARGET]
|
||||||
```
|
```
|
||||||
|
|
||||||
**Commands:**
|
**Commands:**
|
||||||
- `build [docker|npm]` - Build the card (auto-detects method if not specified)
|
- `build [docker|npm] [dev|prod]` - Build the card (auto-detects method if not specified)
|
||||||
- `test` - Build and start the test Home Assistant environment
|
- `test` - Build and start the test Home Assistant environment
|
||||||
- `update [docker|npm]` - Rebuild card and update running test environment (preserves HA state)
|
- `update [docker|npm]` - Rebuild card and update running test environment (preserves HA state)
|
||||||
- `clean` - Clean test environment (stops containers, removes data)
|
- `clean` - Clean test environment (stops containers, removes data)
|
||||||
@@ -515,10 +515,15 @@ The main script that handles building, testing, and cleaning:
|
|||||||
- `docker` - Use Docker to build (isolated, no local Node.js needed)
|
- `docker` - Use Docker to build (isolated, no local Node.js needed)
|
||||||
- `npm` - Use local npm/Node.js to build
|
- `npm` - Use local npm/Node.js to build
|
||||||
|
|
||||||
|
**Targets:**
|
||||||
|
- `dev` (default) - Unminified build with sourcemaps for debugging
|
||||||
|
- `prod` - Minified build using Terser, no sourcemaps (for HACS release)
|
||||||
|
|
||||||
**Examples:**
|
**Examples:**
|
||||||
```bash
|
```bash
|
||||||
./run.sh build # Auto-detect: Docker (preferred) or npm
|
./run.sh build # Auto-detect method, dev build
|
||||||
./run.sh build docker # Force Docker build
|
./run.sh build docker # Force Docker, dev build
|
||||||
|
./run.sh build npm prod # Build production version with local npm
|
||||||
./run.sh test # Build and start test environment
|
./run.sh test # Build and start test environment
|
||||||
./run.sh update # Rebuild and update running environment (no data loss)
|
./run.sh update # Rebuild and update running environment (no data loss)
|
||||||
./run.sh clean # Clean test environment completely
|
./run.sh clean # Clean test environment completely
|
||||||
@@ -568,7 +573,7 @@ If you prefer to build manually:
|
|||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
The built file will be in `dist/bom-local-radar-card.js`
|
The built file will be in `dist/bom-local-card.js`
|
||||||
|
|
||||||
4. **Development with watch mode:**
|
4. **Development with watch mode:**
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "BOM Local Radar Card",
|
"name": "BOM Local Radar Card",
|
||||||
"render_readme": true,
|
"render_readme": true,
|
||||||
"filename": "bom-local-radar-card.js",
|
"filename": "bom-local-card.js",
|
||||||
"homeassistant": "2024.1.0"
|
"homeassistant": "2024.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "bom-local-radar-card",
|
"name": "bom-local-card",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bom-local-radar-card",
|
"name": "bom-local-card",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "bom-local-radar-card",
|
"name": "bom-local-card",
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"description": "Home Assistant custom card for displaying Australian Bureau of Meteorology (BOM) rain radar data with animated slideshow and historical data support",
|
"description": "Home Assistant custom card for displaying Australian Bureau of Meteorology (BOM) rain radar data with animated slideshow and historical data support",
|
||||||
"module": "bom-local-radar-card.js",
|
"module": "bom-local-card.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"home-assistant",
|
"home-assistant",
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
|
|||||||
+2
-2
@@ -6,9 +6,9 @@ import { terser } from 'rollup-plugin-terser';
|
|||||||
const isProd = process.env.NODE_ENV === 'production';
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
input: 'src/bom-local-radar-card.ts',
|
input: 'src/bom-local-card.ts',
|
||||||
output: {
|
output: {
|
||||||
file: 'dist/bom-local-radar-card.js',
|
file: 'dist/bom-local-card.js',
|
||||||
format: 'es',
|
format: 'es',
|
||||||
sourcemap: !isProd,
|
sourcemap: !isProd,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -99,16 +99,16 @@ clean_test() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up www directory files (card file) using Docker if needed
|
# Clean up www directory files (card file) using Docker if needed
|
||||||
if [ -f "test-ha/config/www/bom-local-radar-card.js" ]; then
|
if [ -f "test-ha/config/www/bom-local-card.js" ]; then
|
||||||
echo " Removing card file..."
|
echo " Removing card file..."
|
||||||
CURRENT_UID=$(id -u)
|
CURRENT_UID=$(id -u)
|
||||||
CURRENT_GID=$(id -g)
|
CURRENT_GID=$(id -g)
|
||||||
if ! rm -f test-ha/config/www/bom-local-radar-card.js 2>/dev/null; then
|
if ! rm -f test-ha/config/www/bom-local-card.js 2>/dev/null; then
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v "$(pwd)/test-ha/config/www:/www:rw" \
|
-v "$(pwd)/test-ha/config/www:/www:rw" \
|
||||||
-u root \
|
-u root \
|
||||||
alpine:latest \
|
alpine:latest \
|
||||||
sh -c "rm -f /www/bom-local-radar-card.js" 2>/dev/null || true
|
sh -c "rm -f /www/bom-local-card.js" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ fi
|
|||||||
docker run --rm $ENV_ARGS -v "$(pwd)/dist:/build/dist" bom-local-card-builder
|
docker run --rm $ENV_ARGS -v "$(pwd)/dist:/build/dist" bom-local-card-builder
|
||||||
|
|
||||||
# Check if build succeeded
|
# Check if build succeeded
|
||||||
if [ ! -f "dist/bom-local-radar-card.js" ]; then
|
if [ ! -f "dist/bom-local-card.js" ]; then
|
||||||
echo "❌ Error: Build failed - dist/bom-local-radar-card.js not found"
|
echo "❌ Error: Build failed - dist/bom-local-card.js not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FILE_SIZE=$(stat -f%z "dist/bom-local-radar-card.js" 2>/dev/null || stat -c%s "dist/bom-local-radar-card.js" 2>/dev/null || echo "0")
|
FILE_SIZE=$(stat -f%z "dist/bom-local-card.js" 2>/dev/null || stat -c%s "dist/bom-local-card.js" 2>/dev/null || echo "0")
|
||||||
echo "✅ Build complete (${FILE_SIZE} bytes)"
|
echo "✅ Build complete (${FILE_SIZE} bytes)"
|
||||||
|
|
||||||
|
|||||||
+28
-28
@@ -170,11 +170,11 @@ build_with_docker() {
|
|||||||
# Build card
|
# Build card
|
||||||
if [ "$SKIP_BUILD" = "1" ]; then
|
if [ "$SKIP_BUILD" = "1" ]; then
|
||||||
echo "⏭️ Skipping build (--skip-build)"
|
echo "⏭️ Skipping build (--skip-build)"
|
||||||
if [ ! -f "dist/bom-local-radar-card.js" ]; then
|
if [ ! -f "dist/bom-local-card.js" ]; then
|
||||||
echo "❌ Error: dist/bom-local-radar-card.js not found and --skip-build was used"
|
echo "❌ Error: dist/bom-local-card.js not found and --skip-build was used"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif [ "$FORCE_BUILD" = "1" ] || [ ! -f "dist/bom-local-radar-card.js" ]; then
|
elif [ "$FORCE_BUILD" = "1" ] || [ ! -f "dist/bom-local-card.js" ]; then
|
||||||
# If FORCE_BUILD is set, also force Docker rebuild
|
# If FORCE_BUILD is set, also force Docker rebuild
|
||||||
if [ "$FORCE_BUILD" = "1" ] && [ "$USE_DOCKER_BUILD" = "1" ]; then
|
if [ "$FORCE_BUILD" = "1" ] && [ "$USE_DOCKER_BUILD" = "1" ]; then
|
||||||
export FORCE_REBUILD=1
|
export FORCE_REBUILD=1
|
||||||
@@ -192,13 +192,13 @@ elif [ "$FORCE_BUILD" = "1" ] || [ ! -f "dist/bom-local-radar-card.js" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "dist/bom-local-radar-card.js" ]; then
|
if [ ! -f "dist/bom-local-card.js" ]; then
|
||||||
echo "❌ Error: dist/bom-local-radar-card.js not found after build"
|
echo "❌ Error: dist/bom-local-card.js not found after build"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify build quality
|
# Verify build quality
|
||||||
FILE_SIZE=$(stat -f%z "dist/bom-local-radar-card.js" 2>/dev/null || stat -c%s "dist/bom-local-radar-card.js" 2>/dev/null || echo "0")
|
FILE_SIZE=$(stat -f%z "dist/bom-local-card.js" 2>/dev/null || stat -c%s "dist/bom-local-card.js" 2>/dev/null || echo "0")
|
||||||
if [ "$FILE_SIZE" -lt 50000 ]; then
|
if [ "$FILE_SIZE" -lt 50000 ]; then
|
||||||
echo "⚠️ Warning: Built file is suspiciously small (${FILE_SIZE} bytes)"
|
echo "⚠️ Warning: Built file is suspiciously small (${FILE_SIZE} bytes)"
|
||||||
echo " This might indicate dependencies weren't bundled correctly"
|
echo " This might indicate dependencies weren't bundled correctly"
|
||||||
@@ -206,15 +206,15 @@ elif [ "$FORCE_BUILD" = "1" ] || [ ! -f "dist/bom-local-radar-card.js" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for external imports (should not exist if dependencies are bundled)
|
# Check for external imports (should not exist if dependencies are bundled)
|
||||||
if grep -q "from ['\"]lit['\"]" dist/bom-local-radar-card.js 2>/dev/null || \
|
if grep -q "from ['\"]lit['\"]" dist/bom-local-card.js 2>/dev/null || \
|
||||||
grep -q "from ['\"]custom-card-helpers['\"]" dist/bom-local-radar-card.js 2>/dev/null; then
|
grep -q "from ['\"]custom-card-helpers['\"]" dist/bom-local-card.js 2>/dev/null; then
|
||||||
echo "⚠️ Warning: Found external import statements in built file"
|
echo "⚠️ Warning: Found external import statements in built file"
|
||||||
echo " Dependencies may not be bundled. Check rollup.config.js"
|
echo " Dependencies may not be bundled. Check rollup.config.js"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ Build complete (${FILE_SIZE} bytes)"
|
echo "✅ Build complete (${FILE_SIZE} bytes)"
|
||||||
else
|
else
|
||||||
echo "✅ Using existing dist/bom-local-radar-card.js"
|
echo "✅ Using existing dist/bom-local-card.js"
|
||||||
echo " (Use --force-build to rebuild, --docker-build or --npm-build to specify method)"
|
echo " (Use --force-build to rebuild, --docker-build or --npm-build to specify method)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -252,32 +252,32 @@ if [ "$CONTAINERS_RUNNING" = "1" ]; then
|
|||||||
|
|
||||||
# Copy file using Docker (containers run as root, so we use root to write)
|
# Copy file using Docker (containers run as root, so we use root to write)
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v "$(pwd)/dist/bom-local-radar-card.js:/source/bom-local-radar-card.js:ro" \
|
-v "$(pwd)/dist/bom-local-card.js:/source/bom-local-card.js:ro" \
|
||||||
-v "$(pwd)/test-ha/config/www:/dest:rw" \
|
-v "$(pwd)/test-ha/config/www:/dest:rw" \
|
||||||
-u root \
|
-u root \
|
||||||
alpine:latest \
|
alpine:latest \
|
||||||
sh -c "cp /source/bom-local-radar-card.js /dest/bom-local-radar-card.js && chmod 644 /dest/bom-local-radar-card.js" 2>/dev/null || {
|
sh -c "cp /source/bom-local-card.js /dest/bom-local-card.js && chmod 644 /dest/bom-local-card.js" 2>/dev/null || {
|
||||||
echo "❌ Error: Failed to copy card file"
|
echo "❌ Error: Failed to copy card file"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
echo " ✅ Card file copied successfully"
|
echo " ✅ Card file copied successfully"
|
||||||
|
|
||||||
# Verify copy succeeded
|
# Verify copy succeeded
|
||||||
if [ ! -f "test-ha/config/www/bom-local-radar-card.js" ]; then
|
if [ ! -f "test-ha/config/www/bom-local-card.js" ]; then
|
||||||
echo "❌ Error: Failed to update card file"
|
echo "❌ Error: Failed to update card file"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify file sizes match
|
# Verify file sizes match
|
||||||
SOURCE_SIZE=$(stat -f%z "dist/bom-local-radar-card.js" 2>/dev/null || stat -c%s "dist/bom-local-radar-card.js" 2>/dev/null)
|
SOURCE_SIZE=$(stat -f%z "dist/bom-local-card.js" 2>/dev/null || stat -c%s "dist/bom-local-card.js" 2>/dev/null)
|
||||||
DEST_SIZE=$(stat -f%z "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null || stat -c%s "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null)
|
DEST_SIZE=$(stat -f%z "test-ha/config/www/bom-local-card.js" 2>/dev/null || stat -c%s "test-ha/config/www/bom-local-card.js" 2>/dev/null)
|
||||||
if [ "$SOURCE_SIZE" != "$DEST_SIZE" ]; then
|
if [ "$SOURCE_SIZE" != "$DEST_SIZE" ]; then
|
||||||
echo "❌ Error: File sizes don't match after copy"
|
echo "❌ Error: File sizes don't match after copy"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify file contains expected content (basic sanity check)
|
# Verify file contains expected content (basic sanity check)
|
||||||
if ! grep -q "resolveImageUrl\|BOM-LOCAL-RADAR-CARD" test-ha/config/www/bom-local-radar-card.js 2>/dev/null; then
|
if ! grep -q "resolveImageUrl\|BOM-LOCAL-RADAR-CARD" test-ha/config/www/bom-local-card.js 2>/dev/null; then
|
||||||
echo " ⚠️ Warning: Card file may not be valid (missing expected content)"
|
echo " ⚠️ Warning: Card file may not be valid (missing expected content)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -415,19 +415,19 @@ mkdir -p test-ha/config/www
|
|||||||
|
|
||||||
# Check if update is needed by comparing file sizes and content
|
# Check if update is needed by comparing file sizes and content
|
||||||
NEEDS_UPDATE=1
|
NEEDS_UPDATE=1
|
||||||
if [ -f "test-ha/config/www/bom-local-radar-card.js" ]; then
|
if [ -f "test-ha/config/www/bom-local-card.js" ]; then
|
||||||
SOURCE_SIZE=$(stat -f%z "dist/bom-local-radar-card.js" 2>/dev/null || stat -c%s "dist/bom-local-radar-card.js" 2>/dev/null)
|
SOURCE_SIZE=$(stat -f%z "dist/bom-local-card.js" 2>/dev/null || stat -c%s "dist/bom-local-card.js" 2>/dev/null)
|
||||||
DEST_SIZE=$(stat -f%z "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null || stat -c%s "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null)
|
DEST_SIZE=$(stat -f%z "test-ha/config/www/bom-local-card.js" 2>/dev/null || stat -c%s "test-ha/config/www/bom-local-card.js" 2>/dev/null)
|
||||||
|
|
||||||
# Check if sizes match and if the file contains expected content (resolveImageUrl function)
|
# Check if sizes match and if the file contains expected content (resolveImageUrl function)
|
||||||
if [ "$SOURCE_SIZE" = "$DEST_SIZE" ]; then
|
if [ "$SOURCE_SIZE" = "$DEST_SIZE" ]; then
|
||||||
# Check if file contains key function to verify it's the latest version
|
# Check if file contains key function to verify it's the latest version
|
||||||
if grep -q "resolveImageUrl" test-ha/config/www/bom-local-radar-card.js 2>/dev/null || \
|
if grep -q "resolveImageUrl" test-ha/config/www/bom-local-card.js 2>/dev/null || \
|
||||||
grep -q "Resolve relative image URLs" test-ha/config/www/bom-local-radar-card.js 2>/dev/null; then
|
grep -q "Resolve relative image URLs" test-ha/config/www/bom-local-card.js 2>/dev/null; then
|
||||||
# File exists, sizes match, and contains expected content - may not need update
|
# File exists, sizes match, and contains expected content - may not need update
|
||||||
# But we'll update anyway to be safe, or check modification time
|
# But we'll update anyway to be safe, or check modification time
|
||||||
SOURCE_MTIME=$(stat -f%m "dist/bom-local-radar-card.js" 2>/dev/null || stat -c%Y "dist/bom-local-radar-card.js" 2>/dev/null)
|
SOURCE_MTIME=$(stat -f%m "dist/bom-local-card.js" 2>/dev/null || stat -c%Y "dist/bom-local-card.js" 2>/dev/null)
|
||||||
DEST_MTIME=$(stat -f%m "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null || stat -c%Y "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null)
|
DEST_MTIME=$(stat -f%m "test-ha/config/www/bom-local-card.js" 2>/dev/null || stat -c%Y "test-ha/config/www/bom-local-card.js" 2>/dev/null)
|
||||||
if [ "$SOURCE_MTIME" -le "$DEST_MTIME" ]; then
|
if [ "$SOURCE_MTIME" -le "$DEST_MTIME" ]; then
|
||||||
NEEDS_UPDATE=0
|
NEEDS_UPDATE=0
|
||||||
fi
|
fi
|
||||||
@@ -439,32 +439,32 @@ if [ "$NEEDS_UPDATE" = "1" ]; then
|
|||||||
# Copy file using Docker (containers run as root, so we use root to write)
|
# Copy file using Docker (containers run as root, so we use root to write)
|
||||||
echo " Copying file using Docker..."
|
echo " Copying file using Docker..."
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v "$(pwd)/dist/bom-local-radar-card.js:/source/bom-local-radar-card.js:ro" \
|
-v "$(pwd)/dist/bom-local-card.js:/source/bom-local-card.js:ro" \
|
||||||
-v "$(pwd)/test-ha/config/www:/dest:rw" \
|
-v "$(pwd)/test-ha/config/www:/dest:rw" \
|
||||||
-u root \
|
-u root \
|
||||||
alpine:latest \
|
alpine:latest \
|
||||||
sh -c "cp /source/bom-local-radar-card.js /dest/bom-local-radar-card.js && chmod 644 /dest/bom-local-radar-card.js" 2>/dev/null || {
|
sh -c "cp /source/bom-local-card.js /dest/bom-local-card.js && chmod 644 /dest/bom-local-card.js" 2>/dev/null || {
|
||||||
echo "❌ Error: Failed to copy card file"
|
echo "❌ Error: Failed to copy card file"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
echo " ✅ Card file copied successfully"
|
echo " ✅ Card file copied successfully"
|
||||||
|
|
||||||
# Verify copy succeeded
|
# Verify copy succeeded
|
||||||
if [ ! -f "test-ha/config/www/bom-local-radar-card.js" ]; then
|
if [ ! -f "test-ha/config/www/bom-local-card.js" ]; then
|
||||||
echo "❌ Error: Failed to copy card file to www directory"
|
echo "❌ Error: Failed to copy card file to www directory"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify file sizes match
|
# Verify file sizes match
|
||||||
SOURCE_SIZE=$(stat -f%z "dist/bom-local-radar-card.js" 2>/dev/null || stat -c%s "dist/bom-local-radar-card.js" 2>/dev/null)
|
SOURCE_SIZE=$(stat -f%z "dist/bom-local-card.js" 2>/dev/null || stat -c%s "dist/bom-local-card.js" 2>/dev/null)
|
||||||
DEST_SIZE=$(stat -f%z "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null || stat -c%s "test-ha/config/www/bom-local-radar-card.js" 2>/dev/null)
|
DEST_SIZE=$(stat -f%z "test-ha/config/www/bom-local-card.js" 2>/dev/null || stat -c%s "test-ha/config/www/bom-local-card.js" 2>/dev/null)
|
||||||
if [ "$SOURCE_SIZE" != "$DEST_SIZE" ]; then
|
if [ "$SOURCE_SIZE" != "$DEST_SIZE" ]; then
|
||||||
echo "❌ Error: File sizes don't match after copy"
|
echo "❌ Error: File sizes don't match after copy"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify file contains expected content (basic sanity check)
|
# Verify file contains expected content (basic sanity check)
|
||||||
if ! grep -q "resolveImageUrl\|BOM-LOCAL-RADAR-CARD" test-ha/config/www/bom-local-radar-card.js 2>/dev/null; then
|
if ! grep -q "resolveImageUrl\|BOM-LOCAL-RADAR-CARD" test-ha/config/www/bom-local-card.js 2>/dev/null; then
|
||||||
echo " ⚠️ Warning: Card file may not be valid (missing expected content)"
|
echo " ⚠️ Warning: Card file may not be valid (missing expected content)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ declare global {
|
|||||||
|
|
||||||
window.customCards = window.customCards ?? [];
|
window.customCards = window.customCards ?? [];
|
||||||
window.customCards.push({
|
window.customCards.push({
|
||||||
type: 'bom-local-radar-card',
|
type: 'bom-local-card',
|
||||||
name: 'BOM Local Radar Card',
|
name: 'BOM Local Card',
|
||||||
description: 'A rain radar card using the local BOM service',
|
description: 'A rain radar card using the local BOM service',
|
||||||
});
|
});
|
||||||
|
|
||||||
@customElement('bom-local-radar-card')
|
@customElement('bom-local-card')
|
||||||
export class BomLocalRadarCard extends LitElement implements LovelaceCard {
|
export class BomLocalRadarCard extends LitElement implements LovelaceCard {
|
||||||
static override styles: CSSResultGroup = [
|
static override styles: CSSResultGroup = [
|
||||||
cardStyles,
|
cardStyles,
|
||||||
@@ -71,12 +71,12 @@ export class BomLocalRadarCard extends LitElement implements LovelaceCard {
|
|||||||
private apiService = new RadarApiService();
|
private apiService = new RadarApiService();
|
||||||
|
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
return document.createElement('bom-local-radar-card-editor') as LovelaceCardEditor;
|
return document.createElement('bom-local-card-editor') as LovelaceCardEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getStubConfig(): Record<string, unknown> {
|
public static getStubConfig(): Record<string, unknown> {
|
||||||
return {
|
return {
|
||||||
type: 'custom:bom-local-radar-card',
|
type: 'custom:bom-local-card',
|
||||||
suburb: 'Pomona',
|
suburb: 'Pomona',
|
||||||
state: 'QLD',
|
state: 'QLD',
|
||||||
service_url: 'http://localhost:8082',
|
service_url: 'http://localhost:8082',
|
||||||
@@ -725,8 +725,8 @@ export class BomLocalRadarCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!customElements.get('bom-local-radar-card')) {
|
if (!customElements.get('bom-local-card')) {
|
||||||
customElements.define('bom-local-radar-card', BomLocalRadarCard);
|
customElements.define('bom-local-card', BomLocalRadarCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
+2
-2
@@ -29,7 +29,7 @@ interface CacheRange {
|
|||||||
timeSpanMinutes?: number;
|
timeSpanMinutes?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement('bom-local-radar-card-editor')
|
@customElement('bom-local-card-editor')
|
||||||
export class BomLocalRadarCardEditor extends LitElement implements LovelaceCardEditor {
|
export class BomLocalRadarCardEditor extends LitElement implements LovelaceCardEditor {
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
@state() private _config: BomLocalRadarCardConfig = this._mergeWithDefaults();
|
@state() private _config: BomLocalRadarCardConfig = this._mergeWithDefaults();
|
||||||
@@ -55,7 +55,7 @@ export class BomLocalRadarCardEditor extends LitElement implements LovelaceCardE
|
|||||||
return {
|
return {
|
||||||
...defaults,
|
...defaults,
|
||||||
...config,
|
...config,
|
||||||
type: 'custom:bom-local-radar-card',
|
type: 'custom:bom-local-card',
|
||||||
} as BomLocalRadarCardConfig;
|
} as BomLocalRadarCardConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -106,7 +106,7 @@ export interface GridOptions {
|
|||||||
|
|
||||||
// Card configuration
|
// Card configuration
|
||||||
export interface BomLocalRadarCardConfig extends LovelaceCardConfig {
|
export interface BomLocalRadarCardConfig extends LovelaceCardConfig {
|
||||||
type: 'custom:bom-local-radar-card';
|
type: 'custom:bom-local-card';
|
||||||
|
|
||||||
// Service configuration
|
// Service configuration
|
||||||
service_url?: string; // Base URL of bom-local-service (e.g., "http://localhost:8082")
|
service_url?: string; // Base URL of bom-local-service (e.g., "http://localhost:8082")
|
||||||
|
|||||||
Reference in New Issue
Block a user