Skip to content

Commit

Permalink
Add air quality monitor + remote device types (#601)
Browse files Browse the repository at this point in the history
Signed-off-by: jsetton <jeremy.setton@gmail.com>
  • Loading branch information
jsetton authored Aug 29, 2023
1 parent fc84e48 commit 1bd77ae
Show file tree
Hide file tree
Showing 9 changed files with 1,330 additions and 866 deletions.
2 changes: 2 additions & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ Device Types | Supported Attributes | Description
`AirConditioner` | *[`PowerState`](#powerstate)*, [`TargetTemperature`](#targettemperature), [`CurrentTemperature`](#currenttemperature), [`FanSpeed`](#fanspeed), [`FanDirection`](#fandirection), [`FanOscillate`](#fanoscillate) | A device that cools the air in interior spaces.
`AirFreshener` | Same as `Fan` | A device that emits pleasant odors and masks unpleasant odors in interior spaces.
`AirPurifier` | Same as `Fan` | A device that improves the quality of air in interior spaces.
`AirQualityMonitor` | [`CurrentTemperature`](#currenttemperature), [`CurrentHumidity`](#currenthumidity), [`BatteryLevel`](#batterylevel) | A device that measures air quality in interior spaces.
`Automobile` | [`BatteryLevel`](#batterylevel), [`FanSpeed`](#fanspeed), [`LockState`](#lockstate), [`PowerState`](#powerstate), [`TargetTemperature`](#targettemperature), [`CurrentTemperature`](#currenttemperature) | A motor vehicle (automobile, car).
`AutomobileAccessory` | [`BatteryLevel`](#batterylevel), [`CameraStream`](#camerastream), [`FanSpeed`](#fanspeed), [`PowerState`](#powerstate) | A smart device in an automobile, such as a dash camera.
`Blind`, `Curtain`, `Shade` | *[`OpenState`](#openstate)*, *[`PositionState`](#positionstate)*, [`TiltAngle`](#tiltangle), [`TargetOpenState`](#targetopenstate), [`CurrentOpenState`](#currentopenstate) | A window covering on the inside of a structure.
Expand Down Expand Up @@ -542,6 +543,7 @@ Device Types | Supported Attributes | Description
`Oven` | *[`PowerState`](#powerstate)* | An oven cooking appliance.
`Phone` | *[`PowerState`](#powerstate)* | A non-mobile phone, such as landline or an IP phone.
`Printer` | *[`PowerState`](#powerstate)* | A device that prints.
`Remote` | *[`PowerState`](#powerstate)* | A device that support stateless events, such as a remote switch or smart button.
`Router` | Same as `NetworkHardware` | A network router.
`Screen` | Same as `Television` | A projector screen.
`SecurityPanel` | *[`ArmState`](#armstate)*, [`BurglaryAlarm`](#burglaryalarm), [`CarbonMonoxideAlarm`](#carbonmonoxidealarm), [`FireAlarm`](#firealarm), [`WaterAlarm`](#wateralarm), [`AlarmAlert`](#alarmalert), [`ReadyAlert`](#readyalert), [`TroubleAlert`](#troublealert), [`ZonesAlert`](#zonesalert) | A security panel.
Expand Down
12 changes: 12 additions & 0 deletions lambda/alexa/smarthome/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export default class AlexaDisplayCategory {
*/
static AIR_PURIFIER = 'AIR_PURIFIER';

/**
* Defines air quality monitor display category
* @type {String}
*/
static AIR_QUALITY_MONITOR = 'AIR_QUALITY_MONITOR';

/**
* Defines auto accessory display category
* @type {String}
Expand Down Expand Up @@ -214,6 +220,12 @@ export default class AlexaDisplayCategory {
*/
static PRINTER = 'PRINTER';

/**
* Defines remote display category
* @type {String}
*/
static REMOTE = 'REMOTE';

/**
* Defines router display category
* @type {String}
Expand Down
46 changes: 46 additions & 0 deletions lambda/alexa/smarthome/device/types/airQualityMonitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/

import AlexaDisplayCategory from '#alexa/smarthome/category.js';
import Sensor from './sensor.js';
import { Temperature, Humidity } from '../attributes/index.js';

/**
* Defines air quality monitor device type class
* @extends Sensor
*/
export default class AirQualityMonitor extends Sensor {
/**
* Returns supported names
* @return {Array}
*/
static get supportedNames() {
return ['AirQualityMonitor'];
}

/**
* Returns supported attributes
* @return {Array}
*/
static get supportedAttributes() {
return [Temperature, Humidity, ...super.supportedAttributes];
}

/**
* Returns display categories
* @return {Array}
*/
static get displayCategories() {
return [AlexaDisplayCategory.AIR_QUALITY_MONITOR];
}
}
2 changes: 2 additions & 0 deletions lambda/alexa/smarthome/device/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export { default as Activity } from './activity.js';
export { default as AirConditioner } from './airConditioner.js';
export { default as AirFreshener } from './airFreshener.js';
export { default as AirPurifier } from './airPurifier.js';
export { default as AirQualityMonitor } from './airQualityMonitor.js';
export { default as Automobile } from './automobile.js';
export { default as AutomobileAccessory } from './automobileAccessory.js';
export { default as BluetoothSpeaker } from './bluetoothSpeaker.js';
Expand Down Expand Up @@ -51,6 +52,7 @@ export { default as Outlet } from './outlet.js';
export { default as Oven } from './oven.js';
export { default as Phone } from './phone.js';
export { default as Printer } from './printer.js';
export { default as Remote } from './remote.js';
export { default as Router } from './router.js';
export { default as Scene } from './scene.js';
export { default as Screen } from './screen.js';
Expand Down
37 changes: 37 additions & 0 deletions lambda/alexa/smarthome/device/types/remote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/

import AlexaDisplayCategory from '#alexa/smarthome/category.js';
import GenericDevice from './genericDevice.js';

/**
* Defines remote device type class
* @extends GenericDevice
*/
export default class Remote extends GenericDevice {
/**
* Returns supported names
* @return {Array}
*/
static get supportedNames() {
return ['Remote'];
}

/**
* Returns display categories
* @return {Array}
*/
static get displayCategories() {
return [AlexaDisplayCategory.REMOTE];
}
}
98 changes: 98 additions & 0 deletions lambda/test/alexa/cases/discovery/airQualityMonitor.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/

export default {
description: 'air quality monitor',
items: [
{
type: 'Group',
name: 'gAirQualityMonitor',
label: 'Air Quality Monitor',
metadata: {
alexa: {
value: 'AirQualityMonitor'
}
}
},
{
type: 'Number:Dimensionless',
name: 'humidity',
groupNames: ['gAirQualityMonitor'],
metadata: {
alexa: {
value: 'CurrentHumidity'
}
}
},
{
type: 'Number:Temperature',
name: 'temperature',
groupNames: ['gAirQualityMonitor'],
metadata: {
alexa: {
value: 'CurrentTemperature'
}
}
}
],
catalog: {
'@Setting.Humidity': [
{
text: 'Humidity',
locale: 'en-US'
}
]
},
expected: {
gAirQualityMonitor: {
capabilities: [
'Alexa.RangeController:Humidity.rangeValue',
'Alexa.RangeController:Temperature.rangeValue',
'Alexa.EndpointHealth.connectivity',
'Alexa'
],
displayCategories: ['AIR_QUALITY_MONITOR'],
friendlyName: 'Air Quality Monitor',
propertyFlags: {
'Alexa.RangeController:Humidity': {
proactivelyReported: false,
retrievable: true,
nonControllable: true
},
'Alexa.RangeController:Temperature': {
proactivelyReported: false,
retrievable: true,
nonControllable: true
}
},
resources: {
'Alexa.RangeController:Humidity': {
friendlyNames: ['text:Humidity:en-US']
},
'Alexa.RangeController:Temperature': {
friendlyNames: ['asset:Alexa.Setting.Temperature']
}
},
configuration: {
'Alexa.RangeController:Humidity': {
supportedRange: { minimumValue: 0, maximumValue: 100, precision: 1 },
unitOfMeasure: 'Alexa.Unit.Percent'
},
'Alexa.RangeController:Temperature': {
supportedRange: { minimumValue: -50, maximumValue: 100, precision: 0.5 },
unitOfMeasure: 'Alexa.Unit.Temperature.Celsius'
}
}
}
}
};
35 changes: 35 additions & 0 deletions lambda/test/alexa/cases/discovery/remote.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/

export default {
description: 'remote',
items: [
{
type: 'Switch',
name: 'remote',
label: 'Remote',
metadata: {
alexa: {
value: 'Remote'
}
}
}
],
expected: {
remote: {
capabilities: ['Alexa.PowerController.powerState', 'Alexa.EndpointHealth.connectivity', 'Alexa'],
displayCategories: ['REMOTE'],
friendlyName: 'Remote'
}
}
};
4 changes: 4 additions & 0 deletions lambda/test/alexa/cases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import discoveryActivityTest from './discovery/activity.test.js';
import discoveryAirConditionerTest from './discovery/airConditioner.test.js';
import discoveryAirFreshenerTest from './discovery/airFreshener.test.js';
import discoveryAirPurifierTest from './discovery/airPurifier.test.js';
import discoveryAirQualityMonitorTest from './discovery/airQualityMonitor.test.js';
import discoveryAutomobileTest from './discovery/automobile.test.js';
import discoveryAutomobileAccessoryTest from './discovery/automobileAccessory.test.js';
import discoveryBlindTest from './discovery/blind.test.js';
Expand Down Expand Up @@ -52,6 +53,7 @@ import discoveryOutletTest from './discovery/outlet.test.js';
import discoveryOvenTest from './discovery/oven.test.js';
import discoveryPhoneTest from './discovery/phone.test.js';
import discoveryPrinterTest from './discovery/printer.test.js';
import discoveryRemoteTest from './discovery/remote.test.js';
import discoveryRouterTest from './discovery/router.test.js';
import discoverySceneTest from './discovery/scene.test.js';
import discoveryScreenTest from './discovery/screen.test.js';
Expand Down Expand Up @@ -102,6 +104,7 @@ export default {
discoveryAirConditionerTest,
discoveryAirFreshenerTest,
discoveryAirPurifierTest,
discoveryAirQualityMonitorTest,
discoveryAutomobileTest,
discoveryAutomobileAccessoryTest,
discoveryBlindTest,
Expand Down Expand Up @@ -132,6 +135,7 @@ export default {
discoveryOvenTest,
discoveryPhoneTest,
discoveryPrinterTest,
discoveryRemoteTest,
discoveryRouterTest,
discoverySceneTest,
discoveryScreenTest,
Expand Down
Loading

0 comments on commit 1bd77ae

Please sign in to comment.