Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.openhab.binding.haywardomnilogiclocal.internal.handler;

import java.util.Map;

import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.haywardomnilogiclocal.internal.HaywardException;
import org.openhab.binding.haywardomnilogiclocal.internal.HaywardThingHandler;
import org.openhab.binding.haywardomnilogiclocal.internal.protocol.ParameterValue;
import org.openhab.binding.haywardomnilogiclocal.internal.telemetry.Status;
import org.openhab.binding.haywardomnilogiclocal.internal.telemetry.TelemetryParser;
import org.openhab.binding.haywardomnilogiclocal.internal.telemetry.ValveActuator;
import org.openhab.core.thing.Thing;

public class HaywardValveActuatorHandler extends HaywardThingHandler {

public HaywardValveActuatorHandler(Thing thing) {
super(thing);
}

public void updateFromConfig(Map<String, ParameterValue> values) {
String sysId = getThing().getProperties().get("systemID");
if (sysId == null) {
return;
}

updateIfPresent(values, "valveActuatorState_" + sysId, "valveActuatorState");
}

@Override
public void getTelemetry(String xmlResponse) throws HaywardException {
Status status = TelemetryParser.parse(xmlResponse);
String sysId = getThing().getProperties().get("systemID");
if (sysId == null) {
return;
}
for (ValveActuator valveActuator : status.getValveActuators()) {
if (sysId.equals(valveActuator.getSystemId())) {
@Nullable String valveActuatorState = valveActuator.getValveActuatorState();
if (valveActuatorState != null) {
updateData("valveActuatorState", valveActuatorState);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class Status {
@XStreamImplicit(itemFieldName = "Relay")
private final List<Relay> relays = new ArrayList<>();

@XStreamImplicit(itemFieldName = "ValveActuator")
private final List<ValveActuator> valveActuators = new ArrayList<>();

@XStreamImplicit(itemFieldName = "Pump")
private final List<Pump> pumps = new ArrayList<>();

Expand Down Expand Up @@ -73,6 +76,10 @@ public List<Relay> getRelays() {
return relays;
}

public List<ValveActuator> getValveActuators() {
return valveActuators;
}

public List<Pump> getPumps() {
return pumps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public final class TelemetryParser {
XSTREAM.addPermission(AnyTypePermission.ANY);
XSTREAM.setClassLoader(TelemetryParser.class.getClassLoader());
XSTREAM.processAnnotations(Status.class);
XSTREAM.processAnnotations(ValveActuator.class);
}

private TelemetryParser() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.openhab.binding.haywardomnilogiclocal.internal.telemetry;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

@NonNullByDefault
@XStreamAlias("ValveActuator")
public class ValveActuator {
@XStreamAsAttribute
@XStreamAlias("systemId")
private @Nullable String systemId;

@XStreamAsAttribute
@XStreamAlias("valveActuatorState")
private @Nullable String valveActuatorState;

public @Nullable String getSystemId() {
return systemId;
}

public @Nullable String getValveActuatorState() {
return valveActuatorState;
}
}