I am using a RPi4 8Gb with OH3.
To better explain my system, I will detail here what I have being controlledread in these rules:
- 1 outside gate where I control it and have a sensor that tells me when it’s oppened or closed (problem here: since the gate is a rail gate, it also has a magnet to understand when it has to stop open or stop close, which means that my sensor “opens contact” when the gate starts moving and “closes contact” when the gate stops moving, independently of the gate being fully open of fully closed)
- 1 garage door where I have a basic 2 ways RF 433Mhz sensor that tells me when the door is oppened or closed, plus a magnet sensor that tells me when the door is fully oppened (that’s when it touches the magnet sensor)
- Alarm in my house that, is ON, it’s then turned OFF
- Outside “welcome” lights that should turn on when outside gate opens at night
So I have some rules that are not working as they should.
Here’s what I’ve put in the begining of the file to use in different ways inside it:
var Timer offTimer = null
val Number hours = now.getHour
val PorSol = (Por_Sol.historicState(now).state as DateTimeType).getZonedDateTime
val NascerSol = (Nascer_Sol.historicState(now).state as DateTimeType).getZonedDateTime
This rule is triggered when I open outside gate from OH.
- Alarm turning OFF if it’s ON, works just fine.
- Garage door opening after 15 seconds works just fine (problem: if I open my garage door from OH, since I have bellow a rule to open outside gate immediately, it triggers this rule after 15 seconds and it shouldn’t)
- Lights turning ON if they are OFF and if it’s between sunset and sunrise, not working now (when I had this rule in OH2.5 it was working)
rule "Ações com o portão exterior"
when
Item Portao_Exterior received command ON
then
if (Alarme_Casa.state == ON) {
Alarme_Casa.sendCommand(OFF)
}
if (Portao_Garagem.changedSince(now.minusSeconds(180)) == false) {
offTimer = createTimer(now.plusSeconds(15), [|
Portao_Garagem.sendCommand(ON)
])
}
if ((now.isAfter(PorSol) || now.isBefore(NascerSol))
&& Luz_Exterior_Frente.state == OFF
&& Luz_Exterior_Garagem.state == OFF) {
Luz_Exterior_Frente.sendCommand(ON)
Luz_Exterior_Garagem.sendCommand(ON)
offTimer = createTimer(now.plusMinutes(1), [|
Luz_Exterior_Frente.sendCommand(OFF)
Luz_Exterior_Garagem.sendCommand(OFF)
])
}
end
rule "Ações com o portão da garagem"
when
Item Portao_Garagem received command ON
then
if (Sensor_Portao_Exterior.changedSince(now.minusSeconds(180)) == false) {
Portao_Exterior.sendCommand(ON)
}
end
This rule is supposed to trigger only when the outside gate sensor changes state from OFF to ON (meaning, the magnet from the gate starts moving so it turns ON the sensor).
- This rule doesn’t even seem to be triggered and I don’t know why because the sensor is working and in mysql I do see all the changes there
rule "Portão exterior a abrir/fechar com comando"
when
Item Sensor_Portao_Exterior changed from OFF to ON
then
if (Sensor_Portao_Exterior.changedSince(now.minusSeconds(180)) == false) {
sendBroadcastNotification("Portão exterior abriu")
}
if (Sensor_Portao_Garagem.changedSince(now.minusSeconds(180)) == false) {
If (Alarme_Casa.state == ON) {
Alarme_Casa.sendCommand(OFF)
}
Portao_Garagem.sendCommand(ON)
}
if ((now.isAfter(PorSol) || now.isBefore(NascerSol))
&& Luz_Exterior_Frente.state == OFF
&& Luz_Exterior_Garagem.state == OFF) {
Luz_Exterior_Frente.sendCommand(ON)
Luz_Exterior_Garagem.sendCommand(ON)
offTimer = createTimer(now.plusMinutes(1), [|
Luz_Exterior_Frente.sendCommand(OFF)
Luz_Exterior_Garagem.sendCommand(OFF)
])
}
end
As usual, all help will be much appreciated.