Search in sources :

Example 1 with SoulissT11

use of org.openhab.binding.souliss.internal.network.typicals.SoulissT11 in project openhab1-addons by openhab.

the class SoulissBinding method receiveCommand.

@Override
public /**
     * Get the souliss's typical from the hash table and send a command
     *
     * @author Tonino Fazio
     * @since 1.7.0
     */
void receiveCommand(String itemName, Command command) {
    // Get the typical defined in the hash table
    SoulissGenericTypical T = SoulissGenericBindingProvider.SoulissTypicalsRecipients.getTypicalFromItem(itemName);
    logger.info("receiveCommand - {} = {} - Typical: 0x{}", itemName, command, Integer.toHexString(T.getType()));
    switch(T.getType()) {
        case Constants.Souliss_T11:
            SoulissT11 T11 = (SoulissT11) T;
            T11.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.toString()));
            break;
        case Constants.Souliss_T12:
            SoulissT12 T12 = (SoulissT12) T;
            if (itemName.equals(T12.getsItemNameAutoModeValue())) {
                T12.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T12_Use_Of_Slot_AUTOMODE + "_" + command.toString()));
            } else if (itemName.equals(T12.getsItemNameSwitchValue())) {
                T12.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T12_Use_Of_Slot_SWITCH + "_" + command.toString()));
            }
            break;
        case Constants.Souliss_T14:
            SoulissT14 T14 = (SoulissT14) T;
            T14.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.toString()));
            break;
        case Constants.Souliss_T18:
            SoulissT18 T18 = (SoulissT18) T;
            T18.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.toString()));
            break;
        case Constants.Souliss_T16:
            SoulissT16 T16 = (SoulissT16) T;
            String cmd = command.getClass().getSimpleName();
            if (cmd.equals(Constants.Openhab_RGB_TYPE)) {
                String[] HSB = command.toString().split(",");
                short[] RGB = HSBtoRGB(Float.parseFloat(HSB[0]), Float.parseFloat(HSB[1]), Float.parseFloat(HSB[2]));
                T16.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.getClass().getSimpleName()), RGB[0], RGB[1], RGB[2]);
            } else {
                T16.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.toString()));
            }
            break;
        case Constants.Souliss_T19:
            SoulissT19 T19 = (SoulissT19) T;
            if (command instanceof PercentType) {
                int percentToShort = (((PercentType) command).shortValue() * 254 / 100);
                T19.commandSEND(Constants.Souliss_T1n_Set, Short.parseShort(String.valueOf(percentToShort)));
            } else if (command instanceof DecimalType) {
                int decimalToShort = (((DecimalType) command).shortValue() * 254 / 100);
                T19.commandSEND(Constants.Souliss_T1n_Set, Short.parseShort(String.valueOf(decimalToShort)));
            } else {
                T19.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.toString()));
            }
            break;
        case Constants.Souliss_T21:
            SoulissT21 T21 = (SoulissT21) T;
            T21.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.toString()));
            break;
        case Constants.Souliss_T22:
            SoulissT22 T22 = (SoulissT22) T;
            T22.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), command.toString()));
            break;
        case Constants.Souliss_T31:
            SoulissT31 T31 = (SoulissT31) T;
            // Setpoint
            if (itemName.equals(T31.getsItemNameSetpointValue())) {
                if (command instanceof DecimalType) {
                    int uu = HalfFloatUtils.fromFloat(((DecimalType) command).floatValue());
                    byte B2 = (byte) (uu >> 8);
                    byte B1 = (byte) uu;
                    // setpoint command
                    T31.CommandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_SETPOINT_COMMAND), B1, B2);
                }
            } else // Set As Measured
            if (itemName.equals(T31.setAsMeasured.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_SETASMEASURED + "_" + command.toString()));
            } else if (itemName.equals(T31.heatingCoolingModeValue.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_HEATING_COOLING + "_" + command.toString()));
            } else if (itemName.equals(T31.fanAutoMode.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_FANAUTOMODE + "_" + command.toString()));
            } else if (itemName.equals(T31.fanOff.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_FANOFF + "_" + command.toString()));
            } else if (itemName.equals(T31.fanLow.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_FANLOW + "_" + command.toString()));
            } else if (itemName.equals(T31.fanMed.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_FANMED + "_" + command.toString()));
            } else if (itemName.equals(T31.fanHigh.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_FANHIGH + "_" + command.toString()));
            } else if (itemName.equals(T31.power.getName())) {
                T31.commandSEND(StateTraslator.commandsOHtoSOULISS(T.getType(), Constants.Souliss_T31_Use_Of_Slot_POWER + "_" + command.toString()));
            }
            break;
        default:
            logger.debug("Typical Unknown");
    }
}
Also used : SoulissT21(org.openhab.binding.souliss.internal.network.typicals.SoulissT21) SoulissT31(org.openhab.binding.souliss.internal.network.typicals.SoulissT31) SoulissT12(org.openhab.binding.souliss.internal.network.typicals.SoulissT12) SoulissT11(org.openhab.binding.souliss.internal.network.typicals.SoulissT11) SoulissT22(org.openhab.binding.souliss.internal.network.typicals.SoulissT22) PercentType(org.openhab.core.library.types.PercentType) SoulissT18(org.openhab.binding.souliss.internal.network.typicals.SoulissT18) DecimalType(org.openhab.core.library.types.DecimalType) SoulissT19(org.openhab.binding.souliss.internal.network.typicals.SoulissT19) SoulissT14(org.openhab.binding.souliss.internal.network.typicals.SoulissT14) SoulissT16(org.openhab.binding.souliss.internal.network.typicals.SoulissT16) SoulissGenericTypical(org.openhab.binding.souliss.internal.network.typicals.SoulissGenericTypical)

Aggregations

SoulissGenericTypical (org.openhab.binding.souliss.internal.network.typicals.SoulissGenericTypical)1 SoulissT11 (org.openhab.binding.souliss.internal.network.typicals.SoulissT11)1 SoulissT12 (org.openhab.binding.souliss.internal.network.typicals.SoulissT12)1 SoulissT14 (org.openhab.binding.souliss.internal.network.typicals.SoulissT14)1 SoulissT16 (org.openhab.binding.souliss.internal.network.typicals.SoulissT16)1 SoulissT18 (org.openhab.binding.souliss.internal.network.typicals.SoulissT18)1 SoulissT19 (org.openhab.binding.souliss.internal.network.typicals.SoulissT19)1 SoulissT21 (org.openhab.binding.souliss.internal.network.typicals.SoulissT21)1 SoulissT22 (org.openhab.binding.souliss.internal.network.typicals.SoulissT22)1 SoulissT31 (org.openhab.binding.souliss.internal.network.typicals.SoulissT31)1 DecimalType (org.openhab.core.library.types.DecimalType)1 PercentType (org.openhab.core.library.types.PercentType)1