Compare Numbers in a Rule for Fibaro Dimmer2

Hey,
I am quite new to openhab so excuse my basic issues.
Here is what I try to achieve:
I own a Fibaro Dimmer 2 which controls bathroom lights. I want to use the Switch (s1 and s2) to also control other items.
I managed to get an uptade in openhab when the switch is triggerede by activating Scenes.

rule "test scene"
when
	Item zwave_device_zwave_usb_node4_scene_number received update 16 
then
	logInfo("File", "Bad Licht geschaltet")
end

My log shows that the switch was triggered. Additionaly I would like to know if it was triggered ON or OFF. My approach is to take the dimmer state which is updated. Naturally it increases from 0 to a value between 1 and 100 when turned on and vice versa.

zwave_device_zwave_usb_node4_switch_dimmer changed from 18 to 0

So how can I define in a rule that if the value for item

zwave_device_zwave_usb_node4_switch_dimmer

increased or decreased?

Thanks for your patience and help

Different clicks result in different scene numbers, why don’t you directly trigger on those?

https://manuals.fibaro.com/dimmer-2/

1

if you want to determine if it decreases or increases you have to work with persistence I guess, an easy way would be something like this tough:

rule "whatever"
when
    zwave_device_zwave_usb_node4_switch_dimmer changed
then
   if (zwave_device_zwave_usb_node4_switch_dimmer.state == "0") 
    {
    }
   else 
   {
   }
end

put whatever you want to achieve into the curly brackets, you could do another else if statement as well.

If you just want to “mirror” the state to another dimmer, this should do the trick:

rule "whatever"
when
    zwave_device_zwave_usb_node4_switch_dimmer changed
then
    <itemToControl>.sendCommand(zwave_device_zwave_usb_node4_switch_dimmer.state)
end
1 Like

Hi. That’s indeed a good idea. However I do have a momentary switch so switching off and on will both be Scene 16 according to the table.

Thanks to @Nicolas, your idea helped me out. It was just slightly wrong syntax. Coding it like this worked like a charm:

rule "test scene"
when
	Item zwave_device_zwave_usb_node4_scene_number received update 16 //or whatever numbers your device is creating
 
then
 	if (zwave_device_zwave_usb_node4_switch_dimmer.state==0)
 	{
 	logInfo("File", "Bad Licht AN geschaltet")
	}
	else
	{ 	logInfo("File", "Bad Licht AUS geschaltet")
	}	
	
end

At least now I get the correct entries in my logfile.

The general goal I would like to achieve is the following:
I want the Dimmer to act depending on when it is pressed.
If I use the momentary switch at night it shall turn on at Dimmer=20%
If I use it in the morning it shall turn on at Dimmer=20% and slowly increase to 100%.
If used during the day it shall just turn on at 100%.

To me that seems super complex but I am persistent and positive to eventually achieve this.
Help is of course appreciated.

1 Like

I’m glad it worked.
I have not enough knowledge about the swave switch, but I assume, you can set the “default” brightness in the zwave config?

Then you could change it between 20 and 100% using smth like this:

and in the evening you add another rule that slowly increases it…

On the switch_dimmer channel you will have ON and OFF, on the scene_number channel you will have the numbers according to the table.

@sihui

switch_dimmer

unfortunately did not work.
The following rule did not return anything.

when
Channel 'zwave:device:zwave_usb:node4:switch_dimmer' triggered ON
then 
logInfo("File", "Bad Licht AN geschaltet")

end

You need to trigger on the item, not the channel. See your first post.

when
Item your_item_name changed to ON
then

or

when
Item your_item_name received update ON
then

Hi @sihui - you’re right I mixed that up.
However

rule "test Scene"
when
Item zwave_device_zwave_usb_node4_switch_dimmer changed to ON
then 
logInfo("File", "Bad Licht AN geschaltet")

end

does not work. There is no output. Also the log file only states:

2018-01-21 19:37:53.142 [vent.ItemStateChangedEvent] - zwave_serial_zstick_zwave_usb_serial_sof changed from 6213 to 6214

