Skip to content

Commit

Permalink
APIv6 (#129)
Browse files Browse the repository at this point in the history
* Update auth and command flow for V6
* Add support for multiple accounts
* Handle bad 1% battery sensors
* Update README.md
  • Loading branch information
brbeaird authored Sep 10, 2021
1 parent dde5251 commit b0f487e
Show file tree
Hide file tree
Showing 25 changed files with 473 additions and 406 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.0.0 (2021-09-09)

### Changed
- Update to support MyQ API v6

## 3.1.7 (2021-08-02)

### Fixed
Expand Down
126 changes: 65 additions & 61 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.0.0 (2021-09-09)

### Changed
- Update to support MyQ API v6

## 3.2.0 (2021-08-04)

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ metadata {
attribute "OpenButton", "string"
attribute "CloseButton", "string"
attribute "myQDeviceId", "string"
attribute "myQAccountId", "string"

command "open"
command "close"
Expand Down Expand Up @@ -58,20 +59,20 @@ metadata {

def open() {
openPrep()
parent.sendCommand(getMyQDeviceId(), "open")
parent.sendDoorCommand(getMyQDeviceId(), device.currentState("myQAccountId").value, "open")
}
def close() {
closePrep()
parent.sendCommand(getMyQDeviceId(), "close")
parent.sendDoorCommand(getMyQDeviceId(), device.currentState("myQAccountId").value, "close")
}

def sendOpen() {
openPrep()
parent.sendCommand(getMyQDeviceId(), "open")
parent.sendDoorCommand(getMyQDeviceId(), device.currentState("myQAccountId").value,"open")
}
def sendClose() {
closePrep()
parent.sendCommand(getMyQDeviceId(), "close")
parent.sendDoorCommand(getMyQDeviceId(), device.currentState("myQAccountId").value,"close")
}

def openPrep(){
Expand Down Expand Up @@ -102,15 +103,16 @@ def getMyQDeviceId(){
}
}

def updateMyQDeviceId(Id) {
log.debug "Setting MyQID to ${Id}"
def updateMyQDeviceId(Id, account) {
log.debug "Setting MyQID to ${Id}, accountId to ${account}"
sendEvent(name: "myQDeviceId", value: Id, display: true , displayed: true)
sendEvent(name: "myQAccountId", value: account, display: true , displayed: true)
}

def log(msg){
log.debug msg
}

def showVersion(){
return "3.2.0"
return "4.0.0"
}
5 changes: 5 additions & 0 deletions devicetypes/brbeaird/myq-garage-door-opener.src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.0.0 (2021-09-09)

### Changed
- Update to support MyQ API v6

## 3.2.2 (2021-08-04)

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ metadata {
attribute "OpenButton", "string"
attribute "CloseButton", "string"
attribute "myQDeviceId", "string"
attribute "myQAccountId", "string"

command "updateDeviceStatus", ["string"]
command "updateDeviceLastActivity", ["number"]
Expand Down Expand Up @@ -102,14 +103,12 @@ metadata {
}

def on() {
log.debug "Turning door on!"
open()
sendEvent(name: "switch", value: "on", isStateChange: true, display: true, displayed: true)
if (open())
sendEvent(name: "switch", value: "on", isStateChange: true, display: true, displayed: true)
}
def off() {
log.debug "Turning door off!"
close()
sendEvent(name: "switch", value: "off", isStateChange: true, display: true, displayed: true)
if (close())
sendEvent(name: "switch", value: "off", isStateChange: true, display: true, displayed: true)
}

def push() {
Expand All @@ -123,17 +122,14 @@ def push() {
}

def open() {
log.debug "Garage door open command called."
parent.notify("Garage door open command called.")
updateDeviceStatus("opening")
parent.sendCommand(getMyQDeviceId(), "open")

if (parent.sendDoorCommand(getMyQDeviceId(), device.currentState("myQAccountId").value, "open"))
updateDeviceStatus("opening")
runIn(20, refresh, [overwrite: true]) //Force a sync with tilt sensor after 20 seconds
}
def close() {
log.debug "Garage door close command called."
parent.notify("Garage door close command called.")
parent.sendCommand(getMyQDeviceId(), "close")
parent.sendDoorCommand(getMyQDeviceId(), device.currentState("myQAccountId").value, "close")
// updateDeviceStatus("closing") // Now handled in the parent (in case we have an Acceleration sensor, we can handle "waiting" state)
runIn(30, refresh, [overwrite: true]) //Force a sync with tilt sensor after 30 seconds
}
Expand Down Expand Up @@ -236,7 +232,7 @@ def updateDeviceSensor(sensor) {

def updateSensorBattery(batteryValue) {
def newBattery = batteryValue
if (!batteryValue){
if (!batteryValue || batteryValue == 1){
newBattery = 100
}
sendEvent(name: "battery", value: newBattery, display: true, displayed: true)
Expand All @@ -251,15 +247,16 @@ def updateDeviceMoving(moving) {
sendEvent(name: "doorMoving", value: moving, display: false , displayed: false)
}

def updateMyQDeviceId(Id) {
log.debug "Setting MyQID to ${Id}"
def updateMyQDeviceId(Id, account) {
log.debug "Setting MyQID to ${Id}, accountId to ${account}"
sendEvent(name: "myQDeviceId", value: Id, display: true , displayed: true)
sendEvent(name: "myQAccountId", value: account, display: true , displayed: true)
}

def log(msg){
log.debug msg
}

def showVersion(){
return "3.2.2"
return "4.0.0"
}
5 changes: 5 additions & 0 deletions devicetypes/brbeaird/myq-light-controller.src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.0.0 (2021-09-09)

### Changed
- Update to support MyQ API v6

## 3.1.1 (2019-10-21)

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ metadata {
capability "Sensor"
capability "Switch"
attribute "myQDeviceId", "string"
attribute "myQAccountId", "string"

command "updateDeviceStatus", ["string"]
}
Expand All @@ -41,14 +42,14 @@ metadata {

def on() {
log.debug "Light turned on"
parent.sendCommand(getMyQDeviceId(), "turnon")
updateDeviceStatus("on")
if (parent.sendLampCommand(getMyQDeviceId(), device.currentState("myQAccountId")?.value,"on"))
updateDeviceStatus("on")

}
def off() {
log.debug "Light turned off"
parent.sendCommand(getMyQDeviceId(), "turnoff")
updateDeviceStatus("off")
if (parent.sendLampCommand(getMyQDeviceId(), device.currentState("myQAccountId")?.value,"off"))
updateDeviceStatus("off")
}

def updateDeviceStatus(status) {
Expand All @@ -75,11 +76,12 @@ def getMyQDeviceId(){
}
}

def updateMyQDeviceId(Id) {
log.debug "Setting MyQID to ${Id}"
def updateMyQDeviceId(Id, account) {
log.debug "Setting MyQID to ${Id}, accountId to ${account}"
sendEvent(name: "myQDeviceId", value: Id, display: true , displayed: true)
sendEvent(name: "myQAccountId", value: account, display: true , displayed: true)
}

def showVersion(){
return "3.1.1"
return "4.0.0"
}
Binary file added icons/MyQBlue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/SmartAppList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/SmartAppSettingLink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/SmartAppToken.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/TokenGenerator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/mobileAppDevice.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/mobileAppSelection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/mobileAppSensors.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions installerManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"iconUrl": "https://raw.githubusercontent.com/brbeaird/SmartThings_MyQ/master/icons/myq.png",
"published": true,
"oAuth": true,
"version": "3.1.7",
"version": "4.0.0",
"appSettings": {},
"appUrl": "smartapps/brbeaird/myq-lite.src/myq-lite.groovy"
},
Expand All @@ -32,7 +32,7 @@
"oAuth": false,
"appUrl": "devicetypes/brbeaird/myq-garage-door-opener.src/myq-garage-door-opener.groovy",
"appSettings": {},
"version": "3.2.2",
"version": "4.0.0",
"optional": false
},
{
Expand All @@ -42,7 +42,7 @@
"oAuth": false,
"appUrl": "devicetypes/brbeaird/myq-garage-door-opener-nosensor.src/myq-garage-door-opener-nosensor.groovy",
"appSettings": {},
"version": "3.2.0",
"version": "4.0.0",
"optional": false
},
{
Expand All @@ -62,7 +62,7 @@
"oAuth": false,
"appUrl": "devicetypes/brbeaird/myq-light-controller.src/myq-light-controller.groovy",
"appSettings": {},
"version": "3.1.1",
"version": "4.0.0",
"optional": true
},
{
Expand Down
1 change: 1 addition & 0 deletions myQTokenGenerator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
Loading

0 comments on commit b0f487e

Please sign in to comment.