Aeotec G2 Dimmer odd behavior

I have to get a rule example and the event log when this happens.

Prior to that, I thought I’d ask the question and see if anyone knows what’s happening

I have a few Z-Wave Aeotec G2 Dimmers that I’d like to modify their brightness according to the current light level.
I’d like this control to happen even when switch from the wall switch connected to the aeotec.

so a rule would go something like

when kitchen_switch changes from OFF to ON
if ( light level > 100 ) //set full brightness
kitchen_dimmer.sendCommand(100)
if (light level <100 && >20 ) //set some medium brightness
kitchen_dimmer.sendCommand(60)

you get the idea. so all that goes off fine but what i see in the event log is something like this

kitchen switch changed from off to on
kitchen dimmer set to 60 (via rule)
kitchen dimmer set to 30 (previous value, prior to the rule. happens right after the rule adjusts the dimmer)
and now the dimmer will be at 30 instead of 60

if i change the trigger of the rule to the dimmer instead of the switch the rule will fight the switch it’ll go from 30 to 60 60 to 30 but the dimmer stops listening and stays at 30.

i’ve tried a delay of a few seconds and its like the dimmer waits until the rule fires to revert to 30. it thwarts my every attempt to set it.

Now, i can set the dimmer to 30 straight away in a rule instead of dealing with the switch side of things but I’d like this to work via the wall switch if possible. i hope this all makes sense.
This happens regardless of whether i set the z-wave option of the switch to go to full brightness or last brightness when switched on.

Have you tried postUpdate instead of sendCommand? Using postUpdate may trigger additional events that lead to other rules being triggered etc. See
https://docs.openhab.org/configuration/rules-dsl.html#manipulating-item-states

no, i haven’t. thanks, i’ll try that.

Turns out I was using postUpdate
rule:

rule "Foyer Dim at Night"
when
	Item Foyer_Switch changed from OFF to ON
then
	var Number FDHour = now.getHourOfDay
	if ( (FDHour >= 19) || (FDHour <=7) ) {
		//Thread::sleep(3000)
		Foyer_Dimmer.postUpdate(30)
	}
end

resulting log:

2018-01-11 20:18:25.943 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 0 to 100
2018-01-11 20:18:25.944 [ItemStateChangedEvent     ] - Foyer_Switch changed from OFF to ON
2018-01-11 20:18:25.946 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 100 to 30
2018-01-11 20:18:25.980 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 30 to 100

its like it fights any changes until it settles down

any ideas?

I think the logic is that… line #1) Someone sets the dimmer to 100 with also #2) triggers a changed state of the switch from OFF to ON and #3) the rule is triggered, setting the dimmer value to 30. What I do not understand is the last log entry changing from 100 to 30. Do you have an other rule that could be triggered resulting in this happening? If so, post both rules and I can have a look.

If you like to do your own debugging, I always find it helpful to make log entries in my rules so I can follow what is happening in the openhab.log file. You could gain some more insight by using logInfo at several points in your rules code.

logInfo("Rule Foyer Dim at Night","Rule triggered.... about to check time")
loginfo("Rule Foyer Dim at Night","Yes, it is between 7 and 19 hours past midnight... setting dimmer to 30")

Anyway, why do you have both a switch and a dimmer for what looks like the same device? It could be a perfectly good reason, but a dimmer also responds to OnOff commands like a switch.

It’s not a perfectly good reason. I’m still “new” to openhab (feb '17) and I didn’t get any of these Aeotec things until recently so that rule was something I wrote a couple months ago. It didn’t work then so I just left it alone while I worked on other things.

Now I’d like to revisit it and get it working. I’ll modify it tonight to just the dimmer and see if I can’t get it to work that way.

I have no other rules affecting it. The change from 30->100 seems to be coming from the aeotec itself.

Rule changed:

rule "Foyer Dim at Night"
when
	Item Foyer_Dimmer changed from 0
then
	var Number FDHour = now.getHourOfDay
	if ( (FDHour >= 19) || (FDHour <=7) ) {
		//Thread::sleep(3000)
		Foyer_Dimmer.postUpdate(30)
	}
end

resulting log:

2018-01-12 21:23:53.445 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 0 to 75
2018-01-12 21:23:53.447 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 75 to 30
2018-01-12 21:23:53.482 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 30 to 75

If I uncomment the 3 second sleep i get this in the log:

2018-01-12 21:24:14.487 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 0 to 75
2018-01-12 21:24:17.780 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 75 to 30
2018-01-12 21:24:26.868 [ItemStateChangedEvent     ] - Foyer_Dimmer changed from 30 to 0

which would seem to work except the switch seems to ignore the 75->30 (probably happens too fast, like it’ll only accept a command every few seconds)

the 30->0 is me turning the physical switch back off

It seams like you are right with respect to command not being picked up by the HW when sent without a delay, However, I do not think this has anything to do with OpenHAB core or binding. Alas, I have no experience with Z-wave products so I am not able to help you debug that. Good luck searching the forums

Since upgrading to oh2.2 this is working now.