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.haywardomnilogic.internal.handler;
15 import java.util.ArrayList;
16 import java.util.List;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.haywardomnilogic.internal.HaywardBindingConstants;
20 import org.openhab.binding.haywardomnilogic.internal.HaywardException;
21 import org.openhab.binding.haywardomnilogic.internal.HaywardThingHandler;
22 import org.openhab.binding.haywardomnilogic.internal.config.HaywardConfig;
23 import org.openhab.core.thing.Bridge;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.thing.ThingStatus;
26 import org.openhab.core.thing.ThingStatusDetail;
31 * @author Matt Myers - Initial contribution
34 public class HaywardHeaterHandler extends HaywardThingHandler {
36 HaywardConfig config = getConfig().as(HaywardConfig.class);
38 public HaywardHeaterHandler(Thing thing) {
43 public void getTelemetry(String xmlResponse) throws HaywardException {
44 List<String> systemIDs = new ArrayList<>();
45 List<String> data = new ArrayList<>();
47 Bridge bridge = getBridge();
49 HaywardBridgeHandler bridgehandler = (HaywardBridgeHandler) bridge.getHandler();
50 if (bridgehandler != null) {
51 systemIDs = bridgehandler.evaluateXPath("//Heater/@systemId", xmlResponse);
52 String thingSystemID = getThing().getUID().getId();
53 for (int i = 0; i < systemIDs.size(); i++) {
54 if (systemIDs.get(i).equals(thingSystemID)) {
56 data = bridgehandler.evaluateXPath("//Heater/@heaterState", xmlResponse);
57 updateData(HaywardBindingConstants.CHANNEL_HEATER_STATE, data.get(i));
60 data = bridgehandler.evaluateXPath("//Heater/@enable", xmlResponse);
61 if ("0".equals(data.get(i))) {
62 updateData(HaywardBindingConstants.CHANNEL_HEATER_ENABLE, "0");
64 updateData(HaywardBindingConstants.CHANNEL_HEATER_ENABLE, "1");
68 this.updateStatus(ThingStatus.ONLINE);
70 this.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);