[Solved] Help with rule: led should blink if sun blind is running

Dear Forum

I would like to request your help with a rule.

I can steer my sun blinds with 2 (up/down/stop) touch keys on a sensor. What I want to achieve is that the LED behind the sensor is blinking when the sun blind is running up or down. I already have a rule that is doing what I want but as soon as the sun blind runs into a “end position” (0% fully up / 100% fully down) the LED doesn’t stop blinking. Can you pls help me to correct my rule?

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
import java.util.concurrent.locks.ReentrantLock
import org.openhab.core.library.types.DecimalType

rule "LED's zeigen Verfahrstatus der Markise an"
when 
	Item Jal_EG_WZ_Jalousie_Markise received command
then
	if (receivedCommand == UP) {
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(ON)
		}
	else if (receivedCommand == DOWN) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(ON)
		}
	else if (receivedCommand == STOP) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		}
	else if (Jal_EG_WZ_Jalousie_Markise.state == 0 || Jal_EG_WZ_Jalousie_Markise.state == 100) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		} 
	else if (Jal_EG_WZ_Lamellen_Markise.state == 0 || Jal_EG_WZ_Lamellen_Markise.state == 100) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		} 	
end

rule "Zusatz für Verfahrstatus, Kurz-Betätigung deaktiviert Blinken"
when
	Item Jal_EG_WZ_Lamellen_Markise received command
then
	Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
	Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
end

The result in my logfile looks like that:

2016-06-19 16:29:56 - Jal_EG_WZ_Jalousie_Markise received command DOWN
2016-06-19 16:29:56 - Sperrobjekt_EG_WZ_Sensor01_LED_07 received command OFF
2016-06-19 16:29:56 - Sperrobjekt_EG_WZ_Sensor01_LED_08 received command ON
2016-06-19 16:29:58 - Jal_EG_WZ_Jalousie_Markise received command STOP
2016-06-19 16:29:58 - Jal_EG_WZ_Jalousie_Markise state updated to 2
2016-06-19 16:29:58 - Jal_EG_WZ_Lamellen_Markise state updated to 100
2016-06-19 16:29:58 - Sperrobjekt_EG_WZ_Sensor01_LED_07 received command OFF
2016-06-19 16:29:58 - Sperrobjekt_EG_WZ_Sensor01_LED_08 received command OFF
2016-06-19 16:30:00 - Jal_EG_WZ_Jalousie_Markise received command UP
2016-06-19 16:30:00 - Sperrobjekt_EG_WZ_Sensor01_LED_08 received command OFF
2016-06-19 16:30:00 - Sperrobjekt_EG_WZ_Sensor01_LED_07 received command ON

Obviously the “state updated to 100” is no considered correctly in my rule. What is still wrong?

Thanks & regards
John

As the rule is triggered through received command, it will not be triggered through the state update, so I think, the latter two if clauses will never be reached.
You could add a

or
Item Jal_EG_WZ_Lamellen_Markise received update
or 
Item Jal_EG_WZ_Jalousie_Markise received update

but I think, maybe it would be better to make a new rule for that, so that commands and updates are independent.

Hi @Udo_Hartmann

thanks a lot for your help. I just tried your recommendation (updated rule code below) but unfortunately it didn’t work. The LED is still blinking despite the sun blind has reached full-up or full-down position. Do you have any futher ideas?

Thanks, John

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
import java.util.concurrent.locks.ReentrantLock
import org.openhab.core.library.types.DecimalType

rule "LED's zeigen Verfahrstatus der Markise an"
when 
	Item Jal_EG_WZ_Jalousie_Markise received command
then
	if (receivedCommand == UP) {
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(ON)
		}
	else if (receivedCommand == DOWN) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(ON)
		}
	else if (receivedCommand == STOP) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		}
	else if (Jal_EG_WZ_Jalousie_Markise.state == 0 || Jal_EG_WZ_Jalousie_Markise.state == 100) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		} 
	else if (Jal_EG_WZ_Lamellen_Markise.state == 0 || Jal_EG_WZ_Lamellen_Markise.state == 100) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		} 	
end

//---------------------------------------------------------------------------------------------------------------------

rule "Zusatz für Verfahrstatus, Kurz-Betätigung deaktiviert Blinken"
when
	Item Jal_EG_WZ_Lamellen_Markise received command
then
	Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
	Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
end

//-----------------------------------------------------------------------------------------------------------------

rule "Weiter Zusatz für Verfahrstatus"
when
	Item Jal_EG_WZ_Lamellen_Markise received update
	or 
	Item Jal_EG_WZ_Jalousie_Markise received update
then
	Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
	Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
end

I think you may need to explictly cast the state to a DecimalType to make the comparison work. Try the following and see how it works:

else if ((Jal_EG_WZ_Jalousie_Markise.state as DecimalType) == 0 || (Jal_EG_WZ_Jalousie_Markise.state as DecimalType) == 100) {

Also, I think you need to move the above if-statements to your last rule (named “Weiter Zusatz für Verfahrstatus”) for this to work properly.

After some days of testing, I still have issues with that rule:

  • running down --> no blinking

Confusing for me is that, of its running up the LED is blinking and stops as soon as final position is reached. So far this part is working fine. But I have no clue why its not working while running down. Does anyone of you see any errors in my code?

Thanks, John

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
import java.util.concurrent.locks.ReentrantLock
import org.openhab.core.library.types.DecimalType

rule "LED's zeigen Verfahrstatus der Markise an"
when 
	Item Jal_EG_WZ_Jalousie_Markise received command
then
	if (receivedCommand == UP) {
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(ON)
		}
	else if (receivedCommand == DOWN) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(ON)
		}
	else if (receivedCommand == STOP) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		}
