diff --git a/server/services/philips-hue/lib/light/light.getLights.js b/server/services/philips-hue/lib/light/light.getLights.js index 6137a1f441..fd7324117d 100644 --- a/server/services/philips-hue/lib/light/light.getLights.js +++ b/server/services/philips-hue/lib/light/light.getLights.js @@ -4,9 +4,11 @@ const { NotFoundError } = require('../../../../utils/coreErrors'); const logger = require('../../../../utils/logger'); const { getDeviceParam } = require('../../../../utils/device'); +const { getPhilipsHueColorLight } = require('../models/color'); const { getPhilipsHueColorTemperatureLight } = require('../models/colorWithTemperature'); const { getPhilipsHueWhiteLight } = require('../models/white'); const { getPhilipsHueWhiteTemperatureLight } = require('../models/whiteWithTemperature'); +const { getPlugOnOff } = require('../models/plugOnOff'); const { LIGHT_EXTERNAL_ID_BASE, BRIDGE_SERIAL_NUMBER } = require('../utils/consts'); @@ -36,6 +38,9 @@ async function getLights() { case 'GL-C-008': // Non-hue LED Strip lightsToReturn.push(getPhilipsHueColorTemperatureLight(philipsHueLight, serialNumber, this.serviceId)); break; + case 'LLC010': // Hue iris + lightsToReturn.push(getPhilipsHueColorLight(philipsHueLight, serialNumber, this.serviceId)); + break; case 'LWB010': // hue white bulb with fixed warming light (2700K) lightsToReturn.push(getPhilipsHueWhiteLight(philipsHueLight, serialNumber, this.serviceId)); break; @@ -44,6 +49,10 @@ async function getLights() { case 'LTW001': // Hue A19 White & Ambiance Bulb lightsToReturn.push(getPhilipsHueWhiteTemperatureLight(philipsHueLight, serialNumber, this.serviceId)); break; + case 'SP 120': // Innr Smart Plug On/Off + case 'Plug 01': // OSRAM Plug + lightsToReturn.push(getPlugOnOff(philipsHueLight, serialNumber, this.serviceId)); + break; default: logger.info(`Philips Hue Light of model ${philipsHueLight.modelid} is not handled yet !`); lightsToReturn.push({ diff --git a/server/services/philips-hue/lib/models/plugOnOff.js b/server/services/philips-hue/lib/models/plugOnOff.js new file mode 100644 index 0000000000..fd122e954a --- /dev/null +++ b/server/services/philips-hue/lib/models/plugOnOff.js @@ -0,0 +1,34 @@ +const { + DEVICE_FEATURE_CATEGORIES, + DEVICE_FEATURE_TYPES, + DEVICE_POLL_FREQUENCIES, +} = require('../../../../utils/constants'); + +const { LIGHT_EXTERNAL_ID_BASE } = require('../utils/consts'); + +const getPlugOnOff = (philipsHueLight, bridgeSerialNumber, serviceId) => ({ + name: philipsHueLight.name, + service_id: serviceId, + external_id: `${LIGHT_EXTERNAL_ID_BASE}:${bridgeSerialNumber}:${philipsHueLight.id}`, + selector: `${LIGHT_EXTERNAL_ID_BASE}:${bridgeSerialNumber}:${philipsHueLight.id}`, + should_poll: true, + model: philipsHueLight.modelid, + poll_frequency: DEVICE_POLL_FREQUENCIES.EVERY_MINUTES, + features: [ + { + name: `${philipsHueLight.name} On/Off`, + read_only: false, + has_feedback: false, + external_id: `${LIGHT_EXTERNAL_ID_BASE}:${bridgeSerialNumber}:${philipsHueLight.id}:${DEVICE_FEATURE_TYPES.SWITCH.BINARY}`, + selector: `${LIGHT_EXTERNAL_ID_BASE}:${bridgeSerialNumber}:${philipsHueLight.id}:${DEVICE_FEATURE_TYPES.SWITCH.BINARY}`, + category: DEVICE_FEATURE_CATEGORIES.SWITCH, + type: DEVICE_FEATURE_TYPES.LIGHT.BINARY, + min: 0, + max: 1, + }, + ], +}); + +module.exports = { + getPlugOnOff, +}; diff --git a/server/test/services/philips-hue/lights.json b/server/test/services/philips-hue/lights.json index d85673537d..77fff2262b 100644 --- a/server/test/services/philips-hue/lights.json +++ b/server/test/services/philips-hue/lights.json @@ -575,6 +575,114 @@ "_id": 13, "id": 13, "mappedColorGamut": "other" + }, + { + "state": { + "on": false, + "alert": "select", + "mode": "homeautomation", + "reachable": true + }, + "swupdate": { "state": "notupdatable", "lastinstall": null }, + "type": "On/Off plug-in unit", + "name": "Guirlande", + "modelid": "SP 120", + "manufacturername": "innr", + "productname": "On/Off plug", + "_rawData": { + "capabilities": { + "certified": false, + "control": {}, + "streaming": { "renderer": false, "proxy": false } + }, + "config": { + "archetype": "huelightstrip", + "function": "functional", + "direction": "omnidirectional" + }, + "uniqueid": "00:15:8d:00:01:fe:54:7d-01", + "swversion": "2.0" + }, + "_id": 14, + "id": 14 + }, + { + "state": { + "on": false, + "bri": 69, + "hue": 63054, + "sat": 203, + "effect": "none", + "xy": [0.6166, 0.3041], + "alert": "select", + "colormode": "xy", + "mode": "homeautomation", + "reachable": true + }, + "swupdate": { + "state": "noupdates", + "lastinstall": "2018-12-13T13:12:05" + }, + "type": "Color light", + "name": "Iris Télévison", + "modelid": "LLC010", + "manufacturername": "Philips", + "productname": "Hue iris", + "_rawData": { + "capabilities": { + "certified": true, + "control": { + "mindimlevel": 10000, + "maxlumen": 210, + "colorgamuttype": "A", + "colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]] + }, + "streaming": { "renderer": true, "proxy": false } + }, + "config": { + "archetype": "hueiris", + "function": "decorative", + "direction": "upwards", + "startup": { "mode": "safety", "configured": true } + }, + "uniqueid": "00:17:88:01:00:0d:b3:60-0b", + "swversion": "5.127.1.26581" + }, + "_id": 15, + "id": 15 + }, + { + "state": { + "on": true, + "alert": "select", + "mode": "homeautomation", + "reachable": true + }, + "swupdate": { + "state": "notupdatable", + "lastinstall": "2019-11-16T15:51:07" + }, + "type": "On/Off plug-in unit", + "name": "Noël", + "modelid": "Plug 01", + "manufacturername": "OSRAM", + "productname": "On/Off plug", + "_rawData": { + "capabilities": { + "certified": false, + "control": {}, + "streaming": { "renderer": false, "proxy": false } + }, + "config": { + "archetype": "christmastree", + "function": "functional", + "direction": "omnidirectional" + }, + "uniqueid": "7c:b0:3e:aa:00:af:be:7a-03", + "swversion": "V1.04.90" + }, + "_id": 16, + "id": 16 } ] }