Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,33 @@
"Basic (No Wi-Fi)": "standalone"
}
}
},
{
"id": "pump-1-standalone",
"name": "PUMP-1 Standalone Auto Refill",
"category": "Pump",
"unlisted": true,
"description": "Refills a tank on its own: the pump starts when the lower sensor goes dry and stops when the upper sensor goes wet. Control it from its own web page; Home Assistant is optional.",
"image": "images/pump-1-standalone.jpg",
"imageSource": "https://cdn.shopify.com/s/files/1/0792/0959/5187/files/PUMP-1_WWHA_EH_and_H.jpg?v=1771963336",
"wiki": "https://wiki.apolloautomation.com/products/pump1/introduction/",
"repo": "ApolloAutomation/PUMP-1-Standalone-Installer",
"githubPagesInstaller": "https://apolloautomation.github.io/PUMP-1-Standalone-Installer/",
"firmware": {
"stable": {
"Standalone Auto Refill": "https://apolloautomation.github.io/PUMP-1-Standalone-Installer/firmware/manifest.json"
}
},
"variantNotes": {
"stable": {
"Standalone Auto Refill": "Use Chrome or Edge and a USB-C cable that carries data. Hold the boot button while you plug the PUMP-1 in, click <b>Connect</b>, check <b>Erase device</b>, then click <b>Install</b>."
}
},
"config": {
"stable": {
"Standalone Auto Refill": "https://raw.githubusercontent.com/ApolloAutomation/PUMP-1/customer/standalone-auto-refill/Integrations/ESPHome/PUMP-1_Standalone_Auto_Refill.yaml"
}
}
}
]
}
Binary file added images/pump-1-standalone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions js/views/hub.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// js/views/hub.js — device grid with category filters
export function renderHub(el, registry, missingId) {
const cats = [...new Set(registry.devices.map((d) => d.category))];
// Unlisted devices are reachable by link only.
const listed = registry.devices.filter((d) => !d.unlisted);
const cats = [...new Set(listed.map((d) => d.category))];
el.innerHTML = `
<section class="hero">
<h1>Flash your Apollo device from the browser</h1>
Expand All @@ -12,7 +14,7 @@ export function renderHub(el, registry, missingId) {
${cats.map((c) => `<button data-cat="${c}" aria-pressed="false">${c}</button>`).join('')}
</div>
<div class="device-grid">
${registry.devices.map((d) => `
${listed.map((d) => `
<a class="device-card" href="#/${d.id}" data-cat="${d.category}">
<img src="${d.image}" alt="" loading="lazy">
<h3>${d.name}</h3>
Expand Down
5 changes: 5 additions & 0 deletions scripts/test_validate_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ def test_missing_required_field_errors(self):
errs = vr.check_device_shape(d, "x")
self.assertTrue(any(repr(key) in e for e in errs), (key, errs))

def test_unlisted_must_be_boolean(self):
self.assertEqual(vr.check_device_shape(device(unlisted=True), "msr-1"), [])
errs = vr.check_device_shape(device(unlisted="yes"), "x")
self.assertTrue(any("unlisted" in e for e in errs), errs)

def test_id_must_be_lowercase_kebab(self):
for bad in ("MSR-1", "msr_1", "msr 1", "-msr", "msr--1"):
errs = vr.check_device_shape(device(id=bad), "x")
Expand Down
2 changes: 2 additions & 0 deletions scripts/validate_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def check_device_shape(dev, where):
url = dev.get(key)
if url is not None and (not isinstance(url, str) or not url.startswith("https://")):
errs.append(f"{where}: {key} is not an https URL")
if "unlisted" in dev and not isinstance(dev["unlisted"], bool):
errs.append(f"{where}: unlisted must be true or false")
firmware = dev.get("firmware")
if not isinstance(firmware, dict) or not firmware.get("stable"):
errs.append(f"{where}: no stable channel")
Expand Down
24 changes: 19 additions & 5 deletions tests/installer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('fs');
const path = require('path');

const registry = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'devices.json'), 'utf8'));
const listed = registry.devices.filter((d) => !d.unlisted);

const manifestFor = (file, version = '1.0.0') => JSON.stringify({
name: 't', version,
Expand Down Expand Up @@ -46,13 +47,26 @@ const noSerial = (page) => page.addInitScript(() => {
Object.defineProperty(Navigator.prototype, 'serial', { get: () => undefined });
});

test('hub renders a card for every registry device', async ({ page }) => {
test('hub renders a card for every listed registry device', async ({ page }) => {
await page.goto('/');
for (const d of registry.devices) {
for (const d of listed) {
await expect(page.locator(`a.device-card[href="#/${d.id}"] h3`)).toHaveText(d.name);
}
});

test('unlisted devices have no hub card but open by link', async ({ page }) => {
const hidden = registry.devices.filter((d) => d.unlisted);
test.skip(hidden.length === 0, 'no unlisted devices in the registry');
await page.goto('/');
await expect(page.locator('a.device-card')).toHaveCount(listed.length);
for (const d of hidden) {
await expect(page.locator(`a.device-card[href="#/${d.id}"]`)).toHaveCount(0);
await page.goto(`/#/${d.id}`);
await expect(page.locator('.device-page h1')).toHaveText(d.name);
await page.goto('/');
}
});

test('theme toggle is revealed once the script wires it up', async ({ page }) => {
await page.goto('/');
// CSS hides .theme-btn until theme.js sets an explicit visibility; a regression
Expand All @@ -65,7 +79,7 @@ test('category filter shows exactly the cards in that category', async ({ page }
// Pick a category deterministically (most-populated, alphabetical tiebreak)
// instead of depending on devices[0]'s position in the registry.
const byCat = {};
for (const d of registry.devices) (byCat[d.category] ||= []).push(d.id);
for (const d of listed) (byCat[d.category] ||= []).push(d.id);
const cat = Object.keys(byCat)
.sort((a, b) => byCat[b].length - byCat[a].length || a.localeCompare(b))[0];
const expectedIds = byCat[cat].slice().sort();
Expand All @@ -78,7 +92,7 @@ test('category filter shows exactly the cards in that category', async ({ page }
expect(visibleIds).toEqual(expectedIds);

await page.locator('.filters button[data-cat="all"]').click();
await expect(page.locator('a.device-card:visible')).toHaveCount(registry.devices.length);
await expect(page.locator('a.device-card:visible')).toHaveCount(listed.length);
});

test('filter pills expose aria-pressed reflecting the active filter', async ({ page }) => {
Expand Down Expand Up @@ -558,7 +572,7 @@ test('every device and variant puts its own manifest on the install button', asy
test('every hub card image loads', async ({ page }) => {
await page.goto('/');
const imgs = page.locator('a.device-card img');
await expect(imgs).toHaveCount(registry.devices.length);
await expect(imgs).toHaveCount(listed.length);
for (const img of await imgs.all()) {
await img.scrollIntoViewIfNeeded();
await expect.poll(() => img.evaluate((el) => el.complete && el.naturalWidth)).toBeGreaterThan(0);
Expand Down
Loading