Migrating Rules with item.state from OH2 to OH3

Hi,
I am now migration all my rules to OH3 from OH2. I get no error in the logs. I think it has to do with the item.state…

	// sonne runter osten
		if(lux.state > 4500 && t_aussen.state > 20 && sonnenstand.state < 170) {
//		if((lux.state > 4500 && t_aussen.state > 20 && sonnenstand.state < 170) || (hotday.state == ON && sonnenstand.state > 90 && sonnenstand.state < 170)) {
				if ((s_sofafenster.state == CLOSED || (melli.state == OFF && joerg.state == OFF && max.state == OFF && lotte.state == OFF && tom.state == OFF && ben.state == OFF)) && (r_sofafenster.state < 100 && sonnesofafenster.state == OFF)) {
				    r_sofafenster.sendCommand(DOWN)
        		            sonnesofafenster.sendCommand(ON)
				}
				if ((s_hwr.state == CLOSED || (melli.state == OFF && joerg.state == OFF && max.state == OFF && lotte.state == OFF && tom.state == OFF && ben.state == OFF)) && (r_hwr.state < 100 && sonnehwrfenster.state == OFF)) {
		                   r_hwr.sendCommand(DOWN)
		                   sonnehwrfenster.sendCommand(ON)
				}
				if (r_gaeste.state < 100 && sonnegaestefenster.state == OFF) {
				    r_gaeste.sendCommand(DOWN)
        		            sonnegaestefenster.sendCommand(ON)
				}else if (keinerda.state == ON && r_gaeste.state == 100) {
                                    sonnegaestefenster.sendCommand(ON)
                                }
				if (r_treppe.state < 100 && sonnetreppefenster.state == OFF) {
		                   r_treppe.sendCommand(DOWN)
		                   sonnetreppefenster.sendCommand(ON)
				}else if (keinerda.state == ON && r_treppe.state == 100) {
                                    sonnetreppefenster.sendCommand(ON)
                                }
				if (r_buero.state < 100 && sonnebuerofenster.state == OFF) {
				    r_buero.sendCommand(DOWN)
        		            sonnebuerofenster.sendCommand(ON)
				}else if (keinerda.state == ON && r_buero.state == 100) {
        		            sonnebuerofenster.sendCommand(ON)
				}

                                sonnedachostweg.sendCommand(OFF)
				sonneostweg.sendCommand(OFF)
		}

		// sonne runter süden 
		if(lux.state > 4500 && t_aussen.state > 20 && sonnenstand.state < 259) {
//		if((lux.state > 4500 && t_aussen.state > 20 && sonnenstand.state < 259) || (hotday.state == ON && sonnenstand.state > 90 && sonnenstand.state < 259)) {
				if ((s_terrassentuer.state == CLOSED || (melli.state == OFF && joerg.state == OFF && max.state == OFF && lotte.state == OFF && tom.state == OFF && ben.state == OFF)) && (r_terrassentuer.state < 100 && sonnetuerterrasse.state == OFF)) {
				    r_terrassentuer.sendCommand(DOWN)
        		            sonnetuerterrasse.sendCommand(ON)
				}else if (keinerda.state == ON && r_terrassentuer.state == 100) {
                                    sonnetuerterrasse.sendCommand(ON)
                                }
				if (r_sofatuer.state < 100 && sonnesofatuer.state == OFF) {
		                   r_sofatuer.sendCommand(DOWN)
		                   sonnesofatuer.sendCommand(ON)
				}else if (keinerda.state == ON && r_sofatuer.state == 100) {
                                    sonnesofafenster.sendCommand(ON)
                                }
				if (r_tom.state < 100 && sonnetomfenster.state == OFF) {
				    r_tom.sendCommand(DOWN)
        		            sonnetomfenster.sendCommand(ON)
				}else if (keinerda.state == ON && r_tom.state == 100) {
                                    sonnetomfenster.sendCommand(ON)
                                }
				if (r_ben.state < 100 && sonnebenfenster.state == OFF) {
		                   r_ben.sendCommand(DOWN)
		                   sonnebenfenster.sendCommand(ON)
				}else if (keinerda.state == ON && r_ben.state == 100) {
                                    sonnebenfenster.sendCommand(ON)
                                }
				if (r_max.state < 100 && sonnemaxfenster.state == OFF) {
		                   r_max.sendCommand(DOWN)
		                   sonnemaxfenster.sendCommand(ON)
				}else if (keinerda.state == ON && r_max.state == 100) {
                                    sonnemaxfenster.sendCommand(ON)
                                }

				  sonnesuedweg.sendCommand(OFF)
				  sonnedachwestweg.sendCommand(OFF)
		}

Any Ideas ?
Regards
Kobelka

Check new Item types carefully (Units of measurement hint).

Do you have a second hint :blush:
All is defined as number

image
image
image

Regards
Kobelka

No further hint.

Still applies.

I see one Number type Item, one Number:Temperature type, one Number:LuminousIntesity.
These are all different types of Item.
Two of them will have Units of Measurement as part of the Item state.

This doesn’t work with units, because you can’t compare “5000 lux” with “4500” - 4500 what? Lux, candles, supernovae?

I changed all to something like this

if ((((lux.state as Number) < 1000 && (sonnenstand.state as Number) < 170 

and now it works, but this is very laborious…Is this the right way ?

Sure, work with units instead of against them.

if ( (lux.state < 1000 | lux) && (t_aussen.state > 10 | °C) ...

Some handling tips -

All this was introduced in OH2, but more binding channels come with units in OH3

1 Like