mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Add a rules engine so I can be notified when I forget to close my garage door.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.lanternsoftware.services</groupId>
|
||||
<groupId>com.lanternsoftware.zwave</groupId>
|
||||
<artifactId>lantern-datamodel-zwave</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.0</version>
|
||||
|
||||
@@ -154,6 +154,14 @@ public class Switch {
|
||||
return type == SwitchType.RELAY;
|
||||
}
|
||||
|
||||
public boolean isRelayButton() {
|
||||
return type == SwitchType.RELAY_BUTTON;
|
||||
}
|
||||
|
||||
public boolean isSecurity() {
|
||||
return type == SwitchType.SECURITY;
|
||||
}
|
||||
|
||||
public boolean isControlledBy(String _controllerUrl) {
|
||||
return NullUtils.isEqual(_controllerUrl, controllerUrl);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ public enum SwitchType {
|
||||
SPACE_HEATER_THERMOSTAT,
|
||||
THERMOMETER,
|
||||
RELAY,
|
||||
SECURITY
|
||||
SECURITY,
|
||||
RELAY_BUTTON
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public class ZWaveConfig {
|
||||
private String commPort;
|
||||
private String url;
|
||||
private String masterUrl;
|
||||
private String rulesUrl;
|
||||
private List<Switch> switches;
|
||||
|
||||
public int getAccountId() {
|
||||
@@ -47,6 +48,14 @@ public class ZWaveConfig {
|
||||
masterUrl = _masterUrl;
|
||||
}
|
||||
|
||||
public String getRulesUrl() {
|
||||
return rulesUrl;
|
||||
}
|
||||
|
||||
public void setRulesUrl(String _rulesUrl) {
|
||||
rulesUrl = _rulesUrl;
|
||||
}
|
||||
|
||||
public List<Switch> getSwitches() {
|
||||
return switches;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ public class SwitchSerializer extends AbstractDaoSerializer<Switch>
|
||||
d.put("gpio_pin", _o.getGpioPin());
|
||||
d.put("primary", _o.isPrimary());
|
||||
d.put("hold", _o.isHold());
|
||||
d.put("hidden", _o.isHidden());
|
||||
d.put("thermometer_url", _o.getThermometerUrl());
|
||||
d.put("controller_url", _o.getControllerUrl());
|
||||
d.put("thermostat_mode", DaoSerializer.toEnumName(_o.getThermostatMode()));
|
||||
d.put("low_level", _o.getLowLevel());
|
||||
d.put("hidden", _o.isHidden());
|
||||
d.put("schedule", DaoSerializer.toDaoEntities(_o.getSchedule(), DaoProxyType.MONGO));
|
||||
return d;
|
||||
}
|
||||
@@ -57,11 +57,11 @@ public class SwitchSerializer extends AbstractDaoSerializer<Switch>
|
||||
o.setGpioPin(DaoSerializer.getInteger(_d, "gpio_pin"));
|
||||
o.setPrimary(DaoSerializer.getBoolean(_d, "primary"));
|
||||
o.setHold(DaoSerializer.getBoolean(_d, "hold"));
|
||||
o.setHidden(DaoSerializer.getBoolean(_d, "hidden"));
|
||||
o.setThermometerUrl(DaoSerializer.getString(_d, "thermometer_url"));
|
||||
o.setControllerUrl(DaoSerializer.getString(_d, "controller_url"));
|
||||
o.setThermostatMode(DaoSerializer.getEnum(_d, "thermostat_mode", ThermostatMode.class));
|
||||
o.setLowLevel(DaoSerializer.getInteger(_d, "low_level"));
|
||||
o.setHidden(DaoSerializer.getBoolean(_d, "hidden"));
|
||||
o.setSchedule(DaoSerializer.getList(_d, "schedule", SwitchSchedule.class));
|
||||
return o;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class ZWaveConfigSerializer extends AbstractDaoSerializer<ZWaveConfig>
|
||||
d.put("comm_port", _o.getCommPort());
|
||||
d.put("url", _o.getUrl());
|
||||
d.put("master_url", _o.getMasterUrl());
|
||||
d.put("rules_url", _o.getRulesUrl());
|
||||
d.put("switches", DaoSerializer.toDaoEntities(_o.getSwitches(), DaoProxyType.MONGO));
|
||||
return d;
|
||||
}
|
||||
@@ -43,6 +44,7 @@ public class ZWaveConfigSerializer extends AbstractDaoSerializer<ZWaveConfig>
|
||||
o.setCommPort(DaoSerializer.getString(_d, "comm_port"));
|
||||
o.setUrl(DaoSerializer.getString(_d, "url"));
|
||||
o.setMasterUrl(DaoSerializer.getString(_d, "master_url"));
|
||||
o.setRulesUrl(DaoSerializer.getString(_d, "rules_url"));
|
||||
o.setSwitches(DaoSerializer.getList(_d, "switches", Switch.class));
|
||||
return o;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user