Skip to content

Instantly share code, notes, and snippets.

@balloob
Created December 29, 2021 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balloob/23079216f08552853fd7c1c4b9f04e45 to your computer and use it in GitHub Desktop.
Save balloob/23079216f08552853fd7c1c4b9f04e45 to your computer and use it in GitHub Desktop.
User agent card
/*
Copy file to <config>/www/user-agent-card.js
Restart Home Assitant if www folder didn't exist.
In Home Assistant:
- Profile -> Enable advanced mode
- Config -> Dashboards -> Resources
- New resource. `/local/user-agent-card.js`. Type: JS Module
- Go to a Lovelace dashboard, add card, manual, `type: "custom:user-agent-card"`
*/
class UserAgentCard extends HTMLElement {
set hass(hass) {
if (!this.content) {
this.content = true;
this.innerHTML = `
<ha-card header="User Agent">
<div class="card-content">
${navigator.userAgent}
</div>
</ha-card>
`;
}
}
setConfig(config) {}
getCardSize() {
return 3;
}
}
customElements.define("user-agent-card", UserAgentCard);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment