Store value from a dimmer to local var?

Hello Guys.
I’m trying to “store” the old value of a dimmer, before i dim up when movement is detected…
In the rule file i define a “var mem_light”

in the beginning of the rule i try to store the actual value of the dimmer to this value:
“mem_light = outside_dimmer.state” but the compiler wouldn’t allow it… I’ve also tested with the as DecimalType but still no success…
The outside_dimmer is defined in the items as a “Dimmer”

Please post your actual code.

There is no compiler so I’m confused as to what it is that doesn’t allow it. It is unclear if the var is a global or local to a rule/ Dimmer is a reserved word, you should use a more descriptive name for your Items.

Yes ok… I’ll try to explain a bit better…
In my items file I have:

Dimmer light_outside

Then in my rule file

Var men_light

Rule "outside light"
If motion_detected
     mem_light = light_outside.state
     sendCommand(light_outside, 100)

Then I wanna store the value from the dimmer before I set it to 100, so after a time I can revert to the value before :slight_smile:

If that is a literal writing your Rules file rather than pseudocode, I recommend reviewing the Rules wiki page as that code is syntactically incorrect.

Case matters, there is no such thing as “Var”, “Rule”, or “If” .They are var, rule, and if.

A rule must follow the format described on that wiki page with a rule, when, then and end. There must be a triggering event defined inbetween the when and the then.

Hello… Yes i know - was just porsted from my iPhone - seems like it has changed the words… Anyway, here’s my actual code:
Item file:

Dimmer	Spots_Outside_Entreance	"Spot i Indhakket"								<switch>		(Garden

The Rule file:

var mem_outside_light

rule "Udvendigt Lys Nord (Bevægelse)"
	when
        Item PIR_Entrance changed
	then
		mem_outside_light = Spots_Outside_Entreance.state
		if (Lux_Outside_South.state < (Lux_Setpoint_North.state as DecimalType)) 
			{
				sendCommand(Spots_Outside_Entreance, 50)
				sendCommand(CUBE_Outside_North, ON)
				logInfo("Outside", "Lys tændt på bevægelse")
				
				if (presence_north_timer == null)
					{
					presence_north_timer = createTimer(now.plusMinutes(5), [|
						logInfo("Outside", "Lys slukket efter timeout på bevægelse")
						sendCommand(Spots_Outside_Entreance, 0)
						sendCommand(CUBE_Outside_North, OFF)
					])
					}	
			}
			
end		

The smarthome designer doesn’t like the following, where i wanna store the actual value from the dimmer before the rule does anything…

mem_outside_light = Spots_Outside_Entreance.state

For the past 25-20 days there has been an open issue on Designer where it no longer recognizes Items and Actions. Double check that you don’t have a typo in the Item name for Spots_Outside_Entreance and run it to see if it works. If it doesn’t run, come back and tell us what the error is as reported by Designer and in your logs.

Seems like it works… :slight_smile: - even when the designer says something is wrong …