mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-22 01:20:36 +00:00
Initial updates for nest control
This commit is contained in:
51
src/main/java/com/bwssystems/NestBridge/NestHome.java
Normal file
51
src/main/java/com/bwssystems/NestBridge/NestHome.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.bwssystems.NestBridge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bwssystems.HABridge.BridgeSettings;
|
||||
import com.bwssystems.nest.controller.Nest;
|
||||
import com.bwssystems.nest.controller.NestSession;
|
||||
import com.bwssystems.nest.protocol.error.LoginException;
|
||||
|
||||
public class NestHome {
|
||||
private static final Logger log = LoggerFactory.getLogger(NestHome.class);
|
||||
private NestSession theSession;
|
||||
private Nest theNest;
|
||||
|
||||
public NestHome(BridgeSettings bridgeSettings) {
|
||||
theSession = null;
|
||||
theNest = null;
|
||||
|
||||
if(bridgeSettings.isValidNest())
|
||||
return;
|
||||
|
||||
try {
|
||||
theSession = new NestSession(bridgeSettings.getNestuser(), bridgeSettings.getNestpwd());
|
||||
theNest = new Nest(theSession);
|
||||
} catch (LoginException e) {
|
||||
log.error("Caught Login Exception, exiting....");
|
||||
theSession = null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getHomeNames() {
|
||||
if(theNest == null)
|
||||
return null;
|
||||
return new ArrayList<String>(theNest.getHomeNames()); /* list of home structures i.e. MyHouse */
|
||||
}
|
||||
|
||||
public List<String> getThermostatNames() {
|
||||
if(theNest == null)
|
||||
return null;
|
||||
return new ArrayList<String>(theNest.getThermostatNames()); /* list of thermostats in all structure */
|
||||
}
|
||||
|
||||
public Nest getTheNest() {
|
||||
return theNest;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user