mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-05-28 14:21:44 +01:00
Modifying 'LaMetric Time device handler and smart apps'
This commit is contained in:
@@ -15,14 +15,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import groovy.json.JsonOutput
|
||||
|
||||
definition(
|
||||
name: "LaMetric (Connect)",
|
||||
namespace: "com.lametric",
|
||||
author: "Mykola Kirichuk",
|
||||
description: "Lametric connect",
|
||||
category: "Fun & Social",
|
||||
description: "Control your LaMetric Time smart display",
|
||||
category: "Family",
|
||||
iconUrl: "https://developer.lametric.com/assets/smart_things/smart_things_60.png",
|
||||
iconX2Url: "https://developer.lametric.com/assets/smart_things/smart_things_120.png",
|
||||
iconX3Url: "https://developer.lametric.com/assets/smart_things/smart_things_120.png",
|
||||
@@ -42,6 +40,7 @@ mappings {
|
||||
path("/oauth/callback") {action: [GET: "callback"]}
|
||||
}
|
||||
|
||||
import groovy.json.JsonOutput
|
||||
|
||||
def getEventNameListOfUserDeviceParsed(){ "EventListOfUserRemoteDevicesParsed" }
|
||||
def getEventNameTokenRefreshed(){ "EventAuthTokenRefreshed" }
|
||||
@@ -290,7 +289,7 @@ def locationHandler(evt)
|
||||
if (parsedJsonBody)
|
||||
{
|
||||
log.trace (parsedJsonBody)
|
||||
log.debug("responce for device ${parsedJsonBody?.server_id}")
|
||||
log.debug("responce for device ${parsedJsonBody?.id}")
|
||||
//put or post response
|
||||
if (parsedJsonBody.success)
|
||||
{
|
||||
@@ -298,8 +297,8 @@ def locationHandler(evt)
|
||||
} else {
|
||||
//poll response
|
||||
log.debug "poll responce"
|
||||
log.debug ("poll responce ${parsedJsonBody?.info}")
|
||||
def deviceId = parsedJsonBody?.info?.server_id;
|
||||
log.debug ("poll responce ${parsedJsonBody}")
|
||||
def deviceId = parsedJsonBody?.id;
|
||||
if (deviceId)
|
||||
{
|
||||
def devices = getDevices();
|
||||
@@ -430,27 +429,6 @@ def authPage() {
|
||||
subscribeNetworkEvents()
|
||||
listOfUserRemoteDevices()
|
||||
return deviceDiscovery();
|
||||
/*
|
||||
return deviceDiscovery();
|
||||
|
||||
def stats = getEcobeeThermostats()
|
||||
log.debug "thermostat list: $stats"
|
||||
log.debug "sensor list: ${sensorsDiscovered()}"
|
||||
return dynamicPage(name: "auth", title: "Select Your Thermostats", uninstall: true) {
|
||||
section(""){
|
||||
paragraph "Tap below to see the list of ecobee thermostats available in your ecobee account and select the ones you want to connect to SmartThings."
|
||||
input(name: "thermostats", title:"", type: "enum", required:true, multiple:true, description: "Tap to choose", metadata:[values:stats])
|
||||
}
|
||||
|
||||
def options = sensorsDiscovered() ?: []
|
||||
def numFound = options.size() ?: 0
|
||||
if (numFound > 0) {
|
||||
section(""){
|
||||
paragraph "Tap below to see the list of ecobee sensors available in your ecobee account and select the ones you want to connect to SmartThings."
|
||||
input(name: "ecobeesensors", title:"Select Ecobee Sensors (${numFound} found)", type: "enum", required:false, description: "Tap to choose", multiple:true, options:options)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,8 +691,8 @@ def connectionStatus(message, redirectUrl = null) {
|
||||
//******************************************************************************************************************
|
||||
|
||||
def getLocalApiDeviceInfoPath() { "/api/v2/info" }
|
||||
def getLocalApiSendNotificationPath() { "/api/v2/notifications" }
|
||||
def getLocalApiIndexPath() { "/api/v2" }
|
||||
def getLocalApiSendNotificationPath() { "/api/v2/device/notifications" }
|
||||
def getLocalApiIndexPath() { "/api/v2/device" }
|
||||
def getLocalApiUser() { "dev" }
|
||||
|
||||
|
||||
@@ -765,14 +743,15 @@ def getAllInfoFromDevice(localIp, apiKey)
|
||||
log.debug "send something"
|
||||
if (localIp && apiKey)
|
||||
{
|
||||
sendHubCommand(new physicalgraph.device.HubAction([
|
||||
def hubCommand = new physicalgraph.device.HubAction([
|
||||
method: "GET",
|
||||
path: localApiIndexPath,
|
||||
query:["fields": ["info","wifi", "volume", "bluetooth"]],
|
||||
path: localApiIndexPath+"?fields=info,wifi,volume,bluetooth,id,name,mode,model,serial_number,os_version",
|
||||
headers: [
|
||||
HOST: "${localIp}:8080",
|
||||
Authorization: "Basic ${"${localApiUser}:${apiKey}".bytes.encodeBase64()}"
|
||||
]]))
|
||||
]])
|
||||
log.debug "sending request ${hubCommand}"
|
||||
sendHubCommand(hubCommand)
|
||||
}
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
@@ -837,13 +816,7 @@ void listOfUserRemoteDevices()
|
||||
log.debug ("empty device info")
|
||||
}
|
||||
}
|
||||
// state.remoteDevices = remoteDevices;
|
||||
verifyDevices();
|
||||
// return
|
||||
// def serializedData = new JsonOutput().toJson(notification);
|
||||
// app.sendEvent(name: "EventListOfUserRemoteDevicesParsed", value: serializedData)
|
||||
// app.sendEvent(name: "parsed", value: true)
|
||||
// log.debug "Sending 'save new list' event ${result}"
|
||||
} else {
|
||||
log.debug "http status: ${resp.status}"
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ definition(
|
||||
name: "LaMetric Notifier",
|
||||
namespace: "com.lametric",
|
||||
author: "Mykola Kirichuk",
|
||||
description: "Notify about changes with sound and message on your LaMetric",
|
||||
category: "Fun & Social",
|
||||
description: "Allows you to send notifications to your LaMetric Time when something happens in your home to notify the whole family.",
|
||||
category: "Family",
|
||||
iconUrl: "https://developer.lametric.com/assets/smart_things/weather_60.png",
|
||||
iconX2Url: "https://developer.lametric.com/assets/smart_things/weather_120.png",
|
||||
iconX3Url: "https://developer.lametric.com/assets/smart_things/weather_120.png")
|
||||
@@ -388,21 +388,8 @@ def eventHandler(evt) {
|
||||
|
||||
if (allOk) {
|
||||
log.trace "allOk"
|
||||
// def lastTime = state[frequencyKey(evt)]
|
||||
// if (oncePerDayOk(lastTime)) {
|
||||
/*
|
||||
if (frequency) {
|
||||
if (lastTime == null || now() - lastTime >= frequency * 60000) {
|
||||
takeAction(evt)
|
||||
}
|
||||
else {
|
||||
log.debug "Not taking action because $frequency minutes have not elapsed since last action"
|
||||
}
|
||||
/* }
|
||||
else {*/
|
||||
takeAction(evt)
|
||||
// }
|
||||
}
|
||||
else {
|
||||
log.debug "Not taking action because it was already taken today"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user