mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-18 05:10:52 +00:00
Compare commits
23 Commits
PROD_2017.
...
test-10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a14421ef0 | ||
|
|
de1894bfbf | ||
|
|
d0f8ec87bd | ||
|
|
1383ab1e07 | ||
|
|
d4f21b95d7 | ||
|
|
be2e19e406 | ||
|
|
54da556c17 | ||
|
|
8611d2e2d2 | ||
|
|
c650047f31 | ||
|
|
41adc9777a | ||
|
|
f334f6505a | ||
|
|
ded7501b84 | ||
|
|
eb4d5dcfb8 | ||
|
|
6385443f20 | ||
|
|
fd1ad51880 | ||
|
|
550214ceb5 | ||
|
|
a36500a216 | ||
|
|
445c115c14 | ||
|
|
9900e532a4 | ||
|
|
7648fd4a17 | ||
|
|
9686f3770b | ||
|
|
de37d0c813 | ||
|
|
bd3367fe0e |
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Stateless On/Off Button Tile
|
||||||
|
*
|
||||||
|
* Author: Ronald Gouldner
|
||||||
|
*
|
||||||
|
* Date: 2015-05-14
|
||||||
|
*/
|
||||||
|
metadata {
|
||||||
|
// Automatically generated. Make future change here.
|
||||||
|
definition (name: "Stateless On-Off Button Tile", namespace: "gouldner", author: "Ronald Gouldner") {
|
||||||
|
capability "Actuator"
|
||||||
|
capability "Switch"
|
||||||
|
capability "Sensor"
|
||||||
|
}
|
||||||
|
|
||||||
|
// simulator metadata
|
||||||
|
simulator {
|
||||||
|
}
|
||||||
|
|
||||||
|
// UI tile definitions
|
||||||
|
tiles {
|
||||||
|
standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) {
|
||||||
|
state "offReady", label: 'Off', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff", nextState: "onReady"
|
||||||
|
state "onReady", label: 'On', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821", nextState: "offReady"
|
||||||
|
state "off", label: 'Off', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
|
||||||
|
state "on", label: 'On', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
|
||||||
|
}
|
||||||
|
main "button"
|
||||||
|
details "button"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse(String description) {
|
||||||
|
}
|
||||||
|
|
||||||
|
def on() {
|
||||||
|
log.debug "Stateless On/Off Button Tile Virtual Switch ${device.name} turned on"
|
||||||
|
sendEvent(name: "switch", value: "on")
|
||||||
|
sendEvent(name: "switch", value: "onReady")
|
||||||
|
}
|
||||||
|
|
||||||
|
def off() {
|
||||||
|
log.debug "Stateless On/Off Button Tile Virtual Switch ${device.name} turned off"
|
||||||
|
sendEvent(name: "switch", value: "off")
|
||||||
|
sendEvent(name: "switch", value: "offReady")
|
||||||
|
}
|
||||||
@@ -81,49 +81,45 @@ metadata {
|
|||||||
// parse events into attributes
|
// parse events into attributes
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
log.debug "Parse description $description"
|
log.debug "Parse description $description"
|
||||||
def map = [:]
|
List result = []
|
||||||
if (description?.startsWith("read attr -")) {
|
def descMap = zigbee.parseDescriptionAsMap(description)
|
||||||
def descMap = parseDescriptionAsMap(description)
|
|
||||||
log.debug "Desc Map: $descMap"
|
log.debug "Desc Map: $descMap"
|
||||||
if (descMap.cluster == "0201" && descMap.attrId == "0000") {
|
List attrData = [[cluster: descMap.cluster ,attrId: descMap.attrId, value: descMap.value]]
|
||||||
|
descMap.additionalAttrs.each {
|
||||||
|
attrData << [cluster: descMap.cluster, attrId: it.attrId, value: it.value]
|
||||||
|
}
|
||||||
|
attrData.each {
|
||||||
|
def map = [:]
|
||||||
|
if (it.cluster == "0201" && it.attrId == "0000") {
|
||||||
log.debug "TEMP"
|
log.debug "TEMP"
|
||||||
map.name = "temperature"
|
map.name = "temperature"
|
||||||
map.value = getTemperature(descMap.value)
|
map.value = getTemperature(it.value)
|
||||||
map.unit = temperatureScale
|
map.unit = temperatureScale
|
||||||
} else if (descMap.cluster == "0201" && descMap.attrId == "0011") {
|
} else if (it.cluster == "0201" && it.attrId == "0011") {
|
||||||
log.debug "COOLING SETPOINT"
|
log.debug "COOLING SETPOINT"
|
||||||
map.name = "coolingSetpoint"
|
map.name = "coolingSetpoint"
|
||||||
map.value = getTemperature(descMap.value)
|
map.value = getTemperature(it.value)
|
||||||
map.unit = temperatureScale
|
map.unit = temperatureScale
|
||||||
} else if (descMap.cluster == "0201" && descMap.attrId == "0012") {
|
} else if (it.cluster == "0201" && it.attrId == "0012") {
|
||||||
log.debug "HEATING SETPOINT"
|
log.debug "HEATING SETPOINT"
|
||||||
map.name = "heatingSetpoint"
|
map.name = "heatingSetpoint"
|
||||||
map.value = getTemperature(descMap.value)
|
map.value = getTemperature(it.value)
|
||||||
map.unit = temperatureScale
|
map.unit = temperatureScale
|
||||||
} else if (descMap.cluster == "0201" && descMap.attrId == "001c") {
|
} else if (it.cluster == "0201" && it.attrId == "001c") {
|
||||||
log.debug "MODE"
|
log.debug "MODE"
|
||||||
map.name = "thermostatMode"
|
map.name = "thermostatMode"
|
||||||
map.value = getModeMap()[descMap.value]
|
map.value = getModeMap()[it.value]
|
||||||
} else if (descMap.cluster == "0202" && descMap.attrId == "0000") {
|
} else if (it.cluster == "0202" && it.attrId == "0000") {
|
||||||
log.debug "FAN MODE"
|
log.debug "FAN MODE"
|
||||||
map.name = "thermostatFanMode"
|
map.name = "thermostatFanMode"
|
||||||
map.value = getFanModeMap()[descMap.value]
|
map.value = getFanModeMap()[it.value]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
def result = null
|
|
||||||
if (map) {
|
if (map) {
|
||||||
result = createEvent(map)
|
result << createEvent(map)
|
||||||
}
|
}
|
||||||
log.debug "Parse returned $map"
|
log.debug "Parse returned $map"
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
def parseDescriptionAsMap(description) {
|
|
||||||
(description - "read attr - ").split(",").inject([:]) { map, param ->
|
|
||||||
def nameAndValue = param.split(":")
|
|
||||||
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
|
|
||||||
}
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
def getModeMap() { [
|
def getModeMap() { [
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ def on() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(value) {
|
def setLevel(value) {
|
||||||
zigbee.setLevel(value) + ["delay 500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ metadata {
|
|||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Health Check"
|
capability "Health Check"
|
||||||
|
capability "Light"
|
||||||
|
|
||||||
command "setAdjustedColor"
|
command "setAdjustedColor"
|
||||||
command "reset"
|
command "reset"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ metadata {
|
|||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Health Check"
|
capability "Health Check"
|
||||||
|
capability "Light"
|
||||||
|
|
||||||
command "setAdjustedColor"
|
command "setAdjustedColor"
|
||||||
command "reset"
|
command "reset"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ metadata {
|
|||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Health Check"
|
capability "Health Check"
|
||||||
|
capability "Light"
|
||||||
|
|
||||||
command "refresh"
|
command "refresh"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ metadata {
|
|||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Health Check"
|
capability "Health Check"
|
||||||
|
capability "Light"
|
||||||
|
|
||||||
command "refresh"
|
command "refresh"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(description) {
|
||||||
def pair = description.split(":")
|
|
||||||
createEvent(name: pair[0].trim(), value: pair[1].trim())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def on() {
|
def on() {
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ metadata {
|
|||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B05", outClusters: "0019", manufacturer: "OSRAM SYLVANIA", model: "iQBR30", deviceJoinName: "Sylvania Ultra iQ"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B05", outClusters: "0019", manufacturer: "OSRAM SYLVANIA", model: "iQBR30", deviceJoinName: "Sylvania Ultra iQ"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY PAR38 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart PAR38 Soft White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY PAR38 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart PAR38 Soft White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart BR30 Soft White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart BR30 Soft White"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0702, 0B05", outClusters: "0019", manufacturer: "sengled", model: "E11-G13", deviceJoinName: "Sengled Element Classic"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL6HD", deviceJoinName: "Leviton Dimmer Switch"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL3HL", deviceJoinName: "Leviton Lumina RF Plug-In Dimmer"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL1KD", deviceJoinName: "Leviton Lumina RF Dimmer Switch"
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles(scale: 2) {
|
tiles(scale: 2) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ metadata {
|
|||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "0003, 0006, 0019, 0406", manufacturer: "Leviton", model: "ZSS-10", deviceJoinName: "Leviton Switch"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "0003, 0006, 0019, 0406", manufacturer: "Leviton", model: "ZSS-10", deviceJoinName: "Leviton Switch"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "000A", manufacturer: "HAI", model: "65A21-1", deviceJoinName: "Leviton Wireless Load Control Module-30amp"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "000A", manufacturer: "HAI", model: "65A21-1", deviceJoinName: "Leviton Wireless Load Control Module-30amp"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL15A", deviceJoinName: "Leviton Lumina RF Plug-In Appliance Module"
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulator metadata
|
// simulator metadata
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ def on() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(value) {
|
def setLevel(value) {
|
||||||
zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ def refreshAttributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(value) {
|
def setLevel(value) {
|
||||||
zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColor(value){
|
def setColor(value){
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ def setColorTemperature(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(value) {
|
def setLevel(value) {
|
||||||
zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColor(value){
|
def setColor(value){
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ def on() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(value) {
|
def setLevel(value) {
|
||||||
zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh()
|
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ def authPage() {
|
|||||||
return dynamicPage(name: "Credentials", title: "Authorize Connection", nextPage:"listDevices", uninstall: uninstallAllowed, install:false) {
|
return dynamicPage(name: "Credentials", title: "Authorize Connection", nextPage:"listDevices", uninstall: uninstallAllowed, install:false) {
|
||||||
section() {
|
section() {
|
||||||
paragraph "Tap below to log in to the netatmo and authorize SmartThings access."
|
paragraph "Tap below to log in to the netatmo and authorize SmartThings access."
|
||||||
href url:redirectUrl, style:"embedded", required:false, title:"Connect to ${getVendorName()}:", description:description
|
href url:redirectUrl, style:"embedded", required:false, title:"Connect to ${getVendorName()}", description:description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -146,18 +146,23 @@ def callback() {
|
|||||||
|
|
||||||
// log.debug "PARAMS: ${params}"
|
// log.debug "PARAMS: ${params}"
|
||||||
|
|
||||||
|
try {
|
||||||
httpPost(params) { resp ->
|
httpPost(params) { resp ->
|
||||||
|
|
||||||
def slurper = new JsonSlurper()
|
def slurper = new JsonSlurper()
|
||||||
|
|
||||||
resp.data.each { key, value ->
|
resp.data.each { key, value ->
|
||||||
def data = slurper.parseText(key)
|
def data = slurper.parseText(key)
|
||||||
|
log.debug "Data: $data"
|
||||||
state.refreshToken = data.refresh_token
|
state.refreshToken = data.refresh_token
|
||||||
state.authToken = data.access_token
|
state.authToken = data.access_token
|
||||||
|
//state.accessToken = data.access_token
|
||||||
state.tokenExpires = now() + (data.expires_in * 1000)
|
state.tokenExpires = now() + (data.expires_in * 1000)
|
||||||
// log.debug "swapped token: $resp.data"
|
// log.debug "swapped token: $resp.data"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug "callback: Call failed $e"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle success and failure here, and render stuff accordingly
|
// Handle success and failure here, and render stuff accordingly
|
||||||
@@ -387,18 +392,18 @@ def getDeviceList() {
|
|||||||
state.deviceDetail = [:]
|
state.deviceDetail = [:]
|
||||||
state.deviceState = [:]
|
state.deviceState = [:]
|
||||||
|
|
||||||
apiGet("/api/devicelist") { response ->
|
apiGet("/api/getstationsdata") { response ->
|
||||||
response.data.body.devices.each { value ->
|
response.data.body.devices.each { value ->
|
||||||
def key = value._id
|
def key = value._id
|
||||||
deviceList[key] = "${value.station_name}: ${value.module_name}"
|
deviceList[key] = "${value.station_name}: ${value.module_name}"
|
||||||
state.deviceDetail[key] = value
|
state.deviceDetail[key] = value
|
||||||
state.deviceState[key] = value.dashboard_data
|
state.deviceState[key] = value.dashboard_data
|
||||||
|
value.modules.each { value2 ->
|
||||||
|
def key2 = value2._id
|
||||||
|
deviceList[key2] = "${value.station_name}: ${value2.module_name}"
|
||||||
|
state.deviceDetail[key2] = value2
|
||||||
|
state.deviceState[key2] = value2.dashboard_data
|
||||||
}
|
}
|
||||||
response.data.body.modules.each { value ->
|
|
||||||
def key = value._id
|
|
||||||
deviceList[key] = "${state.deviceDetail[value.main_device].station_name}: ${value.module_name}"
|
|
||||||
state.deviceDetail[key] = value
|
|
||||||
state.deviceState[key] = value.dashboard_data
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,6 +453,7 @@ def listDevices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def apiGet(String path, Map query, Closure callback) {
|
def apiGet(String path, Map query, Closure callback) {
|
||||||
|
|
||||||
if(now() >= state.tokenExpires) {
|
if(now() >= state.tokenExpires) {
|
||||||
refreshToken();
|
refreshToken();
|
||||||
}
|
}
|
||||||
@@ -469,9 +475,13 @@ def apiGet(String path, Map query, Closure callback) {
|
|||||||
log.debug "apiGet: Call failed $e"
|
log.debug "apiGet: Call failed $e"
|
||||||
if(refreshToken()) {
|
if(refreshToken()) {
|
||||||
log.debug "apiGet: Trying again after refreshing token"
|
log.debug "apiGet: Trying again after refreshing token"
|
||||||
|
try {
|
||||||
httpGet(params) { response ->
|
httpGet(params) { response ->
|
||||||
callback.call(response)
|
callback.call(response)
|
||||||
}
|
}
|
||||||
|
} catch (Exception f) {
|
||||||
|
log.debug "apiGet: Call failed $f"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ def dock_sensor(device_serial, expected_plant_name) {
|
|||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
]
|
]
|
||||||
log.debug "Creating new plant on myplantlink.com - ${expected_plant_name}"
|
log.debug "Creating new plant on myplantlink.com - ${expected_plant_name}"
|
||||||
|
try {
|
||||||
httpPost(docking_params) { docking_response ->
|
httpPost(docking_params) { docking_response ->
|
||||||
if (parse_api_response(docking_response, "Docking a link")) {
|
if (parse_api_response(docking_response, "Docking a link")) {
|
||||||
if (docking_response.data.plants.size() == 0) {
|
if (docking_response.data.plants.size() == 0) {
|
||||||
@@ -145,6 +146,7 @@ def dock_sensor(device_serial, expected_plant_name) {
|
|||||||
plant_post_body_map['links_key'] = [docking_response.data.key]
|
plant_post_body_map['links_key'] = [docking_response.data.key]
|
||||||
def plant_post_body_json_builder = new JsonBuilder(plant_post_body_map)
|
def plant_post_body_json_builder = new JsonBuilder(plant_post_body_map)
|
||||||
plant_post_params["body"] = plant_post_body_json_builder.toString()
|
plant_post_params["body"] = plant_post_body_json_builder.toString()
|
||||||
|
try {
|
||||||
httpPost(plant_post_params) { plant_post_response ->
|
httpPost(plant_post_params) { plant_post_response ->
|
||||||
if(parse_api_response(plant_post_response, 'creating plant')){
|
if(parse_api_response(plant_post_response, 'creating plant')){
|
||||||
def attached_map = atomicState.attached_sensors
|
def attached_map = atomicState.attached_sensors
|
||||||
@@ -152,6 +154,9 @@ def dock_sensor(device_serial, expected_plant_name) {
|
|||||||
atomicState.attached_sensors = attached_map
|
atomicState.attached_sensors = attached_map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception f) {
|
||||||
|
log.debug "call failed $f"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
def plant = docking_response.data.plants[0]
|
def plant = docking_response.data.plants[0]
|
||||||
def attached_map = atomicState.attached_sensors
|
def attached_map = atomicState.attached_sensors
|
||||||
@@ -161,6 +166,9 @@ def dock_sensor(device_serial, expected_plant_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug "call failed $e"
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,9 +186,13 @@ def checkAndUpdatePlantIfNeeded(plant, expected_plant_name){
|
|||||||
]
|
]
|
||||||
def plant_put_body_json_builder = new JsonBuilder(plant_put_body_map)
|
def plant_put_body_json_builder = new JsonBuilder(plant_put_body_map)
|
||||||
plant_put_params["body"] = plant_put_body_json_builder.toString()
|
plant_put_params["body"] = plant_put_body_json_builder.toString()
|
||||||
|
try {
|
||||||
httpPut(plant_put_params) { plant_put_response ->
|
httpPut(plant_put_params) { plant_put_response ->
|
||||||
parse_api_response(plant_put_response, 'updating plant name')
|
parse_api_response(plant_put_response, 'updating plant name')
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug "call failed $e"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +210,7 @@ def moistureHandler(event){
|
|||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
body: event.value
|
body: event.value
|
||||||
]
|
]
|
||||||
|
try {
|
||||||
httpPost(measurement_post_params) { measurement_post_response ->
|
httpPost(measurement_post_params) { measurement_post_response ->
|
||||||
if (parse_api_response(measurement_post_response, 'creating moisture measurement') &&
|
if (parse_api_response(measurement_post_response, 'creating moisture measurement') &&
|
||||||
measurement_post_response.data.size() >0){
|
measurement_post_response.data.size() >0){
|
||||||
@@ -218,6 +231,9 @@ def moistureHandler(event){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug "call failed $e"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,9 +251,13 @@ def batteryHandler(event){
|
|||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
body: event.value
|
body: event.value
|
||||||
]
|
]
|
||||||
|
try {
|
||||||
httpPost(measurement_post_params) { measurement_post_response ->
|
httpPost(measurement_post_params) { measurement_post_response ->
|
||||||
parse_api_response(measurement_post_response, 'creating battery measurement')
|
parse_api_response(measurement_post_response, 'creating battery measurement')
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug "call failed $e"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,9 +295,13 @@ def swapToken(){
|
|||||||
]
|
]
|
||||||
|
|
||||||
def jsonMap
|
def jsonMap
|
||||||
|
try {
|
||||||
httpPost(postParams) { resp ->
|
httpPost(postParams) { resp ->
|
||||||
jsonMap = resp.data
|
jsonMap = resp.data
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug "call failed $e"
|
||||||
|
}
|
||||||
|
|
||||||
atomicState.refreshToken = jsonMap.refresh_token
|
atomicState.refreshToken = jsonMap.refresh_token
|
||||||
atomicState.authToken = jsonMap.access_token
|
atomicState.authToken = jsonMap.access_token
|
||||||
|
|||||||
Reference in New Issue
Block a user