hi all
I would have the following rule on my oh3 working (partially done, some issues)
setting:
- Hue motion sensor connected to oh3 using deconz (added through UI)
- some bulbs connected to oh3 (using hue bridge)
what I want to do is following:
- Light should go on after motion is detected (done)
- Light should go off 60 seconds after no motion ist detected (done)
- there should be a possibility to disable the sensor and turn light on by switch (done)
- Depending on the time of day there should be another light intensity and temperature (done using two rules)
- During the day (rule 1) the light should only go on if there’s not sufficient light (lux) measured using the illuminance sensor (on the hue motion sensor)
→ my issue here’s the fact that I don’t really know how the illuminance is measured …thin in lux but what range?
→ the other thing is the refreshing cycle on this sensor …it seems that it’s not refreshing really often
Here’s my script till now…
//var Log = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
//Log.info("--- Bewegungsmelder Eingang ---");
this.myTimer = (this.myTimer===undefined) ? null : this.myTimer;
var illuminance = ir.getItem('BeleuchtungsstarkeEingang_Illuminance');
var lampeEingang = ir.getItem('Lampe_Eingang');
var sensorEnabled = ir.getItem('SensorEnabledEingang');
var illValue = illuminance.getStateAs(DecimalType.class);
var lampeEingangValue = lampeEingang.getStateAs(DecimalType.class);
//Log.info("illuminance Value " + illValue);
//Log.info("LampeEingang Value " + lampeEingangValue);
if(((illValue < 100) || (lampeEingangValue > 0)) && (sensorEnabled.getState() == 'ON')){
// Log.info("Wert erreicht...");
events.sendCommand(lampeEingang, 100);
var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution");
var ZonedDateTime = Java.type("java.time.ZonedDateTime");
if(this.myTimer !== undefined && this.myTimer !== null){
this.myTimer.cancel();
this.myTimer = null;
}
this.myTimer = ScriptExecution.createTimer(ZonedDateTime.now().plusSeconds(60), function(){
if(sensorEnabled.getState() == 'ON'){
events.sendCommand(lampeEingang, 0);
}
this.myTimer = null;
});
}
//else{
// Log.info("Wert nicht erreicht...");
//}
with some logging stuff disabled at the moment
any hints how to deal with my issues?
thnx,
Matthias