Skip to content

Commit

Permalink
Fix GladysAssistant#605 : Add Innr plug, Hue iris & OSRAM Plug (Glady…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles authored Nov 18, 2019
1 parent 057de68 commit df6f7aa
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/services/philips-hue/lib/light/light.getLights.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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;
Expand All @@ -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({
Expand Down
34 changes: 34 additions & 0 deletions server/services/philips-hue/lib/models/plugOnOff.js
Original file line number Diff line number Diff line change
@@ -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,
};
108 changes: 108 additions & 0 deletions server/test/services/philips-hue/lights.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}

0 comments on commit df6f7aa

Please sign in to comment.