export const ServicesMixin = (SuperClass) => { return class ServicesMixinClass extends SuperClass { /* Structure of service call: service: [data: ] Sequence: service: browser_mod.sequence data: sequence: - - - ... Delay service: browser_mod.delay data: time: Popup: service: browser_mod.popup data: [title: ] [content: ] [primary_action: ] [secondary_action: ] [dismissable: ] [timeout: ] [callbacks: [primary_action: ] [secondary_action: ] [timeout: ] [dismissed: ] ] Close popup service: browser_mod.close_popup Javascript console print service: browser_mod.console data: message: */ _service_action({ service, data }) { let _service: String = service; if (!_service.startsWith("browser_mod.") && _service.includes(".")) { // CALL HOME ASSISTANT SERVICE } if (_service.startsWith("browser_mod.")) { _service = _service.substring(12); } switch (_service) { case "popup": const { title, content, ...d } = data; if (d.callbacks) { for (const [k, v] of Object.entries(data.callbacks)) { d.callbacks[k] = () => this._service_action(v as any); } } this.showPopup(title, content, d); break; case "close_popup": this.closePopup(); break; case "console": console.log(data.message); break; } } }; };