diff --git a/docs/USAGE.md b/docs/USAGE.md
index 731159d9..da79204d 100644
--- a/docs/USAGE.md
+++ b/docs/USAGE.md
@@ -390,7 +390,7 @@ Number pm25Item (fanGroup) { ga="fanPM25" }
| **Device Type** | [AC_Unit](https://developers.google.com/assistant/smarthome/guides/acunit) |
| **Supported Traits** | [OnOff](https://developers.google.com/assistant/smarthome/traits/OnOff), [FanSpeed](https://developers.google.com/assistant/smarthome/traits/fanspeed), [TemperatureSetting](https://developers.google.com/assistant/smarthome/traits/temperaturesetting), [Modes](https://developers.google.com/assistant/smarthome/traits/modes), [SensorState](https://developers.google.com/assistant/smarthome/traits/sensorstate) |
| **Supported Items** | Group as `AC_Unit` with the following members:
(optional) Switch as `fanPower`
(optional) Dimmer or Number as `fanSpeed`
(optional) Number or String as `fanMode`
(optional) Number as `fanFilterLifeTime`
(optional) Number as `fanPM25`
(optional) Number as `thermostatTemperatureAmbient`
(optional) Number as `thermostatTemperatureSetpoint`
(optional) Number as `thermostatTemperatureSetpointLow`
(optional) Number as `thermostatTemperatureSetpointHigh`
(optional) Number as `thermostatHumidityAmbient`
(optional) String or Number or Switch as `thermostatMode` |
-| **Configuration** | (optional) `checkState=true/false`
(optional) `fanSpeeds="0=away:zero,50=default:standard:one,100=high:two"`
(optional) `fanModeName="OperationMode,Modus"`
(optional) `fanModeSettings="1=Low:Silent,2=Normal,3=High:Night"`
(optional) `useFahrenheit=true/false`
(optional) `humidityUnit=percent/float`
(optional) `thermostatTemperatureRange="10,30"`
(optional) `thermostatModes="off=OFF:WINDOW_OPEN,heat=COMFORT:BOOST,eco=ECO,on=ON,auto"`
(optional) `lang="en"`
(optional) `ordered=true/false` |
+| **Configuration** | (optional) `checkState=true/false`
(optional) `fanSpeeds="0=away:zero,50=default:standard:one,100=high:two"`
(optional) `fanModeName="OperationMode,Modus"`
(optional) `fanModeSettings="1=Low:Silent,2=Normal,3=High:Night"`
(optional) `useFahrenheit=true/false`
(optional) `maxHumidity=1-100`
(optional) `thermostatTemperatureRange="10,30"`
(optional) `thermostatModes="off=OFF:WINDOW_OPEN,heat=COMFORT:BOOST,eco=ECO,on=ON,auto"`
(optional) `lang="en"`
(optional) `ordered=true/false` |
The AC_Unit device is basically the combination of the Fan and the Thermostat device. For explanation on configuration options please take a look at both of them.
@@ -486,7 +486,7 @@ Number { ga="TemperatureSensor" [ useFahrenheit=true, temperatureRange="-20,40"
| **Device Type** | [Sensor](https://developers.home.google.com/cloud-to-cloud/guides/sensor) |
| **Supported Traits** | [HumiditySetting](https://developers.home.google.com/cloud-to-cloud/traits/humiditysetting) |
| **Supported Items** | Number |
-| **Configuration** | (optional) `humidityUnit=percent/float` |
+| **Configuration** | (optional) `maxHumidity=1-100` |
```shell
Number { ga="HumiditySensor" }
@@ -499,7 +499,7 @@ Number { ga="HumiditySensor" }
| **Device Type** | [Sensor](https://developers.home.google.com/cloud-to-cloud/guides/sensor) |
| **Supported Traits** | [HumiditySetting](https://developers.home.google.com/cloud-to-cloud/traits/humiditysetting), [TemperatureControl](https://developers.home.google.com/cloud-to-cloud/traits/temperaturecontrol), [TemperatureSetting](https://developers.home.google.com/cloud-to-cloud/traits/temperaturesetting) |
| **Supported Items** | Group as `ClimateSensor` with the following members:
(optional) Number as `humidityAmbient`
(optional) Number as `temperatureAmbient` |
-| **Configuration** | (optional) `useFahrenheit=true/false`
(optional) `humidityUnit=percent/float`
(optional) `temperatureRange="-10,50"` |
+| **Configuration** | (optional) `useFahrenheit=true/false`
(optional) `maxHumidity=1-100`
(optional) `temperatureRange="-10,50"` |
By default, the temperature range of a climate sensor is set to -100 °C to 100 °C.
The reported state values have to fall into that range!
@@ -518,7 +518,7 @@ Number humidityItem (sensorGroup) { ga="humidityAmbient" }
| **Device Type** | [Thermostat](https://developers.home.google.com/cloud-to-cloud/guides/thermostat) |
| **Supported Traits** | [TemperatureSetting](https://developers.home.google.com/cloud-to-cloud/traits/temperaturesetting) |
| **Supported Items** | Group as `Thermostat` with the following members
(optional) Number as `thermostatTemperatureAmbient`
(optional) Number as `thermostatTemperatureSetpoint`
(optional) Number as `thermostatTemperatureSetpointLow`
(optional) Number as `thermostatTemperatureSetpointHigh`
(optional) Number as `thermostatHumidityAmbient`
(optional) String or Number or Switch as `thermostatMode` |
-| **Configuration** | (optional) `checkState=true/false`
(optional) `useFahrenheit=true/false`
(optional) `humidityUnit=percent/float`
(optional) `thermostatTemperatureRange="10,30"`
(optional) `thermostatModes="off=OFF:WINDOW_OPEN,heat=COMFORT:BOOST,eco=ECO,on=ON,auto"` |
+| **Configuration** | (optional) `checkState=true/false`
(optional) `useFahrenheit=true/false`
(optional) `maxHumidity=1-100`
(optional) `thermostatTemperatureRange="10,30"`
(optional) `thermostatModes="off=OFF:WINDOW_OPEN,heat=COMFORT:BOOST,eco=ECO,on=ON,auto"` |
Thermostat requires a group of items to be properly configured to be used with Google Assistant. The default temperature unit is Celsius.
To change the temperature unit to Fahrenheit, add the config option `useFahrenheit=true` to the thermostat group.
diff --git a/functions/devices/climatesensor.js b/functions/devices/climatesensor.js
index 381a12ef..444954d6 100644
--- a/functions/devices/climatesensor.js
+++ b/functions/devices/climatesensor.js
@@ -72,8 +72,8 @@ class ClimateSensor extends DefaultDevice {
}
if ('humidityAmbient' in members) {
const config = this.getConfig(item);
- const isPercent = !config.humidityUnit || config.humidityUnit.toLowerCase() === 'percent';
- const humidity = Math.round(parseFloat(members.humidityAmbient.state) * (isPercent ? 1 : 100));
+ const maxHumidity = (config.maxHumidity && parseInt(config.maxHumidity)) || 100;
+ const humidity = Math.round(parseFloat(members.humidityAmbient.state) * (100 / maxHumidity));
state.humidityAmbientPercent = humidity;
state.humiditySetpointPercent = humidity;
}
diff --git a/functions/devices/humiditysensor.js b/functions/devices/humiditysensor.js
index e007dd57..53efe9ce 100644
--- a/functions/devices/humiditysensor.js
+++ b/functions/devices/humiditysensor.js
@@ -25,8 +25,8 @@ class HumiditySensor extends DefaultDevice {
static getState(item) {
const config = this.getConfig(item);
- const isPercent = !config.humidityUnit || config.humidityUnit.toLowerCase() === 'percent';
- const state = Math.round(parseFloat(item.state) * (isPercent ? 1 : 100));
+ const maxHumidity = (config.maxHumidity && parseInt(config.maxHumidity)) || 100;
+ const state = Math.round(parseFloat(item.state) * (100 / maxHumidity));
return {
humidityAmbientPercent: state,
humiditySetpointPercent: state
diff --git a/functions/devices/thermostat.js b/functions/devices/thermostat.js
index 0666097a..32303639 100644
--- a/functions/devices/thermostat.js
+++ b/functions/devices/thermostat.js
@@ -58,8 +58,8 @@ class Thermostat extends DefaultDevice {
}
if (member.indexOf('Humidity') > 0) {
const config = this.getConfig(item);
- const isPercent = !config.humidityUnit || config.humidityUnit.toLowerCase() === 'percent';
- state[member] = Math.round(parseFloat(members[member].state) * (isPercent ? 1 : 100));
+ const maxHumidity = (config.maxHumidity && parseInt(config.maxHumidity)) || 100;
+ state[member] = Math.round(parseFloat(members[member].state) * (100 / maxHumidity));
}
}
}
diff --git a/tests/devices/climatesensor.test.js b/tests/devices/climatesensor.test.js
index 9e4ec232..a9cc735a 100644
--- a/tests/devices/climatesensor.test.js
+++ b/tests/devices/climatesensor.test.js
@@ -226,7 +226,7 @@ describe('ClimateSensor Device', () => {
metadata: {
ga: {
config: {
- humidityUnit: 'float'
+ maxHumidity: 1
}
}
},
diff --git a/tests/devices/humiditysensor.test.js b/tests/devices/humiditysensor.test.js
index 9e483b5b..eaee42dd 100644
--- a/tests/devices/humiditysensor.test.js
+++ b/tests/devices/humiditysensor.test.js
@@ -37,13 +37,11 @@ describe('HumiditySensor Device', () => {
});
});
- test('getState humidityUnit float', () => {
- expect(Device.getState({ state: '0.34', metadata: { ga: { config: { humidityUnit: 'float' } } } })).toStrictEqual(
- {
- humidityAmbientPercent: 34,
- humiditySetpointPercent: 34
- }
- );
+ test('getState maxHumidity', () => {
+ expect(Device.getState({ state: '0.34', metadata: { ga: { config: { maxHumidity: 1 } } } })).toStrictEqual({
+ humidityAmbientPercent: 34,
+ humiditySetpointPercent: 34
+ });
});
});
});
diff --git a/tests/devices/thermostat.test.js b/tests/devices/thermostat.test.js
index dcd81b04..79bb505f 100644
--- a/tests/devices/thermostat.test.js
+++ b/tests/devices/thermostat.test.js
@@ -415,12 +415,12 @@ describe('Thermostat Device', () => {
});
});
- test('getState only humdity with unit', () => {
+ test('getState only humdity with maxHumidity', () => {
const item = {
metadata: {
ga: {
config: {
- humidityUnit: 'float'
+ maxHumidity: 1
}
}
},