From 49318f3191652561951c75b1e891d4d98fbd98be Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Wed, 16 Dec 2020 22:30:24 +0100 Subject: [PATCH] Small fixes --- plugins/hal-assistant-google/READNME.md | 4 ---- .../se/hal/plugin/assistant/google/SmartHomeImpl.java | 5 +++-- .../assistant/google/trait/HumiditySettingTrait.java | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/plugins/hal-assistant-google/READNME.md b/plugins/hal-assistant-google/READNME.md index 5ed3801f..f4a4d082 100644 --- a/plugins/hal-assistant-google/READNME.md +++ b/plugins/hal-assistant-google/READNME.md @@ -34,10 +34,6 @@ Account linking is required for your app to interact with the server. * Then in the upper right hand corner select the Test button to generate the draft version Test App. * Add the google_assistant integration configuration to your configuration.yaml file and restart Home Assistant following the configuration guide below. -#### Create Self signed Certificate (does not work with Google as they require a proper cert) -Run the command: -${JAVA_HOME}/bin/keytool -genkey -keyalg RSA -alias tomcat -keystore selfsigned.jks -validity -keysize 2048 - ### On Phone * Open the Google Home app and go to Settings. * Click Add..., + Set up or add, + Set up device, and click Have something already setup?. You should have [test] your app name listed under ‘Add new'. Selecting that should lead you to a browser to login your Home Assistant instance, then redirect back to a screen where you can set rooms and nicknames for your devices if you wish. diff --git a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java index 10cd3480..ad24a134 100644 --- a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java +++ b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java @@ -153,15 +153,16 @@ public class SmartHomeImpl extends SmartHomeApp implements TokenRegistrationList long sensorId = Long.parseLong(device.getId().substring(7)); // Get the number in the id "Sensor-" Sensor sensor = Sensor.getSensor(db, sensorId); DeviceTrait[] traits = DeviceTraitFactory.getTraits(sensor); - Map deviceState = new HashMap<>(); + logger.fine("Generating response for sensor: " + sensor.getName() + " (Id: " + sensor.getId() + ")"); + for (DeviceTrait trait : traits) { deviceState.putAll(trait.generateQueryResponse(sensor.getDeviceData())); } deviceState.put("status", "SUCCESS"); - deviceStates.put(device.id, deviceState); + deviceStates.put(device.getId(), deviceState); } catch (Exception e) { logger.log(Level.SEVERE, "Query request failed for sensor: " + device.getId(), e); Map failedDevice = new HashMap<>(); diff --git a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/HumiditySettingTrait.java b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/HumiditySettingTrait.java index 78038df1..d99a9047 100644 --- a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/HumiditySettingTrait.java +++ b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/HumiditySettingTrait.java @@ -26,7 +26,7 @@ package se.hal.plugin.assistant.google.trait; import se.hal.intf.HalDeviceData; import se.hal.intf.HalSensorConfig; -import se.hal.struct.devicedata.TemperatureSensorData; +import se.hal.struct.devicedata.HumiditySensorData; import java.util.HashMap; @@ -41,11 +41,11 @@ public class HumiditySettingTrait extends DeviceTrait { public HashMap generateSyncResponse(HalSensorConfig config) { HashMap response = new HashMap<>(); //response.put("humiditySetpointRange", new HashMap() {{ - // put("minPercent", -20); - // put("maxPercent", 60); + // put("minPercent", 0); + // put("maxPercent", 100); //}}); //response.put("commandOnlyHumiditySetting", false); - response.put("queryOnlyHumiditySetting", false); + response.put("queryOnlyHumiditySetting", true); return response; } @@ -53,7 +53,7 @@ public class HumiditySettingTrait extends DeviceTrait { public HashMap generateQueryResponse(HalDeviceData data) { HashMap response = new HashMap<>(); - if (data instanceof TemperatureSensorData) { + if (data instanceof HumiditySensorData) { //response.put("humiditySetpointPercent", data.getData()); response.put("humidityAmbientPercent", data.getData()); }