Last active
January 26, 2020 18:26
-
-
Save LightVolk/19efae462e3381ac31597fd320d41c3d to your computer and use it in GitHub Desktop.
IoBroker script: Main door script with Xiaomi door detector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 сек.
}
});