Skip to content

Commit 86d672c

Browse files
authored
Merge pull request #76 from matchews/codex/implement-valve-actuator-support
Add valve actuator support to Hayward OmniLogic binding
2 parents b2e7065 + 3cedefa commit 86d672c

5 files changed

Lines changed: 99 additions & 1 deletion

File tree

bundles/org.openhab.binding.haywardomnilogic/src/main/java/org/openhab/binding/haywardomnilogic/internal/HaywardBindingConstants.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class HaywardBindingConstants {
3838
public static final ThingTypeUID THING_TYPE_HEATER = new ThingTypeUID(BINDING_ID, "heater");
3939
public static final ThingTypeUID THING_TYPE_PUMP = new ThingTypeUID(BINDING_ID, "pump");
4040
public static final ThingTypeUID THING_TYPE_RELAY = new ThingTypeUID(BINDING_ID, "relay");
41+
public static final ThingTypeUID THING_TYPE_VALVEACTUATOR = new ThingTypeUID(BINDING_ID, "valveActuator");
4142
public static final ThingTypeUID THING_TYPE_SENSOR = new ThingTypeUID(BINDING_ID, "sensor");
4243
public static final ThingTypeUID THING_TYPE_VIRTUALHEATER = new ThingTypeUID(BINDING_ID, "virtualHeater");
4344

@@ -48,7 +49,8 @@ public class HaywardBindingConstants {
4849
HaywardBindingConstants.THING_TYPE_CHLORINATOR, HaywardBindingConstants.THING_TYPE_COLORLOGIC,
4950
HaywardBindingConstants.THING_TYPE_FILTER, HaywardBindingConstants.THING_TYPE_HEATER,
5051
HaywardBindingConstants.THING_TYPE_PUMP, HaywardBindingConstants.THING_TYPE_RELAY,
51-
HaywardBindingConstants.THING_TYPE_SENSOR, HaywardBindingConstants.THING_TYPE_VIRTUALHEATER);
52+
HaywardBindingConstants.THING_TYPE_SENSOR, HaywardBindingConstants.THING_TYPE_VALVEACTUATOR,
53+
HaywardBindingConstants.THING_TYPE_VIRTUALHEATER);
5254

5355
// List of all Channel ids (bridge)
5456
// No Channels
@@ -154,6 +156,12 @@ public class HaywardBindingConstants {
154156
public static final String PROPERTY_RELAY_TYPE = "relayType";
155157
public static final String PROPERTY_RELAY_FUNCTION = "relayFunction";
156158

159+
// List of all Channel ids (valve actuator)
160+
public static final String CHANNEL_VALVEACTUATOR_STATE = "valveActuatorState";
161+
162+
public static final String PROPERTY_VALVEACTUATOR_TYPE = "valveActuatorType";
163+
public static final String PROPERTY_VALVEACTUATOR_FUNCTION = "valveActuatorFunction";
164+
157165
// List of all Channel ids (sensor)
158166
public static final String CHANNEL_SENSOR_DATA = "sensorData";
159167

bundles/org.openhab.binding.haywardomnilogic/src/main/java/org/openhab/binding/haywardomnilogic/internal/HaywardHandlerFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.openhab.binding.haywardomnilogic.internal.handler.HaywardHeaterHandler;
3232
import org.openhab.binding.haywardomnilogic.internal.handler.HaywardPumpHandler;
3333
import org.openhab.binding.haywardomnilogic.internal.handler.HaywardRelayHandler;
34+
import org.openhab.binding.haywardomnilogic.internal.handler.HaywardValveActuatorHandler;
3435
import org.openhab.binding.haywardomnilogic.internal.handler.HaywardVirtualHeaterHandler;
3536
import org.openhab.core.io.net.http.HttpClientFactory;
3637
import org.openhab.core.thing.Bridge;
@@ -105,6 +106,9 @@ public HaywardHandlerFactory(final @Reference HaywardDynamicStateDescriptionProv
105106
if (thingTypeUID.equals(HaywardBindingConstants.THING_TYPE_RELAY)) {
106107
return new HaywardRelayHandler(thing);
107108
}
109+
if (thingTypeUID.equals(HaywardBindingConstants.THING_TYPE_VALVEACTUATOR)) {
110+
return new HaywardValveActuatorHandler(thing);
111+
}
108112
if (thingTypeUID.equals(HaywardBindingConstants.THING_TYPE_VIRTUALHEATER)) {
109113
return new HaywardVirtualHeaterHandler(thing);
110114
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2010-2025 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.haywardomnilogic.internal.handler;
14+
15+
import java.util.ArrayList;
16+
import java.util.List;
17+
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;
26+
27+
/**
28+
* The Valve Actuator Handler
29+
*
30+
* @author Matt Myers - Initial contribution
31+
*/
32+
@NonNullByDefault
33+
public class HaywardValveActuatorHandler extends HaywardThingHandler {
34+
35+
public HaywardValveActuatorHandler(Thing thing) {
36+
super(thing);
37+
}
38+
39+
@Override
40+
public void getTelemetry(String xmlResponse) throws HaywardException {
41+
List<String> systemIDs = new ArrayList<>();
42+
List<String> data = new ArrayList<>();
43+
44+
Bridge bridge = getBridge();
45+
if (bridge != null && bridge.getHandler() instanceof HaywardBridgeHandler bridgehandler) {
46+
systemIDs = bridgehandler.evaluateXPath("//ValveActuator/@systemId", xmlResponse);
47+
data = bridgehandler.evaluateXPath("//ValveActuator/@valveActuatorState", xmlResponse);
48+
String thingSystemID = getThing().getUID().getId();
49+
for (int i = 0; i < systemIDs.size(); i++) {
50+
if (systemIDs.get(i).equals(thingSystemID)) {
51+
updateData(HaywardBindingConstants.CHANNEL_VALVEACTUATOR_STATE, data.get(i));
52+
}
53+
}
54+
this.updateStatus(ThingStatus.ONLINE);
55+
} else {
56+
this.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
57+
}
58+
}
59+
}

bundles/org.openhab.binding.haywardomnilogic/src/main/resources/OH-INF/i18n/haywardomnilogic.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ thing-type.haywardomnilogic.filter.label = Filter
1515
thing-type.haywardomnilogic.heater.label = Heater
1616
thing-type.haywardomnilogic.pump.label = Pump
1717
thing-type.haywardomnilogic.relay.label = Relay
18+
thing-type.haywardomnilogic.valveActuator.label = Valve Actuator
1819
thing-type.haywardomnilogic.virtualHeater.label = Virtual Heater
1920

2021
# thing types config
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<thing:thing-descriptions bindingId="haywardomnilogic"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
5+
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
6+
7+
<thing-type id="valveActuator" listed="false">
8+
<supported-bridge-type-refs>
9+
<bridge-type-ref id="bridge"/>
10+
</supported-bridge-type-refs>
11+
12+
<label>Valve Actuator</label>
13+
<channels>
14+
<channel id="valveActuatorState" typeId="system.power"/>
15+
</channels>
16+
17+
<properties>
18+
<property name="vendor">Hayward</property>
19+
<property name="valveActuatorType"></property>
20+
<property name="valveActuatorFunction"></property>
21+
</properties>
22+
<representation-property>systemID</representation-property>
23+
24+
</thing-type>
25+
26+
</thing:thing-descriptions>

0 commit comments

Comments
 (0)