Skip to content

Instantly share code, notes, and snippets.

@thomasloven
thomasloven / customelement-test.ts
Last active August 15, 2023 06:09
How to use ha elements when using ScopedRegistry
import { LitElement, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ScopedRegistryHost } from "@lit-labs/scoped-registry-mixin";
@customElement("customelement-test")
class CustomElementTest extends ScopedRegistryHost(LitElement) {
@property() hass;
static elementDefinitions = {
"ha-card": customElements.get("ha-card"), // This works because ha-card is ALWAYS loaded before custom cards (for now)
@thomasloven
thomasloven / my-custom-card.js
Last active November 15, 2024 15:44
Simplest custom card
// Simplest possible custom card
// Does nothing. Doesn't look like anything
class MyCustomCard extends HTMLElement {
setConfig(config) {
// The config object contains the configuration specified by the user in ui-lovelace.yaml
// for your card.
// It will minimally contain:
// config.type = "custom:my-custom-card"