<commit_before>/**
 * Copyright (c) 2010-2015, openHAB.org and others.
 *
 * 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.zwave.internal.converter;

import java.util.Map;

import org.openhab.binding.zwave.internal.converter.state.BinaryDecimalTypeConverter;
import org.openhab.binding.zwave.internal.converter.state.IntegerOnOffTypeConverter;
import org.openhab.binding.zwave.internal.converter.state.IntegerOpenClosedTypeConverter;
import org.openhab.binding.zwave.internal.converter.state.ZWaveStateConverter;
import org.openhab.binding.zwave.internal.protocol.ZWaveController;
import org.openhab.binding.zwave.internal.protocol.ZWaveNode;
import org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveBasicCommandClass;
import org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent;
import org.openhab.core.events.EventPublisher;
import org.openhab.core.items.Item;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * ZWaveSceneConverter class. Converters between binding items
 * and the Z-Wave API for scene controllers.
 * @author <NAME>
 * @since 1.4.0
 */
public class ZWaveSceneConverter extends ZWaveCommandClassConverter<ZWaveBasicCommandClass> {

	private static final Logger logger = LoggerFactory.getLogger(ZWaveSceneConverter.class);

	/**
	 * Constructor. Creates a new instance of the {@link ZWaveConverterBase}
	 * class.
	 * @param controller the {@link ZWaveController} to use to send messages.
	 * @param eventPublisher the {@link EventPublisher} that can be used to send updates.
	 */
	public ZWaveSceneConverter(ZWaveController controller, EventPublisher eventPublisher) {
		super(controller, eventPublisher);
        
		// State converters used by this converter. 
		this.addStateConverter(new BinaryDecimalTypeConverter());
		this.addStateConverter(new IntegerOnOffTypeConverter());
		this.addStateConverter(new IntegerOpenClosedTypeConverter());
    }

	/**
	 * {@inheritDoc}
	 */
	@Override
	int getRefreshInterval() {
		return 0;
	}

	@Override
	void executeRefresh(ZWaveNode node, ZWaveBasicCommandClass commandClass, int endpointId,
			Map<String, String> arguments) {
	}

	@Override
	void handleEvent(ZWaveCommandClassValueEvent event, Item item, Map<String, String> arguments) {
		if(arguments.get("scene")==null)
			return;
		
		int scene = Integer.parseInt(arguments.get("scene"));
		if(scene != (Integer)event.getValue())
			return;
		Integer state = Integer.parseInt(arguments.get("state"));
		ZWaveStateConverter<?,?> converter = this.getStateConverter(item, state);
 
		if (converter == null) {
			logger.warn("No converter found for item = {}, node = {} endpoint = {}, ignoring event.", item.getName(), event.getNodeId(), event.getEndpoint());
			return;
		}
		
		State itemState = converter.convertFromValueToState(event.getValue());
		this.getEventPublisher().postUpdate(item.getName(), itemState);
	}

	@Override
	void receiveCommand(Item item, Command command, ZWaveNode node, ZWaveBasicCommandClass commandClass,
			int endpointId, Map<String, String> arguments) {
	}
}<commit_msg>Changed CommandClass-type<commit_after>/**
 * Copyright (c) 2010-2015, openHAB.org and others.
 *
 * 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.zwave.internal.converter;

import java.util.Map;

import org.openhab.binding.zwave.internal.converter.state.BinaryDecimalTypeConverter;
import org.openhab.binding.zwave.internal.converter.state.IntegerOnOffTypeConverter;
import org.openhab.binding.zwave.internal.converter.state.IntegerOpenClosedTypeConverter;
import org.openhab.binding.zwave.internal.converter.state.ZWaveStateConverter;
import org.openhab.binding.zwave.internal.protocol.ZWaveController;
import org.openhab.binding.zwave.internal.protocol.ZWaveNode;
import org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveSceneActivationCommandClass;
import org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent;
import org.openhab.core.events.EventPublisher;
import org.openhab.core.items.Item;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * ZWaveSceneConverter class. Converters between binding items
 * and the Z-Wave API for scene controllers.
 * @author <NAME>
 * @since 1.4.0
 */
public class ZWaveSceneConverter extends ZWaveCommandClassConverter<ZWaveSceneActivationCommandClass> {

	private static final Logger logger = LoggerFactory.getLogger(ZWaveSceneConverter.class);

	/**
	 * Constructor. Creates a new instance of the {@link ZWaveConverterBase}
	 * class.
	 * @param controller the {@link ZWaveController} to use to send messages.
	 * @param eventPublisher the {@link EventPublisher} that can be used to send updates.
	 */
	public ZWaveSceneConverter(ZWaveController controller, EventPublisher eventPublisher) {
		super(controller, eventPublisher);

		// State converters used by this converter.
		this.addStateConverter(new BinaryDecimalTypeConverter());
		this.addStateConverter(new IntegerOnOffTypeConverter());
		this.addStateConverter(new IntegerOpenClosedTypeConverter());
    }

	/**
	 * {@inheritDoc}
	 */
	@Override
	int getRefreshInterval() {
		return 0;
	}

	@Override
	void executeRefresh(ZWaveNode node, ZWaveSceneActivationCommandClass commandClass, int endpointId,
			Map<String, String> arguments) {
	}

	@Override
	void handleEvent(ZWaveCommandClassValueEvent event, Item item, Map<String, String> arguments) {
		if(arguments.get("scene")==null)
			return;

		int scene = Integer.parseInt(arguments.get("scene"));
		if(scene != (Integer)event.getValue())
			return;
		Integer state = Integer.parseInt(arguments.get("state"));
		ZWaveStateConverter<?,?> converter = this.getStateConverter(item, state);

		if (converter == null) {
			logger.warn("No converter found for item = {}, node = {} endpoint = {}, ignoring event.", item.getName(), event.getNodeId(), event.getEndpoint());
			return;
		}

		State itemState = converter.convertFromValueToState(event.getValue());
		this.getEventPublisher().postUpdate(item.getName(), itemState);
	}

	@Override
	void receiveCommand(Item item, Command command, ZWaveNode node, ZWaveSceneActivationCommandClass commandClass,
			int endpointId, Map<String, String> arguments) {
	}
}
{'fraction_non_alphanumeric': 0.10831122900088418, 'fraction_numerical': 0.005305039787798408, 'mean_word_length': 5.457659372026641, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5837868', 'n_tokens_mistral': 2116, 'n_tokens_neox': 1918, 'n_words': 451}