Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lights_out_delta #132

Merged
merged 2 commits into from
Dec 21, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/suripu-service.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ aws_access_key_s3: AKIAJVQV7XJU23UWILSQ
aws_access_secret_s3: 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

ring_duration_sec: 240
calibration_cache_duration_seconds: 10

audio_features_firehose:
endpoint: firehose.us-east-1.amazonaws.com
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<librato.reporter.version>2.2.0.5</librato.reporter.version>
<metrics.version>3.1.2</metrics.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<suripu.version>0.8.5789</suripu.version>
<suripu.version>0.8.5852</suripu.version>
</properties>

<distributionManagement>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/hello/suripu/service/SuripuService.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ protected void configure() {

// 300 sec = 5 minutes, which should maximize cache hitrate
// TODO: add cache hitrate to metrics
final CalibrationDAO calibrationDAO = CalibrationDynamoDB.createWithCacheConfig(calibrationDynamoDBClient, tableNames.get(DynamoDBTableName.CALIBRATION), 300);
final CalibrationDAO calibrationDAO = CalibrationDynamoDB.createWithCacheConfig(
calibrationDynamoDBClient,
tableNames.get(DynamoDBTableName.CALIBRATION),
configuration.calibrationCacheDurationSeconds()
);

final ReceiveResource receiveResource = new ReceiveResource(
senseKeyStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public Integer getRingDuration(){
return this.ringDuration;
}

@JsonProperty("calibration_cache_duration_seconds")
private Integer calibrationCacheDurationSeconds = 300;
public Integer calibrationCacheDurationSeconds() {
return calibrationCacheDurationSeconds;
}

@Valid
@NotNull
@JsonProperty("dynamodb")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.hello.suripu.service.resources;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.annotation.Timed;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.protobuf.TextFormat;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.annotation.Timed;
import com.hello.dropwizard.mikkusu.helpers.AdditionalMediaTypes;
import com.hello.suripu.api.audio.AudioControlProtos;
import com.hello.suripu.api.audio.AudioFeaturesControlProtos;
Expand Down Expand Up @@ -61,7 +60,6 @@
import com.hello.suripu.service.models.UploadSettings;
import com.hello.suripu.service.utils.ServiceFeatureFlipper;
import com.librato.rollout.RolloutClient;

import org.apache.commons.codec.binary.Hex;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
Expand All @@ -70,14 +68,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
Expand All @@ -87,6 +77,13 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static com.codahale.metrics.MetricRegistry.name;

Expand Down Expand Up @@ -595,7 +592,10 @@ private byte[] generateSyncResponse(final String deviceName,

if (i == batch.getDataCount() - 1) {
final Optional<Calibration> calibrationOptional = this.hasCalibrationEnabled(deviceName) ? calibrationDAO.get(deviceName) : Optional.<Calibration>absent();

if(calibrationOptional.isPresent()) {
responseBuilder.setLightsOffThreshold(calibrationOptional.get().lightsOutDelta());
LOGGER.trace("sense_id={} lights_out_delta={}", deviceName, calibrationOptional.get().lightsOutDelta());
}
final CurrentRoomState currentRoomState = CurrentRoomState.fromRawData(data.getTemperature(), data.getHumidity(), data.getDustMax(), data.getLight(), data.getAudioPeakBackgroundEnergyDb(), data.getAudioPeakDisturbanceEnergyDb(),
roundedDateTime.getMillis(),
data.getFirmwareVersion(),
Expand Down Expand Up @@ -675,6 +675,8 @@ private byte[] generateSyncResponse(final String deviceName,
}
}



final AudioControlProtos.AudioControl.Builder audioControl = AudioControlProtos.AudioControl
.newBuilder()
.setAudioCaptureAction(AudioControlProtos.AudioControl.AudioCaptureAction.ON)
Expand Down