2 * Copyright (c) 2010-2024 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.core.thing.Bridge;
23 import org.openhab.core.thing.Thing;
24 import org.openhab.core.thing.ThingStatus;
25 import org.openhab.core.thing.ThingStatusDetail;
28 * The Body of Water Handler
30 * @author Matt Myers - Initial contribution
33 public class HaywardBowHandler extends HaywardThingHandler {
35 public HaywardBowHandler(Thing thing) {
40 public void getTelemetry(String xmlResponse) throws HaywardException {
41 List<String> systemIDs = new ArrayList<>();
42 List<String> data = new ArrayList<>();
44 Bridge bridge = getBridge();
46 HaywardBridgeHandler bridgehandler = (HaywardBridgeHandler) bridge.getHandler();
47 if (bridgehandler != null) {
48 systemIDs = bridgehandler.evaluateXPath("//BodyOfWater/@systemId", xmlResponse);
50 String thingSystemID = getThing().getUID().getId();
51 for (int i = 0; i < systemIDs.size(); i++) {
52 if (systemIDs.get(i).equals(thingSystemID)) {
54 data = bridgehandler.evaluateXPath("//BodyOfWater/@flow", xmlResponse);
55 updateData(HaywardBindingConstants.CHANNEL_BOW_FLOW, data.get(i));
58 data = bridgehandler.evaluateXPath("//BodyOfWater/@waterTemp", xmlResponse);
59 updateData(HaywardBindingConstants.CHANNEL_BOW_WATERTEMP, data.get(i));
62 this.updateStatus(ThingStatus.ONLINE);
64 this.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);