#set( $dt = $package.getClass().forName("java.util.Date").newInstance() ) #set( $year = $dt.getYear() + 1900 ) /** * Copyright (c) 2010-${year} 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 ${package}.handler; import static ${package}.${bindingIdCamelCase}BindingConstants.*; import org.eclipse.smarthome.core.thing.ChannelUID; import org.eclipse.smarthome.core.thing.Thing; import org.eclipse.smarthome.core.thing.ThingStatus; import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; import org.eclipse.smarthome.core.types.Command; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * The {@link ${bindingIdCamelCase}Handler} is responsible for handling commands, which are * sent to one of the channels. * * @author ${author} - Initial contribution */ public class ${bindingIdCamelCase}Handler extends BaseThingHandler { private final Logger logger = LoggerFactory.getLogger(${bindingIdCamelCase}Handler.class); public ${bindingIdCamelCase}Handler(Thing thing) { super(thing); } @Override public void handleCommand(ChannelUID channelUID, Command command) { if (channelUID.getId().equals(CHANNEL_1)) { // TODO: handle command // Note: if communication with thing fails for some reason, // indicate that by setting the status with detail information // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, // "Could not control device at IP address x.x.x.x"); } } @Override public void initialize() { // TODO: Initialize the thing. If done set status to ONLINE to indicate proper working. // Long running initialization should be done asynchronously in background. updateStatus(ThingStatus.ONLINE); // Note: When initialization can NOT be done set the status with more details for further // analysis. See also class ThingStatusDetail for all available status details. // Add a description to give user information to understand why thing does not work // as expected. E.g. // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, // "Can not access device as username and/or password are invalid"); } }