├── README.md ├── devicetypes └── gurase │ ├── home-assistant-switch.src │ └── home-assistant-switch.groovy │ ├── home-assistant-cover.src │ └── home-assistant-cover.groovy │ └── home-assistant-light.src │ └── home-assistant-light.groovy ├── smartapps └── gurase │ └── home-assistant-connect.src │ └── home-assistant-connect.groovy └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # SmartThings-Home-Assistant-Connect 2 | 3 | ## THIS PROJECT IS NO LONGER BEING MAINTAINED 4 | 5 | This SmartApp allows you to connect your existing Home Assistant devices to SmartThings. The main reason I created this is because I was frustrated by the limitations of the emulated_hue component, specifically with Google Home. With your Home Assistant devices available in SmartThings, you can connect your SmartThings hub to Alexa/Google Home instead of relying on emulated_hue. 6 | 7 | ## Supported Devices, Features, and Limitations 8 | Currently cover, light, script, and switch device types are supported. 9 | 10 | - **cover** - Like emulated_hue, cover devices are treated like lights, so you have to say "turn on the shades" to open them, etc. Also supports setting the position. 11 | - **light** - All lights are treated like colored bulbs. You are able to use voice control to set the color. 12 | - **script** - Treated like a switch. 13 | - **switch** - Basic on and off. Surprise, surprise. 14 | 15 | You can use the **smartthings_name** attribute in Home Assistant to set a custom name for your device in SmartThings. Otherwise, **friendly_name** will be used. 16 | 17 | ## Installation 18 | 1. Install and publish the Smart App in the Smart App IDE using "Create via code". 19 | 1. Under Settings in the Smart App IDE, add the following App Settings: 20 | - **token** - a long-lived access token, created in your Home Assistant user account 21 | - **hassUrl** - your Home Assistant URL 22 | 1. Install and publish all Device Handlers in the Device Handler IDE using "Create via code". 23 | 1. Open the SmartThings app on your phone, and install the Home Assistant Connect SmartApp from the Marketplace (under My Apps). 24 | 1. Select all the Home Assistant devices you would like to connect to SmartThings. 25 | 1. You should now be able to control your Home Assistant devices from SmartThings! 26 | -------------------------------------------------------------------------------- /devicetypes/gurase/home-assistant-switch.src/home-assistant-switch.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Home Assistant Switch 3 | * 4 | * Copyright 2017 Grace Mann 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | metadata { 17 | definition (name: "Home Assistant Switch", namespace: "gurase", author: "Grace Mann") { 18 | capability "Actuator" 19 | capability "Light" 20 | capability "Polling" 21 | capability "Refresh" 22 | capability "Sensor" 23 | capability "Switch" 24 | } 25 | 26 | 27 | simulator { } 28 | 29 | tiles(scale: 2) { 30 | multiAttributeTile(name:"rich-control", type: "switch", canChangeIcon: true){ 31 | tileAttribute ("device.switch", key: "PRIMARY_CONTROL") { 32 | attributeState "on", label:'${name}', action:"switch.off", icon:"st.Home.home30", backgroundColor:"#00A0DC", nextState:"turningOff" 33 | attributeState "off", label:'${name}', action:"switch.on", icon:"st.Home.home30", backgroundColor:"#ffffff", nextState:"turningOn" 34 | attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.Home.home30", backgroundColor:"#00A0DC", nextState:"turningOff" 35 | attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.Home.home30", backgroundColor:"#ffffff", nextState:"turningOn" 36 | attributeState "offline", label:'${name}', icon:"st.Home.home30", backgroundColor:"#cccccc" 37 | } 38 | } 39 | 40 | standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) { 41 | state "on", label:'${name}', action:"switch.off", icon:"st.Home.home30", backgroundColor:"#00A0DC", nextState:"turningOff" 42 | state "off", label:'${name}', action:"switch.on", icon:"st.Home.home30", backgroundColor:"#ffffff", nextState:"turningOn" 43 | state "turningOn", label:'${name}', action:"switch.off", icon:"st.Home.home30", backgroundColor:"#00A0DC", nextState:"turningOff" 44 | state "turningOff", label:'${name}', action:"switch.on", icon:"st.Home.home30", backgroundColor:"#ffffff", nextState:"turningOn" 45 | state "offline", label:'${name}', icon:"st.Home.home30", backgroundColor:"#cccccc" 46 | } 47 | 48 | standardTile("refresh", "device.switch", inactiveLabel: false, height: 2, width: 2, decoration: "flat") { 49 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 50 | } 51 | 52 | main(["switch"]) 53 | details(["rich-control", "refresh"]) 54 | } 55 | } 56 | 57 | // handle commands 58 | def poll() { 59 | parent.poll() 60 | } 61 | 62 | def refresh() { 63 | poll() 64 | } 65 | 66 | def on() { 67 | if (parent.postService("/api/services/homeassistant/turn_on", ["entity_id": device.deviceNetworkId])) { 68 | sendEvent(name: "switch", value: "on") 69 | } 70 | } 71 | 72 | def off() { 73 | if (parent.postService("/api/services/homeassistant/turn_off", ["entity_id": device.deviceNetworkId])) { 74 | sendEvent(name: "switch", value: "off") 75 | } 76 | } -------------------------------------------------------------------------------- /devicetypes/gurase/home-assistant-cover.src/home-assistant-cover.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Home Assistant Cover 3 | * 4 | * Copyright 2017 Grace Mann 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | metadata { 17 | definition (name: "Home Assistant Cover", namespace: "gurase", author: "Grace Mann") { 18 | capability "Actuator" 19 | capability "Polling" 20 | capability "Refresh" 21 | capability "Sensor" 22 | capability "Switch" 23 | capability "Switch Level" 24 | capability "Window Shade" 25 | } 26 | 27 | 28 | simulator { } 29 | 30 | tiles(scale: 2) { 31 | multiAttributeTile(name:"shade", type: "lighting", width: 6, height: 4, canChangeIcon: true){ 32 | tileAttribute ("device.windowShade", key: "PRIMARY_CONTROL") { 33 | attributeState "open", label:'${name}', action:"close", icon:"st.Home.home9", backgroundColor:"#00A0DC", nextState:"closing" 34 | attributeState "closed", label:'${name}', action:"open", icon:"st.Home.home9", backgroundColor:"#ffffff", nextState:"opening" 35 | attributeState "opening", label:'${name}', action:"open", icon:"st.Home.home9", backgroundColor:"#00A0DC", nextState:"closing" 36 | attributeState "closing", label:'${name}', action:"close", icon:"st.Home.home9", backgroundColor:"#ffffff", nextState:"opening" 37 | } 38 | 39 | tileAttribute ("device.level", key: "SLIDER_CONTROL") { 40 | attributeState "level", action:"presetPosition" 41 | } 42 | } 43 | 44 | standardTile("refresh", "device.switch", width: 2, height: 2, inactiveLabel: false, decoration: "flat") { 45 | state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh" 46 | } 47 | 48 | /*valueTile("shadeLevel", "device.level", width: 2, height: 1) { 49 | state "level", label: 'Shade is ${currentValue}% up' 50 | } 51 | 52 | controlTile("levelSliderControl", "device.level", "slider", width: 4, height: 1) { 53 | state "level", action:"presetPosition" 54 | } 55 | 56 | valueTile("level", "device.level", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { 57 | state "level", label:'${currentValue} %', unit:"%", backgroundColor:"#ffffff" 58 | }*/ 59 | 60 | main(["shade"]) 61 | details(["shade", "shadeLevel", "levelSliderControl", "level", "refresh"]) 62 | 63 | } 64 | } 65 | 66 | // handle commands 67 | def poll() { 68 | parent.poll() 69 | } 70 | 71 | def refresh() { 72 | poll() 73 | } 74 | 75 | def open() { 76 | if (parent.postService("/api/services/cover/open_cover", ["entity_id": device.deviceNetworkId])) { 77 | sendEvent(name: "switch", value: "on") 78 | } 79 | } 80 | 81 | def close() { 82 | if (parent.postService("/api/services/cover/close_cover", ["entity_id": device.deviceNetworkId])) { 83 | sendEvent(name: "switch", value: "off") 84 | } 85 | } 86 | 87 | def presetPosition(percent) { 88 | def state = (percent == 0 ? "off" : "on") 89 | 90 | if (parent.postService("/api/services/cover/set_cover_position", ["entity_id": device.deviceNetworkId, "position": percent])) { 91 | sendEvent(name: "level", value: percent) 92 | sendEvent(name: "switch.setLevel", value: percent) 93 | sendEvent(name: "switch", value: state) 94 | } 95 | } 96 | 97 | def on() { 98 | open() 99 | } 100 | 101 | def off() { 102 | close() 103 | } 104 | 105 | def setLevel(percent) { 106 | presetPosition(percent) 107 | } -------------------------------------------------------------------------------- /devicetypes/gurase/home-assistant-light.src/home-assistant-light.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Home Assistant Light 3 | * 4 | * Copyright 2017 Grace Mann 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | metadata { 17 | definition (name: "Home Assistant Light", namespace: "gurase", author: "Grace Mann") { 18 | capability "Actuator" 19 | capability "Color Control" 20 | capability "Color Temperature" 21 | capability "Light" 22 | capability "Polling" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "Switch" 26 | capability "Switch Level" 27 | } 28 | 29 | 30 | simulator { } 31 | 32 | tiles (scale: 2){ 33 | multiAttributeTile(name:"rich-control", type: "lighting", width: 6, height: 4, canChangeIcon: true){ 34 | tileAttribute ("device.switch", key: "PRIMARY_CONTROL") { 35 | attributeState "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#00A0DC", nextState:"turningOff" 36 | attributeState "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn" 37 | attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#00A0DC", nextState:"turningOff" 38 | attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn" 39 | } 40 | tileAttribute ("device.level", key: "SLIDER_CONTROL") { 41 | attributeState "level", action:"switch level.setLevel", range:"(0..100)" 42 | } 43 | tileAttribute ("device.color", key: "COLOR_CONTROL") { 44 | attributeState "color", action:"setColor" 45 | } 46 | } 47 | 48 | controlTile("colorTempSliderControl", "device.colorTemperature", "slider", width: 4, height: 2, inactiveLabel: false, range:"(2000..6493)") { 49 | state "colorTemperature", action:"color temperature.setColorTemperature" 50 | } 51 | 52 | valueTile("colorTemp", "device.colorTemperature", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { 53 | state "colorTemperature", label: 'WHITES' 54 | } 55 | 56 | standardTile("refresh", "device.refresh", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { 57 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 58 | } 59 | 60 | main(["rich-control"]) 61 | details(["rich-control", "colorTempSliderControl", "colorTemp", "reset", "refresh"]) 62 | } 63 | } 64 | 65 | def poll() { 66 | parent.poll() 67 | } 68 | 69 | def refresh() { 70 | poll() 71 | } 72 | 73 | def setColor(value) { 74 | def hex = colorUtil.hslToHex(value.hue as int, value.saturation as int) 75 | def rgb = value.hex ?: colorUtil.hexToRgb(hex) 76 | 77 | if (value.red && value.green && value.blue) { 78 | rgb = [value.red, value.green, value.blue] 79 | } 80 | 81 | if (parent.postService("/api/services/light/turn_on", ["entity_id": device.deviceNetworkId, "rgb_color": rgb])) { 82 | sendEvent(name: "color", value: hex) 83 | sendEvent(name: "switch", value: "on") 84 | } 85 | } 86 | 87 | def setColorTemperature(value) { 88 | if (parent.postService("/api/services/light/turn_on", ["entity_id": device.deviceNetworkId, "kelvin": value])) { 89 | sendEvent(name: "colorTemperature", value: value) 90 | sendEvent(name: "switch", value: "on") 91 | } 92 | } 93 | 94 | def on() { 95 | if (parent.postService("/api/services/light/turn_on", ["entity_id": device.deviceNetworkId])) { 96 | sendEvent(name: "switch", value: "on") 97 | } 98 | } 99 | 100 | def off() { 101 | if (parent.postService("/api/services/light/turn_off", ["entity_id": device.deviceNetworkId])) { 102 | sendEvent(name: "switch", value: "off") 103 | } 104 | } 105 | 106 | def setLevel(percent) { 107 | def state = (percent == 0 ? "off" : "on") 108 | 109 | if (parent.postService("/api/services/light/turn_on", ["entity_id": device.deviceNetworkId, "brightness_pct": percent])) { 110 | sendEvent(name: "level", value: percent) 111 | sendEvent(name: "switch.setLevel", value: percent) 112 | sendEvent(name: "switch", value: state) 113 | } 114 | } -------------------------------------------------------------------------------- /smartapps/gurase/home-assistant-connect.src/home-assistant-connect.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Home Assistant Connect 3 | * 4 | * Copyright 2017 Grace Mann 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | definition( 18 | name: "Home Assistant Connect", 19 | namespace: "gurase", 20 | author: "Grace Mann", 21 | description: "Connect your Home Assistant devices to SmartThings.", 22 | category: "My Apps", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 25 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") { 26 | appSetting "hassUrl" 27 | appSetting "token" 28 | singleInstance: true 29 | } 30 | 31 | preferences { 32 | page(name: "setup", content: "setupPage") 33 | } 34 | 35 | def installed() { 36 | log.debug "Installed with settings: ${settings}" 37 | 38 | initialize() 39 | } 40 | 41 | def updated() { 42 | log.debug "Updated with settings: ${settings}" 43 | 44 | unsubscribe() 45 | initialize() 46 | } 47 | 48 | def initialize() { 49 | log.debug "initialize" 50 | 51 | addChildren(covers ?: [], state.entities["covers"], "Home Assistant Cover") 52 | addChildren(lights ?: [], state.entities["lights"], "Home Assistant Light") 53 | addChildren(scripts ?: [], state.entities["scripts"], "Home Assistant Switch") 54 | addChildren(switches ?: [], state.entities["switches"], "Home Assistant Switch") 55 | 56 | // Delete any that are no longer selected 57 | log.debug "selected devices: ${settings.collectMany { it.value }}" 58 | def delete = getChildDevices().findAll { !settings.collectMany { it.value }.contains(it.getDeviceNetworkId()) } 59 | log.warn "delete: ${delete}, deleting ${delete.size()} devices" 60 | delete.each { deleteChildDevice(it.getDeviceNetworkId()) } 61 | 62 | // Polling 63 | poll() 64 | runEvery5Minutes("poll") 65 | } 66 | 67 | def setupPage() { 68 | log.debug "setupPage" 69 | def options = getOptions() 70 | 71 | return dynamicPage(name: "setup", title: "Home Assistant", install: true, uninstall: true) { 72 | section { 73 | paragraph "Tap below to see the list of devices available in Home Assistant and select the ones you want to connect to SmartThings." 74 | input(name: "covers", type: "enum", required: false, title: "Covers", multiple: true, options: options.covers) 75 | input(name: "lights", type: "enum", required: false, title: "Lights", multiple: true, options: options.lights) 76 | input(name: "scripts", type: "enum", required: false, title: "Scripts", multiple: true, options: options.scripts) 77 | input(name: "switches", type: "enum", required: false, title: "Switches", multiple: true, options: options.switches) 78 | } 79 | } 80 | } 81 | 82 | // Get all cover, light, and switch entities from Home Assistant 83 | def getEntities() { 84 | log.debug "getEntities" 85 | 86 | def params = [ 87 | uri: appSettings.hassUrl, 88 | path: "/api/states", 89 | headers: ["Authorization": "Bearer " + appSettings.token], 90 | contentType: "application/json" 91 | ] 92 | 93 | def entities = [:] 94 | 95 | try { 96 | httpGet(params) { resp -> 97 | // Covers 98 | def covers = [:] 99 | resp.data.findAll { 100 | it.entity_id.startsWith("cover.") 101 | }.each { 102 | covers["${it.entity_id}"] = it 103 | } 104 | entities["covers"] = covers 105 | 106 | // Lights 107 | def lights = [:] 108 | resp.data.findAll { 109 | it.entity_id.startsWith("light.") 110 | }.each { 111 | lights["${it.entity_id}"] = it 112 | } 113 | entities["lights"] = lights 114 | 115 | // Scripts 116 | def scripts = [:] 117 | resp.data.findAll { 118 | it.entity_id.startsWith("script.") 119 | }.each { 120 | scripts["${it.entity_id}"] = it 121 | } 122 | entities["scripts"] = scripts 123 | 124 | // Switches 125 | def switches = [:] 126 | resp.data.findAll { 127 | it.entity_id.startsWith("switch.") 128 | }.each { 129 | switches["${it.entity_id}"] = it 130 | } 131 | entities["switches"] = switches 132 | 133 | state.entities = entities 134 | return entities 135 | } 136 | } catch (e) { 137 | log.error "something went wrong: $e" 138 | } 139 | } 140 | 141 | // Populate Smartapp setup page with Home Assistant entities 142 | def getOptions() { 143 | getEntities() 144 | def options = [:] 145 | 146 | state.entities.each { domain, domainEntities -> 147 | def values = [:] 148 | 149 | domainEntities.each { entityId, entity -> 150 | values[entityId] = entity.attributes.smartthings_name ?: entity.attributes.friendly_name 151 | } 152 | 153 | values = values.sort { it.value } 154 | options["${domain}"] = values 155 | } 156 | 157 | return options 158 | } 159 | 160 | def addChildren(chosenEntities, domain, deviceType) { 161 | log.debug "addChildren" 162 | 163 | // Create devices for newly selected Home Assistant entities 164 | chosenEntities.each { entityId -> 165 | if (!getChildDevice(entityId)) { 166 | device = addChildDevice(app.namespace, deviceType, entityId, null, 167 | [name: "Device.${entityId}", label:"${domain[entityId].attributes.smartthings_name ?: domain[entityId].attributes.friendly_name}", completedSetup: true]) 168 | log.debug "created ${device.displayName} with id ${device.getDeviceNetworkId()}" 169 | } 170 | } 171 | } 172 | 173 | // Poll child devices 174 | def poll() { 175 | getEntities() 176 | def devices = getChildDevices() 177 | 178 | // Covers 179 | devices.findAll { 180 | it.getTypeName() == "Home Assistant Cover" 181 | }.each { device -> 182 | def entityId = device.getDeviceNetworkId() 183 | def entity = state.entities.covers[entityId] 184 | 185 | device.sendEvent(name: "windowShade", value: entity.state) 186 | device.sendEvent(name: "level", value: entity.attributes.current_position) 187 | device.sendEvent(name: "label", value: entity.attributes.smartthings_name ?: entity.attributes.friendly_name) 188 | } 189 | 190 | // Lights 191 | devices.findAll { 192 | it.getTypeName() == "Home Assistant Light" 193 | }.each { device -> 194 | def entityId = device.getDeviceNetworkId() 195 | def entity = state.entities.lights[entityId] 196 | 197 | if (entity.attributes.rgb_color) { 198 | device.sendEvent(name: "color", value: colorUtil.rgbToHex(entity.attributes.rgb_color[0], entity.attributes.rgb_color[1], entity.attributes.rgb_color[2])) 199 | } 200 | 201 | if (entity.attributes.color_temp) { 202 | device.sendEvent(name: "colorTemperature", value: (1000000).intdiv(entity.attributes.color_temp)) 203 | } 204 | 205 | if (entity.attributes.brightness) { 206 | device.sendEvent(name: "level", value: entity.attributes.brightness / 255 * 100) 207 | device.sendEvent(name: "switch.setLevel", value: entity.attributes.brightness / 255 * 100) 208 | } 209 | 210 | device.sendEvent(name: "switch", value: entity.state) 211 | device.sendEvent(name: "label", value: entity.attributes.smartthings_name ?: entity.attributes.friendly_name) 212 | } 213 | 214 | // Scripts, Switches 215 | devices.findAll { 216 | it.getTypeName() == "Home Assistant Switch" 217 | }.each { device -> 218 | def entityId = device.getDeviceNetworkId() 219 | def entity = state.entities.subMap(["scripts", "switches"]).collectEntries { it.value }[entityId] 220 | 221 | device.sendEvent(name: "switch", value: entity.state) 222 | device.sendEvent(name: "label", value: entity.attributes.smartthings_name ?: entity.attributes.friendly_name) 223 | } 224 | } 225 | 226 | // Call Home Assistant services via HTTP POST request 227 | def postService(service, data) { 228 | def params = [ 229 | uri: appSettings.hassUrl, 230 | path: service, 231 | headers: ["Authorization": "Bearer " + appSettings.token], 232 | requestContentType: "application/json", 233 | body: data 234 | ] 235 | 236 | try { 237 | httpPost(params) { resp -> 238 | return true 239 | } 240 | } catch (e) { 241 | log.error "something went wrong: $e" 242 | return false 243 | } 244 | } -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------