{"id":50429875,"url":"https://github.com/johro897/tplink-switch-card","last_synced_at":"2026-05-31T13:30:22.402Z","repository":{"id":356986910,"uuid":"1234875102","full_name":"johro897/tplink-switch-card","owner":"johro897","description":"A Lovelace card to make it easy to visualize your TP-Link Switch to Home Assistant","archived":false,"fork":false,"pushed_at":"2026-05-10T19:07:03.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-10T20:28:02.947Z","etag":null,"topics":["poe","quick-card","switch","tp-link"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johro897.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-10T18:51:45.000Z","updated_at":"2026-05-10T19:01:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/johro897/tplink-switch-card","commit_stats":null,"previous_names":["johro897/tplink-switch-card"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/johro897/tplink-switch-card","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johro897%2Ftplink-switch-card","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johro897%2Ftplink-switch-card/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johro897%2Ftplink-switch-card/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johro897%2Ftplink-switch-card/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johro897","download_url":"https://codeload.github.com/johro897/tplink-switch-card/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johro897%2Ftplink-switch-card/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33733754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["poe","quick-card","switch","tp-link"],"created_at":"2026-05-31T13:30:21.887Z","updated_at":"2026-05-31T13:30:22.388Z","avatar_url":"https://github.com/johro897.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TP-Link Switch Card\n\nA custom Lovelace card for Home Assistant that gives you a clean, compact overview of your TP-Link Easy Smart switch — port states, PoE consumption, link speeds, per-port controls and PoE configuration, all in one card.\n\nBuilt for the [TP-Link Easy Smart](https://github.com/vmakeev/hass_tplink_easy_smart) custom integration. No templates, shell commands, or extra helpers required.\n\n![](screenshots/overview.png)\n\n---\n\n## Quick start\n\nInstall the card, then add this to your dashboard:\n\n```yaml\ntype: custom:tplink-switch-card\ntitle: TP-Link Switch\nentity_prefix: tp_link_switch   # match your integration's entity prefix\npoe_ports: 8                    # number of PoE-capable ports (counted from port 1)\ntotal_ports: 16                 # total number of switch ports\nmax_poe_watts: 150              # optional: hardware PoE cap (blocks budget editor above this)\n```\n\nThat's it. MAC address, IP and switch URL are all read automatically from the integration — nothing else to configure.\n\n---\n\n## Features\n\n- **Switch overview** — IP address (with link to switch web UI), MAC, gateway, netmask, PoE used/remaining and a live budget bar\n- **PoE budget bar** — turns amber above 80% and red above 95% load; click ✏️ to edit the budget limit inline\n- **Two port sections** — PoE ports and regular ports displayed separately\n- **Per-port status** — link state dot, formatted link speed (1G / 100M / 2.5G), PoE badge and wattage\n- **Expandable detail rows** — click a port to reveal voltage, current, PD class, configured speed, priority, power limit and enable toggles\n- **PoE configuration panel** — configure PoE priority and power limit per port with Apply/Cancel directly in the card\n- **Click to copy** — click the IP address or MAC tile to copy the value to clipboard; works on both HTTP and HTTPS\n- **Switch UI shortcut** — link icon next to IP opens the switch web UI in a new tab; derived automatically from the integration, no URL to configure\n- **PoE hardware cap** — optional `max_poe_watts` shows the physical limit in the budget editor and blocks Apply if exceeded\n- **Theme-aware** — uses HA CSS variables throughout, works with any theme\n- **Efficient rendering** — only re-renders when a watched entity actually changes state or attribute\n\n---\n\n## Requirements\n\n- Home Assistant 2025.8 or newer\n- [hass_tplink_easy_smart](https://github.com/vmakeev/hass_tplink_easy_smart) custom integration installed and configured\n\n---\n\n## Installation\n\n### Via HACS (recommended)\n\n1. In HACS, go to **Frontend → ⋮ → Custom repositories**\n2. Paste `https://github.com/johro897/tplink-switch-card` and choose **Dashboard**\n3. Click **Add**, locate **TP-Link Switch Card** and install it\n4. Reload Lovelace resources\n\n[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=johro897\u0026repository=tplink-switch-card\u0026category=dashboard)\n\n### Manual install\n\n1. Copy `tplink-switch-card.js` to `/config/www/tplink-switch-card/tplink-switch-card.js`\n2. Add the resource via **Settings → Dashboards → Resources → +**:\n   ```\n   /local/tplink-switch-card/tplink-switch-card.js\n   ```\n3. Hard-refresh your browser (`Ctrl/Cmd + Shift + R`)\n\n---\n\n## How to use the card\n\nThe card has three interaction levels:\n\n**1. Port row** — always visible. Shows link state, speed, PoE badge and wattage at a glance.\n\n**2. Detail row** — click any port that has controllable entities to expand. Shows all sensor values (voltage, current, PD class, configured speed) plus PoE enabled and port enabled toggles.\n\n![](screenshots/port_detail.png)\n\n**3. Configure panel** — click **Configure PoE** inside the detail row to open an inline editor for PoE priority and power limit. Hit **Apply** to send the change to the switch, or **Cancel** to close without saving.\n\n![](screenshots/configure_panel.png)\n\n\u003e Ports without any controllable entities (no `poe_enabled` or `port_enabled` switch) are not expandable — they show status only.\n\n---\n\n## Configuration\n\n### Card options\n\n| Option | Required | Default | Description |\n| --- | --- | --- | --- |\n| `title` | No | `TP-Link Switch` | Card header text |\n| `entity_prefix` | No | `tp_link_switch` | Prefix used to build all entity IDs — must match the prefix your integration uses |\n| `poe_ports` | No | `8` | Number of PoE-capable ports, counted from port 1 |\n| `total_ports` | No | `16` | Total number of switch ports |\n| `max_poe_watts` | No | — | Hardware PoE maximum in watts (e.g. `150` for TL-SG1016PE). Shows the cap in the budget editor and blocks Apply if exceeded |\n\n### Services used for write operations\n\nThe card calls two services from the `tplink_easy_smart` integration. Both identify the switch via `mac_address`, which is read automatically from the `network_info` sensor — no manual configuration needed.\n\n| Service | Description |\n| --- | --- |\n| `tplink_easy_smart.set_port_poe_settings` | Sets PoE priority and power limit per port |\n| `tplink_easy_smart.set_general_poe_limit` | Sets the global PoE budget for the switch |\n\n**Priority values:** `Low`, `Middle`, `High`\n\n**Power limit values:** `Auto`, `Class 1`, `Class 2`, `Class 3`, `Class 4`, `Manual`\n\n---\n\n## Entity naming\n\nThe card builds all entity IDs automatically from `entity_prefix`. No manual entity mapping is needed.\n\n### Overview sensors\n\n| Entity | Description |\n| --- | --- |\n| `sensor.{prefix}_network_info` | IP address (state), MAC, gateway, netmask (attributes) |\n| `sensor.{prefix}_poe_consumption` | Total PoE consumption (state, W) with `power_limit_w` and `power_remain_w` attributes |\n\n### Per-port entities\n\n| Entity | Description |\n| --- | --- |\n| `binary_sensor.{prefix}_port_{n}_state` | Port link state — `on` = connected; attributes include `speed` and `speed_config` |\n| `binary_sensor.{prefix}_port_{n}_poe_state` | PoE state — attributes: `power_w`, `current_ma`, `voltage_v`, `pd_class`, `priority`, `power_limit` |\n| `switch.{prefix}_port_{n}_poe_enabled` | PoE enable/disable toggle |\n| `switch.{prefix}_port_{n}_enabled` | Port enable/disable toggle |\n\nEntities that are missing or unavailable are handled gracefully — the corresponding field is hidden or shows `—`.\n\n---\n\n## Screenshots\n\n### Full card overview\n![Full card overview](screenshots/overview.png)\n*Switch overview tiles, PoE budget bar, PoE port section and regular port section.*\n\n### Overview tiles — copy and UI link\n![Overview tiles with IP copy and link icon](screenshots/overview_tiles.png)\n*Click the IP or MAC tile to copy the value. The link icon opens the switch web UI in a new tab.*\n\n### Expanded port detail\n![Expanded port detail row](screenshots/port_detail.png)\n*Expand a port to see all sensor values, configured speed and enable toggles.*\n\n### PoE configure panel\n![PoE configure panel with priority and power limit dropdowns](screenshots/configure_panel.png)\n*Configure PoE priority and power limit per port directly in the card.*\n\n### PoE budget editor with hardware cap\n![PoE budget editor showing max_poe_watts warning](screenshots/poe_budget_editor.png)\n*The budget editor shows the hardware cap and blocks Apply if the value exceeds it.*\n\n### PoE budget warning\n![PoE bar turning amber at high load](screenshots/poe_warning.png)\n*Budget bar turns amber above 80% and red above 95% load.*\n\n---\n\n## Troubleshooting\n\n| Problem | Solution |\n| --- | --- |\n| Card not found | Verify the resource URL is registered and hard-refresh the browser |\n| All ports show \"Down\" | Check that `entity_prefix` matches the prefix your integration uses — look up one entity in Developer Tools → States to confirm |\n| Ports are not expandable | The port has no `switch.*_poe_enabled` or `switch.*_enabled` entity — check the integration has created them; some switch models don't support all features |\n| Configure PoE button missing | Only shown on PoE ports (ports 1–`poe_ports`) that have a `poe_state` entity |\n| PoE Apply fails | Check that `mac_address` is available on `sensor.{prefix}_network_info` — open the entity in Developer Tools → States and look for the `mac` attribute |\n| Copy doesn't work | On HTTP installs `navigator.clipboard` is blocked by the browser; the card falls back to `execCommand` automatically — if that also fails, switch HA to HTTPS |\n| Budget editor blocks Apply | The value exceeds `max_poe_watts`; lower the value or remove `max_poe_watts` from the config if you want no cap |\n| Budget editor shows stale value | The editor pre-fills from the current `power_limit_w` attribute — if the switch hasn't reported the new value yet, wait a few seconds and reopen |\n\n---\n\n## Tested with\n\n| Device | Firmware |\n| --- | --- |\n| TL-SG1016PE | 2.0 |\n\nOther TP-Link Easy Smart switches using the same integration should work as long as their entities follow the same naming pattern.\n\n---\n\n## Changelog\n\n### v0.9.0\n**PoE configuration**\n- Inline configure panel per PoE port — set priority (Low/Middle/High) and power limit (Auto/Class 1–4/Manual) with Apply/Cancel\n- Global PoE budget editor via ✏️ icon in the budget bar\n- Optional `max_poe_watts` config key shows hardware cap and blocks Apply if exceeded\n- Budget validation on Set click with inline error message — no re-render on input\n- All service calls use `mac_address` read automatically from `network_info` sensor\n\n**Overview**\n- Click IP or MAC tile to copy value to clipboard; falls back to `execCommand` on HTTP\n- Link icon next to IP opens switch web UI in new tab\n- PoE budget bar turns amber above 80% and red above 95%\n\n**Port details**\n- `speed_config` shown as \"Configured\" in detail row\n- Speed formatter: `1000MF` → `1G`, `2500M` → `2.5G` etc.\n- `role=\"button\"` and `aria-expanded` on expandable rows\n\n**Performance**\n- Dirty-check on `hass` updates — skips re-render when no watched entity changes\n- Per-render entity cache via `_portEntitiesCache`\n\n### v0.1.0\n- Initial release\n- Switch overview: IP, MAC, gateway, netmask, PoE consumption, budget bar\n- Two port sections: PoE ports and regular ports\n- Expandable detail rows with voltage, current, PD class, speed, toggles\n- Port enable and PoE enable toggles per port\n\n---\n\n## Development\n\nSingle self-contained ES2021 file — no build tooling required.\n\n## License\n\nMIT © 2026\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohro897%2Ftplink-switch-card","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohro897%2Ftplink-switch-card","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohro897%2Ftplink-switch-card/lists"}