[SOLVED] Stupid problem with a simple rule

Gentleman,

I have small problem with my simple rule:

var Number Dusche_Temp_Soll

rule "Soll Temperatur Dusche"
	when
		Item OG_Bad_Dusche_Temp_Taster received command
	then
 		if (Dusche_Temp_Soll == NULL) {
			Dusche_Temp_Soll = 50
			sendCommand(OG_Bad_Dusche_Temp_Display, Dusche_Temp_Soll)
			}
		if (OG_Bad_Dusche_Temp_Taster.state == ON) {
			if (Dusche_Temp_Soll == 100) {
				sendCommand(OG_Bad_Dusche_Temp_Display, "Max Temp")
			}
			else {
			Dusche_Temp_Soll = (Dusche_Temp_Soll + 10)
			sendCommand(OG_Bad_Dusche_Temp_Soll, Dusche_Temp_Soll)
			sendCommand(OG_Bad_Dusche_Temp_Display, Dusche_Temp_Soll)
			} 
		}	
		else (OG_Bad_Dusche_Temp_Taster.state == OFF) {
			if (Dusche_Temp_Soll == 0) {
				sendCommand(OG_Bad_Dusche_Temp_Display, "Min Temp")
			}
			else {
			Dusche_Temp_Soll = (Dusche_Temp_Soll - 10)
			sendCommand(OG_Bad_Dusche_Temp_Soll, Dusche_Temp_Soll)
			sendCommand(OG_Bad_Dusche_Temp_Display, Dusche_Temp_Soll)
			}
		}
end

When I change in the last “else” case the calculation from a plus to a minus the hole rule is not working anymore and I get this ERROR in the logging:

Rule 'Soll Temperatur Dusche': The argument 'command' must not be null or empty.

Is there something wrong with the declaration of this values? I no idea anymore to solve this problem, maybe someone could help me!

Thank you very much and a nice sunday!
Manfred

Moin Manfred,

probably it is the command at “when …”. Could you try sth. like “Channel “amazondashbutton:dashbutton:XX-XX-XX-XX-XX-XX:press” triggered”. How does your items/things look like?

Found something about a dash button here (german): http://onesmarthome.de/smart-home-openhab-2-dash-button/

Maybe its functional like that:

rule "Soll Temperatur Dusche"
	when
		Item OG_Bad_Dusche_Temp_Taster triggered
....

I want to include buttons in my rules too in the evening. If I know how my Xiaomi Buttons work I will tell you. Which buttons are you using?

Greetings
Andreas

Hi Andreas,

change into “triggered” don’t solve this problem. The rule himself works unless I use minus instead of plus in my calculation.

I use KNX buttons, my items look like this for this rule:

Number OG_Bad_Dusche_Temp_Taster		"Soll Temp [%.1f]"														{knx="1.001:3/2/60"}
Dimmer OG_Bad_Dusche_Temp_Soll			"Soll Temp [%.s]"														{knx="5.001:3/2/61"}
String OG_Bad_Dusche_Temp_Display		"Soll Temp [%.1f]"														{knx="16.001:3/2/56"}

Regards
Manfred

Could it be that Dusche_Temp_Soll number/value becomes negative?

No, I don’t think so. The crazy thing is, if I use in both calculations a plus, it runs. For example, I start with a value of 50, if one of the two buttons getting pressed it counts from 50 up to 100. 50, press button, 60, press button 70, etc…

If I change to minus in one of the two calulations, both calculations don’t running anymore. If I press the “increase” or “decrease” button dosen’t matter, the error message appears. :confused:

I always suggest not to use the action but the method :wink:
Another thing is: Really using a Number Item bound to a switch? I guess this is only a typo here…
The next to last else is missing an if:

	else (OG_Bad_Dusche_Temp_Taster.state == OFF) {

I guess this may be the cause of the error.

I would try to use Int for Dusche_Temp_Soll instead of Number.
Another point to omit duplicate lines of code, you can use Dusche_Temp_Soll in another way…:

rule "Soll Temperatur Dusche"
when
Item OG_Bad_Dusche_Temp_Taster received command
then
    var Int Dusche_Temp_Soll
    if (OG_Bad_Dusche_Temp_Soll instanceof DecimalType)
        Dusche_Temp_Soll = OG_Bad_Dusche_Temp_Soll.state as DecimalType
    else
        Dusche_Temp_Soll = 50

    if (receivedCommand == ON)
        Dusche_Temp_Soll = Dusche_Temp_Soll + 10           //don't care if overflow at this point
    else                                                   // must be OFF...
        Dusche_Temp_Soll = Dusche_Temp_Soll - 10           //don't care if underrun at this point

    if (Dusche_Temp_Soll < 0)                              //underrun, so...
        OG_Bad_Dusche_Temp_Display.sendCommand("Min Temp")
    else if (Dusche_Temp_Soll > 100)                       //overflow, so...
        OG_Bad_Dusche_Temp_Display.sendCommand("Max Temp")
    else {                                                 //Range OK
        OG_Bad_Dusche_Temp_Soll.sendCommand(Dusche_Temp_Soll)
        OG_Bad_Dusche_Temp_Display.sendCommand(Dusche_Temp_Soll)
    }
end
1 Like

Hello Udo,
you helped me a lot, thank you!

At the end it was a combination of two mistakes:
This topic, I don’t know why I used “Number” instead of “Switch”:

and this:

So again, thank you very much for your help!
Grüße
Manfred