/*! phoscon-app 2024-02-26 */

export const startScanAction=(context,event)=>{if(document.body.classList.contains("devtool"))return;if(!event.data)throw new Error("parameter is missing - startScanAction()");context.enableSensorSearch(context),document.documentElement.style.setProperty("--progress-time",event.data+"s"),context.scanTimer=setTimeout(()=>{context.service.send(context.constants.NO_DEVICE_ADDED),context.scanTimer=null},1e3*event.data)};export const stopScanAction=(context,event)=>{context.disableSensorSearch(context),clearTimeout(context.scanTimer),context.scanTimer=null};export const deviceAddedAction=(context,event)=>{app.sensors.fetch();var device=event.device;device&&(device.get("modelid").indexOf("lumi.sensor_cube")?setTimeout(()=>{context.disableSensorSearch(context)},6e3):context.disableSensorSearch(context),setTimeout(()=>{var s=app.switches?app.switches.get(device.id):void 0;s?context.renameSwitch(s,function(){}):(s=app.sensors?app.sensors.get(device.id):void 0)&&context.renameDevice&&context.renameDevice(s,function(){})},1e3))};export const noDeviceAddedAction=(context,event)=>{context.disableSensorSearch()};export const startUpdateTimerAction=(context,event)=>{context.updatedTimer=setTimeout(()=>{context.service.send(context.constants.DEVICE_NO_UPDATED)},3e4)};