Hi,
i don´t have a wall switch to switch the light for my stairs. If someone switches light in the room before stairs, then stairs will be switched on, too.
But it is not wirking all the time. Sometime it works, sometimes the stair lights stay off.
Here are my rules:
rule "Stufenlicht Treppe OG ein"
when
Item Licht_EG_Flur received update or
Item Licht_OG_Flur received update
then
if (Licht_EG_Flur.state==ON) {
if (Licht_OG_Stufenlicht.state==OFF) {
sendCommand(Licht_OG_Stufenlicht, ON)
}
}
if (Licht_OG_Flur.state==ON) {
if (Licht_OG_Stufenlicht.state==OFF) {
sendCommand(Licht_OG_Stufenlicht, ON)
}
}
end
rule "Stufenlicht Treppe OG aus"
when
Item Licht_EG_Flur received update or
Item Licht_OG_Flur received update
then
if (Licht_EG_Flur.state==OFF && Licht_OG_Flur.state==OFF) {
sendCommand(Licht_OG_Stufenlicht, OFF)
}
end
rule "Stufenlicht Treppe KG ein"
when
Item Licht_EG_Flur received update or
Item Licht_KG_Flur received update
then
if (Licht_EG_Flur.state==ON) {
if (Licht_KG_Stufenlicht.state==OFF) {
sendCommand(Licht_KG_Stufenlicht, ON)
}
}
if (Licht_KG_Flur.state==ON) {
if (Licht_KG_Stufenlicht.state==OFF) {
sendCommand(Licht_KG_Stufenlicht, ON)
}
}
end
rule "Stufenlicht Treppe KG aus"
when
Item Licht_EG_Flur received update or
Item Licht_KG_Flur received update
then
if (Licht_EG_Flur.state==OFF && Licht_KG_Flur.state==OFF) {
sendCommand(Licht_KG_Stufenlicht, OFF)
}
end
I changed for testing “received update” to “changed” - but still it was not working all the time.
Can someone help me? Why is this not working all the time?
how do the “Licht_*G_Flur” change their values? Are theese states really “updated” or are theese “commands”? So you should switch to “received command”: Item <item> received command [<command>]
Greetings
i don’t understand what “not working” means.
First of all: Check the Busevents and show us what happens when you toggle the wall switch (which shall be the trigger for the rules).
If i switch on the Licht_EG_Flur, the Licht_OG_Treppenlicht ist not switching on.
Only Light_EG_Flur is on then.
If i press button on openhab-sitemap, it shows on or off in the log-file. If i press the separate button for Licht_OG_Stufenlicht, the light in the stairs is switched on at once. There i can also see on or off in the log-file.
I only have wall switches for Licht_*G_Flur, not so for *-Stufenlicht". “Stufenlicht” should always switch on if Licht_Flur will switch on.
I can switch Licht_EG_Flur with wall switch and with openhab. Both is working, same behaviour.
Now i changed the rule to “changed to ON” instead of “receiving update”. On my first few tries it wasn´t working. Both lights switched on, but “Steufenlicht” was not switched to off if both lights are off.
But after a few tries now it works… Strange…
Same rule for another light is working for weeks without any problems…
rule "Licht Eingang EG ein"
when
Item Licht_EG_Speis received update or
Item Licht_EG_WC_Spots received update
then
if (Licht_EG_Speis.state==ON) {
if (Licht_EG_Eingang.state==OFF) {
sendCommand(Licht_EG_Eingang, ON)
}
}
if (Licht_EG_WC_Spots.state==ON) {
if (Licht_EG_Eingang.state==OFF) {
sendCommand(Licht_EG_Eingang, ON)
}
}
end
rule "Licht Eingang EG aus"
when
Item Licht_EG_Speis received update or
Item Licht_EG_WC_Spots received update
then
if (Licht_EG_Speis.state==OFF && Licht_EG_WC_Spots.state==OFF) {
sendCommand(Licht_EG_Eingang, OFF)
}
end
This was working from the beginning.
But the rules for my stair-lights (Treppenlight) was not working like it shopuld be.
Now i changed to this and i will keep an eye ont his… I will report back, if it will fail in future again.
rule "Stufenlicht Treppe OG ein"
when
Item Licht_EG_Flur changed to ON or
Item Licht_OG_Flur changed to ON
then
if (Licht_OG_Stufenlicht.state==OFF) {
sendCommand(Licht_OG_Stufenlicht, ON)
}
if (Licht_OG_Stufenlicht.state==OFF) {
sendCommand(Licht_OG_Stufenlicht, ON)
}
end
rule "Stufenlicht Treppe OG aus"
when
Item Licht_EG_Flur changed to OFF or
Item Licht_OG_Flur changed to OFF
then
if (Licht_EG_Flur.state==OFF && Licht_OG_Flur.state==OFF) {
sendCommand(Licht_OG_Stufenlicht, OFF)
}
end
rule "Stufenlicht Treppe KG ein"
when
Item Licht_EG_Flur changed to ON or
Item Licht_KG_Flur changed to ON
then
if (Licht_KG_Stufenlicht.state==OFF) {
sendCommand(Licht_KG_Stufenlicht, ON)
}
if (Licht_KG_Stufenlicht.state==OFF) {
sendCommand(Licht_KG_Stufenlicht, ON)
}
end
rule "Stufenlicht Treppe KG aus"
when
Item Licht_EG_Flur changed to OFF or
Item Licht_KG_Flur changed to OFF
then
if (Licht_EG_Flur.state==OFF && Licht_KG_Flur.state==OFF) {
sendCommand(Licht_KG_Stufenlicht, OFF)
}
end
Maybe if Licht_Stufenlicht has no status - like after a restart of openhab, then i think the rule will not work, because
if (Licht_OG_Stufenlicht.state==OFF) {
(or ==on) will be false.
Can this be the answer? But my knx wall switches get the right status, even after a complete restart of knx and openhab. LED on the wall switch will change color, after a few seconds when all is restarting. red=light off, green=light on
But openhab will not get this information? Openhab will first get information about the state of the switches when i change their state for the first time?
Or will openhab be informed from knx after restart? Is openhab reading all states of the switches in my items file after restart?
Do you use any persistence?
If not, I recommend to implement a “Initializing” Rule, which checks all items if they are uninizialized
if (Lueftung.state == Uninitialized) {
Lueftung.postUpdate(OFF)
}
In my early beginning I triggered this to all of my items on regulary basis
System started or
Time cron "* * /1 * * ?"
Every single item must be initialized (OH1) or have another state as “NULL” (OH2)…
When you start OH, they are all uninitialized. After the first switch they get their status (ON/OFF).
I use rrd4j - but only for temperature and things like this. Not for state of switches.
What will be the benefit of a rule, which checks all items for uninitialized state? And what will be, if a light will be powered on, but switch is uninitialised and so the rule will give the switch the state “off”?
Is Lueftung in your exymple above the name of an item or the name of a group?
Thanks, that sounds better. But i installed MapDB and persist all my rollershutters, lights and so on with this. So i never get uninitialised any more (in therory )