Skip to content

Commit

Permalink
Updated C/F setting. Started to implement UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
bwssytems committed Mar 16, 2016
1 parent 73f0f76 commit ad820a6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>1.4.1b</version>
<version>1.4.1c</version>
<packaging>jar</packaging>

<name>HA Bridge</name>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/bwssystems/HABridge/BridgeSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ public void buildSettings() {
String addressString = null;
String theVeraAddress = null;
String theHarmonyAddress = null;

String configFileProperty = System.getProperty("config.file");
if(configFileProperty == null) {
Path filePath = Paths.get(Configuration.CONFIG_FILE);
if(Files.exists(filePath) && Files.isReadable(filePath))
configFileProperty = Configuration.CONFIG_FILE;
}

if(configFileProperty != null)
{
log.info("reading from config file: " + configFileProperty);
Expand All @@ -56,6 +58,7 @@ public void buildSettings() {
{
log.info("reading from system properties");
theBridgeSettings.setNumberoflogmessages(Configuration.NUMBER_OF_LOG_MESSAGES);
theBridgeSettings.setFarenheit(true);
theBridgeSettings.setConfigfile(Configuration.CONFIG_FILE);
theBridgeSettings.setServerPort(System.getProperty("server.port", Configuration.DEFAULT_WEB_PORT));
theBridgeSettings.setUpnpConfigAddress(System.getProperty("upnp.config.address"));
Expand Down Expand Up @@ -182,6 +185,8 @@ private void _loadConfig(Path aPath) {
theBridgeSettings.setVeraconfigured(aBridgeSettings.isValidVera());
theBridgeSettings.setHarmonyconfigured(aBridgeSettings.isValidHarmony());
theBridgeSettings.setNestConfigured(aBridgeSettings.isValidNest());
theBridgeSettings.setNumberoflogmessages(aBridgeSettings.getNumberoflogmessages());
theBridgeSettings.setFarenheit(aBridgeSettings.isFarenheit());
}

public void save(BridgeSettingsDescriptor newBridgeSettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BridgeSettingsDescriptor {
private boolean veraconfigured;
private boolean harmonyconfigured;
private boolean nestconfigured;
private boolean farenheit;
private String configfile;
private Integer numberoflogmessages;

Expand All @@ -29,6 +30,7 @@ public BridgeSettingsDescriptor() {
this.nestconfigured = false;
this.veraconfigured = false;
this.harmonyconfigured = false;
this.farenheit = true;
}
public String getUpnpConfigAddress() {
return upnpconfigaddress;
Expand Down Expand Up @@ -144,6 +146,12 @@ public Integer getNumberoflogmessages() {
public void setNumberoflogmessages(Integer numberoflogmessages) {
this.numberoflogmessages = numberoflogmessages;
}
public boolean isFarenheit() {
return farenheit;
}
public void setFarenheit(boolean farenheit) {
this.farenheit = farenheit;
}
public Boolean isValidVera() {
if(this.getVeraAddress() == null || this.getVeraAddress().getDevices().size() <= 0)
return false;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ else if(device.getDeviceType().toLowerCase().contains("thermo") || (device.getMa
NestInstruction thermoSetting = new Gson().fromJson(url, NestInstruction.class);
if(thermoSetting.getControl().equalsIgnoreCase("temp")) {
if(request.body().contains("bri")) {
thermoSetting.setTemp(String.valueOf((Double.parseDouble(replaceIntensityValue(thermoSetting.getTemp(), state.getBri())) - 32.0)/1.8));
if(bridgeSettings.isFarenheit())
thermoSetting.setTemp(String.valueOf((Double.parseDouble(replaceIntensityValue(thermoSetting.getTemp(), state.getBri())) - 32.0)/1.8));
else
thermoSetting.setTemp(String.valueOf(Double.parseDouble(replaceIntensityValue(thermoSetting.getTemp(), state.getBri()))));
log.debug("Setting thermostat: " + thermoSetting.getName() + " to " + thermoSetting.getTemp() + "C");
theNest.getThermostat(thermoSetting.getName()).setTargetTemperature(Float.parseFloat(thermoSetting.getTemp()));
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/bwssystems/vera/VeraInfo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bwssystems.vera;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.ListIterator;
import java.util.Map;
Expand Down Expand Up @@ -101,7 +102,7 @@ protected String doHttpGETRequest(String url) {
HttpResponse response = httpClient.execute(httpGet);
log.debug("GET on URL responded: " + response.getStatusLine().getStatusCode());
if(response.getStatusLine().getStatusCode() == 200){
theContent = EntityUtils.toString(response.getEntity()); //read content for data
theContent = EntityUtils.toString(response.getEntity(), Charset.forName("UTF-8")); //read content for data
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content
}
} catch (IOException e) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/public/views/system.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ <h1 class="panel-title">Bridge Settings</h1>
<td><input type="checkbox" ng-model="bridge.settings.traceupnp"
ng-true-value=true ng-false-value=false> {{bridge.settings.traceupnp}}</td>
</tr>
<tr>
<td>Nest Temp Farenheit</td>
<td><input type="checkbox" ng-model="bridge.settings.farenheit"
ng-true-value=true ng-false-value=false> {{bridge.settings.farenheit}}</td>
</tr>
</table>
</form>
</div>
Expand Down

0 comments on commit ad820a6

Please sign in to comment.