end

//-------------------------------------------------------------------------------------------------------------------------------------

rule "Erster Zusatz für Verfahrstatus, Kurz-Betätigung deaktiviert Blinken"
when
	Item Jal_EG_WZ_Lamellen_Markise received command
	or
	Item Jal_EG_WZ_Lamellen_Markise received update
	or 
	Item Jal_EG_WZ_Jalousie_Markise received update
then
	Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
	Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
end

//---------------------------------------------------------------------------------------------------------------------------------------------

rule "Zweiter Zusatz für Verfahrstatus"
when
	Item Jal_EG_WZ_Lamellen_Markise received update
	or 
	Item Jal_EG_WZ_Jalousie_Markise received update
then
	if ((Jal_EG_WZ_Jalousie_Markise.state as DecimalType) == 0 || (Jal_EG_WZ_Jalousie_Markise.state as DecimalType) == 100) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		} 
	else if ((Jal_EG_WZ_Lamellen_Markise.state as DecimalType) == 0 || (Jal_EG_WZ_Lamellen_Markise.state as DecimalType) == 100) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
		} 
end

The rule "Erster Zusatz für Verfahrstatus, Kurz-Betätigung deaktiviert Blinken"
detects a command, and does more or less the same as the rule “Zweiter Zusatz für Verfahrstatus” but without the limitations, both rules are triggered from more or less the same triggers, so this is redundant.

Just to understand:
What kind of binding do you use for your blinds? Does the blind send updates about position when stopping?

Hi @Udo_Hartmann

the blinds are connected via KNX, but I’m still using OH1.8.2 with the according KNX binding version.
As far as I can see my blinds are reporting UP/DOWN/STOP as well as a state. Extract from logfile from another blind:

2016-06-23 12:53:16 - Jal_DG_Zi3_Jalousie received command UP
2016-06-23 12:53:18 - Jal_DG_Zi3_Jalousie received command STOP
2016-06-23 12:53:18 - Jal_DG_Zi3_Jalousie state updated to 95
2016-06-23 12:53:18 - Jal_DG_Zi3_Lamellen state updated to 0
2016-06-23 12:53:21 - Jal_DG_Zi3_Jalousie received command DOWN

I’ll delete one of the additional rules - that’s a good point.

I just learned something strange about my blinds:

  • sending them up or down and stop them while running I get a state, e.g. state updated to 95
  • sending them to an end position I don’t get a state reported, I can see only the activating command

BUT: in OH they are always displayed with the correct state, also for 0% and 100%

Is this a correct behavior? If yes, how do I get a trigger for final UP/DOWN positions if they are not reported?

So, the next question is, there should be a max runtime defined in the knx actuator (I think the actuator uses this also to get knowings about the absolute position)
The actuator should send the position at least when stopping the motor, regardless if stopped manually or stopped when reaching end position.
If you setup the item like

Rollershutter MyShutter "My Shutter is at [%.0f%%]" {knx="1/1/1...", autoupdate="false"}

then the item will update it’s state only if receiving an update/command from knx or a postUpdate() through the rules, but not through sendCommands() or UI. Be aware that you have to setup all Group Addresses which belong to the channel of the actuator, so maybe

{knx="1/1/1+<1/1/2, 1/1/3, 1/1/4+<1/1/5"}

when 1/1/1 is UP/DOWN, 1/1/2 is state ‘last direction’, 1/1/3 is step/move(stop), 1/1/4 is absolute position and 1/1/5 is state ‘absolute position’ - needles to say, the actuator should send 1/1/2 when changing direction and 1/1/5 whenever the motor stops (maybe this is configurable)…

Finally, I made it. Thank you @Udo_Hartmann. Your hint gave me the right direction. Indeed, there are configurable parameters that the actor reports final up and final down position as well as when it is running. Hereinafter my code, incl German comments from the actors user manual. I’m grateful for any ideas to improve it :slight_smile:

In every case, thanks a lot for the support.
Best regards
John

rule "Markise 1/3"
	when
	Item Jal_EG_WZ_Jalousie_Markise received command
then
	if (receivedCommand == UP) { 
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(ON)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
	}
	else if (receivedCommand == DOWN) { 
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(ON)
		}
end

rule "Markise 2/3"
	when
	Item Jal_EG_WZ_Markise_Verfahrstatus received command
then 
	if (receivedCommand == STOP) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
	}
end

rule "Markise 3/3"
	when
	Item Jal_EG_WZ_Markise_unterePos received command
	or
	Item Jal_EG_WZ_Markise_oberePos received command
then
	if(receivedCommand == ON) {
		Sperrobjekt_EG_WZ_Sensor01_LED_07.sendCommand(OFF)
		Sperrobjekt_EG_WZ_Sensor01_LED_08.sendCommand(OFF)
	}
end


//Das Objekt „Verfahrstatus“ meldet eine momentan andauernde Fahrt mit einer „1“.
//das 1 Bit Objekt „Status aktuelle Richtung“ gibt über eine logische „0“ (OFF = LED 7) eine Aufwärtsfahrt an und über eine logische „1“ (ON = LED 8) eine Abwärtsfahrt an
//Der Status wird jeweils ausgegeben, sobald eine Fahrt gestartet wird und bleibt solange intern bestehen bis ein neuer Aufwärts‐/Abwärtsbefehl gesendet wird.
//Die 1 Bit Objekte „Status untere Position“ und „Status obere Position“ geben jeweils ein 1‐Signal aus, wenn die untere bzw. obere Endlage erreicht wurde. Sobald die Endlage wieder verlassen wurde wechselt das Signal von 1 auf 0.