MMM-HomeAssistant-Touch/UIClasses/Switch.js
2021-04-04 19:38:03 +02:00

22 lines
516 B
JavaScript

class Switch extends Base {
getContainer() {
const entity = super.getContainer();
entity.onclick = () => {
this.mm.sendSocketNotification("TOGGLE_STATE", { entity: this.id });
};
entity.ontouchend = () => {
this.mm.sendSocketNotification("TOGGLE_STATE", { entity: this.id });
}
return entity;
}
render() {
super.render();
const container = document.getElementById(this.id);
container.classList.add(this.state)
container.appendChild(statusCheckbox);
}
}