public static Object BuildPackage(NexaLampDevice device, float level) { int command = device.Group ? 3 : 0; var dimmable = device.Dimmable; if (level == 1.0f && !dimmable) { command += 1; // Switch it on } else if (level > 0.0f) { command += 2; // Dim it } // Else turn it off. // Convert level to 0-15 level = level * 15.0f; LIGHTING2 package = new LIGHTING2(LIGHTING2.SUBTYPE_AC); package.id1 = (byte)((device.Address >> 24) & 0xFF); package.id2 = (byte)((device.Address >> 16) & 0xFF); package.id3 = (byte)((device.Address >> 8) & 0xFF); package.id4 = (byte)(device.Address & 0xFF); package.unitcode = (byte)(device.Unit + 1); // RfxTrx433 uses a 1-based unit package.cmnd = (byte)command; package.level = (byte)level; return(package); }
public static Object BuildPackage(NexaLampDevice device, float level) { int command = device.Group ? 3 : 0; var dimmable = device.Dimmable; if (level == 1.0f && !dimmable) command += 1; // Switch it on else if (level > 0.0f) command += 2; // Dim it // Else turn it off. // Convert level to 0-15 level = level * 15.0f; LIGHTING2 package = new LIGHTING2(LIGHTING2.SUBTYPE_AC); package.id1 = (byte)((device.Address >> 24) & 0xFF); package.id2 = (byte)((device.Address >> 16) & 0xFF); package.id3 = (byte)((device.Address >> 8) & 0xFF); package.id4 = (byte)(device.Address & 0xFF); package.unitcode = (byte)(device.Unit + 1); // RfxTrx433 uses a 1-based unit package.cmnd = (byte)command; package.level = (byte)level; return package; }