Command re-writing, or how I intend to make the fanlink do it right.

The Insteon FanLinc is a pretty slick piece of kit. It sits in the canopy of the fan, it is dual band and it is a dimmer for the light kit and has fan speed control. On the down side, the fan speed control is really designed to be operated from multiple controller groups, like a KeypadLinc with each of the four buttons set to a different speed. Trying to control it from a dimmer is frustrating, you have to watch the fan change speed and stop when you hit the desired speed. The fan being a mechanical device has enough inertia that by the time you notice the speed is right it's actually accelerating toward the next speed.

This is where plcd comes in, the light and fan will be linked as responders to the PLM, the controlling dimmer will also be linked as a controller there will be no direct link between the dimmer and the fan. When the user presses the top of the paddle, plcd will get the 'on' command for the group. It will send out a command (or several commands as the case turns out) to change the fan speed to the next highest speed. The same will happen in reverse for the bottom of the paddle. In the case of using a single keypad button, the button will be turned from "toggle" mode to "always send offs" mode, and when plcd determines the user has clicked the off button and the fan is currently in the fully off it will send out a full on command.

As it is impossible to send discrete dim levels to groups (all you can do is send "resume linked level" commands) it becomes necessary to send multiple "change by one step" commands. There are 32 steps between full on and full off. Fortunately the 4 levels of fan control can be spaced equally in the range 0-100% (0 - off, 33% - slow, 66% - medium, 100% fast) so sending 11 steps (either up or down) will select the next level in sequence. There will be some drift if there are many medium to slow or opposite transitions without going to full on or full off, but going to full on or full off will reset it as the percentage hits the endstop.

This is going to be good!