mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-04-17 22:05:36 +01:00
Compare commits
13 Commits
MSA-1604-1
...
Dianoga-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
559bc31194 | ||
|
|
0a82077b24 | ||
|
|
38ef9e5c77 | ||
|
|
6a71615ca5 | ||
|
|
9939591005 | ||
|
|
d7f2bc1d79 | ||
|
|
3c5d727d4c | ||
|
|
bbad6dfa7a | ||
|
|
df6c815aa4 | ||
|
|
d16ac00eb6 | ||
|
|
1941f56007 | ||
|
|
f34df19a65 | ||
|
|
20239ca982 |
@@ -39,7 +39,7 @@ metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def generatePresenceEvent(boolean present) {
|
def generatePresenceEvent(boolean present) {
|
||||||
log.debug "Here in generatePresenceEvent!"
|
log.info "Life360 generatePresenceEvent($present)"
|
||||||
def value = formatValue(present)
|
def value = formatValue(present)
|
||||||
def linkText = getLinkText(device)
|
def linkText = getLinkText(device)
|
||||||
def descriptionText = formatDescriptionText(linkText, present)
|
def descriptionText = formatDescriptionText(linkText, present)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00){
|
if (cluster.data[0] == 0x00){
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00) {
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if(cluster.data[0] == 0x00) {
|
if(cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
@@ -339,7 +339,7 @@ private Map getContactResult(value) {
|
|||||||
log.debug "Contact: ${device.displayName} value = ${value}"
|
log.debug "Contact: ${device.displayName} value = ${value}"
|
||||||
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
|
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
|
||||||
sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
|
sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
|
||||||
sendEvent(name: 'status', value: value, descriptionText: descriptionText, translatable: true)
|
return [name: 'status', value: value, descriptionText: descriptionText, translatable: true]
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAccelerationResult(numValue) {
|
private getAccelerationResult(numValue) {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07){
|
if (cluster.command == 0x07){
|
||||||
if (cluster.data[0] == 0x00) {
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00){
|
if (cluster.data[0] == 0x00){
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -16,12 +16,15 @@
|
|||||||
*
|
*
|
||||||
* Date: 2013-04-30
|
* Date: 2013-04-30
|
||||||
*/
|
*/
|
||||||
|
// for the UI
|
||||||
metadata {
|
metadata {
|
||||||
|
// Automatically generated. Make future change here.
|
||||||
definition (name: "SmartWeather Station Tile", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "SmartWeather Station Tile", namespace: "smartthings", author: "SmartThings") {
|
||||||
capability "Illuminance Measurement"
|
capability "Illuminance Measurement"
|
||||||
capability "Temperature Measurement"
|
capability "Temperature Measurement"
|
||||||
capability "Relative Humidity Measurement"
|
capability "Relative Humidity Measurement"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
|
capability "Polling"
|
||||||
|
|
||||||
attribute "localSunrise", "string"
|
attribute "localSunrise", "string"
|
||||||
attribute "localSunset", "string"
|
attribute "localSunset", "string"
|
||||||
@@ -214,7 +217,7 @@ def poll() {
|
|||||||
send(name: "localSunrise", value: localSunrise, descriptionText: "Sunrise today is at $localSunrise")
|
send(name: "localSunrise", value: localSunrise, descriptionText: "Sunrise today is at $localSunrise")
|
||||||
send(name: "localSunset", value: localSunset, descriptionText: "Sunset today at is $localSunset")
|
send(name: "localSunset", value: localSunset, descriptionText: "Sunset today at is $localSunset")
|
||||||
|
|
||||||
send(name: "illuminance", value: estimateLux(sunriseDate, sunsetDate, weatherIcon))
|
send(name: "illuminance", value: estimateLux(obs.solarradiation, sunriseDate, sunsetDate, weatherIcon) as Integer)
|
||||||
|
|
||||||
// Forecast
|
// Forecast
|
||||||
def f = get("forecast")
|
def f = get("forecast")
|
||||||
@@ -305,48 +308,53 @@ private send(map) {
|
|||||||
sendEvent(map)
|
sendEvent(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
private estimateLux(sunriseDate, sunsetDate, weatherIcon) {
|
private estimateLux(solarradiation, sunriseDate, sunsetDate, weatherIcon) {
|
||||||
def lux = 0
|
def lux = 0
|
||||||
def now = new Date().time
|
|
||||||
if (now > sunriseDate.time && now < sunsetDate.time) {
|
|
||||||
//day
|
|
||||||
switch(weatherIcon) {
|
|
||||||
case 'tstorms':
|
|
||||||
lux = 200
|
|
||||||
break
|
|
||||||
case ['cloudy', 'fog', 'rain', 'sleet', 'snow', 'flurries',
|
|
||||||
'chanceflurries', 'chancerain', 'chancesleet',
|
|
||||||
'chancesnow', 'chancetstorms']:
|
|
||||||
lux = 1000
|
|
||||||
break
|
|
||||||
case 'mostlycloudy':
|
|
||||||
lux = 2500
|
|
||||||
break
|
|
||||||
case ['partlysunny', 'partlycloudy', 'hazy']:
|
|
||||||
lux = 7500
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
//sunny, clear
|
|
||||||
lux = 10000
|
|
||||||
}
|
|
||||||
|
|
||||||
//adjust for dusk/dawn
|
if (solarradiation != '--') {
|
||||||
def afterSunrise = now - sunriseDate.time
|
lux = solarradiation.toDouble() / 0.0079
|
||||||
def beforeSunset = sunsetDate.time - now
|
} else {
|
||||||
def oneHour = 1000 * 60 * 60
|
def now = new Date().time
|
||||||
|
if (now > sunriseDate.time && now < sunsetDate.time) {
|
||||||
|
//day
|
||||||
|
switch(weatherIcon) {
|
||||||
|
case 'tstorms':
|
||||||
|
lux = 200
|
||||||
|
break
|
||||||
|
case ['cloudy', 'fog', 'rain', 'sleet', 'snow', 'flurries',
|
||||||
|
'chanceflurries', 'chancerain', 'chancesleet',
|
||||||
|
'chancesnow', 'chancetstorms']:
|
||||||
|
lux = 1000
|
||||||
|
break
|
||||||
|
case 'mostlycloudy':
|
||||||
|
lux = 2500
|
||||||
|
break
|
||||||
|
case ['partlysunny', 'partlycloudy', 'hazy']:
|
||||||
|
lux = 7500
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
//sunny, clear
|
||||||
|
lux = 10000
|
||||||
|
}
|
||||||
|
|
||||||
if(afterSunrise < oneHour) {
|
//adjust for dusk/dawn
|
||||||
//dawn
|
def afterSunrise = now - sunriseDate.time
|
||||||
lux = (long)(lux * (afterSunrise/oneHour))
|
def beforeSunset = sunsetDate.time - now
|
||||||
} else if (beforeSunset < oneHour) {
|
def oneHour = 1000 * 60 * 60
|
||||||
//dusk
|
|
||||||
lux = (long)(lux * (beforeSunset/oneHour))
|
if(afterSunrise < oneHour) {
|
||||||
|
//dawn
|
||||||
|
lux = (long)(lux * (afterSunrise/oneHour))
|
||||||
|
} else if (beforeSunset < oneHour) {
|
||||||
|
//dusk
|
||||||
|
lux = (long)(lux * (beforeSunset/oneHour))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//night - always set to 10 for now
|
||||||
|
//could do calculations for dusk/dawn too
|
||||||
|
lux = 10
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
//night - always set to 10 for now
|
|
||||||
//could do calculations for dusk/dawn too
|
|
||||||
lux = 10
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lux
|
lux
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ def configureHealthCheck() {
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "configure()"
|
log.debug "configure()"
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
|
||||||
configureHealthCheck()
|
configureHealthCheck()
|
||||||
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
|
|||||||
@@ -289,12 +289,12 @@ def initializeLife360Connection() {
|
|||||||
state.life360AccessToken = result.data.access_token
|
state.life360AccessToken = result.data.access_token
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
log.debug "Response=${result.data}"
|
log.info "Life360 initializeLife360Connection, response=${result.data}"
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
log.debug e
|
log.error "Life360 initializeLife360Connection, error: $e"
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,7 +656,7 @@ def generateInitialEvent (member, childDevice) {
|
|||||||
|
|
||||||
try { // we are going to just ignore any errors
|
try { // we are going to just ignore any errors
|
||||||
|
|
||||||
log.debug "Generate Initial Event for New Device for Member = ${member.id}"
|
log.info "Life360 generateInitialEvent($member, $childDevice)"
|
||||||
|
|
||||||
def place = state.places.find{it.id==settings.place}
|
def place = state.places.find{it.id==settings.place}
|
||||||
|
|
||||||
@@ -677,6 +677,8 @@ def generateInitialEvent (member, childDevice) {
|
|||||||
// log.debug "Distance Away = ${distanceAway}"
|
// log.debug "Distance Away = ${distanceAway}"
|
||||||
|
|
||||||
boolean isPresent = (distanceAway <= placeRadius)
|
boolean isPresent = (distanceAway <= placeRadius)
|
||||||
|
|
||||||
|
log.info "Life360 generateInitialEvent, member: ($memberLatitude, $memberLongitude), place: ($placeLatitude, $placeLongitude), radius: $placeRadius, dist: $distanceAway, present: $isPresent"
|
||||||
|
|
||||||
// log.debug "External Id=${app.id}:${member.id}"
|
// log.debug "External Id=${app.id}:${member.id}"
|
||||||
|
|
||||||
@@ -718,7 +720,7 @@ def haversine(lat1, lon1, lat2, lon2) {
|
|||||||
|
|
||||||
def placeEventHandler() {
|
def placeEventHandler() {
|
||||||
|
|
||||||
log.debug "In placeEventHandler method."
|
log.info "Life360 placeEventHandler: params=$params, settings.place=$settings.place"
|
||||||
|
|
||||||
// the POST to this end-point will look like:
|
// the POST to this end-point will look like:
|
||||||
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
||||||
@@ -729,8 +731,6 @@ def placeEventHandler() {
|
|||||||
def direction = params?.direction
|
def direction = params?.direction
|
||||||
def timestamp = params?.timestamp
|
def timestamp = params?.timestamp
|
||||||
|
|
||||||
log.debug "Life360 Event: Circle: ${circleId}, Place: ${placeId}, User: ${userId}, Direction: ${direction}"
|
|
||||||
|
|
||||||
if (placeId == settings.place) {
|
if (placeId == settings.place) {
|
||||||
|
|
||||||
def presenceState = (direction=="in")
|
def presenceState = (direction=="in")
|
||||||
@@ -745,10 +745,10 @@ def placeEventHandler() {
|
|||||||
|
|
||||||
if (deviceWrapper) {
|
if (deviceWrapper) {
|
||||||
deviceWrapper.generatePresenceEvent(presenceState)
|
deviceWrapper.generatePresenceEvent(presenceState)
|
||||||
log.debug "Event raised on child device: ${externalId}"
|
log.debug "Life360 event raised on child device: ${externalId}"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.debug "Couldn't find child device associated with inbound Life360 event."
|
log.warn "Life360 couldn't find child device associated with inbound Life360 event."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user