]> git.basschouten.com Git - openhab-addons.git/blob
476e1cdbd4891ff2d43bcf96e00c6cc170ea2f12
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.nibeuplink.internal.handler;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.nibeuplink.internal.command.GenericStatusUpdate;
17 import org.openhab.binding.nibeuplink.internal.command.NibeUplinkCommand;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Polling worker class. This is responsible for periodic polling of status values.
23  *
24  * @author Alexander Friese - initial contribution
25  */
26 @NonNullByDefault
27 public class UplinkPolling implements Runnable {
28     private final Logger logger = LoggerFactory.getLogger(getClass());
29
30     /**
31      * Handler for delegation to callbacks.
32      */
33     private final NibeUplinkHandler handler;
34
35     /**
36      * Constructor.
37      *
38      * @param handler instance of the thing handler
39      */
40     public UplinkPolling(NibeUplinkHandler handler) {
41         this.handler = handler;
42     }
43
44     /**
45      * Poll the Nibe Uplink webservice one time.
46      */
47     @Override
48     public void run() {
49         logger.debug("polling NibeUplink {}", handler.getConfiguration());
50
51         NibeUplinkCommand command = new GenericStatusUpdate(handler);
52         handler.getWebInterface().enqueueCommand(command);
53     }
54 }