The best starting documentation would be Custom Cards | Home Assistant Developer Docs
To start, you’ll change what the class extends from Polymer > LitElement
assuming your doing
import {
LitElement,
html,
css,
} from "https://unpkg.com/[email protected]/lit-element.js?module";
Next instead of
static get template() {
return Polymer.html
}
you’d do
// Instead of hass="[[hass]]" etc. you would do .hass=${this.hass} and so forth (normal attributes don't have the period(.) at the start
// For events from the element instead of on-click="_handleClick" do @click=${this._handleClick}
render() {
return html`
...
`;
}
All styles from your template function would go in
// Dont add style tags
static get styles() {
return css`
...
`;
}
That should get you started but if you want to observe changes etc you can check the life cycle of LitElement in their docs or use the getters and setters
set hass( obj ) {
...
}
Just be careful as there is a caveat in using the getters and setters, if you don’t store the setter then you won’t be able to access it which the document above doesn’t elaborate on with the set hass method. So to be able to handle changes to the hass object and still access it in your class without rewriting a bunch of code do the following.
set hass( obj ) {
this._hass = obj; // Don't set it to the same name or you'll cause an infinite loop
// Add code here that handles a change in the hass object
}
get hass() {
return this._hass; // Wherever your code calls this.hass it will return the stored value of _hass
}