Add support for adding and removing zwave nodes via software. Support secondary z-wave controllers.

This commit is contained in:
MarkBryanMilligan
2021-10-28 21:45:56 -05:00
parent 88933a2286
commit f5066c541f
28 changed files with 346 additions and 87 deletions

View File

@@ -21,7 +21,7 @@ public class Switch {
private boolean hold;
private boolean hidden;
private boolean suppressEvents;
private String thermometerUrl;
private String sourceUrl;
private String controllerUrl;
private ThermostatMode thermostatMode;
private int lowLevel;
@@ -30,18 +30,18 @@ public class Switch {
public Switch() {
}
public Switch(String _room, String _name, int _nodeId, boolean _primary, boolean _multilevel, String _thermometerUrl, int _lowLevel) {
this(_room, _name, _nodeId, 0, _primary, false, _thermometerUrl, _lowLevel, null);
public Switch(String _room, String _name, int _nodeId, boolean _primary, boolean _multilevel, String _sourceUrl, int _lowLevel) {
this(_room, _name, _nodeId, 0, _primary, false, _sourceUrl, _lowLevel, null);
}
public Switch(String _room, String _name, int _nodeId, int _level, boolean _primary, boolean _hold, String _thermometerUrl, int _lowLevel, List<SwitchSchedule> _schedule) {
public Switch(String _room, String _name, int _nodeId, int _level, boolean _primary, boolean _hold, String _sourceUrl, int _lowLevel, List<SwitchSchedule> _schedule) {
room = _room;
name = _name;
nodeId = _nodeId;
level = _level;
primary = _primary;
hold = _hold;
thermometerUrl = _thermometerUrl;
sourceUrl = _sourceUrl;
lowLevel = _lowLevel;
schedule = _schedule;
}
@@ -128,12 +128,12 @@ public class Switch {
hold = _hold;
}
public String getThermometerUrl() {
return thermometerUrl;
public String getSourceUrl() {
return sourceUrl;
}
public void setThermometerUrl(String _thermometerUrl) {
thermometerUrl = _thermometerUrl;
public void setSourceUrl(String _sourceUrl) {
sourceUrl = _sourceUrl;
}
public String getControllerUrl() {
@@ -152,8 +152,8 @@ public class Switch {
return type == SwitchType.SPACE_HEATER_THERMOSTAT;
}
public boolean isThermometerUrlValid() {
return NullUtils.makeNotNull(thermometerUrl).startsWith("http");
public boolean isSourceUrlValid() {
return NullUtils.makeNotNull(sourceUrl).startsWith("http");
}
public boolean isZWaveThermostat() {
@@ -244,7 +244,7 @@ public class Switch {
s.setPrimary(isPrimary());
s.setHold(isHold());
s.setHidden(isHidden());
s.setThermometerUrl(getThermometerUrl());
s.setSourceUrl(getSourceUrl());
s.setControllerUrl(getControllerUrl());
s.setThermostatMode(getThermostatMode());
s.setLowLevel(getLowLevel());

View File

@@ -8,5 +8,6 @@ public enum SwitchType {
THERMOMETER,
RELAY,
SECURITY,
RELAY_BUTTON
RELAY_BUTTON,
CO2_SENSOR
}

View File

@@ -5,7 +5,9 @@ import com.lanternsoftware.util.NullUtils;
import com.lanternsoftware.util.dao.annotations.DBSerializable;
import com.lanternsoftware.util.dao.annotations.PrimaryKey;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
@DBSerializable(autogen = false)
public class ZWaveConfig {
@@ -75,4 +77,10 @@ public class ZWaveConfig {
public boolean isMySwitch(Switch _sw) {
return (isMaster() && NullUtils.isEmpty(_sw.getControllerUrl())) || _sw.isControlledBy(getUrl());
}
public List<String> getControllers() {
TreeSet<String> controllers = new TreeSet<>(CollectionUtils.filter(CollectionUtils.transform(switches, Switch::getControllerUrl), NullUtils::isNotEmpty));
controllers.add(masterUrl);
return new ArrayList<>(controllers);
}
}

View File

@@ -39,7 +39,7 @@ public class SwitchSerializer extends AbstractDaoSerializer<Switch>
d.put("hold", _o.isHold());
d.put("hidden", _o.isHidden());
d.put("suppress_events", _o.isSuppressEvents());
d.put("thermometer_url", _o.getThermometerUrl());
d.put("source_url", _o.getSourceUrl());
d.put("controller_url", _o.getControllerUrl());
d.put("thermostat_mode", DaoSerializer.toEnumName(_o.getThermostatMode()));
d.put("low_level", _o.getLowLevel());
@@ -62,7 +62,7 @@ public class SwitchSerializer extends AbstractDaoSerializer<Switch>
o.setHold(DaoSerializer.getBoolean(_d, "hold"));
o.setHidden(DaoSerializer.getBoolean(_d, "hidden"));
o.setSuppressEvents(DaoSerializer.getBoolean(_d, "suppress_events"));
o.setThermometerUrl(DaoSerializer.getString(_d, "thermometer_url"));
o.setSourceUrl(DaoSerializer.getString(_d, "source_url"));
o.setControllerUrl(DaoSerializer.getString(_d, "controller_url"));
o.setThermostatMode(DaoSerializer.getEnum(_d, "thermostat_mode", ThermostatMode.class));
o.setLowLevel(DaoSerializer.getInteger(_d, "low_level"));