Skip to content

Commit

Permalink
Temperature Sensor Outside Group v2 Category Fix (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsetton authored and digitaldan committed May 7, 2018
1 parent 8157e34 commit 8c7860e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ohConnectorV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,23 +717,24 @@ function discoverDevices(token, success, failure) {
applianceTypes = ['SMARTPLUG'];
break;
case 'Lighting':
applianceTypes = ['LIGHT'];
actions = getSwitchableActions(item);
applianceTypes = ['LIGHT'];
break;
case 'Switchable':
applianceTypes = ['SWITCH'];
actions = getSwitchableActions(item);
applianceTypes = ['SWITCH'];
break;
case 'CurrentTemperature':
//if this is not part of a thermostatGroup then add it
//standalone otherwise it will be available as a thermostat
if(!matchesGroup(thermostatGroups, item.groupNames)){
actions = [
'getTemperatureReading'
];
setTempFormat(item,additionalApplianceDetails);
}
break;
//if this is not part of a thermostatGroup then add it
//standalone otherwise it will be available as a thermostat
if(!matchesGroup(thermostatGroups, item.groupNames)){
actions = [
'getTemperatureReading'
];
setTempFormat(item,additionalApplianceDetails);
applianceTypes = ['TEMPERATURE_SENSOR'];
}
break;
case 'Thermostat':
//only group items are allowed to have a Temperature tag
if (item.type === 'Group') {
Expand Down
18 changes: 18 additions & 0 deletions test/v2/test_discoverThermostat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ module.exports = {
"label": "Thermostat",
"tags": ["Thermostat", "Fahrenheit"],
"groupNames": []
},
{
"link": "https://myopenhab.org/rest/items/temperature",
"type": "Group",
"name": "temperature",
"label": "Temperature",
"tags": ["CurrentTemperature", "Fahrenheit"],
"groupNames": []
}
],
expected: {
Expand All @@ -47,6 +55,16 @@ module.exports = {
},
"applianceTypes": ["THERMOSTAT"],
"friendlyName": "Thermostat"
},
"temperature": {
"actions": [
"getTemperatureReading"
],
"additionalApplianceDetails": {
"temperatureFormat": "fahrenheit"
},
"applianceTypes": ["TEMPERATURE_SENSOR"],
"friendlyName": "Temperature"
}
}
};
29 changes: 29 additions & 0 deletions test/v3/test_discoverThermostat.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ module.exports = {
}
},
"groupNames": []
},
{
"link": "https://myopenhab.org/rest/items/temperature1",
"type": "Group",
"name": "temperature1",
"label": "Temperature 1",
"tags": [],
"metadata": {
"alexa": {
"value": "TemperatureSensor.temperature",
"config": {
"scale": "Fahrenheit"
}
}
},
"groupNames": []
}
],
expected: {
Expand Down Expand Up @@ -183,6 +199,19 @@ module.exports = {
"thermostatMode": { "parameters": {"binding": "foobar"}, "itemName": "thermostatMode2" }
}
}
},
"temperature1": {
"capabilities": [
"Alexa",
"Alexa.TemperatureSensor.temperature"
],
"displayCategories": ["TEMPERATURE_SENSOR"],
"friendlyName": "Temperature 1",
"propertyMap": {
"TemperatureSensor": {
"temperature": {"parameters": {"scale": "Fahrenheit"}, "itemName": "temperature1"}
}
}
}
}
};

0 comments on commit 8c7860e

Please sign in to comment.