<commit_before>/**
 * Copyright (c) 2010-2017 by the respective copyright holders.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.openhab.binding.rfxcom.internal.messages;

import java.util.Arrays;
import java.util.List;

import org.eclipse.smarthome.core.library.items.NumberItem;
import org.eclipse.smarthome.core.library.items.RollershutterItem;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.OpenClosedType;
import org.eclipse.smarthome.core.library.types.StopMoveType;
import org.eclipse.smarthome.core.library.types.UpDownType;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.Type;
import org.eclipse.smarthome.core.types.UnDefType;
import org.openhab.binding.rfxcom.RFXComValueSelector;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;

/**
 * RFXCOM data class for RFY (Somfy RTS) message.
 *
 * @author <NAME> - Initial contribution
 * @author <NAME> - Ported from OpenHAB1
 * @author <NAME> - Added venetian support and sun+wind detector
 */
public class RFXComRfyMessage extends RFXComBaseMessage {

    public enum Commands {
        STOP(0x00),
        UP(0x01),
        DOWN(0x03),
        PROGRAM(0x07),
        UP_SHORT(0x0F),
        DOWN_SHORT(0x10),
        UP_LONG(0x11),
        DOWN_LONG(0x12),
        ENABLE_SUN_WIND_DETECTOR(0x13),
        DISABLE_SUN_DETECTOR(0x14);

        private final int command;

        Commands(int command) {
            this.command = command;
        }

        public byte toByte() {
            return (byte) command;
        }

        public static Commands fromByte(int input) throws RFXComUnsupportedValueException {
            for (Commands c : Commands.values()) {
                if (c.command == input) {
                    return c;
                }
            }

            throw new RFXComUnsupportedValueException(Commands.class, input);
        }
    }

    public enum SubType {
        RFY(0),
        RFY_EXT(1),
        RESERVED(2),
        ASA(3);

        private final int subType;

        SubType(int subType) {
            this.subType = subType;
        }

        public byte toByte() {
            return (byte) subType;
        }

        public static SubType fromByte(int input) throws RFXComUnsupportedValueException {
            for (SubType c : SubType.values()) {
                if (c.subType == input) {
                    return c;
                }
            }

            throw new RFXComUnsupportedValueException(SubType.class, input);
        }
    }

    private static final List<RFXComValueSelector> SUPPORTED_INPUT_VALUE_SELECTORS = Arrays
            .asList(RFXComValueSelector.SIGNAL_LEVEL, RFXComValueSelector.COMMAND);

    private static final List<RFXComValueSelector> SUPPORTED_OUTPUT_VALUE_SELECTORS = Arrays
            .asList(RFXComValueSelector.SHUTTER);

    private boolean sunDetector;

    public SubType subType;
    public int unitId;
    public byte unitCode;
    public Commands command;
    public byte signalLevel; // maximum 0xF

    public RFXComRfyMessage() {
        packetType = PacketType.RFY;

    }

    public RFXComRfyMessage(byte[] data) throws RFXComException {

        encodeMessage(data);
    }

    @Override
    public String toString() {
        return super.toString()
            + ", Sub type = " + subType
            + ", Unit Id = " + getDeviceId()
            + ", Unit Code = " + unitCode
            + ", Command = " + command
            + ", Signal level = " + signalLevel;
    }
<commit_msg>[RFXCOM] Allow Rfy things to send on venetian blind channels. (#2689)<commit_after>/**
 * Copyright (c) 2010-2017 by the respective copyright holders.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.openhab.binding.rfxcom.internal.messages;

import java.util.Arrays;
import java.util.List;

import org.eclipse.smarthome.core.library.items.NumberItem;
import org.eclipse.smarthome.core.library.items.RollershutterItem;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.OpenClosedType;
import org.eclipse.smarthome.core.library.types.StopMoveType;
import org.eclipse.smarthome.core.library.types.UpDownType;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.Type;
import org.eclipse.smarthome.core.types.UnDefType;
import org.openhab.binding.rfxcom.RFXComValueSelector;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;

/**
 * RFXCOM data class for RFY (Somfy RTS) message.
 *
 * @author <NAME> - Initial contribution
 * @author <NAME> - Ported from OpenHAB1
 * @author <NAME> - Added venetian support and sun+wind detector
 */
public class RFXComRfyMessage extends RFXComBaseMessage {

    public enum Commands {
        STOP(0x00),
        UP(0x01),
        DOWN(0x03),
        PROGRAM(0x07),
        UP_SHORT(0x0F),
        DOWN_SHORT(0x10),
        UP_LONG(0x11),
        DOWN_LONG(0x12),
        ENABLE_SUN_WIND_DETECTOR(0x13),
        DISABLE_SUN_DETECTOR(0x14);

        private final int command;

        Commands(int command) {
            this.command = command;
        }

        public byte toByte() {
            return (byte) command;
        }

        public static Commands fromByte(int input) throws RFXComUnsupportedValueException {
            for (Commands c : Commands.values()) {
                if (c.command == input) {
                    return c;
                }
            }

            throw new RFXComUnsupportedValueException(Commands.class, input);
        }
    }

    public enum SubType {
        RFY(0),
        RFY_EXT(1),
        RESERVED(2),
        ASA(3);

        private final int subType;

        SubType(int subType) {
            this.subType = subType;
        }

        public byte toByte() {
            return (byte) subType;
        }

        public static SubType fromByte(int input) throws RFXComUnsupportedValueException {
            for (SubType c : SubType.values()) {
                if (c.subType == input) {
                    return c;
                }
            }

            throw new RFXComUnsupportedValueException(SubType.class, input);
        }
    }

    private static final List<RFXComValueSelector> SUPPORTED_INPUT_VALUE_SELECTORS = Arrays
            .asList(RFXComValueSelector.SIGNAL_LEVEL, RFXComValueSelector.COMMAND);

    private static final List<RFXComValueSelector> SUPPORTED_OUTPUT_VALUE_SELECTORS = Arrays
            .asList(RFXComValueSelector.SHUTTER, RFXComValueSelector.VENETIAN_BLIND);

    private boolean sunDetector;

    public SubType subType;
    public int unitId;
    public byte unitCode;
    public Commands command;
    public byte signalLevel; // maximum 0xF

    public RFXComRfyMessage() {
        packetType = PacketType.RFY;

    }

    public RFXComRfyMessage(byte[] data) throws RFXComException {

        encodeMessage(data);
    }

    @Override
    public String toString() {
        return super.toString()
            + ", Sub type = " + subType
            + ", Unit Id = " + getDeviceId()
            + ", Unit Code = " + unitCode
            + ", Command = " + command
            + ", Signal level = " + signalLevel;
    }

{'fraction_non_alphanumeric': 0.09241005421389847, 'fraction_numerical': 0.012074913750616067, 'mean_word_length': 2.5600877192982456, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7397869', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2400, 'n_words': 523}