2 * Copyright (c) 2010-2021 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.miio.internal.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.miio.internal.basic.MiIoDatabaseWatchService;
17 import org.openhab.binding.miio.internal.cloud.CloudConnector;
18 import org.openhab.core.thing.ChannelUID;
19 import org.openhab.core.thing.Thing;
20 import org.openhab.core.types.Command;
21 import org.openhab.core.types.RefreshType;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * The {@link MiIoGenericHandler} is responsible for handling commands for devices that are not yet defined.
27 * Once the device has been determined, the proper handler is loaded.
29 * @author Marcel Verpaalen - Initial contribution
32 public class MiIoGenericHandler extends MiIoAbstractHandler {
33 private final Logger logger = LoggerFactory.getLogger(MiIoGenericHandler.class);
35 public MiIoGenericHandler(Thing thing, MiIoDatabaseWatchService miIoDatabaseWatchService,
36 CloudConnector cloudConnector) {
37 super(thing, miIoDatabaseWatchService, cloudConnector);
41 public void handleCommand(ChannelUID channelUID, Command command) {
42 if (command == RefreshType.REFRESH) {
43 logger.debug("Refreshing {}", channelUID);
47 if (handleCommandsChannels(channelUID, command)) {
53 protected synchronized void updateData() {
57 logger.debug("Periodic update for '{}' ({})", getThing().getUID().toString(), getThing().getThingTypeUID());
60 } catch (Exception e) {
61 logger.debug("Error while updating '{}'", getThing().getUID().toString(), e);