From ce089d4522ebd8a75b68475300d232737e4ed64c Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Tue, 29 Oct 2019 15:46:19 +0100 Subject: [PATCH 1/4] Improve UX on service --- front/src/config/i18n/en.json | 6 +- .../philips-hue/device-page/FoundDevices.jsx | 7 ++ .../all/philips-hue/device-page/index.js | 4 +- .../all/philips-hue/device-page/style.css | 3 + .../all/philips-hue/setup-page/SetupTab.jsx | 100 ++++++++++-------- .../all/philips-hue/setup-page/style.css | 3 + 6 files changed, 77 insertions(+), 46 deletions(-) create mode 100644 front/src/routes/integration/all/philips-hue/setup-page/style.css diff --git a/front/src/config/i18n/en.json b/front/src/config/i18n/en.json index 32b3f79734..09ad5499ba 100644 --- a/front/src/config/i18n/en.json +++ b/front/src/config/i18n/en.json @@ -192,14 +192,16 @@ "scanButton": "Scan network", "bridgeButtonNotPressed": "Bridge button not pressed: Please press the button on your Philips Hue bridge and try again.", "unknownError": "An unknown error occured. Please try again or contact Gladys community.", - "noBridgesConnected": "No bridges connected." + "noBridgesConnected": "No bridges connected.", + "noBridgesFound": "We didn't find any Philips Hue bridges on your network. Are you sure you are connected to the same network as your bridge and your bridge is turned on?" }, "device": { "title": "Devices in Gladys", "deviceOnNetworkTitle": "Devices detected on network", "connectButton": "Connect/Reconnect", "search": "Search devices", - "deviceNotHandled": "Device not handled yet, please contact us to help us connect it in Gladys!" + "deviceNotHandled": "Device not handled yet, please contact us to help us connect it in Gladys!", + "noDevicesFound": "No devices found. Make sure you have connected one Philips Hue bridge in the setup tab." } }, "rtspCamera": { diff --git a/front/src/routes/integration/all/philips-hue/device-page/FoundDevices.jsx b/front/src/routes/integration/all/philips-hue/device-page/FoundDevices.jsx index ff4ba21396..c8afa1d303 100644 --- a/front/src/routes/integration/all/philips-hue/device-page/FoundDevices.jsx +++ b/front/src/routes/integration/all/philips-hue/device-page/FoundDevices.jsx @@ -27,6 +27,13 @@ const FoundDevices = ({ children, ...props }) => (
{props.getPhilipsHueNewDevicesStatus === RequestStatus.Getting &&
}
+ {props.philipsHueNewDevices && props.philipsHueNewDevices.length === 0 && ( +
+
+ +
+
+ )} {props.philipsHueNewDevices && props.philipsHueNewDevices.map((device, index) => (
diff --git a/front/src/routes/integration/all/philips-hue/device-page/index.js b/front/src/routes/integration/all/philips-hue/device-page/index.js index 92e944cf0a..431d7533cd 100644 --- a/front/src/routes/integration/all/philips-hue/device-page/index.js +++ b/front/src/routes/integration/all/philips-hue/device-page/index.js @@ -6,7 +6,7 @@ import DevicePage from './DevicePage'; import FoundDevices from './FoundDevices'; @connect( - 'session,user,philipsHueDevices,houses,getPhilipsHueDevicesStatus,philipsHueNewDevices,getPhilipsHueCreateDeviceStatus', + 'session,user,philipsHueDevices,houses,getPhilipsHueDevicesStatus,philipsHueNewDevices,getPhilipsHueCreateDeviceStatus,getPhilipsHueNewDevicesStatus', actions ) class PhilipsHueDevicePage extends Component { @@ -20,7 +20,7 @@ class PhilipsHueDevicePage extends Component { render(props, {}) { return ( - + {props.philipsHueDevices && props.philipsHueDevices.length ? :
} ); diff --git a/front/src/routes/integration/all/philips-hue/device-page/style.css b/front/src/routes/integration/all/philips-hue/device-page/style.css index e69de29bb2..67713e8fb7 100644 --- a/front/src/routes/integration/all/philips-hue/device-page/style.css +++ b/front/src/routes/integration/all/philips-hue/device-page/style.css @@ -0,0 +1,3 @@ +.emptyDiv { + min-height: 200px +} diff --git a/front/src/routes/integration/all/philips-hue/setup-page/SetupTab.jsx b/front/src/routes/integration/all/philips-hue/setup-page/SetupTab.jsx index d85ed34aea..09484af7ea 100644 --- a/front/src/routes/integration/all/philips-hue/setup-page/SetupTab.jsx +++ b/front/src/routes/integration/all/philips-hue/setup-page/SetupTab.jsx @@ -1,6 +1,7 @@ import { Text } from 'preact-i18n'; import cx from 'classnames'; import { RequestStatus } from '../../../../../utils/consts'; +import style from './style.css'; const disconnectBridge = (props, device, index) => () => { props.deleteDevice(device, index); @@ -13,61 +14,68 @@ const connectBridge = (props, device) => () => { const SetupTab = ({ children, ...props }) => { return (
-
-
-

- -

-
-
-
-
-
- {props.philipsHueDeleteDeviceStatus === RequestStatus.Error && ( -

- -

- )} -
- {props.philipsHueBridgesDevices && - props.philipsHueBridgesDevices.map((bridge, index) => ( -
-
-
-

{bridge.name}

-
-
- + {props.philipsHueBridgesDevices && props.philipsHueBridgesDevices.length > 0 && ( +
+
+

+ +

+
+
+
+
+
+ {props.philipsHueDeleteDeviceStatus === RequestStatus.Error && ( +

+ +

+ )} + {props.philipsHueGetDevicesStatus === RequestStatus.Getting &&
} +
+ {props.philipsHueBridgesDevices && + props.philipsHueBridgesDevices.map((bridge, index) => ( +
+
+
+

{bridge.name}

+
+
+ +
+ ))} +
+ {props.philipsHueBridgesDevices && props.philipsHueBridgesDevices.length === 0 && ( +
+
+
- ))} -
- {props.philipsHueBridgesDevices && props.philipsHueBridgesDevices.length === 0 && ( -
-
-
-
- )} + )} +
-
+ )}

-
@@ -81,6 +89,14 @@ const SetupTab = ({ children, ...props }) => { >
+ {props.philipsHueGetBridgesStatus === RequestStatus.Getting &&
} + {props.philipsHueBridges && props.philipsHueBridges.length === 0 && ( +
+
+ +
+
+ )} {props.philipsHueCreateDeviceStatus === RequestStatus.PhilipsHueBridgeButtonNotPressed && (

diff --git a/front/src/routes/integration/all/philips-hue/setup-page/style.css b/front/src/routes/integration/all/philips-hue/setup-page/style.css new file mode 100644 index 0000000000..67713e8fb7 --- /dev/null +++ b/front/src/routes/integration/all/philips-hue/setup-page/style.css @@ -0,0 +1,3 @@ +.emptyDiv { + min-height: 200px +} From c13e97f4763238e5108af946445d094b96c5e7d9 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Tue, 29 Oct 2019 16:00:55 +0100 Subject: [PATCH 2/4] Fix #592 : Add philips hue compatibilities --- .../philips-hue/lib/light/light.getLights.js | 3 + server/test/services/philips-hue/lights.json | 149 +++++++++++++++++- 2 files changed, 144 insertions(+), 8 deletions(-) diff --git a/server/services/philips-hue/lib/light/light.getLights.js b/server/services/philips-hue/lib/light/light.getLights.js index ab9fb50afb..6137a1f441 100644 --- a/server/services/philips-hue/lib/light/light.getLights.js +++ b/server/services/philips-hue/lib/light/light.getLights.js @@ -32,6 +32,8 @@ async function getLights() { case 'LCT015': // hue white & color 4th generation case 'LST002': // hue lightstrip indoor 2nd generation case 'LCT024': // Hue play 1 + case 'LCT010': // Hue A19 White & Color w/ Richer Colors + case 'GL-C-008': // Non-hue LED Strip lightsToReturn.push(getPhilipsHueColorTemperatureLight(philipsHueLight, serialNumber, this.serviceId)); break; case 'LWB010': // hue white bulb with fixed warming light (2700K) @@ -39,6 +41,7 @@ async function getLights() { break; case 'LTW012': // hue White Ambiance E12 case 'LTW010': // hue White & Ambiance Bulb + case 'LTW001': // Hue A19 White & Ambiance Bulb lightsToReturn.push(getPhilipsHueWhiteTemperatureLight(philipsHueLight, serialNumber, this.serviceId)); break; default: diff --git a/server/test/services/philips-hue/lights.json b/server/test/services/philips-hue/lights.json index 90c730f950..d85673537d 100644 --- a/server/test/services/philips-hue/lights.json +++ b/server/test/services/philips-hue/lights.json @@ -37,7 +37,7 @@ "function": "mixed", "direction": "omnidirectional" }, - "uniqueid": "00:17:88:01:10:42:77:4e-0b", + "uniqueid": "unique-id", "swversion": "5.50.1.19085", "_id": 1, "id": 1, @@ -140,7 +140,7 @@ "configured": true } }, - "uniqueid": "00:17:88:01:04:25:4e:45-0b", + "uniqueid": "unique-id", "swversion": "1.46.13_r26312", "swconfigid": "5E2017D8", "productid": "Philips-LTW012-1-E14CTv1" @@ -193,7 +193,7 @@ "configured": true } }, - "uniqueid": "00:17:88:01:04:24:18:04-0b", + "uniqueid": "unique-id", "swversion": "1.46.13_r26312", "swconfigid": "7A2E82CC", "productid": "Philips-LTW010-1-A19CTv2" @@ -252,7 +252,7 @@ "configured": true } }, - "uniqueid": "00:17:88:01:03:a2:f2:66-0b", + "uniqueid": "unique-id", "swversion": "1.46.13_r26312", "swconfigid": "A25796CB", "productid": "Philips-LST002-1-LedStripsv3" @@ -306,7 +306,7 @@ "customsettings": { "bri": 254, "xy": [0.309, 0.3276] } } }, - "uniqueid": "00:17:88:01:06:40:f3:ba-0b", + "uniqueid": "unique-id", "swversion": "1.46.13_r26312", "swconfigid": "869E2FE2", "productid": "3241-3127-7871-LS00" @@ -360,7 +360,7 @@ "customsettings": { "bri": 254, "ct": 301 } } }, - "uniqueid": "00:17:88:01:04:3d:1f:aa-0b", + "uniqueid": "unique-id", "swversion": "1.46.13_r26312", "swconfigid": "52E3234B", "productid": "Philips-LCT015-1-A19ECLv5" @@ -398,7 +398,7 @@ "direction": "omnidirectional", "startup": { "mode": "safety", "configured": true } }, - "uniqueid": "00:17:88:01:04:40:0b:53-0b", + "uniqueid": "unique-id", "swversion": "1.46.13_r26312", "swconfigid": "322BB2EC", "productid": "Philips-LWB010-1-A19DLv4" @@ -435,13 +435,146 @@ "direction": "omnidirectional", "startup": { "mode": "safety", "configured": true } }, - "uniqueid": "00:17:88:01:04:40:0b:53-0b", + "uniqueid": "unique-id", "swversion": "1.46.13_r26312", "swconfigid": "322BB2EC", "productid": "Philips-LWB010-1-A19DLv4" }, "_id": 11, "id": 11 + }, + { + "state": { + "on": true, + "bri": 144, + "ct": 443, + "alert": "lselect", + "colormode": "ct", + "mode": "homeautomation", + "reachable": true + }, + "swupdate": { + "state": "noupdates", + "lastinstall": "2018-12-11T22:38:56" + }, + "type": "Color temperature light", + "name": "Hue ambiance lamp Salon", + "modelid": "LTW001", + "manufacturername": "Philips", + "productname": "Hue ambiance lamp", + "_rawData": { + "capabilities": { + "certified": true, + "control": { + "mindimlevel": 1000, + "maxlumen": 806, + "ct": { "min": 153, "max": 454 } + }, + "streaming": { "renderer": false, "proxy": false } + }, + "config": { + "archetype": "sultanbulb", + "function": "functional", + "direction": "omnidirectional", + "startup": { "mode": "powerfail", "configured": true } + }, + "uniqueid": "unique-id", + "swversion": "version" + }, + "_id": 11, + "id": 11, + "mappedColorGamut": "2200K-6500K" + }, + { + "state": { + "on": false, + "bri": 144, + "hue": 7676, + "sat": 199, + "effect": "none", + "xy": [0.5016, 0.4151], + "ct": 443, + "alert": "none", + "colormode": "xy", + "mode": "homeautomation", + "reachable": true + }, + "swupdate": { + "state": "noupdates", + "lastinstall": "2018-12-05T13:27:07" + }, + "type": "Extended color light", + "name": "Hue color lamp Chambre", + "modelid": "LCT010", + "manufacturername": "Philips", + "productname": "Hue color lamp", + "_rawData": { + "capabilities": { + "certified": true, + "control": { + "mindimlevel": 1000, + "maxlumen": 806, + "colorgamuttype": "C", + "colorgamut": [[0.6915, 0.3083], [0.17, 0.7], [0.1532, 0.0475]], + "ct": { "min": 153, "max": 500 } + }, + "streaming": { "renderer": true, "proxy": true } + }, + "config": { + "archetype": "sultanbulb", + "function": "mixed", + "direction": "omnidirectional", + "startup": { "mode": "powerfail", "configured": true } + }, + "uniqueid": "unique-id", + "swversion": "1.46.13_r26312", + "swconfigid": "0CE67A8F", + "productid": "Philips-LCT010-1-A19ECLv4" + }, + "_id": 12, + "id": 12, + "mappedColorGamut": "C" + }, + { + "state": { + "on": true, + "bri": 246, + "hue": 0, + "sat": 0, + "effect": "none", + "xy": [0.3979, 0.3984], + "ct": 447, + "alert": "lselect", + "colormode": "xy", + "mode": "homeautomation", + "reachable": false + }, + "swupdate": { "state": "notupdatable", "lastinstall": null }, + "type": "Extended color light", + "name": "Led Strip bureau", + "modelid": "GL-C-008", + "manufacturername": "GLEDOPTO", + "productname": "Extended color light", + "_rawData": { + "capabilities": { + "certified": false, + "control": { + "colorgamuttype": "other", + "ct": { "min": 0, "max": 65535 } + }, + "streaming": { "renderer": false, "proxy": false } + }, + "config": { + "archetype": "classicbulb", + "function": "mixed", + "direction": "omnidirectional" + }, + "uniqueid": "unique-id", + "swversion": "1.0.2" + }, + "_id": 13, + "id": 13, + "mappedColorGamut": "other" } ] } From d7d077a2af3174719bfa4a70638ece4a046d1d1a Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Tue, 29 Oct 2019 16:19:23 +0100 Subject: [PATCH 3/4] Philips hue: display in new only devices which are not in Gladys --- .../all/philips-hue/device-page/actions.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/front/src/routes/integration/all/philips-hue/device-page/actions.js b/front/src/routes/integration/all/philips-hue/device-page/actions.js index 913d89f456..f1e000e8a7 100644 --- a/front/src/routes/integration/all/philips-hue/device-page/actions.js +++ b/front/src/routes/integration/all/philips-hue/device-page/actions.js @@ -25,10 +25,14 @@ function createActions(store) { } const philipsHueDevicesReceived = await state.httpClient.get('/api/v1/service/philips-hue/device', options); const philipsHueDevices = philipsHueDevicesReceived.filter(device => device.model !== BRIDGE_MODEL); + const philipsHueDevicesMap = new Map(); + philipsHueDevices.forEach(device => philipsHueDevicesMap.set(device.external_id, device)); store.setState({ philipsHueDevices, + philipsHueDevicesMap, getPhilipsHueDevicesStatus: RequestStatus.Success }); + actions.getPhilipsHueNewDevices(store.getState()); } catch (e) { store.setState({ getPhilipsHueDevicesStatus: RequestStatus.Error @@ -41,8 +45,14 @@ function createActions(store) { }); try { const philipsHueNewDevices = await state.httpClient.get('/api/v1/service/philips-hue/light'); + const philipsHueNewDevicesFiltered = philipsHueNewDevices.filter(device => { + if (!state.philipsHueDevicesMap) { + return true; + } + return !state.philipsHueDevicesMap.has(device.external_id); + }); store.setState({ - philipsHueNewDevices, + philipsHueNewDevices: philipsHueNewDevicesFiltered, getPhilipsHueNewDevicesStatus: RequestStatus.Success }); } catch (e) { From e7187c461d28967feb2d1cbf3f0a7822bcefc691 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Tue, 29 Oct 2019 16:19:29 +0100 Subject: [PATCH 4/4] Improve demo mode for lights --- front/src/config/demo.json | 162 ++++++++++++++----------------------- 1 file changed, 62 insertions(+), 100 deletions(-) diff --git a/front/src/config/demo.json b/front/src/config/demo.json index 119aea789b..33755bcd18 100644 --- a/front/src/config/demo.json +++ b/front/src/config/demo.json @@ -202,6 +202,7 @@ "devices": [ { "id": "b32daa9a-8f77-4394-b4f3-ffea215062d2", + "name": "Main Lamp", "selector": "main-lamp", "features": [ { @@ -219,6 +220,7 @@ }, { "id": "b32daa9a-8f77-4394-b4f3-ffea215062d2", + "name": "TV Lamp", "selector": "tv-lamp", "features": [ { @@ -1030,125 +1032,85 @@ "get /api/v1/service/philips-hue/light": [ { "id": "1", - "name": "Lounge Living Color", - "type": "Extended color light", - "modelid": "LCT007", - "manufacturername": "Phillips", - "uniqueid": "00:17:88:01:xx:xx:xx:xx-xx", - "swversion": "66013452", - "state": { - "on": true, - "bri": 202, - "hue": 11315, - "sat": 237, - "effect": "none", - "xy": [0.5534, 0.4239], - "alert": "none", - "colormode": "xy", - "reachable": true - } + "name": "New Lamp", + "model": "LCT007", + "external_id": "philips-hue:4" }, { "id": "2", - "name": "Right Bedside", - "type": "Extended color light", - "modelid": "LCT001", - "manufacturername": "Phillips", - "uniqueid": "00:17:88:01:xx:xx:xx:xx-xx", - "swversion": "66013452", - "state": { - "on": true, - "bri": 202, - "hue": 11315, - "sat": 237, - "effect": "none", - "xy": [0.5534, 0.4239], - "alert": "none", - "colormode": "xy", - "reachable": true - } - }, - { - "id": "3", - "name": "Left Bedside", - "type": "Extended color light", - "modelid": "LCT001", - "manufacturername": "Phillips", - "uniqueid": "00:17:88:01:xx:xx:xx:xx-xx", - "swversion": "66013452", - "state": { - "on": true, - "bri": 202, - "hue": 11315, - "sat": 237, - "effect": "none", - "xy": [0.5534, 0.4239], - "alert": "none", - "colormode": "xy", - "reachable": true - } + "name": "Living room lamp", + "model": "LCT007", + "external_id": "philips-hue:5" } ], "get /api/v1/service/philips-hue/device": [ { "id": "1", "name": "Lounge Living Color", - "type": "Extended color light", - "modelid": "LCT007", - "manufacturername": "Phillips", - "uniqueid": "00:17:88:01:xx:xx:xx:xx-xx", - "swversion": "66013452", - "state": { - "on": true, - "bri": 202, - "hue": 11315, - "sat": 237, - "effect": "none", - "xy": [0.5534, 0.4239], - "alert": "none", - "colormode": "xy", - "reachable": true - } + "model": "LCT007", + "external_id": "philips-hue:1", + "features": [ + { + "name": "On/Off", + "category": "light", + "type": "binary", + "min": 0, + "max": 1 + }, + { + "name": "Color", + "category": "light", + "type": "color", + "min": 0, + "max": 1 + } + ] }, { "id": "2", "name": "Right Bedside", "type": "Extended color light", - "modelid": "LCT001", - "manufacturername": "Phillips", - "uniqueid": "00:17:88:01:xx:xx:xx:xx-xx", - "swversion": "66013452", - "state": { - "on": true, - "bri": 202, - "hue": 11315, - "sat": 237, - "effect": "none", - "xy": [0.5534, 0.4239], - "alert": "none", - "colormode": "xy", - "reachable": true - } + "model": "LCT001", + "external_id": "philips-hue:2", + "features": [ + { + "name": "On/Off", + "category": "light", + "type": "binary", + "min": 0, + "max": 1 + }, + { + "name": "Color", + "category": "light", + "type": "color", + "min": 0, + "max": 1 + } + ] }, { "id": "3", "name": "Left Bedside", "type": "Extended color light", - "modelid": "LCT001", - "manufacturername": "Phillips", - "uniqueid": "00:17:88:01:xx:xx:xx:xx-xx", - "swversion": "66013452", - "state": { - "on": true, - "bri": 202, - "hue": 11315, - "sat": 237, - "effect": "none", - "xy": [0.5534, 0.4239], - "alert": "none", - "colormode": "xy", - "reachable": true - } + "model": "LCT001", + "external_id": "philips-hue:3", + "features": [ + { + "name": "On/Off", + "category": "light", + "type": "binary", + "min": 0, + "max": 1 + }, + { + "name": "Color", + "category": "light", + "type": "color", + "min": 0, + "max": 1 + } + ] } ] }