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.solaredge.internal.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.solaredge.internal.command.LiveDataUpdateMeterless;
17 import org.openhab.binding.solaredge.internal.command.LiveDataUpdatePrivateApi;
18 import org.openhab.binding.solaredge.internal.command.LiveDataUpdatePublicApi;
19 import org.openhab.binding.solaredge.internal.command.SolarEdgeCommand;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * Polling worker class. This is responsible for periodic polling of sensor data.
26 * @author Alexander Friese - initial contribution
29 public class SolarEdgeLiveDataPolling implements Runnable {
33 private final Logger logger = LoggerFactory.getLogger(getClass());
36 * Handler for delegation to callbacks.
38 private final SolarEdgeHandler handler;
43 * @param handler handler which handles results of polling
45 public SolarEdgeLiveDataPolling(SolarEdgeHandler handler) {
46 this.handler = handler;
50 * Poll the SolarEdge Webservice one time per call.
54 logger.debug("polling SolarEdge live data {}", handler.getConfiguration());
58 if (handler.getConfiguration().isUsePrivateApi()) {
59 ldu = new LiveDataUpdatePrivateApi(handler);
61 if (handler.getConfiguration().isMeterInstalled()) {
62 ldu = new LiveDataUpdatePublicApi(handler);
64 ldu = new LiveDataUpdateMeterless(handler);
68 handler.getWebInterface().enqueueCommand(ldu);