├── .gitignore ├── docs └── Cover-main.JPG ├── src ├── hass │ ├── supports-feature.js │ ├── hass-utils.js │ └── cover-model.js └── cover-element.js ├── rollup.config.js ├── tracker.json ├── .babelrc ├── package.json ├── .eslintrc.json ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /dist/ 3 | package-lock.json 4 | .DS_Store 5 | tasks.json 6 | -------------------------------------------------------------------------------- /docs/Cover-main.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/custom-cards/cover-element/HEAD/docs/Cover-main.JPG -------------------------------------------------------------------------------- /src/hass/supports-feature.js: -------------------------------------------------------------------------------- 1 | export const supportsFeature = (stateObj, feature) => { 2 | // tslint:disable-next-line:no-bitwise 3 | return (stateObj.attributes.supported_features & feature) !== 0; 4 | }; 5 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import resolve from "rollup-plugin-node-resolve"; 2 | 3 | export default { 4 | input: "src/cover-element.js", 5 | output: { 6 | file: "dist/cover-element-bundle.js", 7 | format: "umd", 8 | name: "GroupElement", 9 | }, 10 | plugins: [resolve()], 11 | }; 12 | -------------------------------------------------------------------------------- /tracker.json: -------------------------------------------------------------------------------- 1 | { 2 | "cover-element-bundle": { 3 | "updated_at": "2019-05-07", 4 | "version": "0.2.0", 5 | "remote_location": "https://github.com/custom-cards/cover-element/releases/download/0.2.0/cover-element-bundle.js", 6 | "visit_repo": "https://github.com/custom-cards/cover-element", 7 | "changelog": "https://github.com/custom-cards/cover-element/releases/latest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "esmodules": true 9 | } 10 | } 11 | ], 12 | ["minify"] 13 | ], 14 | "comments": false, 15 | "plugins": [ 16 | [ 17 | "@babel/plugin-proposal-decorators", 18 | { "legacy": true } 19 | ], 20 | [ 21 | "@babel/plugin-proposal-class-properties", 22 | { "loose": true } 23 | ], 24 | ["@babel/plugin-transform-template-literals"], 25 | ["iife-wrap"], 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cover-element", 3 | "version": "v0.1.0", 4 | "description": "An element that allows control of covers/blinds within picture-elements.", 5 | "keywords": [ 6 | "home-assistant", 7 | "homeassistant", 8 | "hass", 9 | "automation", 10 | "lovelace", 11 | "media", 12 | "custom-cards", 13 | "picture-elements" 14 | ], 15 | "main": "src/cover-element.js", 16 | "module": "src/cover-element.js", 17 | "repository": "git@github.com:yosilevy/cover-element.git", 18 | "author": "Yosi Levy ", 19 | "license": "Apache-2.0", 20 | "dependencies": { 21 | }, 22 | "devDependencies": { 23 | "@babel/cli": "^7.2.3", 24 | "@babel/core": "^7.3.3", 25 | "@babel/plugin-proposal-class-properties": "^7.3.3", 26 | "@babel/plugin-proposal-decorators": "^7.3.0", 27 | "@babel/plugin-transform-template-literals": "^7.2.0", 28 | "@babel/preset-env": "^7.3.1", 29 | "babel-eslint": "^10.0.1", 30 | "babel-plugin-iife-wrap": "^1.1.0", 31 | "babel-preset-minify": "^0.5.0", 32 | "eslint": "^5.16.0", 33 | "eslint-config-airbnb-base": "^13.1.0", 34 | "eslint-config-prettier": "^4.1.0", 35 | "eslint-plugin-import": "^2.16.0", 36 | "eslint-plugin-prettier": "^3.0.1", 37 | "eslint-plugin-react": "^7.12.4", 38 | "prettier": "^1.16.4", 39 | "rollup": "^0.66.6", 40 | "rollup-plugin-node-resolve": "^3.4.0" 41 | }, 42 | "scripts": { 43 | "build": "npm run lint && npm run rollup && npm run babel", 44 | "rollup": "rollup -c", 45 | "babel": "babel dist/cover-element-bundle.js --out-file dist/cover-element-bundle.js", 46 | "lint": "./node_modules/.bin/eslint src/* --ext .js", 47 | "watch": "rollup -c --watch" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["airbnb-base", "prettier"], 3 | "parser": "babel-eslint", 4 | "parserOptions": { 5 | "ecmaFeatures": { 6 | "jsx": true, 7 | "modules": true 8 | } 9 | }, 10 | "settings": { 11 | "react": { 12 | "pragma": "h", 13 | "version": "15.0" 14 | } 15 | }, 16 | "env": { 17 | "browser": true, 18 | "mocha": true 19 | }, 20 | "rules": { 21 | "class-methods-use-this": 0, 22 | "new-cap": 0, 23 | "prefer-template": 0, 24 | "object-shorthand": 0, 25 | "func-names": 0, 26 | "prefer-arrow-callback": 0, 27 | "array-callback-return": 0, 28 | "no-underscore-dangle": 0, 29 | "no-use-before-define": 0, 30 | "no-var": 0, 31 | "strict": 0, 32 | "prefer-spread": 0, 33 | "no-plusplus": 0, 34 | "no-bitwise": 0, 35 | "comma-dangle": 0, 36 | "vars-on-top": 0, 37 | "no-continue": 0, 38 | "no-param-reassign": 0, 39 | "no-multi-assign": 0, 40 | "radix": 0, 41 | "no-alert": 0, 42 | "no-return-await": 0, 43 | "prefer-destructuring": 0, 44 | "no-restricted-globals": [2, "event"], 45 | "prefer-promise-reject-errors": 0, 46 | "import/prefer-default-export": 0, 47 | "import/extensions": [2, "ignorePackages"], 48 | "import/no-unresolved": 2, 49 | "linebreak-style": 0, 50 | "implicit-arrow-linebreak": 0, 51 | "object-curly-newline": 0, 52 | "default-case": 0, 53 | "react/jsx-no-bind": [2, { "ignoreRefs": true }], 54 | "react/jsx-no-duplicate-props": 2, 55 | "react/self-closing-comp": 2, 56 | "react/prefer-es6-class": 2, 57 | "react/no-string-refs": 2, 58 | "react/require-render-return": 2, 59 | "react/no-find-dom-node": 2, 60 | "react/no-is-mounted": 2, 61 | "react/jsx-no-comment-textnodes": 2, 62 | "react/jsx-no-undef": 2, 63 | "react/jsx-uses-react": 2, 64 | "react/jsx-uses-vars": 2, 65 | "no-restricted-syntax": [0, "ForOfStatement"], 66 | "prettier/prettier": "error" 67 | }, 68 | "plugins": ["react", "prettier"] 69 | } -------------------------------------------------------------------------------- /src/hass/hass-utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | Home Assistant utility class 3 | Inspired by Thomas Loven's card-tools (no-license) 4 | */ 5 | export class HassUtils { 6 | static get LitElement() { 7 | return Object.getPrototypeOf(customElements.get("home-assistant-main")); 8 | } 9 | 10 | static get LitHtml() { 11 | return this.LitElement.prototype.html; 12 | } 13 | 14 | static get LitCSS() { 15 | return this.LitElement.prototype.css; 16 | } 17 | 18 | static callService(hass, domain, service, entity_id, inOptions) { 19 | hass.callService(domain, service, { 20 | entity_id: entity_id, 21 | ...inOptions, 22 | }); 23 | } 24 | 25 | static popUp(hass, title, content, large = false) { 26 | let popup = document.createElement("div"); 27 | popup.innerHTML = ` 28 | 34 | 35 | 39 |
40 | ${title} 41 |
42 |
43 | `; 44 | popup.appendChild(content); 45 | this.moreInfo(Object.keys(hass.states)[0]); 46 | let moreInfo = document.querySelector("home-assistant")._moreInfoEl; 47 | moreInfo._page = "none"; 48 | moreInfo.shadowRoot.appendChild(popup); 49 | // moreInfo.large = large; 50 | moreInfo.style.width = "570px"; 51 | document.querySelector("home-assistant").provideHass(content); 52 | 53 | setTimeout(() => { 54 | let interval = setInterval(() => { 55 | if (moreInfo.getAttribute("aria-hidden")) { 56 | popup.parentNode.removeChild(popup); 57 | clearInterval(interval); 58 | } 59 | }, 100); 60 | }, 1000); 61 | return moreInfo; 62 | } 63 | 64 | static closePopUp() { 65 | let moreInfo = document.querySelector("home-assistant")._moreInfoEl; 66 | if (moreInfo) moreInfo.close(); 67 | } 68 | 69 | static moreInfo(entity) { 70 | this.fireEvent("hass-more-info", { entityId: entity }); 71 | } 72 | 73 | static fireEvent(ev, detail, entity = null) { 74 | ev = new Event(ev, { 75 | bubbles: true, 76 | cancelable: false, 77 | composed: true, 78 | }); 79 | ev.detail = detail || {}; 80 | if (entity) { 81 | entity.dispatchEvent(ev); 82 | } else { 83 | var root = document.querySelector("home-assistant"); 84 | root = root && root.shadowRoot; 85 | root = root && root.querySelector("home-assistant-main"); 86 | root = root && root.shadowRoot; 87 | root = 88 | root && root.querySelector("app-drawer-layout partial-panel-resolver"); 89 | root = (root && root.shadowRoot) || root; 90 | root = root && root.querySelector("ha-panel-lovelace"); 91 | root = root && root.shadowRoot; 92 | root = root && root.querySelector("hui-root"); 93 | root = root && root.shadowRoot; 94 | root = root && root.querySelector("ha-app-layout #view"); 95 | root = root && root.firstElementChild; 96 | if (root) root.dispatchEvent(ev); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/cover-element.js: -------------------------------------------------------------------------------- 1 | import { HassUtils } from "./hass/hass-utils"; 2 | import { isTiltOnly } from "./hass/cover-model"; 3 | 4 | class HuiCoverElement extends HassUtils.LitElement { 5 | constructor() { 6 | super(); 7 | this._config = {}; 8 | } 9 | 10 | static get properties() { 11 | return { 12 | hass: {}, 13 | config: {}, 14 | }; 15 | } 16 | 17 | setConfig(config) { 18 | if (!config.entity) { 19 | throw Error("Invalid Configuration: 'entity' required"); 20 | } 21 | 22 | if (config.tap_action) { 23 | throw Error("Invalid Configuration: 'tap_action' not allowed"); 24 | } 25 | 26 | if (config.hold_action) { 27 | throw Error("Invalid Configuration: 'hold_action' not allowed"); 28 | } 29 | 30 | this._config = config; 31 | } 32 | 33 | render() { 34 | if (!this._config || !this.hass) { 35 | return HassUtils.LitHtml``; 36 | } 37 | 38 | const stateObj = this.hass.states[this._config.entity]; 39 | 40 | if (!stateObj) { 41 | return HassUtils.LitHtml` 42 | Entity not found 43 | `; 44 | } 45 | 46 | return HassUtils.LitHtml` 47 |
48 | ${ 49 | this._config.label 50 | ? HassUtils.LitHtml` 51 |
52 | ${this._config.label} 53 |
54 | ` 55 | : HassUtils.LitHtml`` 56 | } 57 | ${ 58 | isTiltOnly(stateObj) 59 | ? HassUtils.LitHtml` 60 | 64 | ` 65 | : HassUtils.LitHtml` 66 | 70 | ` 71 | } 72 | ${ 73 | this._config.position_label && this._config.position_label.show 74 | ? HassUtils.LitHtml` 75 |
76 | ${this._computePosition(stateObj)} 77 |
78 | ` 79 | : HassUtils.LitHtml`` 80 | } 81 |
82 | `; 83 | } 84 | 85 | _computePosition(stateObj) { 86 | if (stateObj.attributes.current_position === undefined) { 87 | return ""; 88 | } 89 | 90 | const position = stateObj.attributes.current_position; 91 | 92 | if (position === 0) { 93 | return this._config.position_label.closed_text 94 | ? this._config.position_label.closed_text 95 | : "closed"; 96 | } 97 | if (position === 100) { 98 | return this._config.position_label.open_text 99 | ? this._config.position_label.open_text 100 | : "open"; 101 | } 102 | return ( 103 | position + 104 | "% " + 105 | (this._config.position_label.interim_text 106 | ? this._config.position_label.interim_text 107 | : "open") 108 | ); 109 | } 110 | 111 | static get styles() { 112 | return HassUtils.LitCSS` 113 | @media (max-width: 400px) { 114 | .content { 115 | transform: scale(var(--narrow-scale-factor, 0.8)); 116 | transform-origin: top; 117 | } 118 | } 119 | .content { 120 | display: flex; 121 | flex-direction: column; 122 | align-items: center; 123 | justify-content: center; 124 | } 125 | .label { 126 | text-align: center; 127 | margin-top: var(--label-margin-top, 10px); 128 | color: var(--label-color); 129 | font-size: var(--label-font-size); 130 | font-weight: var(--label-font-weight); 131 | } 132 | .position { 133 | text-align: center; 134 | margin-top: var(--position-label-margin-top, -5px); 135 | color: var(--position-label-color); 136 | font-size: var(--position-label-font-size); 137 | font-weight: var(--position-label-font-weight); 138 | } 139 | `; 140 | } 141 | } 142 | 143 | customElements.define("cover-element", HuiCoverElement); 144 | -------------------------------------------------------------------------------- /src/hass/cover-model.js: -------------------------------------------------------------------------------- 1 | import { supportsFeature } from "./supports-feature"; 2 | 3 | /* eslint-enable no-bitwise */ 4 | export default class CoverEntity { 5 | constructor(hass, stateObj) { 6 | this.hass = hass; 7 | this.stateObj = stateObj; 8 | this._attr = stateObj.attributes; 9 | this._feat = this._attr.supported_features; 10 | } 11 | 12 | get isFullyOpen() { 13 | if (this._attr.current_position !== undefined) { 14 | return this._attr.current_position === 100; 15 | } 16 | return this.stateObj.state === "open"; 17 | } 18 | 19 | get isFullyClosed() { 20 | if (this._attr.current_position !== undefined) { 21 | return this._attr.current_position === 0; 22 | } 23 | return this.stateObj.state === "closed"; 24 | } 25 | 26 | get isFullyOpenTilt() { 27 | return this._attr.current_tilt_position === 100; 28 | } 29 | 30 | get isFullyClosedTilt() { 31 | return this._attr.current_tilt_position === 0; 32 | } 33 | 34 | get isOpening() { 35 | return this.stateObj.state === "opening"; 36 | } 37 | 38 | get isClosing() { 39 | return this.stateObj.state === "closing"; 40 | } 41 | 42 | get supportsOpen() { 43 | return supportsFeature(this.stateObj, 1); 44 | } 45 | 46 | get supportsClose() { 47 | return supportsFeature(this.stateObj, 2); 48 | } 49 | 50 | get supportsSetPosition() { 51 | return supportsFeature(this.stateObj, 4); 52 | } 53 | 54 | get supportsStop() { 55 | return supportsFeature(this.stateObj, 8); 56 | } 57 | 58 | get supportsOpenTilt() { 59 | return supportsFeature(this.stateObj, 16); 60 | } 61 | 62 | get supportsCloseTilt() { 63 | return supportsFeature(this.stateObj, 32); 64 | } 65 | 66 | get supportsStopTilt() { 67 | return supportsFeature(this.stateObj, 64); 68 | } 69 | 70 | get supportsSetTiltPosition() { 71 | return supportsFeature(this.stateObj, 128); 72 | } 73 | 74 | get isTiltOnly() { 75 | const supportsCover = 76 | this.supportsOpen || this.supportsClose || this.supportsStop; 77 | const supportsTilt = 78 | this.supportsOpenTilt || this.supportsCloseTilt || this.supportsStopTilt; 79 | return supportsTilt && !supportsCover; 80 | } 81 | 82 | openCover() { 83 | this.callService("open_cover"); 84 | } 85 | 86 | closeCover() { 87 | this.callService("close_cover"); 88 | } 89 | 90 | stopCover() { 91 | this.callService("stop_cover"); 92 | } 93 | 94 | openCoverTilt() { 95 | this.callService("open_cover_tilt"); 96 | } 97 | 98 | closeCoverTilt() { 99 | this.callService("close_cover_tilt"); 100 | } 101 | 102 | stopCoverTilt() { 103 | this.callService("stop_cover_tilt"); 104 | } 105 | 106 | setCoverPosition(position) { 107 | this.callService("set_cover_position", { position }); 108 | } 109 | 110 | setCoverTiltPosition(tiltPosition) { 111 | this.callService("set_cover_tilt_position", { 112 | tilt_position: tiltPosition, 113 | }); 114 | } 115 | 116 | // helper method 117 | 118 | callService(service, data = {}) { 119 | data.entity_id = this.stateObj.entity_id; 120 | this.hass.callService("cover", service, data); 121 | } 122 | } 123 | 124 | export const supportsOpen = (stateObj) => supportsFeature(stateObj, 1); 125 | 126 | export const supportsClose = (stateObj) => supportsFeature(stateObj, 2); 127 | 128 | export const supportsSetPosition = (stateObj) => supportsFeature(stateObj, 4); 129 | 130 | export const supportsStop = (stateObj) => supportsFeature(stateObj, 8); 131 | 132 | export const supportsOpenTilt = (stateObj) => supportsFeature(stateObj, 16); 133 | 134 | export const supportsCloseTilt = (stateObj) => supportsFeature(stateObj, 32); 135 | 136 | export const supportsStopTilt = (stateObj) => supportsFeature(stateObj, 64); 137 | 138 | export const supportsSetTiltPosition = (stateObj) => 139 | supportsFeature(stateObj, 128); 140 | 141 | export function isTiltOnly(stateObj) { 142 | const supportsCover = 143 | supportsOpen(stateObj) || supportsClose(stateObj) || supportsStop(stateObj); 144 | const supportsTilt = 145 | supportsOpenTilt(stateObj) || 146 | supportsCloseTilt(stateObj) || 147 | supportsStopTilt(stateObj); 148 | return supportsTilt && !supportsCover; 149 | } 150 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cover Element 2 | 3 | An element that allows cover/blinds control in a [Home Assistant](https://github.com/home-assistant/home-assistant) [picture-elements](https://www.home-assistant.io/lovelace/picture-elements/) card. 4 | 5 | 6 | 7 | ## Using the card 8 | 9 | #### Element options 10 | | Name | Type | Default | Since | Description | 11 | |------|------|---------|-------|-------------| 12 | | type | string | **required** | v0.1 | `custom:cover-element` 13 | | entity | string | **required** | v0.1 | Cover entity to control. 14 | | label | string | | v0.3 | Heading label 15 | 16 | 17 | #### Position_label object 18 | | Name | Type | Default | Since | Description | 19 | |------|------|---------|-------|-------------| 20 | | show | boolean | false | v0.1 | Show the current position of the cover. 21 | | open_text | string | open | v0.1 | Sets the text to show when cover is fully open. 22 | | closed_text | string | closed | v0.1 | Sets the text to show when cover is fully closed. 23 | | interim_text | string | open | v0.1 | Sets the text to show when cover is partially open. 24 | 25 | ### Example usage 26 | 27 | 28 | 29 | ```yaml 30 | - type: picture-elements 31 | image: /local/LivingRoom.jpg 32 | elements: 33 | - type: 'custom:cover-element' 34 | entity: cover.livingroom_terrace_shutter 35 | position_label: 36 | show: true 37 | open_text: open 38 | closed_text: closed 39 | interim_text: open 40 | style: 41 | top: 40% 42 | height: 15% 43 | background-color: 'rgba(255, 255, 255, 0.6)' 44 | width: 23% 45 | border-radius: 10px 46 | left: 53% 47 | ``` 48 | 49 | ## Install 50 | 51 | ### Simple install 52 | 53 | 1. Download and copy `cover-element-bundle.js` from the [latest release](https://github.com/custom-cards/cover-element/releases/latest) into your `config/www` directory. 54 | 55 | 2. Add a reference to `cover-element-bundle.js` in lovelace. 56 | 57 | ```yaml 58 | resources: 59 | - url: /local/cover-element-bundle.js?v=0.3.0 60 | type: module 61 | ``` 62 | To do this, go to Configure UI -> Raw Config Editor and paste this under resources or use [YAML Mode](https://www.home-assistant.io/lovelace/yaml-mode/) (not recommended)) 63 | 64 | ### CLI install 65 | 66 | 1. Move into your `config/www` directory 67 | 68 | 2. Grab `cover-element-bundle.js` 69 | 70 | ```console 71 | $ wget https://github.com/custom-cards/cover-element/releases/download/0.3.0/cover-element-bundle.js 72 | ``` 73 | 74 | 3. Add a reference to `cover-element-bundle.js` inside your `ui-lovelace.yaml`. 75 | 76 | ```yaml 77 | resources: 78 | - url: /local/cover-element-bundle.js?v=0.3.0 79 | type: module 80 | ``` 81 | 82 | ### *(Optional)* Add to custom updater 83 | 84 | 1. Make sure you have the [custom_updater](https://github.com/custom-components/custom_updater) component installed and working. 85 | 86 | 2. Add a new reference under `card_urls` in your `custom_updater` configuration in `configuration.yaml`. 87 | //todo: implement tracker 88 | ```yaml 89 | custom_updater: 90 | card_urls: 91 | - https://raw.githubusercontent.com/custom-cards/cover-element/master/tracker.json 92 | ``` 93 | 94 | ## Updating 95 | 1. Find your `cover-element-bundle.js` file in `config/www` or wherever you ended up storing it. 96 | 97 | 2. Replace the local file with the latest one attached in the [latest release](https://github.com/custom-cards/cover-element/releases/latest). 98 | 99 | 3. Add the new version number to the end of the cards reference url in your `ui-lovelace.yaml` like below. 100 | 101 | ```yaml 102 | resources: 103 | - url: /local/cover-element-bundle.js?v=0.3.0 104 | type: module 105 | ``` 106 | 107 | *You may need to empty the browsers cache if you have problems loading the updated card.* 108 | 109 | ## Getting errors? 110 | Make sure you have `javascript_version: latest` in your `configuration.yaml` under `frontend:`. 111 | 112 | Make sure you have the latest version of `cover-element-bundle.js`. 113 | 114 | If you have issues after updating the card, try clearing your browsers cache or restart Home Assistant. 115 | 116 | If you get "Custom element doesn't exist: cover-element" or running older browsers try replacing `type: module` with `type: js` in your resource reference, like below. 117 | 118 | ```yaml 119 | resources: 120 | - url: ... 121 | type: js 122 | ``` 123 | 124 | ## License 125 | This project is under the Apache 2.0 license. 126 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------