mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-05 16:04:19 +01:00
28 lines
631 B
JavaScript
28 lines
631 B
JavaScript
import { sendAction } from './connection.mjs';
|
|
|
|
/**
|
|
* @param {Event} event
|
|
* @param {number} state
|
|
*/
|
|
function publishState(event, state) {
|
|
event.preventDefault();
|
|
sendAction("ha-publish", {state});
|
|
}
|
|
|
|
/** @param {Event} event */
|
|
function publishEnabled(event) {
|
|
publishState(event, 1);
|
|
}
|
|
|
|
/** @param {Event} event */
|
|
function publishDisabled(event) {
|
|
publishState(event, 0);
|
|
}
|
|
|
|
export function init() {
|
|
document.querySelector(".button-ha-enabled")
|
|
?.addEventListener("click", publishEnabled);
|
|
document.querySelector(".button-ha-disabled")
|
|
?.addEventListener("click", publishDisabled);
|
|
}
|