Skip to content

Instantly share code, notes, and snippets.

@LightVolk
Last active January 26, 2020 18:26
Show Gist options
  • Save LightVolk/19efae462e3381ac31597fd320d41c3d to your computer and use it in GitHub Desktop.
Save LightVolk/19efae462e3381ac31597fd320d41c3d to your computer and use it in GitHub Desktop.
IoBroker script: Main door script with Xiaomi door detector
var doorId="mihome.0.devices.some_id.state";
function SendToDevices(deviceId:string,message:string):void
{
sendTo(deviceId,message);
}
subscribe(doorId,function(obj)
{
// door detector
var doorState=getState(doorId);
if(doorState.val===true)
{
SendToDevices("telegram.0", "Door open");
}
else if(doorState.val===false)
{
SendToDevices("telegram.0", "Door close");
}
});
@salambelgord
Copy link

salambelgord commented Jan 26, 2020

var flag =true;
on({id: 'zigbee.0.00158d0001228eb5.no_motion'/Time from last motion/, change: 'ne'}, function (data) {
// следить изминения датчик движения
if (data.newState.val =='0' && flag)
{
sendGif();//глобальная функция
sendTo("telegram.0", "send", {text: '‼️ Движение в доме' });
log('Движение');
flag = false;
}
else if (data.newState.val =='1800')
{
flag = true;//сброс флага при достижении 1800 сек.
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment