Skip to content

Commit

Permalink
Changed all logging to trace level. Added new device name to regex. F…
Browse files Browse the repository at this point in the history
…ixed door state logging.
  • Loading branch information
computergeek1507 authored and teichsta committed Jan 9, 2016
1 parent 56c5e7d commit 75d44f2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ public class GarageDoorData {
/**
* Matching pattern for door device types, some models have spaces in them,
* some don't
*
* "VGDO"
* "Garage Door Opener WGDO"
* "GarageDoorOpener"
*/
private static final Pattern DEVICE_TYPE_PATTERN = Pattern
.compile("Garage\\s?Door\\s?Opener");
.compile("Garage\\s?Door\\s?Opener|VGDO");

LinkedList<GarageDoorDevice> devices = new LinkedList<GarageDoorDevice>();

Expand Down Expand Up @@ -68,7 +72,7 @@ public GarageDoorData(JsonNode rootNode) throws IOException {
int doorstate = attributes.get(j)
.get("Value").asInt();
logger.trace(
"DeviceID: {} DeviceName: {} DeviceType: {} Doorstate : ",
"DeviceID: {} DeviceName: {} DeviceType: {} Doorstate : {}",
deviceId, deviceName, deviceType,
doorstate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public LoginData(JsonNode root) throws IOException, InvalidDataException {
throw new InvalidDataException(
"Could not find SecurityToken in JSON data");
securityToken = data.toString();
logger.debug("myq securityToken: {}", securityToken);
logger.trace("myq securityToken: {}", securityToken);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void deactivate(final int reason) {
*/
private void poll() {
if (invalidCredentials || this.myqOnlineData == null) {
logger.debug("Invalid Account Credentials");
logger.trace("Invalid Account Credentials");
return;
}

Expand Down Expand Up @@ -278,7 +278,7 @@ private void poll() {
@Override
public void internalReceiveCommand(String itemName, Command command) {
super.internalReceiveCommand(itemName, command);
logger.debug("MyQ binding received command '{}' for item '{}'",
logger.trace("MyQ binding received command '{}' for item '{}'",
command, itemName);
if (myqOnlineData != null) {
computeCommandForItem(command, itemName);
Expand Down Expand Up @@ -357,7 +357,7 @@ private void schedulePoll(long millis) {
if (pollFuture != null && !pollFuture.isCancelled())
pollFuture.cancel(false);

logger.debug("rapidRefreshFuture scheduleing for {} millis", millis);
logger.trace("rapidRefreshFuture scheduleing for {} millis", millis);
// start polling at the RAPID_REFRESH_SECS interval
pollFuture = pollService.scheduleAtFixedRate(new Runnable() {
@Override
Expand All @@ -374,7 +374,7 @@ private void scheduleFuturePollReset() {
// stop rapid polling after MAX_RAPID_REFRESH_SECS
pollResetFuture = pollService.schedule(new Runnable() {
public void run() {
logger.debug("rapidRefreshFutureEnd stopping");
logger.trace("rapidRefreshFutureEnd stopping");
schedulePoll(refreshInterval);
}
}, MAX_RAPID_REFRESH, TimeUnit.MILLISECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public MyqData(String username, String password, String appId, int timeout) {
*/
public GarageDoorData getGarageData() throws InvalidLoginException,
IOException {
logger.debug("Retreiveing door data");
logger.trace("Retreiveing door data");
String url = String.format(
"%s/api/v4/userdevicedetails/get?appId=%s&SecurityToken=%s",
WEBSITE, enc(appId), enc(getSecurityToken()));
Expand All @@ -112,7 +112,7 @@ public GarageDoorData getGarageData() throws InvalidLoginException,
* Validates Username and Password then saved sercurityToken to a variable
*/
private void login() throws InvalidLoginException, IOException {
logger.debug("attempting to login");
logger.trace("attempting to login");
String url = String
.format("%s/api/user/validate?appId=%s&SecurityToken=null&username=%s&password=%s",
WEBSITE, enc(appId), enc(userName), enc(password));
Expand Down Expand Up @@ -183,13 +183,13 @@ private synchronized JsonNode request(String method, String url,
String payload, String payloadType, boolean retry)
throws IOException, InvalidLoginException {

logger.debug("Requsting URL {}", url);
logger.trace("Requsting URL {}", url);

String dataString = executeUrl(method, url, header,
payload == null ? null : IOUtils.toInputStream(payload),
payloadType, timeout);

logger.debug("Received MyQ JSON: {}", dataString);
logger.trace("Received MyQ JSON: {}", dataString);

if (dataString == null) {
throw new IOException("Null response from MyQ server");
Expand All @@ -199,7 +199,7 @@ private synchronized JsonNode request(String method, String url,
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readTree(dataString);
int returnCode = rootNode.get("ReturnCode").asInt();
logger.debug("myq ReturnCode: {}", returnCode);
logger.trace("myq ReturnCode: {}", returnCode);

MyQResponseCode rc = MyQResponseCode.fromCode(returnCode);

Expand Down

0 comments on commit 75d44f2

Please sign in to comment.