[RELEASE] Fibaro Dimmer 2 (FGD-212) - Advanced DTH (V2)

Been playing around with this DTH to make it work better for my needs (and also improve my knowledge), so I thought I’d share what I’ve done.

Background: I’m using the S2 as a separate switch to control a smart light, and while it’s okay to hook into it from WebCore, I’d prefer to keep my simple light rules in the Smart Lighting app.

So…

  1. Add a ‘button’ capability to the top of the DTH - this is because Smart Lighting will only handle one Switch (to my knowledge) on a device
  2. Add a config line to set number of buttons to 2
  3. In the SceneActivation command section (around 560), add a switch on the sceneId to better capture the cases I’m looking at (20 and 21 at the moment)
  4. Add in createEvent(name: 'button', value: 'pushed', data: [buttonNumber: 1], isStateChange, true) for on, [buttonNumber:2] for off

At this point I’ve successfully exposed two buttons which can be used in Smart Lighting (If Fibaro Button 1 pushed, turn light on; if Fibaro Button 2 pushed, turn light off). These will be triggered by physically switching the switch connected to S2 on and off

Great! Now to add some easy app control:

  1. add a couple of commands called “sw2on” and “sw2off”
  2. add a new tile called “switch2” with two actions: sw2on and sw2off again
  3. define the two commands to send the same button pushed command as above
  4. Alongside all the new createEvent lines add some code which sets the value of “switch2” to “on” or “off” as well.

I’ve now got a second switch tile which toggles my second light!

I don’t know if I can make the second tile only appear if other settings are in a state where S2 is being used as a second switch (ie 20: 0 or 1, 26: 0, 28: 1). I’m also not yet looking at supporting momentary switches (because I haven’t rewired them yet) but it should be fairly easy to include them in the SceneActivation section above.

I’d be happy to share the code with anyone who’s interested. I’m not posting it here yet because it’s not at all tidy.

2 Likes