2018-01-21 19:37:53.206 [vent.ItemStateChangedEvent] - zwave_serial_zstick_zwave_usb_serial_sof changed from 6214 to 6215

2018-01-21 19:37:53.224 [vent.ItemStateChangedEvent] - zwave_device_zwave_usb_node4_switch_dimmer changed from 40 to 0

2018-01-21 19:37:53.243 [vent.ItemStateChangedEvent] - zwave_serial_zstick_zwave_usb_serial_sof changed from 6215 to 6216

2018-01-21 19:37:53.533 [vent.ItemStateChangedEvent] - zwave_serial_zstick_zwave_usb_serial_sof changed from 6216 to 6217

2018-01-21 19:37:54.078 [vent.ItemStateChangedEvent] - zwave_serial_zstick_zwave_usb_serial_sof changed from 6217 to 6218

2018-01-21 19:37:54.092 [vent.ItemStateChangedEvent] - zwave_device_zwave_usb_node4_sensor_power changed from 176.1 to 84.6

2018-01-21 19:37:54.751 [vent.ItemStateChangedEvent] - zwave_serial_zstick_zwave_usb_serial_sof changed from 6218 to 6219

2018-01-21 19:37:54.814 [vent.ItemStateChangedEvent] - zwave_serial_zstick_zwave_usb_serial_sof changed from 6219 to 6220

So the only comparable change I find is *dimmer change to 0 instead of change to OFF

Sorry, no idea. For me this config works fine:

Switch FibFGD212_1_Sw (gRestore) { channel="zwave:device:15ca6a108b9:node37:switch_dimmer" }
Dimmer FibFGD212_1_Dim (gRestore) { channel="zwave:device:15ca6a108b9:node37:switch_dimmer" }
Number FibFGD212_1_Num (gRestore) { channel="zwave:device:15ca6a108b9:node37:scene_number" }

2018-01-21 19:38:19.010 [ome.event.ItemCommandEvent] - Item 'FibFGD212_1_Sw' received command OFF
2018-01-21 19:38:19.026 [vent.ItemStateChangedEvent] - FibFGD212_1_Sw changed from ON to OFF
2018-01-21 19:38:21.680 [ome.event.ItemCommandEvent] - Item 'FibFGD212_1_Dim' received command 0
2018-01-21 19:38:21.695 [vent.ItemStateChangedEvent] - FibFGD212_1_Dim changed from 100 to 0

maybe I need to add the switch to a .things file. I only added the dimmer2 through paper UI. I will try tomorrow.

No, you need to link the switch_dimmer channel to a switch item and a dimmer item:

1 Like

Oh my!!! Awesome. It actually works. Thanks for that enlightening screenshot! I need to study up on Channels, Things, items and links…

1 Like

Hey, I have several FGD212 dimmers with firmware 3.5 but the ‘Scene number’ channel is not showing up in the paper UI. I’ve tried adding it manually (using the scene_number property) but that does not seem to work. Configuration 28 (Scene activation functionality) is enabled. Any ideas?

Here ist what worked for me:

  1. Make sure your FGD212 is properly included (shows up in things on PaperUI and Habmin).
  2. in HABmin and not in PaperUI (Error500) activate scenes in Configuration (28). Make sure to do this in Habmin.
  3. In Associations link 1 to openhab. Delete all other Associations.
  4. in your itemsfile you should add the Following item:
Number myzwavedevice_scene    "Scene Number"           (group)    {channel="yourzwavedevice:scene_number"}
  //myzwavedevice_scene will be the name of your item. The name of your channel will be found in your PaperUI in your FGD212 Thing

Now you can add:

Default item=myzwavedevice_scene 

to your sitemap and you should be good to go.

For Fibaro dimmers, relays etc you have to open Things and Items in HABmin in order to access all channels and to set properly. PaperUI display limited options only; it’s not usefull if you have Fibaro products.

Thanks! Followed all suggestions above, seems to work fine now.