class ToggleLockEntityRow extends Polymer.Element {
static get template() {
return Polymer.html`
`
}
setConfig(config)
{
this._config = config;
this.users = null;
if(config.users) {
this.users = config.users;
}
}
set hass(hass) {
this._hass = hass;
this.stateObj = this._config.entity in hass.states ? hass.states[this._config.entity] : null;
}
clickHandler(e) {
e.stopPropagation();
if(this.users) {
if(! document.querySelector("home-assistant").hass.user) return;
let user = document.querySelector("home-assistant").hass.user.name;
if(this.users.indexOf(user) < 0) return;
}
this.$.overlay.style.pointerEvents = 'none';
const lock = this.$.lock;
if(lock) {
lock.icon = 'hass:lock-open';
lock.classList.add('fadeOut');
}
window.setTimeout(() => {
this.$.overlay.style.pointerEvents = '';
if(lock) {
lock.classList.remove('fadeOut');
lock.icon = 'hass:lock';
}
}, 5000);
}
}
customElements.define('toggle-lock-entity-row', ToggleLockEntityRow);