Created
December 29, 2021 06:55
-
-
Save balloob/23079216f08552853fd7c1c4b9f04e45 to your computer and use it in GitHub Desktop.
User agent card
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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