diff --git a/.eslintrc.yaml b/.eslintrc.yaml index c2ad69b4..9d36705c 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,6 +1,6 @@ env: browser: true - es2017: true + es2020: true node: true parserOptions: sourceType: module diff --git a/README.md b/README.md index e3d87cf3..8724bcf0 100644 --- a/README.md +++ b/README.md @@ -356,12 +356,10 @@ Tile Object. [Click here for some real-life examples](TILE_EXAMPLES.md) /** type: LIGHT **/ /* sliders: list of slider object. See slider documentation below */ sliders: [{}], - - /* colorpicker: whether or not the color picker should be used. - * Only works with lights that have the rgb_color attribute - * Valid options: true, false + /* colorpicker: whether or not the color picker should be shown. + * Valid options: true, false, function. Default: auto-detected */ - colorpicker: true, + colorpicker: false, /** type: POPUP_IFRAME **/ url: String || Function, /* optional */ diff --git a/TILE_EXAMPLES.md b/TILE_EXAMPLES.md index a4bbfc95..7262a974 100644 --- a/TILE_EXAMPLES.md +++ b/TILE_EXAMPLES.md @@ -414,7 +414,6 @@ Light switch. You can optionally define sliders to control colour temperature or } } ], - colorpicker: true } ``` diff --git a/index.html.ejs b/index.html.ejs index b24931f9..ec27e76f 100644 --- a/index.html.ejs +++ b/index.html.ejs @@ -582,7 +582,7 @@ -
+
Color: supportsFeature(FEATURES.LIGHT.COLOR, entity), + }, +}; diff --git a/scripts/globals/utils.js b/scripts/globals/utils.js index 15f1287d..c3359117 100644 --- a/scripts/globals/utils.js +++ b/scripts/globals/utils.js @@ -129,3 +129,8 @@ export const toAbsoluteServerURL = function (path) { // Replace extra forward slashes but not in protocol. return url.replace(/([^:])\/+/g, '$1/'); }; + +export function supportsFeature (feature, entity) { + return 'supported_features' in entity.attributes + && (entity.attributes.supported_features & feature) !== 0; +}