2 * Copyright (c) 2010-2023 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.i18n.LocaleProvider;
19 import org.openhab.core.i18n.TranslationProvider;
20 import org.openhab.core.thing.ChannelUID;
21 import org.openhab.core.thing.Thing;
22 import org.openhab.core.types.Command;
23 import org.openhab.core.types.RefreshType;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * The {@link MiIoGenericHandler} is responsible for handling commands for devices that are not yet defined.
29 * Once the device has been determined, the proper handler is loaded.
31 * @author Marcel Verpaalen - Initial contribution
34 public class MiIoGenericHandler extends MiIoAbstractHandler {
35 private final Logger logger = LoggerFactory.getLogger(MiIoGenericHandler.class);
37 public MiIoGenericHandler(Thing thing, MiIoDatabaseWatchService miIoDatabaseWatchService,
38 CloudConnector cloudConnector, TranslationProvider i18nProvider, LocaleProvider localeProvider) {
39 super(thing, miIoDatabaseWatchService, cloudConnector, i18nProvider, localeProvider);
43 public void handleCommand(ChannelUID channelUID, Command command) {
44 if (command == RefreshType.REFRESH) {
45 logger.debug("Refreshing {}", channelUID);
49 if (handleCommandsChannels(channelUID, command)) {
55 protected synchronized void updateData() {
59 logger.debug("Periodic update for '{}' ({})", getThing().getUID().toString(), getThing().getThingTypeUID());
62 } catch (Exception e) {
63 logger.debug("Error while updating '{}'", getThing().getUID().toString(), e);